*******************************
安装操作
author:Guoyj;
createdate:2012-05-05
*******************************
一、安装完Linux后修改VMware的配置文件后缀带.vmx:
disk.locking = "false"
diskLib.dataCacheMaxSize = "0"
diskLib.dataCacheMaxReadAheadSize = "0"
diskLib.DataCacheMinReadAheadSize = "0"
diskLib.dataCachePageSize = "4096"
diskLib.maxUnsyncedWrites = "0"
scsi1.sharedBus = "virtual"
scsi1:0.deviceType = "disk"
scsi1:1.deviceType = "disk"
scsi1:2.deviceType = "disk"
scsi1:3.deviceType = "disk"
scsi1:4.deviceType = "disk"
scsi1:5.deviceType = "disk"
***注:两节点上的共享存储文件名的绝对路径指向同一个共享磁盘!
二、网络
1、IP地址规划
公共IP地址
私有IP地址
虚拟IP地址
2、vi /etc/hosts
10.1.0.173 rac1
10.1.0.174 rac2
10.1.0.175 rac1-vip
10.1.0.176 rac2-vip
192.168.0.173 rac1-priv
192.168.0.174 rac2-priv
172.25.27.101 rac1
172.25.27.102 rac2
172.25.27.103 rac1-vip
172.25.27.104 rac2-vip
192.168.0.173 rac1-priv
192.168.0.174 rac2-priv
三、建用户及目录
[root@rac1 ~]# groupadd oinstall
[root@rac1 ~]# groupadd dba
[root@rac1 ~]# useradd -d /home/ oracle -g oinstall -G dba oracle
[root@rac1 ~]# passwd oracle
[root@rac1 ~]# id oracle
[root@rac1 ~]# mkdir -p /u01/app/oracle/product/10.2.0
[root@rac1 ~]# chown -R oracle:oinstall /u01/app/oracle
[root@rac1 ~]# chmod -R 755 /u01/app/oracle
四、Oracle环境变量
export PS1="`/bin/hostname -s`-> "
export EDITOR=vi
export ORACLE_SID=rac2
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_1
export ORA_CRS_HOME=$ORACLE_BASE/product/10.2.0/crs_1
export LD_LIBRARY_PATH=$ORACLE_HOME/lib
export PATH=$ORACLE_HOME/bin:$ORA_CRS_HOME/bin:$PATH
umask 022
source .bash_profile
五、系统变量
[root@rac1 ~]# vi /etc/sysctl.conf
kernel.shmall = 2097152
kernel.shmmax = 536870912
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
fs.file-max = 65536
net.ipv4.ip_local_port_range = 1024 65000
net.core.rmem_default = 1048576
net.core.rmem_max = 1048576
net.core.wmem_default = 262144
net.core.wmem_max = 262144
[root@node1 Server]# sysctl -p
六、存储规划
LUN1 512M ORC /dev/sdb1 --raw1
LUN2 512M VOTE /dev/sdc1 --raw2
LUN3 2G DATA1 /dev/sdd1 --asm1
LUN4 2G DATA2 /dev/sde1 --asm2
LUN3 2G ARCH1 /dev/sdf1 --asm3
LUN4 2G ARCH2 /dev/sdg1 --asm4
七、配置裸设备
[root@node1 ~]# vi /etc/udev/rules.d/60-raw.rules
增加如下内容:参照/proc/partitions
ACTION=="add", KERNEL=="/dev/sdb1",RUN+="/bin/raw /dev/raw/raw1 %N"
ACTION=="add", ENV{MAJOR}=="8",ENV{MINOR}=="17",RUN+="/bin/raw /dev/raw/raw1 %M %m"
ACTION=="add", KERNEL=="/dev/sdc1",RUN+="/bin/raw /dev/raw/raw2 %N"
ACTION=="add", ENV{MAJOR}=="8",ENV{MINOR}=="33",RUN+="/bin/raw /dev/raw/raw2 %M %m"
ACTION=="add", KERNEL=="/dev/sdd1",RUN+="/bin/raw /dev/raw/raw3 %N"
ACTION=="add", ENV{MAJOR}=="8",ENV{MINOR}=="49",RUN+="/bin/raw /dev/raw/raw3 %M %m"
ACTION=="add", KERNEL=="/dev/sde1",RUN+="/bin/raw /dev/raw/raw4 %N"
ACTION=="add", ENV{MAJOR}=="8",ENV{MINOR}=="65",RUN+="/bin/raw /dev/raw/raw4 %M %m"
ACTION=="add", KERNEL=="/dev/sdf1",RUN+="/bin/raw /dev/raw/raw5 %N"
ACTION=="add", ENV{MAJOR}=="8",ENV{MINOR}=="81",RUN+="/bin/raw /dev/raw/raw5 %M %m"
ACTION=="add", KERNEL=="/dev/sdg1",RUN+="/bin/raw /dev/raw/raw6 %N"
ACTION=="add", ENV{MAJOR}=="8",ENV{MINOR}=="97",RUN+="/bin/raw /dev/raw/raw6 %M %m"
KERNEL=="raw1", WNER="root", GROUP="oinstall", MODE="640"
KERNEL=="raw[2-6]", WNER="oracle", GROUP="oinstall", MODE="660"
[root@rac1 ~]# start_udev
[root@rac1 ~]# ls /dev/raw/ -l
***注意:在第二节点没有看到祼设备,重启即可!
八、其他配置:
设置oracle使用的文件数权限
[root@node1 ~]# vi /etc/security/limits.conf
oracle soft nproc 2047
oracle hard nproc 163844
oracle soft nofile 1024
oracle hard nofile 65536
修改安全限制
[root@rac1 ~]# vi /etc/pam.d/login
session required /lib/security/pam_limits.so
[root@rac1 ~]# vi /etc/profile
if [ $USER = "oracle" ]; then
if [ $SHELL = "/bin/ksh" ]; then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
fi
配置Hangcheck 计时器
[root@rac1 ~]# vi /etc/rc.local
modprobe hangcheck-timer hangcheck-tick=30 hangcheck_margin=180
要立即加载模块,执行“modprobe -v hangcheck-timer”。
九、配置两台机器的SSH信任:
(注意:在开始配置前,检查/etc/hosts文件,并使用Ping命令检查一下各个节点是否可达)
在 rac1 上执行
rac1-> mkdir ~/.ssh
rac1-> chmod 700 ~/.ssh
rac1-> ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/export/home/oracle/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /export/home/oracle/.ssh/id_rsa.
Your public key has been saved in /export/home/oracle/.ssh/id_rsa.pub.
The key fingerprint is:
87:54:4f:92:ba:ed:7b:51:5d:1d:59:5b:f9:44:da:b6
[email protected]
rac1-> ssh-keygen -t dsa
Generating public/private dsa key pair.
Enter file in which to save the key (/export/home/oracle/.ssh/id_dsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /export/home/oracle/.ssh/id_dsa.
Your public key has been saved in /export/home/oracle/.ssh/id_dsa.pub.
The key fingerprint is:
31:76:96:e6:fc:b7:25:04:fd:70:42:04:1f:fc:9a:26
[email protected]
在 rac2 上执行
rac2-> mkdir ~/.ssh
rac2-> chmod 700 ~/.ssh
rac2-> ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/export/home/oracle/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /export/home/oracle/.ssh/id_rsa.
Your public key has been saved in /export/home/oracle/.ssh/id_rsa.pub.
The key fingerprint is:
29:5a:35:ac:0a:03:2c:38:22:3c:95:5d:68:aa:56:66
[email protected]
rac2-> ssh-keygen -t dsa
Generating public/private dsa key pair.
Enter file in which to save the key (/export/home/oracle/.ssh/id_dsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /export/home/oracle/.ssh/id_dsa.
Your public key has been saved in /export/home/oracle/.ssh/id_dsa.pub.
The key fingerprint is:
4c:b2:5a:8d:56:0f:dc:7b:bc:e0:cd:3b:8e:b9:5c:7c
[email protected]
在 rac1 上执行
rac1-> cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
rac1-> cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
rac1-> ssh rac2 cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
The authenticity of host 'rac2 (192.168.2.132)' can't be established.
RSA key fingerprint is 63:d3:52:d4:4d:e2:cb:ac:8d:4a:66:9f:f1:ab:28:1f.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'rac2,192.168.2.132' (RSA) to the list of known hosts.
oracle@rac2's password:
rac1-> ssh rac2 cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
oracle@rac2's password:
rac1-> scp ~/.ssh/authorized_keys rac2:~/.ssh/authorized_keys
oracle@rac2's password:
authorized_keys 100% 1716 1.7KB/s 00:00
在每个节点上测试连接。验证当您再次运行以下命令时,系统是否不提示您输入口令。
ssh rac1 date
ssh rac2 date
ssh rac1-priv date
ssh rac2-priv date
十、安装Cluster
1、可以先检查环境,在Oracle用户执行
[oracle@rac1 cluvfy]$ ./runcluvfy.sh stage -pre crsinst -n rac1,rac2 -verbose
注意,此步执行时,最好两台机器处于同一状态下,/etc/hosts文件中的内容最好一模一样,连空格数、跳格数最好都一模一样。
2、安装到Specify Cluster Configuration时:
点击右下方的Add按钮,依次输入rac2的主机名、私有连接名和虚拟连接名
(注意此步,如果两台机器的/etc/hosts配置不一样,很可能会出现错误。注意都要有127.0.0.1,此IP只能对应localhost.localdomain localhost)
3、设置网卡
会出现两卡,将eth0设为公共的
4、OCR设置,选外部冗余,位置/dev/raw/raw1
5、voting disk的存储位置,外部冗余,位置/dev/raw/raw2
6、安装过程很快
7、运行要求的脚本:
在 rac1 上执行:/opt/ora10g/oraInventory/orainstRoot.sh;
在 rac2 上执行:/opt/ora10g/oraInventory/orainstRoot.sh;
在 rac1 上执行:/opt/ora10g/product/10.2.0/crs_1/root.sh;
在 rac2 上执行:/opt/ora10g/product/10.2.0/crs_1/root.sh;
8.VIP报错(在第二个节点执行第二个脚本之前最好就要修改避免报错)
报错信息:
/opt/ora10g/product/10.2.0/crs_1/jdk/jre//bin/java: error while loading shared libraries: libpthread.so.0:
cannot open shared object file: No such file or directory
那么就在第二个节点修改:
[root@rac2 ~]# vi /home/oracle/product/10.2.1/crs_1/bin/vipca
if [ "$arch" = "i686" -o "$arch" = "ia64" -o "$arch" = "x86_64" ]
then
LD_ASSUME_KERNEL=2.4.19
export LD_ASSUME_KERNEL
fi
unset LD_ASSUME_KERNEL #增加此内容
[root@rac2 ~]# vi /home/oracle/product/10.2.1/crs_1/bin/srvctl
LD_ASSUME_KERNEL=2.4.19
export LD_ASSUME_KERNEL
unset LD_ASSUME_KERNEL #增加此内容
8.在第二个节点执行第二个脚本,如有报错如下操作
Error 0(Native: listNetInterfaces:[3])
[Error 0(Native: listNetInterfaces:[3])]
执行以下命令:
cd $CRS_ORA_HOME/bin
[root@rac2 bin]# ./oifcfg setif -global eth0/172.25.27.0:public
[root@rac2 bin]# ./oifcfg setif -global eth1/192.168.0.0:cluster_interconnect
[root@rac2 bin]# ./oifcfg getif
eth0 121.49.0.128 global public
eth2 192.168.1.0 global cluster_interconnect
[root@rac2 opt]# /opt/ora10g/product/10.2.0/crs_1/bin/vipca
9、安装Oracle软件
安装完成后要执行一个脚本,应该在两台机器分别执行。
10、ORACLE 10gR2 RAC升级至10
11、创建数据库
(1)、注意在第二(或第三个)画面中,选择主机时要选两台主机
(2)、输入全局数据库名时注意大、小写
(3)、选择在ASM中创建数据库,ASM的参数文件选择使用PFILE(没试过选择SPFILE会怎样)
(4)、创建ASM磁盘组 (创建ASM实例前会报告无效的监听器,点OK就行了,它自己会创建一个)
(5)、选择使用OMF,文本框中的内容不必改,直接下一步
(6)、把remote_listener参数注释掉
11、配置网络
所有文件都已经自动配置好,只需要在任意节点进入数据库,发布如下命令:
SQL> alter system set remote_listener=LISTENERS_RACDB sid='*';
System altered.
注意,LISTENERS_RACDB是在Tnsnames.ora中自动配置的端监听器命令。
解决ORA-12545连接失败问题
Oracle在文档Note:364855.1:RAC Connection Redirected To Wrong Host/IP ORA-12545中进行了相信的描述。
并给出了解决方法:修改数据库中的初始化参数LOCAL_LISTENER:
SQL> CONN SYS@TESTRAC1 AS SYSDBA输入口令: ****已连接。
SQL> ALTER SYSTEM SET LOCAL_LISTENER = '(ADDRESS = (PROTOCOL = TCP)(HOST = 172.25.198.224)(PORT = 1521))' SID = 'testrac1';
系统已更改。
SQL> CONN SYS@TESTRAC2 AS SYSDBA输入口令: ****已连接。
SQL> ALTER SYSTEM SET LOCAL_LISTENER = '(ADDRESS = (PROTOCOL = TCP)(HOST = 172.25.198.225)(PORT = 1521))' SID = 'testrac2';
系统已更改。
vi tnsnames.ora
LISTENERS_NCDATA =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = nchost01-vip)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = nchost02-vip)(PORT = 1521))
)
NCDATA =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = nchost01-vip)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = nchost02-vip)(PORT = 1521))
(LOAD_BALANCE = yes)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = ncdata)
(FAILOVER_MODE =
(TYPE = SELECT)
(METHOD = BASIC)
(RETRIES = 180)
(DELAY = 5)
)
)
)
NCDATA2 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = nchost02-vip)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = ncdata)
(INSTANCE_NAME = ncdata2)
)
)
NCDATA1 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = nchost01-vip)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = ncdata)
(INSTANCE_NAME = ncdata1)
)
)
十一、添加服务、配置归档
1、添加服务
看这篇文档:Oracle Clusterware and Oracle Real Application Clusters Administration and Deployment Guide
注意有三步:
(1)、创建服务:
srvctl add service -d RACDB -s test1 -r RACDB1,RACDB2 -a RACDB1,RACDB2 -P Preconnect
(2)、激活服务
这命令只创建服务,在启动新建的服务前,service_name参数不变。下面的命令启动服务:
srvctl start service -d RACDB -s test1
(3)、在Tnsnames.ora中添加TEST2。
2、配置归档
修改参数:
alter system set log_archive_dest_1="location=+DG1";
停止所有实例,重启到Mount状态:
srvctl stop instance -d RACDB -i RACDB1,RACDB2 -o immediate
srvctl start instance -d RACDB -i RACDB1,RACDB2 -o mount
在任一实例执行如下命令:
SQL> alter database archivelog;
Database altered.
在两个实例中都执行alter database open
归档配置完成
3、配置闪回数据库
(1)、设置两个参数:
SQL> alter system set DB_RECOVERY_FILE_DEST_SIZE=500m;
System altered.
SQL> alter system set db_recovery_file_dest='+DG1';
System altered.
(2)、关闭并重启实例到Mount
[oracle@rac1 admin]$ srvctl stop instance -d RACDB -i RACDB1,RACDB2 -o immediate
注意,只能在某一个节点上启动到Mount状态:
[oracle@rac1 admin]$ srvctl start instance -d RACDB -i RACDB1 -o mount
(3)、开启闪回数据库:
alter database flashback on;
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/28460966/viewspace-753587/,如需转载,请注明出处,否则将追究法律责任。