Device File Management methods

Source: Internet
Author: User
Tags time 0

2_ Device File Management method Devfs
Linux早期采用的静态管理方法/dev目录下由大量静态文件内核版本2.6.13开始被完全取代
Udev
只有连接系统上来的设备才在/dev下创建设备文件与主、次设备编号无关为设备提供持久、一致的名字设备命名规则按设备被加载的顺序命名
Access Device event Chain
内核发现设备并导入设备状态到sysfsudev接到事件统治udev创建设备节点或是运行指定程序udev通知hald守护进程HAL探测设备信息HAL创建设备对象结构HAL通过系统消息总线广播该事件用户程序也可以监控该事件
The role of Udev
从内核收到添加/一出硬件事件时,udev将会分析:/sys目录下信息/etc/udev/rules.d目录中的规则基于分析结果,udev会:处理设备命名决定要创建那些设备文件或链接决定如何设置属性决定触发那些事件
Work process
当设备接入,设备信息固定的信息(容量、生产厂商、型号)就会被加载进入内存里面,存入udev配置文件里面
Get the information that has been interfaced into the device
编写udev规则文件
    vim /etc/udev/rules.d/50-iscsidisk.rules  //文件命名规则1~99 必须有“-”                            后面是描述信息,以.rules结尾    udev主配置文件    vim /etc/udev/udev.conf  //处理详细,不用做处理,保持默认就好    udev_root:创建设备文件位置,默认为/dev    udev_rules:udev规则文件位置,默认为/etc/udev/rules.d    udev_log:syslog优先级,缺省为err
Experiment: Question:
   在linux系统中,一切设备皆文件,由于新增设备加载顺序的先后不同,导致相同设备在/dev下的文件名不同,由而引发在服务与存储分离中分区(磁盘)共享时的挂载问题
Objective:
   在设备连接上系统时,系统自动给相同设备创建一个链接文件,以后有对该共享设备操作时,利用该链接文件即可对该设备进行操作,解决实验问题
Get ready:
client50:192.168.4.50storage51:192.168.4.51
1. Display the system's device information
udevadm monitor --property
2. Get the physical path of the device
    udevadm info -q path -n /dev/sdd     /devices/platform/host4/session2/target4:0:0/4:0:0:0/block/sdd
3. Check the system identifies the device's parameter information key value type
    udevadm info -q all -p     /devices/platform/host4/session2/target4:0:0/4:0:0:0/block/sdd -a        UBSYSTEM=="block"                //设备类型,是一个块设备        ATTR{size}=="10483712"           //设备的大小        ATTRS{model}=="diskb           "  //该设备的型号,空格不能少        ATTRS{vendor}=="LIO-ORG "   //生产厂商信息
4. Write the above information to/etc/udev/rules.d/50-iscsidisk.rules
UBSYSTEM=="block",  ATTR{size}=="10483712", ATTRS{model}=="diskb         ",  ATTRS{vendor}=="LIO-ORG ",  SYMLINK+=”iscsi/vdc”    //当该设备登入后,会对该设备创建一个链接/dev/iscsi/vdc,每个逗号后面的空格不能少
5. Verify that:
    把iscsi设备登出,再登入,查看ls /dev/iscsi/vdc 链接文件存在即成功        登出设备        iscsiadm --mode node --targetname         iqn.2018-10.cn.tedu.storage51:vdb --portal 192.168.1.1:3260 --logout        登陆设备        iscsiadm --mode node --targetname         iqn.2018-10.cn.tedu.storage51:vdb --portal 192.168.1.1:3260 --login
To configure the Multipath multipath problem:
   单网卡连接之间的网络存储设备的共享不可靠,容易由于非人为破坏导致共享断开,由而引发设置多网卡,然后让多网卡对相同设备进行连接,然而,多网卡之间连接相同的共享设备时,相同设备不同连接不可以进行相互冗余,致使连接无意义
Objective:
使多张网卡之间的连接相同的共享设备时可以形成相互冗余、备份,高可用
Get ready:
添加网卡eth1client50:192.168.2.50storage51:192.168.2.51
Log out of iSCSI devices and log in using the devices below
    ]# iscsiadm --mode discoverydb --type sendtargets --portal 192.168.2.51 --discover //发现    ]# iscsiadm --mode node --targetname                                   //登陆       iqn.2018-10.cn.tedu.storage51:vdb --portal 192.168.2.51:3260 --login    ]# iscsiadm --mode discoverydb --type sendtargets --portal 192.168.4.51 --discover //发现    ]# iscsiadm --mode node --targetname                        //登陆       iqn.2018-10.cn.tedu.storage51:vdb --portal 192.168.4.51:3260 --login
Installing the Multipathing Package
    yum -y install device-mapper-multipath.x86_64    mpathconf --user_friendly_names n   //设置非友好方式产生以下配置文件    ls /etc/multipath.conf              //由上一个命令产生的文件    /usr/lib/udev/scsi_id --whitelisted --device=/dev/sda         360014051854c2ad423e4170a9e4ca149                                //该设备是iscsi设备,会出现一个值
Configuring the/etc/multipath.conf File
    vim /etc/multipath.conf        //此处内容不动        23 defaults {        24         user_friendly_names no //设置非友好方式产生以下配置文件        25         find_multipaths yes        26 }        //以下内容为新增        97 multipaths {        98         multipath {        99          wwid "360014051854c2ad423e4170a9e4ca149"           100          alias mpatha           101 }           102 }
Enable Multipath Multipath, and test
    multipath -rr   //重新加载多路径信息       |-+- policy=‘service-time 0‘ prio=1 status=enabled       | `- 14:0:0:0 sda 8:0  active ready running       `-+- policy=‘service-time 0‘ prio=1 status=enabled       `- 15:0:0:0 sdb 8:16 active ready running    multipath -ll   //查看多路径信息    ifdown eth1     multipath -rr  //重新加载后就会少一个网口的信息       |-+- policy=‘service-time 0‘ prio=1 status=enabled       | `- 14:0:0:0 sda 8:0  active ready running    multipath -ll
All of the above experiments are based on red Hat Enterprise Linux Server release 7.4 (Maipo)

Device File Management methods

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.