标签:style blog io ar color os sp for 数据
GRID版本: 11.2.0.0.0
Oracle版本: 11.2.0.1
OS: RHEL5.8 x86_64 (2.6.18-308.el5)
#!/bin/bash # 设置当前要配置的节点, 1为node101机器, 2为node102机 SID=1 #SID=2 # ============================================ # 环境 # ============================================ # --------------------------------------- # | 节点 | 主机名称 | IP地址 | # |---------|----------|----------------| # | | rac1-pub | 192.168.80.101 | # | node101 | rac1-vip | 192.168.80.111 | # | | rac1 | 10.0.0.101 | # |---------|----------|----------------| # | | rac2-pub | 192.168.80.102 | # | node102 | rac2-vip | 192.168.80.112 | # | | rac2 | 10.0.0.102 | # |---------|----------|----------------| # | node101 | scan-ip | 192.168.80.121 | # --------------------------------------- # 以上节点为虚拟机, 本地机器IP为192.168.1.175, 且对node101和node102配置了对应的DNS # ============================================ # 准备 # ============================================ 节点内存1600M yum groupinstall "X Window System" -y yum install nfs-utils.x86_64 -y service portmap start yum install rsync -y mkdir /mnt/{grid,database} mount /dev/cdrom /media/cdrom mount -t nfs dns:/media/disk1/grid /mnt/grid mount -t nfs dns:/media/disk1/database /mnt/database/ # ============================================ # 删除 # ============================================ #rm -rf /etc/oracle/ /etc/oraInst.loc /etc/oratab #cd /usr/local/bin/ #rm -f coraenv dbhome oraenv #rm -f /etc/init.d/init.ohasd #rm -f /etc/init.d/ohasd #rm -f /etc/inittab.crs #rm -f /etc/inittab.no_crs #sed -i -r ‘/init.ohasd/d‘ /etc/inittab # ============================================ # 用户和组 # ============================================ groupadd -g 1000 oinstall groupadd -g 1200 asmadmin groupadd -g 1201 asmdba groupadd -g 1202 asmoper groupadd -g 1300 dba groupadd -g 1301 oper useradd -u 1000 -g oinstall -G dba,asmadmin,asmdba,asmoper grid -c "Grid Infrastructure Owner" echo 123456|passwd --stdin grid useradd -u 1001 -g oinstall -G dba,oper,asmdba -c "Oracle Software Owner" oracle echo 123456|passwd --stdin oracle # ============================================ # 环境变量 # ============================================ cat >> /home/grid/.bash_profile <<EOF export ORACLE_BASE=/u01/app/grid export ORACLE_HOME=/u01/app/11.2.0/grid export ORACLE_SID=+ASM$SID export PATH=\$ORACLE_HOME/bin:\$PATH EOF cat >> /home/oracle/.bash_profile <<EOF export ORACLE_BASE=/u01/app/oracle export ORACLE_HOME=\$ORACLE_BASE/product/11.2.0/dbhome_1 export ORACLE_SID=rac$SID export PATH=\$ORACLE_HOME/bin:\$PATH EOF # ============================================ # network # ============================================ sed -s -e ‘s/eth0/eth0:0/‘ -e ‘s/192.168.80.10‘$SID‘/10.0.0.10‘$SID‘/‘ /etc/sysconfig/network-scripts/ifcfg-eth0 > /etc/sysconfig/network-scripts/ifcfg-eth0:0 service network restart ip addr list | grep inet # ============================================ # hostname # ============================================ sed -i -r ‘s/(HOSTNAME=).*/\1rac‘$SID‘/‘ /etc/sysconfig/network hostname rac$SID # ============================================ # hosts # ============================================ [ "$(hostname)" = "rac1" ] && { cat >> /etc/hosts <<EOF 192.168.80.101 rac1-pub.linux.com rac1-pub 192.168.80.111 rac1-vip.linux.com rac1-vip 10.0.0.101 rac1.linux.com rac1 192.168.80.102 rac2-pub.linux.com rac2-pub 192.168.80.112 rac2-vip.linux.com rac2-vip 10.0.0.102 rac2.linux.com rac2 EOF } [ "$(hostname)" = "rac1" ] && { cat >> /etc/hosts << EOF 192.168.80.121 scan-ip.linux.com scan-ip EOF } #rsync -avR /etc/hosts node102:/ # ============================================ # 节点互信 # ============================================ for u in root grid oracle; do su $u -c "ssh-keygen -t rsa" su $u -c "ssh-keygen -t dsa" done for u in root grid oracle; do eval "rsync -av $u@node102:~$u/.ssh/id_rsa.pub ~$u/.ssh/id_rsa.pub.tmp" eval "rsync -av $u@node102:~$u/.ssh/id_dsa.pub ~$u/.ssh/id_dsa.pub.tmp" eval "cat ~$u/.ssh/id_rsa.pub ~$u/.ssh/id_dsa.pub ~$u/.ssh/id_rsa.pub.tmp ~$u/.ssh/id_dsa.pub.tmp > ~$u/.ssh/authorized_keys" # 虚拟机与本地机器的互信, 方便登录配置 eval "cat >> ~$u/.ssh/authorized_keys <<EOF ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA+lexExdw90eqWl6zpLIejL76xIx6LFCBM65tDyL4Pu3IxHoyzKhtD5jK6C3mXIjFCI7YLseDvdVMOkVb8KtPMqsYkiLtQHb2uwNy94XpIzAl0BSDfxWM5/icXr+dnCupDNHMZjcFI6kUU4wZNhzI4Xt+/cFv7+U7Qj6Ij1WJUJGZcxc8F4iVb4n9Ldeukkvc+UQ5j8iMrIykz9aqF31toFgBDMq5ORyKATKRShsU2BKFSkubaEYxOeaNfPFLi2Ycq703yTTCVFRlJkDdZs5J3++uOAcH9mVoeWmYZH4ooN0VE6ILTb0Y8LJOzOSYoYx6nyTG13Ulx0BmOry7rt7ygw== root@dns.linux.com EOF" eval "rsync -av ~$u/.ssh/authorized_keys $u@node102:~/.ssh" eval rm -f ~$u/.ssh/id_rsa.pub.tmp ~$u/.ssh/id_dsa.pub.tmp done for u in grid oracle; do su grid -c ‘for h in rac1 rac1-pub node101 rac2 rac2-pub node102; do echo -ne "$h\t"; ssh $h "date +%F\ %T"; done‘ done #su grid -c "for h in rac1-priv rac1-priv.linux.com rac1-pub rac1-pub.linux.com node101 rac2-priv rac2-priv.linux.com rac2-pub rac2-pub.linux.com node102; do echo -ne \"\$h\t\"; ssh \$h \"date +%F\\\ %T\"; done" # ============================================ # iscsi设备与裸设备 # ============================================ iscsiadm -m discovery -t sendtargets -p 192.168.1.175:3260 iscsiadm -m node -T iqn.2014-11.com.linux:Storage1.target1 -l #iscsiadm -m node -T iqn.2014-11.com.linux:Storage1.target1 -u fdisk /dev/sda # 划分两个4G大小的分区(sda1, sda2) # ============================================ # udev配置 # ============================================ cat >> /etc/udev/rules.d/60-raw.rules <<EOF ACTION=="add", KERNEL=="sda1", RUN+="/bin/raw /dev/raw/raw1 %N" ACTION=="add", KERNEL=="sda2", RUN+="/bin/raw /dev/raw/raw2 %N" KERNEL=="raw[0-9]*", OWNER="grid", GROUP="oinstall", MODE="0660" EOF udevtrigger #rsync -avR /etc/udev/rules.d/60-raw.rules node102:/ # ============================================ # ntpd # ============================================ sed -i -r ‘s/-u/-x -u/‘ /etc/sysconfig/ntpd service ntpd start chkconfig ntpd on # rsync -avR /etc/sysconfig/ntpd node102:/ # ============================================ # 安装目录权限 # ============================================ # grid mkdir /u01 chown -R grid:oinstall /u01/ # oracle mkdir -p /u01/app/oracle chown -R oracle:oinstall /u01/app/oracle # ============================================ # 依赖 # ============================================ yum install libaio.i386 libaio.x86_64 libaio-devel.i386 libaio-devel.x86_64 sysstat.x86_64 unixODBC.i386 unixODBC.x86_64 unixODBC-devel.i386 unixODBC-devel.x86_64 ksh.x86_64 smartmontools.x86_64 -y # ============================================ # 验证 grid环境 # ============================================ su - grid cd /mnt/grid/ ./runcluvfy.sh stage -pre crsinst -n rac1,rac2 -fixup -verbose # ============================================ # 安装 grid # ============================================ ./runInstaller # ============================================ # 安装 oracle 数据库软件 # ============================================ su - oracle cd /mnt/database ./runInstaller # ============================================ # dbca创建数据库 # ============================================ su - oracle dbca
标签:style blog io ar color os sp for 数据
原文地址:http://www.cnblogs.com/tjm-1990/p/4116614.html