在vmware workstation 10版本上部署 oracle 11g R2 RAC
oracle版本 11.2.0.1
grid版本 11.2.0.1
系统版本 oracle enterprise 5.5 x86-64 (2G内存、单核双线程cpu)
#!/bin/sh
cat <<EOF > /etc/sysconfig/network
NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=rac2.yuanlei.com
EOF
hostname rac2.yuanlei.com
安装之前,两个节点的共享存储是一个大问题,注意先调节好磁盘问题再进行其它操作
-- 解决两个节点的共享问题是
1、在一台节点上添加磁盘
2、添加完成后,在磁盘高级选项处次改磁盘的配置
vmware虚拟机 默认使用SCSI 0:0 --->以此类推
我们之后在第一台机器上,添加了4块磁盘
在磁盘容量处勾选 将虚拟磁盘存储为单个文件(O)
设置第一个节点编号为
SCSI 1:0 1G
SCSI 1:1 1G
SCSI 2:0 5G
SCSI 2:1 5G
3、在第二个节点添加的时候 选择已经存在的磁盘,将四块磁盘添加上
并设置四块磁盘编号
SCSI 1:0 1G
SCSI 1:1 1G
SCSI 2:0 5G
SCSI 2:1 5G
4、最后打开两天虚拟机的.vmx配置文件,添加以下所缺少的内容,
保证两个节点之间的配置文件都有以下内容
disk.locking="FALSE"
diskLib.dataCacheMaxSize="0"
diskLib.dataCacheMaxReadAheadSize="0"
diskLib.dataCacheMinReadAheadSize="0"
diskLib.maxUnsyncedWrites="0"
scsi1.present = "TRUE"
scsi2.present = "TRUE"
scsi1.virtualDev = "lsilogic"
scsi2.virtualDev = "lsilogic"
scsi1.ShareBus="Virtual"
scsi2.ShareBus="Virtual"
scsi1:0.present = "TRUE"
scsi1:0.deviceType = "disk"
scsi1:0.redo = ""
scsi1:0.mode = "independent-persistent"
scsi1:0.fileName = "D:\虚拟机 集合\vm share disk\rac001.vmdk"
scsi1:1.present = "TRUE"
scsi1:1.deviceType = "disk"
scsi1:1.redo = ""
scsi1:1.mode = "independent-persistent"
scsi1:1.fileName = "D:\虚拟机 集合\vm share disk\rac002.vmdk"
scsi2:0.present = "TRUE"
scsi2:0.deviceType = "disk"
scsi2:0.redo = ""
scsi2:0.mode = "independent-persistent"
scsi2:0.fileName = "D:\虚拟机 集合\vm share disk\rac003.vmdk"
scsi2:1.present = "TRUE"
scsi2:1.deviceType = "disk"
scsi2:1.redo = ""
scsi2:1.mode = "independent-persistent"
scsi2:1.fileName = "D:\虚拟机 集合\vm share disk\rac004.vmdk"
这样能实现两个节点对四块磁盘的共享
-- 确保三个地方主机名一致
hostname rac1.yuanlei.com
[root@yuanlei ~]# vi /etc/sysconfig/network
NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=rac1.yuanlei.com
[root@yuanlei ~]# vi /etc/hosts
1、-- 编辑hosts文件,两个节点都执行
cat >> /etc/hosts <<EOF
#eth0 public
192.168.2.1 rac1.yuanlei.com rac1
192.168.2.2 rac2.yuanlei.com rac2
#virtual
192.168.2.3 rac1-vip.yuanlei.com rac1-vip
192.168.2.4 rac2-vip.yuanlei.com rac2-vip
#eth1 private
172.16.79.1 rac1-priv.yuanlei.com rac1-priv
172.16.79.2 rac2-priv.yuanlei.com rac2-priv
#scan
192.168.2.5 rac-scan.yuanlei.com rac-scan
EOF
-- 挂载光盘
mount -t iso9660 /dev/cdrom/ /media
-- 配置开机挂载光盘
cat >> /etc/fstab <<EOF
/dev/cdrom /media iso9660 defaults 0 0
EOF
5、-- 配置yum客户端
cat <<EOF > /etc/yum.repos.d/rhel-source.repo
[rhel-source]
name=Red Hat Enterprise Linux
baseurl=file:///media/Server
enabled=1
gpgcheck=0
EOF
2、-- 搭建DNS服务器,集体过程请参看其它资料
-- DNS客户端
[root@rac1 ~]# vi /etc/resolv.conf
search yuanlei.com
nameserver 192.168.2.2
-- 实现结果如下
[root@yuanlei ~]# host rac-scan.yuanlei.com
scan.yuanlei.com has address 192.168.2.5
[root@rac1 ~]# host rac-scan
rac-scan.yuanlei.com has address 192.168.2.5
[root@rac1 ~]# host 192.168.2.5
5.2.168.192.in-addr.arpa domain name pointer scan.yuanlei.com.
5.2.168.192.in-addr.arpa domain name pointer rac-scan.
3、-- 配置各个网卡的ip
cat <<EOF > /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
HWADDR=00:0C:29:46:CA:AD
TYPE=Ethernet
UUID=06aa639b-4c46-4477-b5a4-8aaba2ab511f
NM_CONTROLLED=no
ONBOOT=yes
IPADDR=192.168.1.1
NETMASK=255.255.255.0
GATEWAY=192.168.1.10
EOF
4、 -- 系统配置,关掉一些不必要的服务
chkconfig cups off
chkconfig sendmail off
service iptables stop
chkconfig iptables off
setenforce 0
6、-- 建立oracle和grid用户和组
groupadd oper
groupadd asmadmin
groupadd asmdba
groupadd asmoper
groupadd oinstall
groupadd dba
useradd -g oinstall -G dba,asmdba,oper oracle
useradd -g oinstall -G dba,asmdba,asmadmin,asmoper grid
mkdir -p /u01/app/11.2.0/grid
mkdir -p /u01/app/grid
mkdir -p /u01/app/oracle
mkdir -p /u01/app/oraInventory
chmod -R 775 /u01/
chown -R grid:oinstall /u01
chown -R oracle:oinstall /u01/app/oracle
chown -R grid:oinstall /u01/app/grid
chown -R grid:oinstall /u01/app/11.2.0/grid
cat >> /etc/security/limits.conf <<EOF
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
oracle soft stack 10240
grid soft nproc 2047
grid hard nproc 16384
grid soft nofile 1024
grid hard nofile 65536
grid soft stack 10240
EOF
cat >>/etc/profile <<EOF
if [ $USER = "oracle" ] || [ $USER = "grid" ]; then
if [ $SHELL = "/bin/ksh" ]; then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
umask 022
fi
EOF
-- 节点rac1 脚本用root身份执行
cat >> /home/oracle/.bash_profile <<EOF
PATH=$PATH:$HOME/bin
export NLS_DATE_FORMAT="yy-mm-dd HH24:MI:SS"
export ORACLE_SID=rac1
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1
export PATH=$PATH:$ORACLE_HOME/bin
EOF
cat >> /home/grid/.bash_profile <<EOF
export TMP=/tmp
export TMPDIR=$TMP
PATH=$PATH:$HOME/bin
export NLS_DATE_FORMAT="yy-mm-dd HH24:MI:SS"
export ORACLE_SID=+ASM1
export ORACLE_HOSTNAME=rac1.yuanlei.com
export ORACLE_BASE=/u01/app/grid
export ORACLE_HOME=/u01/app/11.2.0/grid
export PATH=$PATH:$ORACLE_HOME/bin
EOF
-- 节点二
cat >> /home/oracle/.bash_profile <<EOF
PATH=$PATH:$HOME/bin
export NLS_DATE_FORMAT="yy-mm-dd HH24:MI:SS"
export ORACLE_SID=rac2
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_2
export PATH=$PATH:$ORACLE_HOME/bin
EOF
cat >> /home/grid/.bash_profile <<EOF
PATH=$PATH:$HOME/bin
export NLS_DATE_FORMAT="yy-mm-dd HH24:MI:SS"
export TMP=/tmp
export TMPDIR=$TMP
export ORACLE_SID=+ASM2
export ORACLE_HOSTNAME=rac2.yuanlei.com
export ORACLE_BASE=/u01/app/grid
export ORACLE_HOME=/u01/app/11.2.0/grid
export PATH=/u01/app/11.2.0/grid/bin:$PATH
EOF
cat >> /etc/sysctl.conf <<EOF
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 = 1048576
EOF
sysctl -p
-- 安装必要的系统软件包
yum -y install binutils-* \
binutils-* \
compat-libstdc++* \
elfutils-libelf-* \
elfutils-libelf-devel-* \
gcc-* \
gcc-c++-* \
glibc-* \
glibc-common-* \
glibc-devel-* \
glibc-headers-* \
ksh-20060214* \
libaio-* \
libaio-devel-* \
libgcc-4.1.2* \
libstdc++-* \
libstdc++-devel* \
make-* \
sysstat-* \
unixODBC-* \
lrzsz*
-- 在两个节点上都停止NTP服务,因为oracle 11g R2 集群自己又维护时间同步的机制
-- 两个节点都执行
-- 停止ntp服务,11g r2 时间同步采用集群自带同步软件
service ntpd stop
chkconfig ntpd off
cp /etc/ntp.conf /etc/ntp.conf.bak
rm -rf /etc/ntp.conf
-- 建立两台服务器之间的等效对等性
-- grid用户执行
- rac1 上
mkdir ~/.ssh
chmod 700 ~/.ssh
ssh-keygen -t rsa
ssh-keygen -t dsa
- rac2 上
mkdir ~/.ssh
chmod 700 ~/.ssh
ssh-keygen -t rsa
ssh-keygen -t dsa
- rac1 因为是相互拷贝,所以在一台节点上执行一次就可以
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
ssh grid@rac2 cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
ssh grid@rac2 cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
因为是相互拷贝,所以在一台节点上执行一次就可以
scp ~/.ssh/authorized_keys grid@rac2:~/.ssh/authorized_keys
-- oracle用户执行
- rac1 上
mkdir ~/.ssh
chmod 700 ~/.ssh
ssh-keygen -t rsa
ssh-keygen -t dsa
- rac2 上
mkdir ~/.ssh
chmod 700 ~/.ssh
ssh-keygen -t rsa
ssh-keygen -t dsa
- rac1
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
ssh oracle@rac2 cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
ssh oracle@rac2 cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
scp ~/.ssh/authorized_keys oracle@rac2:~/.ssh/authorized_keys
-- 检查要保证每个节点每个用户执行以下8次,保证不让输入密码
ssh rac1 date
ssh rac1.yuanlei.com date
ssh rac2 date
ssh rac2.yuanlei.com date
ssh rac1-priv date
ssh rac1-priv.yuanlei.com date
ssh rac2-priv date
ssh rac2-priv.yuanlei.com date
-- 配置ASM磁盘
-- 查看系统内核版本,确保asm版本与系统的内核版本一致
[root@yuanlei ~]# uname -rm
2.6.18-194.el5 x86_64
[root@yuanlei oracleasm]# ll
total 252
-rwxrwxr-x 1 oracle oinstall 137486 Oct 22 21:32 oracleasm-2.6.18-194.el5-2.0.5-1.el5.x86_64.rpm
-rwxrwxr-x 1 oracle oinstall 14176 Oct 21 17:06 oracleasmlib-2.0.4-1.el5.x86_64.rpm
-rwxrwxr-x 1 oracle oinstall 91430 Oct 21 17:05 oracleasm-support-2.1.7-1.el5.x86_64.rpm
-- 安装asm软件包,注意按照顺序安装软件包
[root@yuanlei oracleasm]# rpm -ivh oracleasm-support-2.1.7-1.el5.x86_64.rpm
warning: oracleasm-support-2.1.7-1.el5.x86_64.rpm: Header V3 DSA signature: NOKEY, key ID 1e5e0159
Preparing... ########################################### [100%]
1:oracleasm-support ########################################### [100%]
[root@yuanlei oracleasm]# rpm -ivh oracleasm-2.6.18-194.el5-2.0.5-1.el5.x86_64.rpm
warning: oracleasm-2.6.18-194.el5-2.0.5-1.el5.x86_64.rpm: Header V3 DSA signature: NOKEY, key ID 1e5e0159
Preparing... ########################################### [100%]
1:oracleasm-2.6.18-194.el########################################### [100%]
[root@yuanlei oracleasm]# rpm -ivh oracleasmlib-2.0.4-1.el5.x86_64.rpm
warning: oracleasmlib-2.0.4-1.el5.x86_64.rpm: Header V3 DSA signature: NOKEY, key ID 1e5e0159
Preparing... ########################################### [100%]
1:oracleasmlib ########################################### [100%]
[root@yuanlei oracleasm]#
-- 配置ASM driver服务,两个节点都执行
-- 查看服务状态
[root@yuanlei ~]# /usr/sbin/oracleasm status
Checking if ASM is loaded: no
Checking if /dev/oracleasm is mounted: no
-- 查看帮助
[root@yuanlei ~]# /usr/sbin/oracleasm -h
Usage: oracleasm [--exec-path=<exec_path>] <command> [ <args> ]
oracleasm --exec-path
oracleasm -h
oracleasm -V
The basic oracleasm commands are:
configure Configure the Oracle Linux ASMLib driver
init Load and initialize the ASMLib driver
exit Stop the ASMLib driver
scandisks Scan the system for Oracle ASMLib disks
status Display the status of the Oracle ASMLib driver
listdisks List known Oracle ASMLib disks
querydisk Determine if a disk belongs to Oracle ASMlib
createdisk Allocate a device for Oracle ASMLib use
deletedisk Return a device to the operating system
renamedisk Change the label of an Oracle ASMlib disk
update-driver Download the latest ASMLib driver
-- 配置asm
[root@yuanlei ~]# /usr/sbin/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 <ENTER> without typing an
answer will keep that current value. Ctrl-C will abort.
Default user to own the driver interface []: grid
Default group to own the driver interface []: asmadmin
Start Oracle ASM library driver on boot (y/n) [n]: y
Scan for Oracle ASM disks on boot (y/n) [y]: y
Writing Oracle ASM library driver configuration: done
-- 初始化加载
[root@yuanlei oracleasm]# /usr/sbin/oracleasm init
Loading module "oracleasm": oracleasm
Mounting ASMlib driver filesystem: /dev/oracleasm
-- 用四个共享的分区去创建asm标签磁盘
-- 在其中任何一个节点上执行
[grid@rac1 grid]$ /usr/sbin/oracleasm createdisk name1 /dev/sdb1
[grid@rac1 grid]$ /usr/sbin/oracleasm createdisk name2 /dev/sdc1
[grid@rac1 grid]$ /usr/sbin/oracleasm createdisk name3 /dev/sdd1
[grid@rac1 grid]$ /usr/sbin/oracleasm createdisk name4 /dev/sde1
[grid@rac1 grid]$ /usr/sbin/oracleasm listdisks --查看
-- 在另外一个节点上第一次查看,会看不到所创建的asm磁盘
-- 要扫描一下,即可看到
[grid@rac1 grid]$ /usr/sbin/oracleasm scandisks
[grid@rac1 grid]$ /usr/sbin/oracleasm listdisks
ok
-- 在grid用户下,最后检查一下整体的grid配置环境,是否满足检测要求
[grid@rac1 grid]$ ./runcluvfy.sh stage -pre crsinst -n rac1,rac2 -fixup -verbose
如果所有的检查项目在两个节点都 显示 passed
则最后会显示最后一条成功报告
-- 我的在检查的时候,遇到几个问题,检查不成功,原因提示有相关的软件包没有安装,和ntp服务没有停止
安装相关包和停止ntp 服务后都解决
Pre-check for cluster services setup was successful. ---看到这个基本就没事了ok
-- 两个节点都安装cvuqdisk-1.0.7-1.rpm包
[root@yuanlei rpm]# cd ..
[root@yuanlei grid]# ls
doc install response rpm runcluvfy.sh runInstaller sshsetup stage welcome.html
[root@yuanlei grid]# cd rpm/
[root@yuanlei rpm]# ls
cvuqdisk-1.0.7-1.rpm
[root@yuanlei rpm]# rpm -ivh cvuqdisk-1.0.7-1.rpm
Preparing... ########################################### [100%]
Using default group oinstall to install package
1:cvuqdisk ########################################### [100%]
-- 在安装grid时,遭遇OUI-10182的
解决方法
1.确保安装的ORACLE_BASE目录是属于oinstall组。
2.用root帐户在/etc下建立oraInst.loc,并写入以下内容:
inventory_loc=/u01/app/oraInventory
inst_group=oinstall
3.重新执行安装程序。
OK
-- 命令
ls -ltr 最新所创建的目录
df -TH