ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 【专题1】4、配置共享存储和UDEV存储设备绑定

【专题1】4、配置共享存储和UDEV存储设备绑定

原创 Linux操作系统 作者:mibvg 时间:2013-07-29 21:00:09 0 删除 编辑
配置共享存储和UDEV存储设备绑定
2013年7月29日,星期一

1.vrh1新建磁盘

前提条件:vrh2主机需要是关闭状态
共享磁盘必须使用固定大小磁盘类型,否则无法把其设置为共享类型
磁盘名称 创建类型 格式 磁盘类型 大小 说明
ocr 新建 VDI 固定大小 3G 放置OCR和vodvoting Disk
dbshare1 新建 VDI 固定大小 5G 放置数据文件
dbshare2 新建 VDI 固定大小 5G 放置数据文件
dbshare3 新建 VDI 固定大小 5G 放置数据文件
将以上四个磁盘设置为可共享的类型
点击“管理”->“虚拟介质管理”->选择磁盘->选择类型为共享
在virtual Box管理器上显示可能会有一点延迟
打开主机的I/O Cache

2.vrh2添加现有磁盘

磁盘名称 创建类型 格式 磁盘类型 大小 说明
ocr 现有 VDI 固定大小 3G 放置OCR和vodvoting Disk
dbshare1 现有 VDI 固定大小 5G 放置数据文件
dbshare2 现有 VDI 固定大小 5G 放置数据文件
dbshare3 现有 VDI 固定大小 5G 放置数据文件
添加磁盘并且打开主机的I/O Cache

3.在vrh1上绑定存储磁盘

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

[root@vrh1 ~]# 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@vrh1 ~]# partprobe /dev/sdb
[root@vrh1 ~]# 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@vrh1 ~]# cd /etc/udev/rules.d/
[root@vrh1 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@vrh1 rules.d]# start_udev
Starting udev: [  OK  ]
[root@vrh1 rules.d]# cd /dev/raw
[root@vrh1 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@vrh1 raw]# ls
raw1  raw2
[root@vrh1 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@vrh1 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@vrh1 raw]#
[root@vrh1 ~]# cd /etc/udev/rules.d/
[root@vrh1 rules.d]# touch 99-oracle-asmdevices.rules
[root@vrh1 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@vrh1 rules.d]# start_udev
Starting udev: [  OK  ]
[root@vrh1 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.在vrh2上绑定存储磁盘

4.1启动vrh2

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

[root@vrh1 rules.d]# scp 60-raw.rules vrh2:/etc/udev/rules.d
The authenticity of host 'vrh2 (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 '
vrh2,192.168.1.103' (RSA) to the list of known hosts.
root@vrh2'
s password:
60-raw.rules                                    100%  527     0.5KB/s   00:00   
[root@vrh1 rules.d]# scp 99-oracle-asmdevices.rules vrh2:/etc/udev/rules.d
root@vrh2's password:
99-oracle-asmdevices.rules                      100%  544     0.5KB/s   00:00

4.3启动服务

[root@vrh2 rules.d]# start_udev
Starting udev: [  OK  ]
[root@vrh2 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@vrh2 rules.d]#
[root@vrh2 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.vrh1与vrh2 sshd互信配置

5.1 vrh1上执行

[root@vrh1 /]# su - oracle
[oracle@vrh1 ~]$ 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@vrh1.oracle.com
[oracle@vrh1 ~]$ 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@vrh1.oracle.com

5.2 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:
83:a3:22:6a:aa:cf:90:74:11:7e:48:58:86:06:7b:aa 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:
29:3b:dc:1b:49:bb:0e:90:29:a7:d6:6b:26:99:de:b7 oracle@vrh2.oracle.com

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

[oracle@vrh1 .ssh]$ touch authorized_keys
[oracle@vrh1 .ssh]$ cat id_dsa.pub  >> authorized_keys                #将本机vrh1上的dsa保存到授权文件中
[oracle@vrh1 .ssh]$ cat id_rsa.pub  >> authorized_keys                #将本机vrh1上的rsa保存到授权文件中
[oracle@vrh1 .ssh]$ ssh vrh2 cat ~/.ssh/id_dsa.pub >> authorized_keys #将vrh2上的dsa保存到授权文件中
The authenticity of host 'vrh2 (192.168.1.103)' can't be established. #将vrh2上的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 '
vrh2,192.168.1.103' (RSA) to the list of known hosts.
oracle@vrh2'
s password:
[oracle@vrh1 .ssh]$ ssh vrh2 cat ~/.ssh/id_rsa.pub >> authorized_keys #将授权文件拷贝到vrh2主机上
oracle@vrh2's password:
[oracle@vrh1 .ssh]$ scp authorized_keys vrh2:~/.ssh
oracle@vrh2'
s password:
authorized_keys                                 100% 2032     2.0KB/s   00:00

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

[oracle@vrh1 .ssh]$ date;ssh vrh2 date
Mon Jul 29 20:53:44 CST 2013
Mon Jul 29 20:53:44 CST 2013
[oracle@vrh1 .ssh]$ date;ssh vrh2-priv date
Mon Jul 29 20:54:15 CST 2013
Mon Jul 29 20:54:15 CST 2013
[oracle@vrh1 .ssh]$ date;ssh vrh1 date
Mon Jul 29 20:55:36 CST 2013
Mon Jul 29 20:55:36 CST 2013
[oracle@vrh1 .ssh]$ date;ssh vrh1-priv date
Mon Jul 29 20:55:45 CST 2013
Mon Jul 29 20:55:45 CST 2013

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

[oracle@vrh2 ~]$ date;ssh vrh1 date
Mon Jul 29 20:56:50 CST 2013
Mon Jul 29 20:56:50 CST 2013
[oracle@vrh2 ~]$ date;ssh vrh1-priv date
Mon Jul 29 20:56:59 CST 2013
Mon Jul 29 20:56:59 CST 2013
[oracle@vrh2 ~]$ date;ssh vrh2 date
Mon Jul 29 20:57:54 CST 2013
Mon Jul 29 20:57:54 CST 2013
[oracle@vrh2 ~]$ date;ssh vrh2-priv date
Mon Jul 29 20:57:45 CST 2013
Mon Jul 29 20:57:46 CST 2013
 
 
 
 
 
 
 
 

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/15693674/viewspace-767406/,如需转载,请注明出处,否则将追究法律责任。

上一篇: 洋葱炒木耳
请登录后发表评论 登录
全部评论

注册时间:2013-07-26

  • 博文量
    8
  • 访问量
    43077