关闭虚拟机,开始配置ASM磁盘
配置ASM磁盘
VBoxManage createhd --filename H:\rac\sharestorage\asm1.vdi --size 5120 --format VDI --variant Fixed
VBoxManage createhd --filename H:\rac\sharestorage\asm2.vdi --size 5120 --format VDI --variant Fixed
VBoxManage createhd --filename H:\rac\sharestorage\asm3.vdi --size 5120 --format VDI --variant Fixed
VBoxManage createhd --filename H:\rac\sharestorage\asm4.vdi --size 5120 --format VDI --variant Fixed
VBoxManage createhd --filename H:\rac\sharestorage\asm5.vdi --size 5120 --format VDI --variant Fixed
把磁盘关联到虚拟机上 这里控制器是SATA 有些是SATA控制器 有些是SATA control 按照不同的版本来就可以
VBoxManage storageattach rac1 --storagectl "SATA" --port 1 --device 0 --type hdd --medium H:\rac\sharestorage\asm1.vdi --mtype shareable
VBoxManage storageattach rac1 --storagectl "SATA" --port 2 --device 0 --type hdd --medium H:\rac\sharestorage\asm2.vdi --mtype shareable
VBoxManage storageattach rac1 --storagectl "SATA" --port 3 --device 0 --type hdd --medium H:\rac\sharestorage\asm3.vdi --mtype shareable
VBoxManage storageattach rac1 --storagectl "SATA" --port 4 --device 0 --type hdd --medium H:\rac\sharestorage\asm4.vdi --mtype shareable
VBoxManage storageattach rac1 --storagectl "SATA" --port 5 --device 0 --type hdd --medium H:\rac\sharestorage\asm5.vdi --mtype shareable
设置ASM磁盘共享
VBoxManage modifyhd H:\rac\sharestorage\asm1.vdi --type shareable
VBoxManage modifyhd H:\rac\sharestorage\asm2.vdi --type shareable
VBoxManage modifyhd H:\rac\sharestorage\asm3.vdi --type shareable
VBoxManage modifyhd H:\rac\sharestorage\asm4.vdi --type shareable
VBoxManage modifyhd H:\rac\sharestorage\asm5.vdi --type shareable
对磁盘分区
[root@rac1 dev]# ls sd*
sda sda1 sda2 sdb sdc sdd sde sdf
[root@rac1 dev]# 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): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-652, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-652, default 652):
Using default value 652
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
依次对其余四个盘进行分区
安装ASM需要的包
oracleasm-2.6.18-164.el5-2.0.5-1.el5.x86_64.rpm
oracleasmlib-2.0.4-1.el5.i386.rpm
oracleasm-support-2.1.8-1.el5.i386.rpm
这里安装的这三个包由于依赖关系,安装顺序要按照下面的这样才可以
rpm -ivh oracleasm-support-2.1.8-1.el5.i386.rpm
rpm -ivh oracleasm-2.6.18-164.el5-2.0.5-1.el5.x86_64.rpm
rpm -ivh oracleasmlib-2.0.4-1.el5.i386.rpm
[root@rac1 ~]# cd /dev/
[root@rac1 dev]# ls sd*
sda sda1 sda2 sdb sdb1 sdc sdc1 sdd sdd1 sde sde1 sdf sdf1
[root@rac1 dev]# oracleasm configure -i
Configuring the Oracle ASM library driver.
This will configure the on-boot properties of the Oracle ASM library
driver. The following questions will determine whether the driver is
loaded on boot and what permissions it will have. The current values
will be shown in brackets ('[]'). Hitting without typing an
answer will keep that current value. Ctrl-C will abort.
Default user to own the driver interface []: oracle
Default group to own the driver interface []: dba
Start Oracle ASM library driver on boot (y/n) [n]: y
Scan for Oracle ASM disks on boot (y/n) [y]:
Writing Oracle ASM library driver configuration: done
把硬盘加载到ASM,命令及输出如下:
[root@rac1 dev]# /usr/sbin/oracleasm init
Creating /dev/oracleasm mount point: /dev/oracleasm
Loading module "oracleasm": oracleasm
Mounting ASMlib driver filesystem: /dev/oracleasm
[root@rac1 dev]# cd
[root@rac1 ~]# /usr/sbin/oracleasm createdisk DISK1 /dev/sdb1
Writing disk header: done
Instantiating disk: done
[root@rac1 ~]# /usr/sbin/oracleasm createdisk DISK2 /dev/sdb1
Device "/dev/sdb1" is already labeled for ASM disk "DISK1"
[root@rac1 ~]# /usr/sbin/oracleasm createdisk DISK2 /dev/sdc1
Writing disk header: done
Instantiating disk: done
[root@rac1 ~]# /usr/sbin/oracleasm createdisk DISK3 /dev/sdd1
Writing disk header: done
Instantiating disk: done
[root@rac1 ~]# /usr/sbin/oracleasm createdisk DISK4 /dev/sde1
Writing disk header: done
Instantiating disk: done
[root@rac1 ~]# /usr/sbin/oracleasm createdisk DISK5 /dev/sdf1
Writing disk header: done
Instantiating disk: done
之后执行命令及输出如下:
[root@rac1 ~]# /usr/sbin/oracleasm scandisks
Reloading disk partitions: done
Cleaning any stale ASM disks...
Scanning system for ASM disks...
[root@rac1 ~]# /usr/sbin/oracleasm listdisks
DISK1
DISK2
DISK3
DISK4
DISK5
[root@rac1 ~]#
Edit the "/etc/sysconfig/rawdevices" file, adding the following lines.
/dev/raw/raw1 /dev/sdb1
/dev/raw/raw2 /dev/sdc1
/dev/raw/raw3 /dev/sdd1
/dev/raw/raw4 /dev/sde1
/dev/raw/raw5 /dev/sdf1
Restart the rawdevices service using the following command.
service rawdevices restart
Create some symbolic links to the raw devices. This is not really necessary, but it acts as a reminder of the true locatons.
ln -s /dev/raw/raw1 /u01/oradata/ocr
ln -s /dev/raw/raw2 /u01/oradata/votingdisk
ln -s /dev/raw/raw3 /u01/oradata/asm1
ln -s /dev/raw/raw4 /u01/oradata/asm2
ln -s /dev/raw/raw5 /u01/oradata/asm3
Run the following commands and add them the "/etc/rc.local" file.
chown oracle:oinstall /dev/raw/raw1
chown oracle:oinstall /dev/raw/raw2
chown oracle:oinstall /dev/raw/raw3
chown oracle:oinstall /dev/raw/raw4
chown oracle:oinstall /dev/raw/raw5
chmod 600 /dev/raw/raw1
chmod 600 /dev/raw/raw2
chmod 600 /dev/raw/raw3
chmod 600 /dev/raw/raw4
chmod 600 /dev/raw/raw5
The shared disks are now configured.
至此节点1已经完全配置好,建议最好做个备份
下面复制节点2
VBoxManage clonehd H:\rac\node1\rac1.vdi H:\rac\node2\rac2.vdi
然后新建虚拟机,在硬盘出选择已有硬盘H:\rac\node2\rac2.vdi ,选择和节点1一样的两个网卡
关联磁盘
VBoxManage storageattach rac2 --storagectl "SATA" --port 1 --device 0 --type hdd --medium H:\rac\sharestorage\asm1.vdi --mtype shareable
VBoxManage storageattach rac2 --storagectl "SATA" --port 2 --device 0 --type hdd --medium H:\rac\sharestorage\asm2.vdi --mtype shareable
VBoxManage storageattach rac2 --storagectl "SATA" --port 3 --device 0 --type hdd --medium H:\rac\sharestorage\asm3.vdi --mtype shareable
VBoxManage storageattach rac2 --storagectl "SATA" --port 4 --device 0 --type hdd --medium H:\rac\sharestorage\asm4.vdi --mtype shareable
VBoxManage storageattach rac2 --storagectl "SATA" --port 5 --device 0 --type hdd --medium H:\rac\sharestorage\asm5.vdi --mtype shareable
然后打开节点2
删除两个bak网卡
修改IP hosts文件、环境变量等 这里不在贴过程了
下面开始配置SSH
a) 配置 SSH(每个节点)
修改 sshd_config 文件,允许root登录和证书认证:
[root@odbrac1 ~]# vim /etc/ssh/sshd_config
PermitRootLogin yes
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
重启SSH服务:
[root@odbrac1 ~]# service sshd restart
采用ssh建立oracle用户的互信:
[root@odbrac1 ~]# su - oracle
[oracle@odbrac1 ~]$ ssh-keygen -t dsa
Generating public/private dsa key pair.
Enter file in which to save the key (/home/oracle/.ssh/id_dsa):
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_dsa.
Your public key has been saved in /home/oracle/.ssh/id_dsa.pub.
The key fingerprint is:
f6:7b:c7:d8:70:ab:1c:dd:90:15:f3:89:95:46:62:f1 oracle@odbrac1.localdomain
(采用默认一路回车)
[root@odbrac2 ~]# su - oracle
[oracle@odbrac2 ~]$ ssh-keygen -t dsa
在每个节点上生成 authorized_keys 文件(注意:每个节点都生成并复制到其它节点):
[oracle@odbrac1 ~]$ cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
[oracle@odbrac2 ~]$ cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
[oracle@odbrac1 ~]$ scp ~/.ssh/authorized_keys root@10.10.100.102:/tmp/authorized_keys.odbrac1
[oracle@odbrac2 ~]$ scp ~/.ssh/authorized_keys root@10.10.100.101:/tmp/authorized_keys.odbrac2
在每个节点上合并 authorized_keys 文件:
[oracle@odbrac1 ~]$ cat /tmp/authorized_keys.odbrac2 >> ~/.ssh/authorized_keys
[oracle@odbrac2 ~]$ cat /tmp/authorized_keys.odbrac1 >> ~/.ssh/authorized_keys
使用more命令可以查看每个节点的 authorized_keys 文件是否一致:
oracle@odbrac1 ~]$ more ~/.ssh/authorized_keys
[oracle@odbrac2 ~]$ more ~/.ssh/authorized_keys
更改 authorized_keys 文件的权限:
[oracle@odbrac1 ~]$ chmod 644 ~/.ssh/authorized_keys
[oracle@odbrac2 ~]$ chmod 644 ~/.ssh/authorized_keys
开始建立SSH信任关系(每个节点):
[oracle@odbrac1 ~]$ exec /usr/bin/ssh-agent $SHELL
[oracle@odbrac1 ~]$ /usr/bin/ssh-add
[oracle@odbrac2 ~]$ exec /usr/bin/ssh-agent $SHELL
[oracle@odbrac2 ~]$ /usr/bin/ssh-add
执行如下命令以测试连通性(每个节点):
[oracle@odbrac1 ~]$ ssh localhost date
[oracle@odbrac1 ~]$ ssh odbrac1 date
[oracle@odbrac1 ~]$ ssh odbrac2 date
[oracle@odbrac1 ~]$ ssh odbrac1-priv date
[oracle@odbrac1 ~]$ ssh odbrac2-priv date
[oracle@odbrac2 ~]$ ssh localhost date
[oracle@odbrac2 ~]$ ssh odbrac2 date
[oracle@odbrac2 ~]$ ssh odbrac1 date
[oracle@odbrac2 ~]$ ssh odbrac2-priv date
[oracle@odbrac2 ~]$ ssh odbrac1-priv date
(输入“Yes”将接受并注册此密钥)
到这里就配置完成了
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/29598413/viewspace-1173153/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/29598413/viewspace-1173153/