赞
踩
作者:IT邦德
中国DBA联盟(ACDU)成员,目前从事DBA及程序编程
(Web\java\Python)工作,主要服务于生产制造
现拥有 Oracle 11g OCP/OCM、
Mysql、Oceanbase(OBCA)认证
分布式TBase\TDSQL数据库、国产达梦数据库以及红帽子认证
从业8年DBA工作,在数据库领域有丰富的经验
擅长主流数据Oracle、MySQL、PG 运维开发,备份恢复,安装迁移,性能优化、故障应急处理等。
本文介绍了RAC的原理以及RHEL6.4操作系统安装部署Oracle11G的详细过程
希望给各位大学僧,网友,DBA们一些帮助,我是一个乐于分享的人,大家点赞关注哈
具体安装步骤参考以下博客
RHEL 6.4 操作系统安装文档
视频教程:
RHEL 6.4 操作系统安装视频教程
节点 1:rac1,添加两块网卡,一块 NAT 模式,一块仅主机模式,添加共享文件夹
节点 2:rac2,添加两块网卡,一块 NAT 模式,一块仅主机模式,添加共享文件夹
注:MAC地址重新生成
注意:2台服务器均做设置,并修改对应的Mac地址 vi /etc/sysconfig/network-scripts/ifcfg-eth0 vi /etc/sysconfig/network-scripts/ifcfg-eth1 DEVICE=eth0 HWADDR=00:50:56:3D:59:C1 TYPE=Ethernet UUID=d75da050-2a7c-4c1a-877d-103596eff910 ONBOOT=yes NM_CONTROLLED=yes BOOTPROTO=static GATEWAY=192.168.1.4 IPADDR=192.168.1.10 NETMASK=255.255.255.0 DEVICE=eth1 HWADDR=00:50:56:25:4D:F5 TYPE=Ethernet UUID=d75da050-2a7c-4c1a-877d-103596eff910 ONBOOT=yes NM_CONTROLLED=yes BOOTPROTO=static #GATEWAY=192.168.1.4 IPADDR=192.168.6.118 NETMASK=255.255.255.0 service network restart --重启网络 reboot --重启系统
重启后生效
开启: chkconfig iptables on
关闭: chkconfig iptables off
即时生效,重启后失效
开启: service iptables start
关闭: service iptables stop
永久方法 – 需要重启服务器
修改/etc/selinux/config文件中设置SELINUX=disabled ,然后重启服务器
查看状态为:/usr/sbin/sestatus
vi /etc/hosts 节点1和节点2相同 #eth0 public 192.168.1.10 rac1 192.168.1.11 rac2 #virtual 192.168.1.12 rac1-vip 192.168.1.13 rac2-vip #private 192.168.6.118 rac1-priv 192.168.6.119 rac2-priv #scan 192.168.1.111 rac-scan 192.168.1.112 rac-scan 192.168.1.113 rac-scan 注:vi /etc/sysconfig/network,然后将HOSTNAME后面的值改为想要设置的主机名 service network restart --重启网卡
在 D:\Program Files (x86)\VMware\VMware Workstation 路径下打开 DOS 窗口
运行如下命令:
vmware-vdiskmanager.exe -c -s 2g -a lsilogic -t 2 F:\rac\rac-sharedisk\ocr_voting_disk.vmdk
vmware-vdiskmanager.exe -c -s 5g -a lsilogic -t 2 F:\rac\rac-sharedisk\fra_arc_disk.vmdk
vmware-vdiskmanager.exe -c -s 5g -a lsilogic -t 2 F:\rac\rac-sharedisk\data_disk.vmdk
关闭两台虚拟机,用记事本打开虚拟机名字.wmx(11G RAC1.vmx/11G RAC2.vmx),添加以下内容: disk.locking = "FALSE" diskLib.dataCacheMaxSize = "0" diskLib.dataCacheMaxReadAheadSize = "0" diskLib.dataCacheMinReadAheadSize = "0" diskLib.maxUnsyncedWrites = "0" scsi1.present = "TRUE" scsi1.virtualDev = "lsilogic" scsil.sharedBus = "VIRTUAL" scsi1:0.present = "TRUE" scsi1:0.mode = "independent-persistent" scsi1:0.fileName = "F:\rac\rac-sharedisk\ocr_voting_disk1.vmdk" scsi1:0.deviceType = "disk" scsi1:0.redo = "" scsi1:1.present = "TRUE" scsi1:1.mode = "independent-persistent" scsi1:1.fileName = "F:\rac\rac-sharedisk\ocr_voting_disk2.vmdk" scsi1:1.deviceType = "disk" scsi1:1.redo = "" scsi1:2.present = "TRUE" scsi1:2.mode = "independent-persistent" scsi1:2.fileName = "F:\rac\rac-sharedisk\ocr_voting_disk3.vmdk" scsi1:2.deviceType = "disk" scsi1:2.redo = "" scsi1:3.present = "TRUE" scsi1:3.mode = "independent-persistent" scsi1:3.fileName = "F:\rac\rac-sharedisk\data_disk.vmdk" scsi1:3.deviceType = "disk" scsi1:3.redo = "" scsi1:4.present = "TRUE" scsi1:4.mode = "independent-persistent" scsi1:4.fileName = "F:\rac\rac-sharedisk\fra_arc_disk.vmdk" scsi1:4.deviceType = "disk" scsi1:4.redo = ""
a.放系统光盘到光驱 b.创建光盘挂载目录 mkdir -p /mnt/cdrom c.挂载光驱到/mnt/cdrom目录(确保设备状态:已连接/启动时连接) mount /dev/sr0 /mnt/cdrom 返回mount: /dev/sr0 写保护,将以只读方式挂载 表示成功 d.检测是否成功 df -h | tail -n 1 e.进入光盘目录查看光盘文件 cd /mnt/cdrom && ls f.修改yum配置 备份你的原镜像文件,以免出错后可以恢复 mkdir /etc/yum.repos.d/backup && mv /etc/yum.repos.d/*.repo /etc/yum.repos.d/backup/ g.添加一个新的yum源配置文件 vi /etc/yum.repos.d/dvd.repo 添加: [RHEL] name=CentOS7 baseurl=file:///mnt/cdrom gpgcheck=0 gpgkey=file:///mnt/cdrom/RPM-GPG-KEY-CentOS-7 enabled=1 h.清空并重载yum yum clean all yum makecache i.测试yum安装 yum -y install tree
yum install gcc* binutils* compat* elfutils-libelf-* glibc* ksh* libgcc* libstdc* libaio* make* sysstat* unixODBC* expect* java* xdpy* nfs-utils* ntp* perl*-y
记住此处少一个包,需要下载安装,方法如下:
rpm -e ksh-20100621-19.el6.x86_64 --卸载依赖包
rpm -ivh pdksh-5.2.14-30.x86_64.rpm
groupadd oinstall groupadd dba groupadd oper groupadd asmadmin groupadd asmdba groupadd asmoper useradd -g oinstall -G dba,asmdba,asmadmin,asmoper grid --添加grid用户 useradd -g oinstall -G dba,oper,asmdba oracle --添加oracle用户 echo -n oracle|passwd --stdin grid --修改密码 echo -n oracle|passwd --stdin oracle --修改密码 mkdir -p /u01/app/11.2.0/grid mkdir -p /u01/app/grid mkdir -p /u01/app/oracle chown grid:oinstall /u01/app/11.2.0/grid chown grid:oinstall /u01/app/grid chown -R oracle:oinstall /u01/app/oracle chmod -R 775 /u01/ chown grid:oinstall /u01
sed -i 's/kernel.shmmax/#kernel.shmmax/g' /etc/sysctl.conf sed -i 's/kernel.shmall/#kernel.shmall/g' /etc/sysctl.conf cat >> /etc/sysctl.conf << EOF fs.aio-max-nr = 1048576 fs.file-max = 6815744 kernel.shmall = 2097152 kernel.shmmax = 1073741824 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 EOF sysctl -p #提交内核参数
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
#############################
export PATH=\$PATH:/u01/app/11.2.0/grid/bin
#color of grep
alias grep='grep --color=auto'
EOF
节点1 cat >> /home/grid/.bash_profile <<EOF export TMP=/tmp; export TMPDIR=\$TMP; export ORACLE_HOSTNAME=rac1; export ORACLE_SID=+ASM1; export ORACLE_BASE=/u01/app/grid; export ORACLE_HOME=/u01/app/11.2.0/grid; export NLS_DATE_FORMAT="yy-mm-dd HH24:MI:SS"; export PATH=\$ORACLE_HOME/bin:\$PATH; export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK; EOF 节点2 cat >> /home/grid/.bash_profile <<EOF export TMP=/tmp; export TMPDIR=\$TMP; export ORACLE_HOSTNAME=rac2; export ORACLE_SID=+ASM2; export ORACLE_BASE=/u01/app/grid; export ORACLE_HOME=/u01/app/11.2.0/grid; export NLS_DATE_FORMAT="yy-mm-dd HH24:MI:SS"; export PATH=\$ORACLE_HOME/bin:\$PATH; export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK; EOF
节点1 cat >> /home/oracle/.bash_profile <<EOF export TMP=/tmp; export TMPDIR=\$TMP; export ORACLE_HOSTNAME=rac1; export ORACLE_BASE=/u01/app/oracle; export ORACLE_HOME=\$ORACLE_BASE/product/11.2.0/db_1; export ORACLE_UNQNAME=prod; export ORACLE_SID=prod1; export ORACLE_TERM=xterm; export PATH=/usr/sbin:\$PATH; export PATH=\$ORACLE_HOME/bin:\$PATH; export LD_LIBRARY_PATH=\$ORACLE_HOME/lib:/lib:/usr/lib; export CLASSPATH=\$ORACLE_HOME/JRE:\$ORACLE_HOME/jlib:\$ORACLE_HOME/rdbms/jlib; export NLS_DATE_FORMAT="yyyy-mm-dd HH24:MI:SS"; export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK; EOF 节点2 cat >> /home/oracle/.bash_profile <<EOF export TMP=/tmp; export TMPDIR=\$TMP; export ORACLE_HOSTNAME=rac2; export ORACLE_BASE=/u01/app/oracle; export ORACLE_HOME=\$ORACLE_BASE/product/11.2.0/db_1; export ORACLE_UNQNAME=prod; export ORACLE_SID=prod2; export ORACLE_TERM=xterm; export PATH=/usr/sbin:\$PATH; export PATH=\$ORACLE_HOME/bin:\$PATH; export LD_LIBRARY_PATH=\$ORACLE_HOME/lib:/lib:/usr/lib; export CLASSPATH=\$ORACLE_HOME/JRE:\$ORACLE_HOME/jlib:\$ORACLE_HOME/rdbms/jlib; export NLS_DATE_FORMAT="yyyy-mm-dd HH24:MI:SS"; export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK; EOF . .bash_profile 或者 source .bash_profile --环境变量设置生效
rac1 ssh-keygen -t rsa ssh-keygen -t dsa rac2 ssh-keygen -t rsa ssh-keygen -t dsa #以上用默认配置,一路回车即可 rac1 cat ~/.ssh/*.pub >> ~/.ssh/authorized_keys ssh grid@rac2 cat ~/.ssh/*.pub >> ~/.ssh/authorized_keys rac2 cat ~/.ssh/*.pub >> ~/.ssh/authorized_keys ssh grid@rac1 cat ~/.ssh/*.pub >> ~/.ssh/authorized_keys #建立等效性 rac1,rac2 双节点执行 ssh rac1 date ssh rac1-priv date ssh rac2 date ssh rac2-priv date
rac1 ssh-keygen -t rsa ssh-keygen -t dsa rac2 ssh-keygen -t rsa ssh-keygen -t dsa #以上用默认配置,一路回车即可 rac1 cat ~/.ssh/*.pub >> ~/.ssh/authorized_keys ssh oracle@rac2 cat ~/.ssh/*.pub >> ~/.ssh/authorized_keys rac2 cat ~/.ssh/*.pub >> ~/.ssh/authorized_keys ssh oracle@rac1 cat ~/.ssh/*.pub >> ~/.ssh/authorized_keys #建立等效性 rac1,rac2 双节点执行 ssh rac1 date ssh rac1-priv date ssh rac2 date ssh rac2-priv date
[root@rac1 ~]# uname -r
[root@rac1 ~]# uname -a
[root@rac1 ~]# lsb_release -a
2.6.32-358.el6.x86_64
注意:双节点执行 Oracle ASMlib 下载地址 http://www.oracle.com/technetwork/server-storage/linux/downloads/index.html 下载以下 rpm 包(注意 rpm 包版本和 Linux 内核版本一致): oracleasmlib-2.0.4-1.el6.x86_64.rpm oracleasm-support-2.1.8-1.el6.x86_64.rpm kmod-oracleasm-2.0.6.rh1-2.el6.x86_64.rpm 执行顺序如下: rpm -ivh kmod-oracleasm-2.0.6.rh1-2.el6.x86_64.rpm rpm -ivh oracleasm-support-2.1.8-1.el6.x86_64.rpm rpm -ivh oracleasmlib-2.0.4-1.el6.x86_64.rpm 查看oracleasm.ko 的位置 [root@rac1 ~]# cd /lib/modules/ [root@rac1 modules]# ll
注意:双节点执行
[root@rac1 ~]# oracleasm configure -i
Default user to own the driver interface []: grid
Default group to own the driver interface []: oinstall
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@rac1 ~]# oracleasm init
Creating /dev/oracleasm mount point: /dev/oracleasm
Loading module "oracleasm": oracleasm
Mounting ASMlib driver filesystem: /dev/oracleasm
注意:节点1执行即可 fdisk -l [root@rac1 ~]# fdisk /dev/sdb Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel Building a new DOS disklabel. Changes will remain in memory only, until you decide to write them. After that, of course, the previous content won't be recoverable. Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite) Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 1 First cylinder (1-261, default 1): Using default value 1 Last cylinder or +size or +sizeM or +sizeK (1-261, default 261): Using default value 261 Command (m for help): Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks. /dev/sdc,/dev/sdd 执行相同操作 [root@rac1 ~]# fdisk -l --查看分区情况
注意:节点1执行即可 [root@rac1 ~]# oracleasm createdisk OCR_VOTE /dev/sdb1 Writing disk header: done Instantiating disk: done [root@rac1 ~]# oracleasm createdisk DATA /dev/sdc1 Writing disk header: done Instantiating disk: done [root@rac1 ~]# oracleasm createdisk FRA /dev/sdd1 Writing disk header: done Instantiating disk: done 注:若有报错可能原因是selinux阻止访问disk header 修改/etc/selinux/config 注释掉 SELINUX=enforcing 添加 SELINUX=disable 查看状态为:/usr/sbin/sestatus
节点1: [root@rac1 ~]# oracleasm scandisks Reloading disk partitions: done Cleaning any stale ASM disks... Scanning system for ASM disks... [root@rac1 ~]# oracleasm listdisks DATA FRA OCR_VOTE 节点2: [root@rac2 ~]# oracleasm scandisks Reloading disk partitions: done Cleaning any stale ASM disks... Scanning system for ASM disks... Instantiating disk "OCR_VOTE" Instantiating disk "DATA" Instantiating disk "FRA" [root@rac2 ~]# oracleasm listdisks DATA FRA OCR_VOTE
find -name cvuqdisk* 1节点: [root@rac1 ~]# mkdir -p /software/grid [root@rac1 ~]# cd /software/grid [root@rac1 grid]# ll [root@rac1 grid]# unzip linux.x64_11gR2_grid.zip [root@rac1 grid]# chown -R grid:oinstall grid/ [root@rac1 rpm]# export CVUQDISK_GRP=oinstall [root@rac1 rpm]# rpm -ivh cvuqdisk-1.0.9-1.rpm 2节点: [root@rac2 ~]# mkdir -p /software/grid [root@rac2 ~]# cd /software/grid [root@rac2 grid]# ll [root@rac2 grid]# unzip linux.x64_11gR2_grid.zip [root@rac2 grid]# chown -R grid:oinstall grid/ [root@rac2 rpm]# export CVUQDISK_GRP=oinstall [root@rac2 rpm]# rpm -ivh cvuqdisk-1.0.9-1.rpm
[grid@rac1 grid]$ pwd
/software/grid/grid
[grid@rac1 grid]$ ./runcluvfy.sh stage -post hwos -n rac1,rac2 -verbose
Checking for multiple users with UID value 0
Result: Check for multiple users with UID value 0 passed
Post-check for hardware and operating system setup was successful
注意:此处若有以下报错,则授权即可
/bin/rm: cannot remove `/tmp/bootstrap': Operation not permitted
./runcluvfy.sh: line 99: /tmp/bootstrap/ouibootstrap.log: Permission denied
[root@rac1 ~]# chown -R grid:oinstall /tmp/bootstrap
Xmanager软件安装与使用
使用 Xmanager,可以将远程服务器的图形化安装界面显示到宿主机(win7)
Linux 操作系统上安装 Oracle 数据库软件时将会使用到 Xmanager 软件
在启动Xmanager 后就可以调用图形化界面
[grid@rac1 grid]$ export DISPLAY=192.168.1.2:0.0
[grid@rac1 grid]$ ./runInstaller
以 root 用户按顺序执行 1.[root@rac1 ~]# /u01/app/oraInventory/orainstRoot.sh 2.[root@rac2 ~]# /u01/app/oraInventory/orainstRoot.sh 3.[root@rac1 ~]# /u01/app/11.2.0/grid/root.sh 4.[root@rac2 ~]# /u01/app/11.2.0/grid/root.sh 11G的BUG处理 CRS-4124: Oracle High Availability Services startup failed. 如何处理? 首先卸载grid软件: /u01/app/11.2.0/grid/crs/install/roothas.pl -deconfig -force -verbose 重新执行root.sh脚本 在执行Adding daemon to inittab这一步的同时,打开个窗口, 用root用户执行:/bin/dd if=/var/tmp/.oracle/npohasd of=/dev/null bs=1024 count=1 配置 root 环境变量 [root@rac1 ~]# vi .bash_profile export PATH=$PATH:/u01/app/11.2.0/grid/bin . .bash_profile [root@rac2 ~]# vi .bash_profile export PATH=$PATH:/u01/app/11.2.0/grid/bin . .bash_profile [root@rac1 ~]# crsctl check crs [root@rac2 ~]# crsctl check crs [root@rac1 ~]# crsctl stat res -t [grid@rac1 ~]$ crs_stat -t [grid@rac1 ~]$ crs_stat -t -v
本次任务将创建 3 个 asm 磁盘组,分别为:DATA,FRA。
其中 DATA 将存放数据库文件;ARC存放归档
在 grid 用户下,执行 asmca,启动 asm 磁盘组创建向导
点击 create 按钮,在弹出的创建界面中填写磁盘组名称,
选择 external(none),并勾选成员,选择完毕后点击 ok
[root@rac1 ~]# crsctl check crs
[root@rac2 ~]# crsctl check crs
[root@rac1 software]# unzip linux.x64_11gR2_database_1of2.zip
[root@rac1 software]# unzip linux.x64_11gR2_database_2of2.zip
以 oracle 用户登录到节点一,切换到软件安装目录,执行安装
[root@rac1 software]# chown -R oracle:oinstall database/
[oracle@rac1 software]$ cd database
[oracle@rac1 database]$ ll
以 oracle 用户登录到节点一,切换到软件安装目录,执行安装
[oracle@rac1 database]$ export DISPLAY=192.168.1.2:0.0
[oracle@rac1 database]$ ./runInstaller
以 oracle 用户登录到节点一,切换到软件安装目录,执行安装
以 root 用户,在两个节点上执行脚本,执行顺序如下:
[root@rac1 ~]# /u01/app/oracle/product/11.2.0/db_1/root.sh
[root@rac2 ~]# /u01/app/oracle/product/11.2.0/db_1/root.sh
本文涉及到所有安装包,请通过以下链接下载:
RAC部署安装包下载
大家点赞、收藏、关注、评论啦 、查看
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。