配置11gR2 RAC需要安装Oracle Grid Infrastructure软件、Oracle数据库软件,其中Grid软件等同于Oracle 10g的Clusterware集群件。Oracle建议以不同的用户分别安装Grid Infrastructure软件、Oracle数据库软件,我们这里以grid用户安装Grid Infrastructure,oracle用户安装Oracle数据库软件。并且grid、oracle用户需要属于不同的用户组。在配置RAC时,还要求这两个用户在RAC的不同节点上uid、gid要一致。用户、组的对应信息见下表:
Group Name |
Group ID |
Group Info |
Oracle User(1100) |
Grid User(1101) |
---|---|---|---|---|
oinstall |
1000 |
Inventory Group |
Y |
Y |
dba |
1300 |
OSDBA Group |
Y |
|
oper |
1301 |
OSOPER Group |
Y |
|
asmadmin |
1200 |
OSASM |
|
Y |
asmdba |
1201 |
OSDBA for ASM |
Y |
Y |
asmoper |
1202 |
OSOPER for ASM |
|
Y |
(Figure 2.4用户、组配置信息表)
我们可以通过执行下述shell脚本的1preusers.sh来完成用户、组的创建,脚本的具体内容可见本文档附录。
[root@node1 shell]# pwd
/root/shell
[root@node1 shell]# ll
total 24
-rwxr–r– 1 root root 3544 Apr 24 09:40 1preusers.sh
-rwxr–r– 1 root root 678 Apr 24 09:40 2predir.sh
-rwxr–r– 1 root root 858 Apr 24 09:40 3prelimits.sh
-rwxr–r– 1 root root 465 Apr 24 09:40 4prelogin.sh
-rwxr–r– 1 root root 651 Apr 24 09:40 5preprofile.sh
-rwxr–r– 1 root root 1132 Apr 24 09:40 6presysctl.sh
[root@node1 shell]# ./1preusers.sh
Now create 6 groups named ‘oinstall’,’dba’,’asmadmin’,’asmdba’,’asmoper’,’oper’
Plus 2 users named ‘oracle’,’grid’,Also setting the Environment
Changing password for user grid.
passwd: all authentication tokens updated successfully.
Changing password for user oracle.
passwd: all authentication tokens updated successfully.
The Groups and users has been created
The Environment for grid,oracle also has been set successfully
[root@node1 shell]# id grid
uid=1100(grid) gid=1000(oinstall) groups=1000(oinstall),1200(asmadmin),1201(asmdba),1202(asmoper)
[root@node1 shell]# id oracle
uid=1101(oracle) gid=1000(oinstall) groups=1000(oinstall),1201(asmdba),1300(dba),1301(oper)
[root@node1 shell]#
说明:在节点node2上执行该脚本时,需要将grid用户环境变量ORACLE_SID修改为+ASM2,oracle用户环境变量ORACLE_SID修改为devdb2,ORACLE_HOSTNAME环境变量修改为node2.localdomain
关于grid、oracle用户的环境变量配置信息,见下述表格。
Environment Variable |
Grid User |
Oracle User |
ORACLE_BASE |
/u01/app/grid |
/u01/app/oracle |
ORACLE_HOME |
/u01/app/11.2.0/grid |
/u01/app/oracle/product/11.2.0/db_1 |
ORACLE_SID [node1] |
+ASM1 |
devdb1 |
ORACLE_SID [node2] |
+ASM2 |
devdb2 |
(Figure 2.5环境变量配置信息表)
通过执行上述2.4节中脚本2predir.sh来完成相关路径、权限的配置。脚本的具体内容可见本文档附录。
[root@node1 shell]# pwd
/root/shell
[root@node1 shell]# ./2predir.sh
Now create the necessary directory for oracle,grid users and change the authention to oracle,grid users…
The necessary directory for oracle,grid users and change the authention to oracle,grid users has been
finished
[root@node1 shell]# cd /u01/app/
[root@node1 app]# ll
total 12
drwxrwxr-x 3 grid oinstall 4096 Apr 24 10:06 11.2.0
drwxrwxr-x 2 grid oinstall 4096 Apr 24 10:06 grid
drwxrwxr-x 2 oracle oinstall 4096 Apr 24 10:06 oracle
[root@node1 app]#
通过执行上述2.4节中脚本3prelimits.sh完成。脚本的具体内容可见本文档附录。
[root@node1 shell]# pwd
/root/shell
[root@node1 shell]# ./3prelimits.sh
Now modify the /etc/security/limits.conf,but backup it named /etc/security/limits.conf.bak before
Modifing the /etc/security/limits.conf has been succeed.
[root@node1 shell]#
通过执行上述2.4节中脚本4prelogin.sh完成。脚本的具体内容可见本文档附录。
[root@node1 shell]# pwd
/root/shell
[root@node1 shell]# ./4prelogin.sh
Now modify the /etc/pam.d/login,but with a backup named /etc/pam.d/login.bak
Modifing the /etc/pam.d/login has been succeed.
[root@node1 shell]#
通过执行上述2.4节中脚本5preprofile.sh完成。脚本的具体内容可见本文档附录。
[root@node1 shell]# pwd
/root/shell
[root@node1 shell]# ./5preprofile.sh
Now modify the /etc/profile,but with a backup named /etc/profile.bak
Modifing the /etc/profile has been succeed.
[root@node1 shell]#
通过执行上述2.4节中脚本6presysctl.sh完成。脚本的具体内容可见本文档附录。
[root@node1 shell]# pwd
/root/shell
[root@node1 shell]# ./6presysctl.sh
Now modify the /etc/sysctl.conf,but with a backup named /etc/sysctl.bak
Modifing the /etc/sysctl.conf has been succeed.
Now make the changes take effect…..
net.ipv4.ip_forward = 0
net.ipv4.conf.default.rp_filter = 1
net.ipv4.conf.default.accept_source_route = 0
kernel.sysrq = 0
kernel.core_uses_pid = 1
net.ipv4.tcp_syncookies = 1
kernel.msgmnb = 65536
kernel.msgmax = 65536
kernel.shmmax = 68719476736
kernel.shmall = 4294967296
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2097152
kernel.shmmax = 536870912
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
net.ipv4.ip_local_port_range = 9000 65500
net.core.rmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048586
net.ipv4.tcp_wmem = 262144 262144 262144
net.ipv4.tcp_rmem = 4194304 4194304 4194304
[root@node1 shell]#
[root@node1 ~]# service ntpd status
ntpd is stopped
[root@node1 ~]# chkconfig ntpd off
[root@node1 ~]# cat /etc/ntp
ntp/ ntp.conf
[root@node1 ~]# cp /etc/ntp.conf /etc/ntp.conf.bak
[root@node1 ~]# rm -rf /etc/ntp.conf
[root@node1 ~]#
我们已经在node1完成基本准备配置工作,在node2上重复上述2.2到2.10节中准备工作,以完成节点2的准备工作。
说明:2.3节配置SCAN IP已在节点2上完成,可忽略。2.4节中需要修改对应的环境变量。
虽然在安装软件的过程中,oracle会自动配置SSH对等性,建议在安装软件之前手工配置。
配置oracle用户对等性:
node1:
[root@node1 ~]# su – oracle
node1-> env | grep ORA
ORACLE_UNQNAME=devdb
ORACLE_SID=devdb1
ORACLE_BASE=/u01/app/oracle
ORACLE_HOSTNAME=node1.localdomain
ORACLE_TERM=xterm
ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1
node1-> pwd
/home/oracle
node1-> mkdir ~/.ssh
node1-> chmod 700 ~/.ssh
node1-> ls -al
total 44
drwx—— 4 oracle oinstall 4096 Apr 24 10:47 .
drwxr-xr-x 4 root root 4096 Apr 24 09:41 ..
-rw——- 1 oracle oinstall 5 Apr 24 10:43 .bash_history
-rw-r–r– 1 oracle oinstall 33 Apr 24 09:41 .bash_logout
-rw-r–r– 1 oracle oinstall 823 Apr 24 09:41 .bash_profile
-rw-r–r– 1 oracle oinstall 124 Apr 24 09:41 .bashrc
-rw-r–r– 1 oracle oinstall 515 Apr 24 09:41 .emacs
drwxr-xr-x 4 oracle oinstall 4096 Apr 24 09:41 .mozilla
drwx—— 2 oracle oinstall 4096 Apr 24 10:47 .ssh
-rw-r–r– 1 oracle oinstall 658 Apr 24 09:41 .zshrc
node1-> ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/oracle/.ssh/id_rsa):
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:
4a:bd:22:4c:cc:6a:33:ae:5a:de:7d:7c:8b:77:9e:81 oracle@node1.localdomain
node1-> 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:
8b:50:73:41:03:ad:1c:59:25:aa:40:1c:c9:5e:03:99 oracle@node1.localdomain
node1->
node2:
[root@node2 ~]# su – oracle
node2-> env|grep ORA
ORACLE_UNQNAME=devdb
ORACLE_SID=devdb2
ORACLE_BASE=/u01/app/oracle
ORACLE_HOSTNAME=node2.localdomain
ORACLE_TERM=xterm
ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1
node2-> pwd
/home/oracle
node2-> ls -al
total 40
drwx—— 3 oracle oinstall 4096 Apr 24 10:45 .
drwxr-xr-x 4 root root 4096 Apr 24 10:44 ..
-rw——- 1 oracle oinstall 10 Apr 24 10:49 .bash_history
-rw-r–r– 1 oracle oinstall 33 Apr 24 10:44 .bash_logout
-rw-r–r– 1 oracle oinstall 823 Apr 24 10:44 .bash_profile
-rw-r–r– 1 oracle oinstall 124 Apr 24 10:44 .bashrc
-rw-r–r– 1 oracle oinstall 515 Apr 24 10:44 .emacs
drwxr-xr-x 4 oracle oinstall 4096 Apr 24 10:44 .mozilla
-rw-r–r– 1 oracle oinstall 658 Apr 24 10:44 .zshrc
node2-> mkdir ~/.ssh
node2-> chmod 770 ~/.ssh/
node2-> ls -al
total 44
drwx—— 4 oracle oinstall 4096 Apr 24 10:49 .
drwxr-xr-x 4 root root 4096 Apr 24 10:44 ..
-rw——- 1 oracle oinstall 10 Apr 24 10:49 .bash_history
-rw-r–r– 1 oracle oinstall 33 Apr 24 10:44 .bash_logout
-rw-r–r– 1 oracle oinstall 823 Apr 24 10:44 .bash_profile
-rw-r–r– 1 oracle oinstall 124 Apr 24 10:44 .bashrc
-rw-r–r– 1 oracle oinstall 515 Apr 24 10:44 .emacs
drwxr-xr-x 4 oracle oinstall 4096 Apr 24 10:44 .mozilla
drwxrwx— 2 oracle oinstall 4096 Apr 24 10:49 .ssh
-rw-r–r– 1 oracle oinstall 658 Apr 24 10:44 .zshrc
node2-> ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/oracle/.ssh/id_rsa):
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:
a0:64:81:a6:12:b2:18:4e:01:c3:bd:9d:f6:bb:55:b0 oracle@node2.localdomain
node2-> 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:
85:56:69:73:74:a3:ef:5b:88:d7:6d:ef:90:03:b6:72 oracle@node2.localdomain
node2->
【补充说明:在网友的细心发现下,在node2上配置SSH对等性时,权限需要改成700而不是770!
大大,发现个问题
node2的:
chmod 770 ~/.ssh 需改成
chmod 700 ~/.ssh 么。
770的话node2 一直要口令啊。】
返回节点1:
node1-> id
uid=1101(oracle) gid=1000(oinstall) groups=1000(oinstall),1201(asmdba),1300(dba),1301(oper)
node1-> pwd
/home/oracle
node1-> cat ~/.ssh/id_rsa.pub >>~/.ssh/authorized_keys
node1-> cat ~/.ssh/id_dsa.pub >>~/.ssh/authorized_keys
node1-> ssh node2 cat ~/.ssh/id_rsa.pub >>~/.ssh/authorized_keys
The authenticity of host ‘node2 (172.16.0.192)’ can’t be established.
RSA key fingerprint is a7:6b:2c:2d:fb:c3:ff:33:af:92:cd:7b:99:3b:cf:3a.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added ‘node2,172.16.0.192’ (RSA) to the list of known hosts.
oracle@node2’s password:
node1-> ssh node2 cat ~/.ssh/id_dsa.pub >>~/.ssh/authorized_keys
oracle@node2’s password:
node1-> scp ~/.ssh/authorized_keys node2:~/.ssh/authorized_keys
oracle@node2’s password:
authorized_keys
100% 2040 2.0KB/s 00:00
node1->
验证oracle SSH对等性:
在node1,node2两个节点上分别执行下述命令,第一次执行时需要口令验证:
node1-> id
uid=1101(oracle) gid=1000(oinstall) groups=1000(oinstall),1201(asmdba),1300(dba),1301(oper)
node1-> ssh node1 date
The authenticity of host ‘node1 (172.16.0.191)’ can’t be established.
RSA key fingerprint is 16:c2:67:cd:73:dd:b7:8b:f4:07:ef:e0:fb:36:34:3e.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added ‘node1,172.16.0.191’ (RSA) to the list of known hosts.
Tue Apr 24 11:28:15 CST 2012
node1-> ssh node2 date
Tue Apr 24 11:28:18 CST 2012
node1-> ssh node1-priv date
The authenticity of host ‘node1-priv (192.168.94.11)’ can’t be established.
RSA key fingerprint is 16:c2:67:cd:73:dd:b7:8b:f4:07:ef:e0:fb:36:34:3e.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added ‘node1-priv,192.168.94.11’ (RSA) to the list of known hosts.
Tue Apr 24 11:28:25 CST 2012
node1-> ssh node2-priv date
The authenticity of host ‘node2-priv (192.168.94.12)’ can’t be established.
RSA key fingerprint is a7:6b:2c:2d:fb:c3:ff:33:af:92:cd:7b:99:3b:cf:3a.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added ‘node2-priv,192.168.94.12’ (RSA) to the list of known hosts.
Tue Apr 24 11:28:30 CST 2012
node1-> ssh node1.localdomain date
The authenticity of host ‘node1.localdomain (172.16.0.191)’ can’t be established.
RSA key fingerprint is 16:c2:67:cd:73:dd:b7:8b:f4:07:ef:e0:fb:36:34:3e.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added ‘node1.localdomain’ (RSA) to the list of known hosts.
Tue Apr 24 11:28:39 CST 2012
node1-> ssh node2.localdomain date
The authenticity of host ‘node2.localdomain (172.16.0.192)’ can’t be established.
RSA key fingerprint is a7:6b:2c:2d:fb:c3:ff:33:af:92:cd:7b:99:3b:cf:3a.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added ‘node2.localdomain’ (RSA) to the list of known hosts.
Tue Apr 24 11:28:46 CST 2012
node1-> ssh node2-priv.localdomain date
The authenticity of host ‘node2-priv.localdomain (192.168.94.12)’ can’t be established.
RSA key fingerprint is a7:6b:2c:2d:fb:c3:ff:33:af:92:cd:7b:99:3b:cf:3a.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added ‘node2-priv.localdomain’ (RSA) to the list of known hosts.
Tue Apr 24 11:28:52 CST 2012
node1-> ssh node1-priv.localdomain date
The authenticity of host ‘node1-priv.localdomain (192.168.94.11)’ can’t be established.
RSA key fingerprint is 16:c2:67:cd:73:dd:b7:8b:f4:07:ef:e0:fb:36:34:3e.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added ‘node1-priv.localdomain’ (RSA) to the list of known hosts.
Tue Apr 24 11:28:59 CST 2012
第二次执行时不再提示输入口令,并且可以成功执行命令,则表示oracle用户SSH对等性配置成功
node1:
node1-> ssh node1 date
Tue Apr 24 11:29:02 CST 2012
node1-> ssh node2 date
Tue Apr 24 11:29:07 CST 2012
node1-> ssh node1-priv date
Tue Apr 24 11:29:13 CST 2012
node1-> ssh node2-priv date
Tue Apr 24 11:29:18 CST 2012
node1-> ssh node2-priv.localdomain date
Tue Apr 24 11:29:27 CST 2012
node1-> ssh node1-priv.localdomain date
Tue Apr 24 11:29:33 CST 2012
node1->
node2:
node2-> id
uid=1101(oracle) gid=1000(oinstall) groups=1000(oinstall),1201(asmdba),1300(dba),1301(oper)
node2-> pwd
/home/oracle
node2-> ssh node1 date
Tue Apr 24 11:32:06 CST 2012
node2-> ssh node2 date
Tue Apr 24 11:32:09 CST 2012
node2-> ssh node1-priv date
Tue Apr 24 11:32:14 CST 2012
node2-> ssh node2-priv date
Tue Apr 24 11:32:17 CST 2012
node2-> ssh node1.localdomain date
Tue Apr 24 11:32:26 CST 2012
node2-> ssh node2.localdomain date
Tue Apr 24 11:32:29 CST 2012
node2-> ssh node1-priv.localdomain date
Tue Apr 24 11:32:39 CST 2012
node2-> ssh node2-priv.localdomain date
Tue Apr 24 11:32:43 CST 2012
node2->
至此,Oracle用户SSH对等性配置完成!重复上述步骤,以grid用户配置其对等性。
在任意节点上先创建共享磁盘,然后在另外的节点上选择添加已有磁盘。这里选择先在node2节点机器上创建共享磁盘,然后在node1上添加。共创建4块硬盘,其中2块500M的硬盘,将来用于配置GRIDDG磁盘组,专门存放OCR和Voting Disk;1块3G的磁盘,用于配置DATA磁盘组,存放数据库;1块3G的磁盘,用于配置FLASH磁盘组,用于闪回区;
在node2上创建共享硬盘详细步骤:
① 先关闭节点2 11gnode2,然后选择11gnode2,右键选择编辑设置,Edit settings:
② 在编辑虚拟机对话框下,选择添加,Add,选择硬盘,Next:
③ 选择创建新硬盘,Next:
④ 磁盘大小选择500M,选中支持集群属性,指定磁盘的存放位置,Next:
⑤ 驱动器设备选择SCSI 1:0,模式选择独立,Next:
⑥ 弹出对话框中,Finish:
⑦ 虚拟机属性中,选择刚才新添加的SCSI controller 1驱动器,配置其为Physical模式,用于支持共享,因为这块新添加的硬盘将来要被node1、node2两个节点访问:
⑧ 重复执行上述③—⑥步骤,添加第二块500M硬盘,将其驱动器设备选择SCSI 1:1;
⑨ 如法炮制,添加另外两块3G硬盘,驱动器设备分别选择SCSI 2:0,SCSI 2:1,同样需要配置新添加的SCSI controller 2驱动器模式为Physical模式,用于支持共享。最后,添加完4块共享硬盘的node2配置信息如下:
在node1上添加已有共享硬盘详细步骤:
① 先关闭节点1 11gnode1,然后选择11gnode1,右键选择编辑设置,Edit settings,操作界面同node2上创建共享硬盘步骤①:
② 在编辑虚拟机对话框下,选择添加,Add,选择硬盘,Next,操作界面同node2上创建共享硬盘步骤②:
③ 选择已有虚拟硬盘,Next:
④ 选择指定的存储设备,注意要选择在node2节点中创建的第1块硬盘:
⑤ 驱动器设备选择SCSI 1:0,模式选择独立,Next,操作界面同node2上创建共享硬盘步骤⑤:
⑥ 同样选择新添加的SCSI controller 1驱动器,配置其为Physical模式,用于支持共享,操作界面同node2上创建共享硬盘步骤7:
⑦ 如法炮制,添加剩余的3块硬盘,注意,驱动器编号要依次选择SCSI 1:1、SCSI 2:0、SCSI 2:1。同时要将新添加的SCSI controller 2驱动器模式为Physical模式,用于支持共享。最后,添加完4块共享硬盘的node1配置信息如下:
至此,完成在两个节点上对共享硬盘的添加配置。
评论 (15)
lan| 2012年7月30日
在安装grid的第五步,增加节点时报错。INS-40912
随风| 2013年6月27日
@lan 兄弟,你的问题解决了么?我碰到和你相似的问题,求分享啊
learner| 2013年7月21日
@随风
地址只配eth0和eth1的2个地址其他的子地址不要配,安装时系统会配的,早配上了就提示这个错误
刘延庆·| 2012年11月20日
脚本的具体内容可见本文档附录,脚本在哪里下载呢?
Asher Huang| 2012年11月20日
脚本可在本系列的第8篇日志里下载:
http://www.oracleonlinux.cn/2012/06/step-by-step-install-11gr2-rac-on-linux-8/
刘延庆·| 2012年11月21日
thank you very much!
Danny| 2013年1月3日
Asher 大大 ,感谢您花这么多心思制作,但有一个地方您可能没注意到,在shell script 中 grid user id 为1100, 但表格中填的是1101
dog| 2014年1月10日
大大,发现个问题
node2的:
chmod 770 ~/.ssh 需改成
chmod 700 ~/.ssh 么。
770的话node2 一直要口令啊。
admin| 2014年1月10日
@dog OMG,确实是有问题。配置SSH对等性时,要改成chmod 700 ~/.ssh。
多谢指正!
文章中,我也做出标识说明了,再次多谢!
黑颈| 2014年11月6日
老大:
preusers.sh脚本中grid的ORACLE_SID是+ASM1,
这个+ASM1是从哪里来的,怎么还有个“+”,不同环境应该对应的是什么东西呀?
90root| 2016年1月27日
安装脚本在第8篇日志里没找到
mr.chen| 2018年9月6日
11g自带处理ssh互信问题脚本执行如下:
./sshUserSetup.sh -user oracle -hosts “node1 node2” -advanced -noPromptPassphrase
./sshUserSetup.sh -user grid -hosts “node1 node2” -advanced -noPromptPassphrase
admin| 2018年9月7日
多谢。
ZhouYu| 2018年11月3日
大神,6个shell脚本可以分享出来吗?
admin| 2018年12月7日
文章上就有啊。如果需要完整的文档,脚本、配套软件和视频教程,可以参考:https://dbca.taobao.com/