1.实验环境:
1.OS:Oracle Linux Server release 6.6;
2.Oracle:12.1.0.2.0;
3.Node1:
1.hostname:node1.oracle.com;
2.public ip:192.168.10.170(eth0);
3.private ip:191.168.20.170(eth1);
4.virtual ip:192.168.10.173;
4.Node2:
1.hostname:node2.oracle.com;
2.public ip:192.168.10.171(eth0);
3.private ip:191.168.20.171(eth1);
4.virtual ip:192.168.10.174;
5.SCAN IP:192.168.10.177/192.168.10.178/192.168.10.179;
2.配置网络环境,安装软件包并调整服务器的时间和参数:
1.设置服务器名:hostname;
2.修改/etc/hosts,/etc/sysconfig/network;
3.使用ntp服务器保持时间同步;
4.设置IP地址;
5.配置DNS服务器,并修改/etc/resolv.conf配置文件;
6.安装软件包:yum -y install binutils* compat-lib* gcc* glibc* ksh make* sysstat* unixODBC* libgcc* libstdc++* libaio* libXext* libXtst* libX11* libXau* libxcb* libXi*;
7.分别修改/etc/sysctl.conf文件;
8.分别修改/etc/security/limits.conf文件;
9.修改/etc/pam.d/login文件;
10.创建grid和oracle用户及添加相应的环境变量;
11.关闭防火墙和SELinux;
3.使用udev创建共享磁盘;
4.安装GI;
1.解压软件;
2.安装cvu相关rpm包:rpm -ivh /tools/grid/rpm/cvuqdisk-1.0.9-1.rpm;
3.安装前校验:/tools/grid/runcluvfy.sh stage -pre crsinst -n node1,node2 -verbose;
4.最后检查资源状态:crsctl stat res -t;
5.使用asmca命令创建磁盘组;
1.创建GI的时候已经创建了CRS磁盘组;
2.创建DATA磁盘组;
3.创建FRA磁盘组;
6.安装数据库软件;
7.安装数据库;
1.查看资源状态:crsctl stat res -t;
2.查看RAC数据库配置信息:srvctl config database -d ORCL/srvctl status database -d ORCL/srvctl status listener;
----------------------- 网络配置 -----------------------
-- 修改主机名;
hostname node1.oracle.com
hostname node2.oracle.com
-- 修改/etc/hosts;
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
# Public IP
192.168.10.170 node1.oracle.com node1
192.168.10.171 node2.oracle.com node2
# Private IP
192.168.20.170 node1-pri.oracle.com node1-pri
192.168.20.171 node2-pri.oracle.com node2-pri
# VIP
192.168.10.172 node1-vip.oracle.com node1-vip
192.168.10.173 node2-vip.oracle.com node2-vip
# Scan IP
192.168.10.177 rac-cluster-scan.oracle.com rac-cluster-scan
#192.168.10.178 rac-cluster-scan.oracle.com rac-cluster-scan
#192.168.10.179 rac-cluster-scan.oracle.com rac-cluster-scan
# DNS Server
#192.168.10.180 rac-dns.oracle.com rac-dns
-- 修改/etc/sysconfig/network;
HOSTNAME=node1.oracle.com
HOSTNAME=node2.oracle.com
----------------------- 网络配置 -----------------------
----------------------- 系统参数 -----------------------
-- 修改/etc/sysctl.conf文件;
fs.file-max = 6815744
kernel.sem = 250 32000 100 128
kernel.shmmni = 4096
kernel.shmall = 1073741824
kernel.shmmax = 4398046511104
net.core.rmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048576
fs.aio-max-nr = 1048576
net.ipv4.ip_local_port_range = 9000 65500
> sysctl -p;
-- 修改/etc/security/limits.conf文件;
grid soft nproc 2047
grid hard nproc 16384
grid soft nofile 4096
grid hard nofile 65536
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 4096
oracle hard nofile 65536
-- 修改/etc/pam.d/login文件;
session required /lib/security/pam_limits.so
session required pam_limits.so
----------------------- 系统参数 -----------------------
----------------------- 创建用户 -----------------------
-- 创建用户组;
groupadd -g 10001 oinstall
groupadd -g 10002 dba
groupadd -g 10003 oper
groupadd -g 10004 backupdba
groupadd -g 10005 dgdba
groupadd -g 10006 kmdba
groupadd -g 10007 asmdba
groupadd -g 10008 asmoper
groupadd -g 10009 asmadmin
-- 创建用户;
useradd -u 10000 -g oinstall -G dba,oper,asmdba,backupdba,dgdba,kmdba oracle;
useradd -u 10001 -g oinstall -G dba,asmdba,asmoper,asmadmin grid;
-- 创建软件目录;
mkdir -p /u01/app/grid;
mkdir -p /u01/app/12.1.0/grid;
mkdir -p /u01/app/oracle/product/12.1.0/db_1;
chown -R grid:oinstall /u01;
chown -R oracle:oinstall /u01/app/oracle;
chmod -R 775 /u01;
-- 设置grid用户的环境变量.bash_profile
ORACLE_HOSTNAME=node1.oracle.com
ORACLE_SID=+ASM1
ORACLE_BASE=/u01/app/grid
ORACLE_HOME=/u01/app/12.1.0/grid
PATH=$ORACLE_HOME/bin:/usr/sbin:$PATH
LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib:/lib
CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
export ORACLE_HOSTNAME ORACLE_SID ORACLE_BASE ORACLE_HOME PATH LD_LIBRARY_PATH CLASSPATH
alias sqlplus='rlwrap sqlplus'
-- 设置oracle用户的环境变量.bash_profile
ORACLE_HOSTNAME=node1.oracle.com
ORACLE_SID=ORCL1
ORACLE_UNQNAME=ORCL
ORACLE_BASE=/u01/app/oracle
ORACLE_HOME=$ORACLE_BASE/product/12.1.0/db_1
PATH=$ORACLE_HOME/bin:/usr/sbin:$PATH
LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
export ORACLE_HOSTNAME ORACLE_SID ORACLE_UNQNAME ORACLE_BASE ORACLE_HOME PATH LD_LIBRARY_PATH CLASSPATH
alias sqlplus='rlwrap sqlplus'
----------------------- 创建用户 -----------------------
----------------------- 创建共享磁盘 -----------------------
-- 在一个虚拟机中创建[固定大小]的虚拟磁盘;
-- 然后在[管理]->[虚拟介质管理]界面,修虚拟磁盘的类型为[可共享];
-- 添加到另外的虚拟机中;
----------------------- 创建共享磁盘 -----------------------
----------------------- 使用udev配置共享磁盘 -----------------------
-- 生成udev规则文件的脚本;
for i in a b c d e f g h i j k l m n o p q r s t u v w x y z
do
echo "KERNEL==\"sd*\", BUS==\"scsi\", PROGRAM==\"/sbin/scsi_id --whitelisted --replace-whitespace --device=/dev/\$name\", RESULT==\"`/sbin/scsi_id --whitelisted --replace-whitespace --device=/dev/sd$i`\", NAME=\"asm-disk$i\", OWNER=\"grid\", GROUP=\"asmadmin\", MODE=\"0660\""
done
-- 检查是否安装udev;
rpm -qa | grep udev
-- 添加规则文件vi /etc/udev/rules.d/99-oracle-asmdevices.rules;(内容可以通过脚本生成)
KERNEL=="sd*", BUS=="scsi", PROGRAM=="/sbin/scsi_id --whitelisted --replace-whitespace --device=/dev/$name", RESULT=="1ATA_VBOX_HARDDISK_VBab81d7dc-431ca37f", NAME="asm-crs", OWNER="grid", GROUP="asmadmin", MODE="0660"
KERNEL=="sd*", BUS=="scsi", PROGRAM=="/sbin/scsi_id --whitelisted --replace-whitespace --device=/dev/$name", RESULT=="1ATA_VBOX_HARDDISK_VBe8fa478f-cd38bd32", NAME="asm-data1", OWNER="grid", GROUP="asmadmin", MODE="0660"
KERNEL=="sd*", BUS=="scsi", PROGRAM=="/sbin/scsi_id --whitelisted --replace-whitespace --device=/dev/$name", RESULT=="1ATA_VBOX_HARDDISK_VB57dac3e5-ff6636ce", NAME="asm-data2", OWNER="grid", GROUP="asmadmin", MODE="0660"
KERNEL=="sd*", BUS=="scsi", PROGRAM=="/sbin/scsi_id --whitelisted --replace-whitespace --device=/dev/$name", RESULT=="1ATA_VBOX_HARDDISK_VB04158991-1baaa75c", NAME="asm-data3", OWNER="grid", GROUP="asmadmin", MODE="0660"
KERNEL=="sd*", BUS=="scsi", PROGRAM=="/sbin/scsi_id --whitelisted --replace-whitespace --device=/dev/$name", RESULT=="1ATA_VBOX_HARDDISK_VB389c5a94-92168d11", NAME="asm-fra1", OWNER="grid", GROUP="asmadmin", MODE="0660"
KERNEL=="sd*", BUS=="scsi", PROGRAM=="/sbin/scsi_id --whitelisted --replace-whitespace --device=/dev/$name", RESULT=="1ATA_VBOX_HARDDISK_VBbfb07df0-3eca3187", NAME="asm-fra2", OWNER="grid", GROUP="asmadmin", MODE="0660"
-- 将该规则文件拷贝到其他节点上;
-- 在所有节点上启动udev服务;
/sbin/start_udev
-- 检查文件;
ll /dev/
----------------------- 使用udev配置共享磁盘 -----------------------
----------------------- RAC的启动和关闭顺序 -----------------------
1.关闭RAC:
1.关闭数据库:停止所有节点上的实例[oracle@node1 ~]$ srvctl stop database -d ORCL;
2.停止OHAS(Oracle High Availability Services):[root@node1 ~]# $GRID_HOME/crsctl stop has -f;
3.停止集群服务:root@node1 ~]# $GRID_HOME/crsctl stop cluster [-all];
2.启动RAC,默认开机会自启动,手工启动的顺序如下:
1.启动集群:root@node1 ~]# $GRID_HOME/crsctl start cluster [-all];
2.启动OHAS:root@node1 ~]# $GRID_HOME/crsctl start has;
3.启动数据库:[oracle@node1 ~]$ srvctl start database -d ORCL;
----------------------- RAC的启动和关闭顺序 -----------------------