1、host配置
cat >> /etc/hosts << EOF
192.168.100.161 dbcc1
192.168.100.162 dbcc2
192.168.100.163 dbcc1-vip
192.168.100.164 dbcc2-vip
192.168.0.161 dbcc1-pip
192.168.0.162 dbcc2-pip
EOF
节点1和节点2一样
2、SSH信任
配置Oracle用户主机之间SSH信任关系
简洁的步骤如下
在主节点上以oracle用户身份生成用户的公匙和私匙
2.1、节点1和2都执行:
rm -rf ~/.ssh/
mkdir ~/.ssh
chmod 700 ~/.ssh/
ssh-keygen -t rsa
ssh-keygen -t dsa
2.2、节点1执行:
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
ssh dbcc2 cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
ssh dbcc2 cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
2.3、节点1执行:
将认证文件传输到节点2
scp ~/.ssh/authorized_keys dbcc2:~/.ssh/authorized_keys
2.4、节点1和2 检验认证命令:
ssh dbcc1 date
ssh dbcc2 date
ssh dbcc1-pip date
ssh dbcc2-pip date
每条命令执行1次后,再次执行,就不需要输入密码,说明信任配置成功;
2.5、操作过程记录如下:
2.5.1节点1
[root@localhost ~]# su - oracle
[oracle@localhost ~]$ rm -rf ~/.ssh/
[oracle@localhost ~]$ mkdir ~/.ssh
[oracle@localhost ~]$ chmod 700 ~/.ssh/
[oracle@localhost ~]$ 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:
4f:58:d4:a8:04:2e:ba:63:bc:8e:c5:c2:16:63:7f:e6 oracle@localhost.localdomain
[oracle@localhost ~]$ 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:
9c:1b:a4:97:27:3e:cb:30:5f:8f:27:e3:48:24:1c:17 oracle@localhost.localdomain
2.5.2、节点2
[root@localhost ~]# su - oracle
[oracle@localhost ~]$ rm -rf ~/.ssh/
[oracle@localhost ~]$ mkdir ~/.ssh
[oracle@localhost ~]$ chmod 700 ~/.ssh/
[oracle@localhost ~]$ 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:
1e:31:9b:11:69:34:68:11:56:79:f5:66:9a:8f:9c:2e oracle@localhost.localdomain
[oracle@localhost ~]$ 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:
e6:77:99:64:50:c5:be:78:88:d9:f9:7e:0e:61:9b:5e oracle@localhost.localdomain
2.5.3、节点1
[oracle@localhost ~]$ cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
[oracle@localhost ~]$ cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
[oracle@localhost ~]$ ssh dbcc2 cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
The authenticity of host 'dbcc2 (192.168.100.162)' can't be established.
RSA key fingerprint is 9e:9d:a7:a2:e2:4d:09:89:a2:bf:dd:ca:02:3f:f3:09.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'dbcc2,192.168.100.162' (RSA) to the list of known hosts.
oracle@dbcc2's password:
[oracle@localhost ~]$ ssh dbcc2 cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
oracle@dbcc2's password:
[oracle@localhost ~]$ scp ~/.ssh/authorized_keys dbcc2:~/.ssh/authorized_keys
oracle@dbcc2's password:
authorized_keys 100% 1712 1.7KB/s 00:00
2.5.4、节点1
[oracle@localhost ~]$ ssh dbcc1 date
The authenticity of host 'dbcc1 (192.168.100.161)' can't be established.
RSA key fingerprint is 9e:9d:a7:a2:e2:4d:09:89:a2:bf:dd:ca:02:3f:f3:09.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'dbcc1,192.168.100.161' (RSA) to the list of known hosts.
Wed Feb 19 14:25:28 CST 2014
[oracle@localhost ~]$ ssh dbcc1 date
Wed Feb 19 14:25:29 CST 2014
[oracle@localhost ~]$ ssh dbcc2 date
Wed Feb 19 14:25:31 CST 2014
[oracle@localhost ~]$ ssh dbcc2 date
Wed Feb 19 14:25:34 CST 2014
[oracle@localhost ~]$ ssh dbcc1 date
Wed Feb 19 14:25:38 CST 2014
公有IP已经不需要密码验证了;
[oracle@localhost ~]$ ssh dbcc1-pip date
The authenticity of host 'dbcc1-pip (192.168.0.161)' can't be established.
RSA key fingerprint is 9e:9d:a7:a2:e2:4d:09:89:a2:bf:dd:ca:02:3f:f3:09.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'dbcc1-pip,192.168.0.161' (RSA) to the list of known hosts.
Wed Feb 19 14:25:51 CST 2014
[oracle@localhost ~]$ ssh dbcc1-pip date
Wed Feb 19 14:25:52 CST 2014
[oracle@localhost ~]$ ssh dbcc2-pip date
The authenticity of host 'dbcc2-pip (192.168.0.162)' can't be established.
RSA key fingerprint is 9e:9d:a7:a2:e2:4d:09:89:a2:bf:dd:ca:02:3f:f3:09.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'dbcc2-pip,192.168.0.162' (RSA) to the list of known hosts.
Wed Feb 19 14:25:56 CST 2014
[oracle@localhost ~]$ ssh dbcc2-pip date
Wed Feb 19 14:25:57 CST 2014
[oracle@localhost ~]$ ssh dbcc1-pip date
Wed Feb 19 14:26:00 CST 2014
私有IP之间也不需要密码验证了;
2.5.5、节点2
[root@localhost ~]# su - oracle
[oracle@localhost ~]$ ssh dbcc1 date
The authenticity of host 'dbcc1 (192.168.100.161)' can't be established.
RSA key fingerprint is 9e:9d:a7:a2:e2:4d:09:89:a2:bf:dd:ca:02:3f:f3:09.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'dbcc1,192.168.100.161' (RSA) to the list of known hosts.
Wed Feb 19 14:26:32 CST 2014
[oracle@localhost ~]$ ssh dbcc1 date
Wed Feb 19 14:26:34 CST 2014
[oracle@localhost ~]$ ssh dbcc2 date
The authenticity of host 'dbcc2 (192.168.100.162)' can't be established.
RSA key fingerprint is 9e:9d:a7:a2:e2:4d:09:89:a2:bf:dd:ca:02:3f:f3:09.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'dbcc2,192.168.100.162' (RSA) to the list of known hosts.
Wed Feb 19 14:26:37 CST 2014
[oracle@localhost ~]$ ssh dbcc2 date
Wed Feb 19 14:26:38 CST 2014
公有IP已经不需要密码验证了;
[oracle@localhost ~]$ ssh dbcc1-pip date
The authenticity of host 'dbcc1-pip (192.168.0.161)' can't be established.
RSA key fingerprint is 9e:9d:a7:a2:e2:4d:09:89:a2:bf:dd:ca:02:3f:f3:09.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'dbcc1-pip,192.168.0.161' (RSA) to the list of known hosts.
Wed Feb 19 14:26:47 CST 2014
[oracle@localhost ~]$ ssh dbcc1-pip date
Wed Feb 19 14:26:49 CST 2014
[oracle@localhost ~]$ ssh dbcc2-pip date
The authenticity of host 'dbcc2-pip (192.168.0.162)' can't be established.
RSA key fingerprint is 9e:9d:a7:a2:e2:4d:09:89:a2:bf:dd:ca:02:3f:f3:09.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'dbcc2-pip,192.168.0.162' (RSA) to the list of known hosts.
Wed Feb 19 14:26:53 CST 2014
[oracle@localhost ~]$ ssh dbcc2-pip date
Wed Feb 19 14:26:54 CST 2014
私有IP已经不需要密码验证了;
3、 ntp时间同步
这里我使用节点1去同步节点1的时间;当然也可以配置一个外部NTP服务器,让两个节点都去与NTP服务器同步
3.1、配置hack计数器
echo "modprobe hangcheck-timer hangcheck-tick=30 hangcheck_margin=180" >> /etc/rc.local
关于hack的作用可以网上查找资料;
简洁 ntp时间同步配置步骤如下:
3.2、节点1
cp /etc/ntp.conf /etc/ntp_`date +%Y%m%d_%H%M%S`.conf
cat /dev/null > /etc/ntp.conf
cat >> /etc/ntp.conf << EOF
server 127.127.1.0
fudge 127.127.1.0 stratum 11
driftfile /var/lib/ntp/drift
broadcastdelay 0.008
EOF
cat /etc/ntp.conf
/etc/init.d/ntpd restart
ntpq -p
chkconfig ntpd on
3.3、节点2
cp /etc/ntp.conf /etc/ntp_`date +%Y%m%d_%H%M%S`.conf
cat /dev/null > /etc/ntp.conf
cat >> /etc/ntp.conf << EOF
server 192.168.100.161 prefer
driftfile /var/lib/ntp/drift
broadcastdelay 0.008
EOF
cat /etc/ntp.conf
ntpdate 192.168.100.161
/etc/init.d/ntpd restart
ntpq -p
chkconfig ntpd on
3.4、节点2手工同步一下
service ntpd stop
ntpdate 192.168.100.161
service ntpd start
4、NTP时间同步执行情况:
[root@localhost asm]# cp /etc/ntp.conf /etc/ntp_`date +%Y%m%d_%H%M%S`.conf
[root@localhost asm]# cat /dev/null > /etc/ntp.conf
[root@localhost asm]# cat >> /etc/ntp.conf << EOF
> server 127.127.1.0
> fudge 127.127.1.0 stratum 11
> driftfile /var/lib/ntp/drift
> broadcastdelay 0.008
> EOF
[root@localhost asm]# cat /etc/ntp.conf
server 127.127.1.0
fudge 127.127.1.0 stratum 11
driftfile /var/lib/ntp/drift
broadcastdelay 0.008
[root@localhost asm]# /etc/init.d/ntpd restart
Shutting down ntpd: [FAILED]
Starting ntpd: [ OK ]
[root@localhost asm]# ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
LOCAL(0) LOCAL(0) 11 l 6 64 1 0.000 0.000 0.008
[root@localhost asm]# chkconfig ntpd on
[root@localhost asm]# chkconfig --list | grep ntp
ntpd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
节点2:
[root@localhost asm]# cp /etc/ntp.conf /etc/ntp_`date +%Y%m%d_%H%M%S`.conf
[root@localhost asm]#
[root@localhost asm]# cat /dev/null > /etc/ntp.conf
[root@localhost asm]#
[root@localhost asm]# cat >> /etc/ntp.conf << EOF
> server 192.168.100.161 prefer
> driftfile /var/lib/ntp/drift
> broadcastdelay 0.008
> EOF
[root@localhost asm]# cat /etc/ntp.conf
server 192.168.100.161 prefer
driftfile /var/lib/ntp/drift
broadcastdelay 0.008
[root@localhost asm]# /etc/init.d/ntpd restart
Shutting down ntpd: ntpq -p
[chkconfig ntpd onFAILED]
Starting ntpd: [ OK ]
[root@localhost asm]# chkconfig ntpd on
[root@localhost asm]# ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
dbcc1 .INIT. 16 u 8 64 0 0.000 0.000 4000.00
说明节点2同步到节点1 dbcc1 了
节点2手工同步一下:
[root@localhost asm]# service ntpd stop
Shutting down ntpd: [ OK ]
[root@localhost asm]# ntpdate 192.168.100.161
19 Feb 14:47:12 ntpdate[3322]: step time server 192.168.100.161 offset 29.177440 sec
[root@localhost asm]# service ntpd start
Starting ntpd: [ OK ]
NTP时间同步配置完成;
