如何配置共享存储和进行UDEV存储设备绑定

这篇文章将为大家详细讲解有关如何配置共享存储和进行UDEV存储设备绑定,文章内容质量较高,因此小编分享给大家做个参考,希望大家阅读完这篇文章后对相关知识有一定的了解。

创新互联建站-专业网站定制、快速模板网站建设、高性价比阳原网站开发、企业建站全套包干低至880元,成熟完善的模板库,直接使用。一站式阳原网站制作公司更省心,省钱,快速模板网站建设找我们,业务覆盖阳原地区。费用合理售后完善,10余年实体公司更值得信赖。

配置共享存储和UDEV存储设备绑定

2013年7月29日,星期一


目录:

  • 1.vrh2新建磁盘

  • 2.vrh3添加现有磁盘

  • 3.在vrh2上绑定存储磁盘

    • 3.1把sdb 3G这个盘划分成两个分区

    • 3.2绑定磁盘sdb

    • 3.3把sdc、sdd、sde绑定成asm文件格式

  • 4.在vrh3上绑定存储磁盘

    • 4.1启动vrh3

    • 4.2复制刚才配置的vrh2上的规则文件到vrh3

    • 4.3启动服务

  • 5.vrh2与vrh3 sshd互信配置

    • 5.1 vrh2上执行

    • 5.2 vrh3上执行

    • 5.3 创建一个授权文件保存两台主机的授权信息

    • 5.4检查vrh2上主机的时间同步情况

    • 5.5检查vrh3上主机的时间同步情况

1.vrh2新建磁盘

前提条件:vrh3主机需要是关闭状态

共享磁盘必须使用固定大小磁盘类型,否则无法把其设置为共享类型

磁盘名称创建类型格式磁盘类型大小说明
ocr新建VDI固定大小3G放置OCR和vodvoting Disk
dbshare1新建VDI固定大小5G放置数据文件
dbshare2新建VDI固定大小5G放置数据文件
dbshare3新建VDI固定大小5G放置数据文件

将以上四个磁盘设置为可共享的类型

点击“管理”->“虚拟介质管理”->选择磁盘->选择类型为共享

在virtual Box管理器上显示可能会有一点延迟

打开主机的I/O Cache

2.vrh3添加现有磁盘

磁盘名称创建类型格式磁盘类型大小说明
ocr现有VDI固定大小3G放置OCR和vodvoting Disk
dbshare1现有VDI固定大小5G放置数据文件
dbshare2现有VDI固定大小5G放置数据文件
dbshare3现有VDI固定大小5G放置数据文件

添加磁盘并且打开主机的I/O Cache

3.在vrh2上绑定存储磁盘

3.1把sdb 3G这个盘划分成两个分区

[root@vrh2 ~]# fdisk /dev/sdb

Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel

Building a new DOS disklabel. Changes will remain in memory only,

until you decide to write them. After that, of course, the previous

content won't be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

Command (m for help): p

Disk /dev/sdb: 3221 MB, 3221225472 bytes

255 heads, 63 sectors/track, 391 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System

Command (m for help): n

Command action

   e   extended

   p   primary partition (1-4)

p

Partition number (1-4): 1

First cylinder (1-391, default 1):

Using default value 1

Last cylinder or +size or +sizeM or +sizeK (1-391, default 391): +1500M

Command (m for help): p

Disk /dev/sdb: 3221 MB, 3221225472 bytes

255 heads, 63 sectors/track, 391 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System

/dev/sdb1               1         183     1469916   83  Linux

Command (m for help): n

Command action

   e   extended

   p   primary partition (1-4)

p

Partition number (1-4): 2

First cylinder (184-391, default 184):

Using default value 184

Last cylinder or +size or +sizeM or +sizeK (184-391, default 391):

Using default value 391

Command (m for help): p

Disk /dev/sdb: 3221 MB, 3221225472 bytes

255 heads, 63 sectors/track, 391 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System

/dev/sdb1               1         183     1469916   83  Linux

/dev/sdb2             184         391     1670760   83  Linux

Command (m for help): w

The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: Device or resource busy.

The kernel still uses the old table.

The new table will be used at the next reboot.

Syncing disks.

[root@vrh2 ~]# partprobe /dev/sdb

[root@vrh2 ~]# ls -l /dev/sdb*

brw-r----- 1 root disk 8, 16 Jul 29 07:39 /dev/sdb

b rw-r----- 1 root disk 8, 17 Jul 29 07:40 /dev/sdb1   #记住8,17  8,18 之后绑定会用到

b rw-r----- 1 root disk 8, 18 Jul 29 07:40 /dev/sdb2   #注意这里的sdb目前还是块设备,我们之后会把它设置为raw设备

3.2绑定磁盘sdb

[root@vrh2 ~]# cd /etc/udev/rules.d/

[root@vrh2 rules.d]# vi 60-raw.rules

# Enter raw device bindings here.

#

# An example would be:

#   ACTION=="add", KERNEL=="sda", RUN+="/bin/raw /dev/raw/raw1 %N"

# to bind /dev/raw/raw1 to /dev/sda, or

#   ACTION=="add", ENV{MAJOR}=="8", ENV{MINOR}=="1", RUN+="/bin/raw /dev/raw/raw2 %M %m"

# to bind /dev/raw/raw2 to the device with major 8, minor 1.

ACTION=="add", KERNEL=="sdb1", RUN+="/bin/raw /dev/raw/raw1 %N"

ACTION=="add", KERNEL=="sdb2", RUN+="/bin/raw /dev/raw/raw2 %N"

ACTION=="add", KERNEL=="raw*", OWNER=="oracle", GROUP=="oinstall", MODE=="0660"             #把权限赋予给oracle用户和oinstall用户组

[root@vrh2 rules.d]# start_udev

Starting udev: [  OK  ]

[root@vrh2 rules.d]# cd /dev/raw

[root@vrh2 raw]# ls -l

total 0

crw-rw---- 1 oracle oinstall 162, 1 Jul 29 07:56 raw1

crw-rw---- 1 oracle oinstall 162, 2 Jul 29 07:56 raw2

3.3把sdc、sdd、sde绑定成asm文件格式

使用以下脚本可以实现,注意该脚本要在/dev/raw目录执行

for i in b c d e f g h i j k ;

do

echo "KERNEL==\"sd*\", BUS==\"scsi\", PROGRAM==\"/sbin/scsi_id -g -u -s %p\", RESULT==\"`scsi_id -g -u -s /block/sd$i`\", NAME=\"asm-disk$i\", WNER=\"oracle\", GROUP=\"oinstall\", MODE=\"0660\""

done

我们这里只有cde三个盘,只需要将in后面写上c d e即可,

解释:

sbin/scsi_id -g -u   该号是唯一的,所以根据它来绑定

[root@vrh2 raw]# ls

raw1  raw2

[root@vrh2 raw]# for i in c d e;

> do

> echo "sd$i" "`scsi_id -g -u -s /block/sd$i`";

> done

sdc SATA_VBOX_HARDDISK_VBb86af276-b24615a9_

sdd SATA_VBOX_HARDDISK_VB453dbb62-ac2d0a41_

sde SATA_VBOX_HARDDISK_VB2a60d1f8-c1fd7b46_

执行脚本

[root@vrh2 raw]# for i in c d e;

> do

> echo "KERNEL==\"sd*\", BUS==\"scsi\", PROGRAM==\"/sbin/scsi_id -g -u -s %p\", RESULT==\"`scsi_id -g -u -s /block/sd$i`\", NAME=\"asm-disk$i\", WNER=\"oracle\", GROUP=\"oinstall\", MODE=\"0660\""

> done

KERNEL=="sd*", BUS=="scsi", PROGRAM=="/sbin/scsi_id -g -u -s %p", RESULT=="SATA_VBOX_HARDDISK_VBb86af276-b24615a9_", NAME="asm-diskc", OWNER="oracle", GROUP="oinstall", MODE="0660"

KERNEL=="sd*", BUS=="scsi", PROGRAM=="/sbin/scsi_id -g -u -s %p", RESULT=="SATA_VBOX_HARDDISK_VB453dbb62-ac2d0a41_", NAME="asm-diskd", OWNER="oracle", GROUP="oinstall", MODE="0660"

KERNEL=="sd*", BUS=="scsi", PROGRAM=="/sbin/scsi_id -g -u -s %p", RESULT=="SATA_VBOX_HARDDISK_VB2a60d1f8-c1fd7b46_", NAME="asm-diske", OWNER="oracle", GROUP="oinstall", MODE="0660"

[root@vrh2 raw]#

[root@vrh2 ~]# cd /etc/udev/rules.d/

[root@vrh2 rules.d]# touch 99-oracle-asmdevices.rules

[root@vrh2 rules.d]# vi 99-oracle-asmdevices.rules

KERNEL=="sd*", BUS=="scsi", PROGRAM=="/sbin/scsi_id -g -u -s %p", RESULT=="SATA_VBOX_HARDDISK_VBb86af276-b24615a9_", NAME="asm-diskc", OWNER="oracle", GROUP="oinstall", MODE="0660"

KERNEL=="sd*", BUS=="scsi", PROGRAM=="/sbin/scsi_id -g -u -s %p", RESULT=="SATA_VBOX_HARDDISK_VB453dbb62-ac2d0a41_", NAME="asm-diskd", OWNER="oracle", GROUP="oinstall", MODE="0660"

KERNEL=="sd*", BUS=="scsi", PROGRAM=="/sbin/scsi_id -g -u -s %p", RESULT=="SATA_VBOX_HARDDISK_VB2a60d1f8-c1fd7b46_", NAME="asm-diske", OWNER="oracle", GROUP="oinstall", MODE="0660"

[root@vrh2 rules.d]# start_udev

Starting udev: [  OK  ]

[root@vrh2 rules.d]# ls -l /dev/asm*

brw-rw---- 1 oracle oinstall 8, 32 Jul 29 20:30 /dev/asm-diskc

brw-rw---- 1 oracle oinstall 8, 48 Jul 29 20:30 /dev/asm-diskd

brw-rw---- 1 oracle oinstall 8, 64 Jul 29 20:30 /dev/asm-diske

4.在vrh3上绑定存储磁盘

4.1启动vrh3

4.2复制刚才配置的vrh2上的规则文件到vrh3

[root@vrh2 rules.d]# scp 60-raw.rules vrh3:/etc/udev/rules.d

The authenticity of host 'vrh3 (192.168.1.103)' can't be established.

RSA key fingerprint is 92:e1:fc:a6:f8:15:37:27:7b:50:41:fa:be:4d:19:0b.

Are you sure you want to continue connecting (yes/no)? yes

Warning: Permanently added 'vrh3,192.168.1.103' (RSA) to the list of known hosts.

root@vrh3's password:

60-raw.rules                                    100%  527     0.5KB/s   00:00   

[root@vrh2 rules.d]# scp 99-oracle-asmdevices.rules vrh3:/etc/udev/rules.d

root@vrh3's password:

99-oracle-asmdevices.rules                      100%  544     0.5KB/s   00:00

4.3启动服务

[root@vrh3 rules.d]# start_udev

Starting udev: [  OK  ]

[root@vrh3 rules.d]# ll /dev/raw/raw*

crw-rw---- 1 oracle oinstall 162, 1 Jul 29 20:39 /dev/raw/raw1

crw-rw---- 1 oracle oinstall 162, 2 Jul 29 20:39 /dev/raw/raw2

[root@vrh3 rules.d]#

[root@vrh3 rules.d]# ll /dev/asm*

brw-rw---- 1 oracle oinstall 8, 32 Jul 29 20:39 /dev/asm-diskc

brw-rw---- 1 oracle oinstall 8, 48 Jul 29 20:39 /dev/asm-diskd

brw-rw---- 1 oracle oinstall 8, 64 Jul 29 20:39 /dev/asm-diske

5.vrh2与vrh3 sshd互信配置

5.1 vrh2上执行

[root@vrh2 /]# su - oracle

[oracle@vrh2 ~]$ ssh-keygen -t rsa

Generating public/private rsa key pair.

Enter file in which to save the key (/home/oracle/.ssh/id_rsa):

Created directory '/home/oracle/.ssh'.

Enter passphrase (empty for no passphrase):

Enter same passphrase again:

Your identification has been saved in /home/oracle/.ssh/id_rsa.

Your public key has been saved in /home/oracle/.ssh/id_rsa.pub.

The key fingerprint is:

87:0f:5e:55:8e:7a:b6:47:e7:34:ad:27:b4:63:a9:da oracle@vrh2.oracle.com

[oracle@vrh2 ~]$ ssh-keygen -t dsa

Generating public/private dsa key pair.

Enter file in which to save the key (/home/oracle/.ssh/id_dsa):

Enter passphrase (empty for no passphrase):

Enter same passphrase again:

Your identification has been saved in /home/oracle/.ssh/id_dsa.

Your public key has been saved in /home/oracle/.ssh/id_dsa.pub.

The key fingerprint is:

0d:ec:9d:41:00:5d:cc:e7:c2:8a:e8:6c:30:00:90:66 oracle@vrh2.oracle.com

5.2 vrh3上执行

[root@vrh3 /]# su - oracle

[oracle@vrh3 ~]$ ssh-keygen -t rsa

Generating public/private rsa key pair.

Enter file in which to save the key (/home/oracle/.ssh/id_rsa):

Created directory '/home/oracle/.ssh'.

Enter passphrase (empty for no passphrase):

Enter same passphrase again:

Your identification has been saved in /home/oracle/.ssh/id_rsa.

Your public key has been saved in /home/oracle/.ssh/id_rsa.pub.

The key fingerprint is:

83:a3:22:6a:aa:cf:90:74:11:7e:48:58:86:06:7b:aa oracle@vrh3.oracle.com

[oracle@vrh3 ~]$ ssh-keygen -t dsa

Generating public/private dsa key pair.

Enter file in which to save the key (/home/oracle/.ssh/id_dsa):

Enter passphrase (empty for no passphrase):

Enter same passphrase again:

Your identification has been saved in /home/oracle/.ssh/id_dsa.

Your public key has been saved in /home/oracle/.ssh/id_dsa.pub.

The key fingerprint is:

29:3b:dc:1b:49:bb:0e:90:29:a7:d6:6b:26:99:de:b7 oracle@vrh3.oracle.com

5.3 创建一个授权文件保存两台主机的授权信息

[oracle@vrh2 .ssh]$ touch authorized_keys

[oracle@vrh2 .ssh]$ cat id_dsa.pub  >> authorized_keys                #将本机vrh2上的dsa保存到授权文件中

[oracle@vrh2 .ssh]$ cat id_rsa.pub  >> authorized_keys                #将本机vrh2上的rsa保存到授权文件中

[oracle@vrh2 .ssh]$ ssh vrh3 cat ~/.ssh/id_dsa.pub >> authorized_keys #将vrh3上的dsa保存到授权文件中

The authenticity of host 'vrh3 (192.168.1.103)' can't be established. #将vrh3上的rsa保存到授权文件中

RSA key fingerprint is 92:e1:fc:a6:f8:15:37:27:7b:50:41:fa:be:4d:19:0b.

Are you sure you want to continue connecting (yes/no)? yes

Warning: Permanently added 'vrh3,192.168.1.103' (RSA) to the list of known hosts.

oracle@vrh3's password:

[oracle@vrh2 .ssh]$ ssh vrh3 cat ~/.ssh/id_rsa.pub >> authorized_keys #将授权文件拷贝到vrh3主机上

oracle@vrh3's password:

[oracle@vrh2 .ssh]$ scp authorized_keys vrh3:~/.ssh

oracle@vrh3's password:

authorized_keys                                 100% 2032     2.0KB/s   00:00

5.4检查vrh2上主机的时间同步情况

[oracle@vrh2 .ssh]$ date;ssh vrh3 date

Mon Jul 29 20:53:44 CST 2013

Mon Jul 29 20:53:44 CST 2013

[oracle@vrh2 .ssh]$ date;ssh vrh3-priv date

Mon Jul 29 20:54:15 CST 2013

Mon Jul 29 20:54:15 CST 2013

[oracle@vrh2 .ssh]$ date;ssh vrh2 date

Mon Jul 29 20:55:36 CST 2013

Mon Jul 29 20:55:36 CST 2013

[oracle@vrh2 .ssh]$ date;ssh vrh2-priv date

Mon Jul 29 20:55:45 CST 2013

Mon Jul 29 20:55:45 CST 2013

5.5检查vrh3上主机的时间同步情况

[oracle@vrh3 ~]$ date;ssh vrh2 date

Mon Jul 29 20:56:50 CST 2013

Mon Jul 29 20:56:50 CST 2013

[oracle@vrh3 ~]$ date;ssh vrh2-priv date

Mon Jul 29 20:56:59 CST 2013

Mon Jul 29 20:56:59 CST 2013

[oracle@vrh3 ~]$ date;ssh vrh3 date

Mon Jul 29 20:57:54 CST 2013

Mon Jul 29 20:57:54 CST 2013

[oracle@vrh3 ~]$ date;ssh vrh3-priv date

Mon Jul 29 20:57:45 CST 2013

Mon Jul 29 20:57:46 CST 2013

关于如何配置共享存储和进行UDEV存储设备绑定就分享到这里了,希望以上内容可以对大家有一定的帮助,可以学到更多知识。如果觉得文章不错,可以把它分享出去让更多的人看到。


本文题目:如何配置共享存储和进行UDEV存储设备绑定
本文路径:http://bzwzjz.com/article/ipshii.html

其他资讯

Copyright © 2007-2020 广东宝晨空调科技有限公司 All Rights Reserved 粤ICP备2022107769号
友情链接: 网站建设改版 成都网站建设 网站建设方案 成都商城网站建设 成都定制网站建设 企业网站设计 网站建设 企业手机网站建设 成都营销网站制作 达州网站设计 手机网站制作 成都网站设计 营销型网站建设 阿坝网站设计 高端网站设计 古蔺网站建设 成都网站建设 成都网站建设流程 手机网站制作设计 成都网站建设公司 成都网站建设 成都网站建设