In Linux, the full name of mapper is "Device mapper", which is a mapping mechanism from logical devices to physical devices; under this mechanism, users can easily manage storage resources according to their own needs; It contains three important concepts: mapped device, target device, etc.
#The operating environment of this tutorial: linux5.9.8 system, Dell G3 computer.
1. What is mapper in linux?
The full name of mapper is "Device mapper", which is the Linux 2.6 kernel A mapping mechanism from logical devices to physical devices provided in . Under this mechanism, users can easily manage storage resources according to their own needs.
Currently popular logical volume managers under Linux such as LVM2 (Linux Volume Manager 2 version), EVMS (Enterprise Volume Management System), dmraid (Device Mapper Raid Tool), etc. are all based on this implemented by the mechanism.
The essential function of Device mapper is to forward IO requests from the logical device mapped device to the corresponding target device based on the mapping relationship and the IO processing rules described by the target driver.
Device mapper is registered in the kernel as a block device driver. It contains three important object concepts, mapped device, mapping table, and target device.
Device mapper is relatively simple in user space, mainly including the device mapper library and dmsetup tool.
The Device mapper library is an encapsulation of the necessary operations required for ioctl and user space to create and delete device mapper logical devices.
dmsetup is a command that provides users with directly available commands to create and delete device mapper devices. line tools.
Function:
You can combine multiple physical devices into one logical device. You can do ordinary merging, or implement striping similar to raid0. You can also use To shield bad sectors in the hard disk, you can also take lvm snapshots to back up the database, or simulate very large devices through zero device files for testing functions.
Device mapper is the underlying technology of lvm and multipating.
2. Installation package:
device-mapper
device-mapper-multipath
3. Working principle:
Create logical devices through mapping table (the corresponding relationship between each sector of the physical device and the logical device ). The contents of the table include:
The starting sector of the logical device:
is usually 0. The sector number type of the logical device (linear
linear, continuous combination; striped
striped ;error
Shield bad sectors;snapshot
Snapshot;zero
Zero device)
4. Disk sector Calculation:
1 sector = 512 bytes b 1kb = 1024b Sector size kb = number of sectors 512/1024 For example, for a 10G disk, the number of sectors is:
10000000kb=Number of sectors512/1024=20000000 sectors
#blockdev --getsize /dev/sda6 查看设备扇区数量 #echo “0 ‘blockdev --getsize /dev/sda6’ linear /dev/sda6 0” | dmsetup create mydevice
Creating logical device 0 through table means that this logical device starts from sector 0 and has 208782 sectors, linear means continuous ,/dev/sda6 0 means starting from the 0th sector of /dev/sda6 as a logical device. When a device uses the remaining space as a logical device, the sectors do not start at 0. It will only take effect after restarting after writing the following boot script
5. Linear type device characteristics:
Contiguous sectors of multiple physical partitions combined to form a logical device. 0 20000 linear /dev/sda1 0 20000 60000 linear /dev/sdb1 0 Note:
The logical device is taken from sda1 from sector 0 to sector 20000, and the logical device is taken from sector 20000 to sector 20000. Starting from sector 0 of sdb1, 60,000 sectors are taken, and the logical device has 80,000 sectors. Implement command
#echo “0 20000 linear /dev/sda1 0\n20000 60000 linear /dev/sdb1 0” | dmsetup create mydevice
6.stripe striping:
Write to disk 0 in turn by chunksize
1024 striped 2 256 /dev/sda1 0 /dev/sdb1 0 Note:
The logical device starts from sector 0 to sector 1024, type is striped, 2 devices, chunksize 256kb from 0 of /dev/sda1 and /dev/sdb1 Each sector starts with 512 sectors (note that the number of sectors must be a multiple of chunksize). Command implementation
#echo “0 1024 striped 2 256 /dev/sda1 0 /dev/sdb1 0” | dmsetup create mydevice
7.error:
Remove error sectors through synthetic logical devices 0 80 linear /dev/sda1 0 80 100 error 181 200 linear /dev/sdb1 0 command to implement
#echo “0 80 linear /dev/sda1 0\n80 100 error\n181 200 linear /dev/sdb1 0” | dmsetup create mydevice
8.snapshot Logical volume snapshot features:
After creating a snapshot, 3 devices appear (original device, snapshot device, cow device). If the data has not changed, read the data from the original device and write the changed data storage In the cow area, the snapshot device saves the data of the original device.
#echo ―0 1000 snapshot /dev/sda1 /dev/vg0/realdev P 16 ‖ | dmsetup create mydevice从0扇区到1000扇区为/dev/sda1创建快照,名字为realdev,P表示下次启动仍然生效,16为chunksize
9.zero zero device characteristics:
is similar to /dev/zero, but it is a block device and cannot be written. It is generally used For testing purposes, create a large file system for testing. For example, the test creates a 10T device formatted with ext3
#export HUGESIZE=$[100 * (2**40)/512] 100T的扇区数量 2**40为2的40次方 #echo "0 $HUGESIZE zero" | dmsetup create zerodev 生成的文件在/dev/mapper/zerodev ext3每个分区最大支持2TB
10. Multi-path features:
多路径功能,用来提供线路冗余,监控每条链路,当链路失败时自动切换链路,而且自动恢复运行,防止单点故障。生成的设备名 /dev/dm-X 类型:
当两路径优先级相等:
负载均衡 当两路径优先级不等: 冗余
multipath列出多路径设备,后台需要开启multipathd服务,优先级大小为0-1024 实验步骤:
存储端配置双网卡,配置/dev/sda6为iscsi设备 服务器端安装device-mapper-multipath包,连接iscsi设备
#vi /etc/multipath.conf 注释掉 blacklist { devnode "*" 不同厂商的配置是不一样的 } 取消注释 default{ udev_dir .. .. path_grouping_policy failover(根据失效域来判断执行策略) } #systemctl enable multipathd #systemctl restart multipathd 之后生成的设备位置在/dev/mpath/下,可制作文件系统,挂载 #multipath –ll 查询设备状态
11.FC存储:
存储端建立raid设备,raid建立与HBA卡WWN号的映射关系(连接哪个HBA卡则使用哪块磁盘设备) WWN为HBA卡的授权名称,用来区分一个或一组网络连接,表示网络上的一个连接
相关推荐:《Linux视频教程》
The above is the detailed content of What is mapper in linux. For more information, please follow other related articles on the PHP Chinese website!

The five core components of the Linux operating system are: 1. Kernel, 2. System libraries, 3. System tools, 4. System services, 5. File system. These components work together to ensure the stable and efficient operation of the system, and together form a powerful and flexible operating system.

The five core elements of Linux are: 1. Kernel, 2. Command line interface, 3. File system, 4. Package management, 5. Community and open source. Together, these elements define the nature and functionality of Linux.

Linux user management and security can be achieved through the following steps: 1. Create users and groups, using commands such as sudouseradd-m-gdevelopers-s/bin/bashjohn. 2. Bulkly create users and set password policies, using the for loop and chpasswd commands. 3. Check and fix common errors, home directory and shell settings. 4. Implement best practices such as strong cryptographic policies, regular audits and the principle of minimum authority. 5. Optimize performance, use sudo and adjust PAM module configuration. Through these methods, users can be effectively managed and system security can be improved.

The core operations of Linux file system and process management include file system management and process control. 1) File system operations include creating, deleting, copying and moving files or directories, using commands such as mkdir, rmdir, cp and mv. 2) Process management involves starting, monitoring and killing processes, using commands such as ./my_script.sh&, top and kill.

Shell scripts are powerful tools for automated execution of commands in Linux systems. 1) The shell script executes commands line by line through the interpreter to process variable substitution and conditional judgment. 2) The basic usage includes backup operations, such as using the tar command to back up the directory. 3) Advanced usage involves the use of functions and case statements to manage services. 4) Debugging skills include using set-x to enable debugging mode and set-e to exit when the command fails. 5) Performance optimization is recommended to avoid subshells, use arrays and optimization loops.

Linux is a Unix-based multi-user, multi-tasking operating system that emphasizes simplicity, modularity and openness. Its core functions include: file system: organized in a tree structure, supports multiple file systems such as ext4, XFS, Btrfs, and use df-T to view file system types. Process management: View the process through the ps command, manage the process using PID, involving priority settings and signal processing. Network configuration: Flexible setting of IP addresses and managing network services, and use sudoipaddradd to configure IP. These features are applied in real-life operations through basic commands and advanced script automation, improving efficiency and reducing errors.

The methods to enter Linux maintenance mode include: 1. Edit the GRUB configuration file, add "single" or "1" parameters and update the GRUB configuration; 2. Edit the startup parameters in the GRUB menu, add "single" or "1". Exit maintenance mode only requires restarting the system. With these steps, you can quickly enter maintenance mode when needed and exit safely, ensuring system stability and security.

The core components of Linux include kernel, shell, file system, process management and memory management. 1) Kernel management system resources, 2) shell provides user interaction interface, 3) file system supports multiple formats, 4) Process management is implemented through system calls such as fork, and 5) memory management uses virtual memory technology.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

SublimeText3 Mac version
God-level code editing software (SublimeText3)

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

Notepad++7.3.1
Easy-to-use and free code editor

WebStorm Mac version
Useful JavaScript development tools
