本篇内容主要讲解“Oracle RAC+DG环境搭建的方法是什么”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“Oracle RAC+DG环境搭建的方法是什么”吧!
公司专注于为企业提供网站制作、网站建设、微信公众号开发、商城网站开发,微信小程序定制开发,软件定制网站制作等一站式互联网企业服务。凭借多年丰富的经验,我们会仔细了解各客户的需求而做出多方面的分析、设计、整合,为客户设计出具风格及创意性的商业解决方案,创新互联公司更提供一系列网站制作和网站推广的服务。
分两个脚本 env.sh 和rpm.sh
env.sh 整体脚本如下,修改相关数据库实例名后,在四台主机上直接执行:
#!/bin/bash # #Purpose: 1. set the Environment and OS parameter # 2. create 6 groups (oinstall,dba,oper,asmadmin,asmdba,asmoper) and 2 user(oracle,grid) # 3. create the necessary directory # #Usage: It would be called by main.sh or you can execute it alonely and Separately in two nodes. # Log on as the superuser('root'),and then execute this script # #Notice: # 2. you can edit the config firtly. It will be run in two nodes, so you must modify # ORACLE_SID and ORACLE_SID_GRID # #Author: yunxiaochong #################################################################################################### ################ config ############################################## #########Define parameter, Same as the following directory. (refer to step 2) ##################### #################################################################################################### #oracle # ORACLE_SID="DEVDB1" # ORACLE_BASE="/u01/app/oracle" # ORACLE_HOME="${ORACLE_BASE}/product/11.2/db_1" # ORACLE_HOSTNAME=`hostname` # ORACLE_UNQNAME='DEVDB' # ORACLE_BASE_HEAD=/`echo $ORACLE_BASE | cut -d\/ -f2` #/u01 # APP=$ORACLE_BASE_HEAD/`echo $ORACLE_BASE | cut -d\/ -f3` #/u01/app # # #grid # ORACLE_SID_GRID="+ASM1" # ORACLE_BASE_GRID="/u01/app/grid" # ORACLE_HOME_GRID="/u01/app/11.2/grid" # #################################################################################################### ## HOSTNAME ## IPTABLES #service iptables stop > /dev/null #chkconfig iptables off > /dev/null #config DNS # vim /etc/resolv.conf # search localdomain # nameserver 10.28.254.19 #chkconfig iptables off # vm /etc/hosts ##SELinux #setenforce 0 #vim /etc/selinux/config #SELINUX=disabled #ntpd #service ntpd status #chkconfig ntpd off ################################################################################ ########### steps infomation ################### ################################################################################ echo "*************************************************************************" echo "** step0 : clean user and group and delete directory **" echo "** step1 : create 6 groups and 2 users **" echo "** step2 : create necessary directory for oracle and grid **" echo "** step3 : Set the Environment ~/.bash_profile **" echo "** step4 : modify the /etc/security/limits.conf. **" echo "** step5 : modify the /etc/pam.d/login. **" echo "** step6 : modify the /etc/profile. **" echo "** step7 : modify the /etc/sysctl.conf and make the changes take effect**" echo "*************************************************************************" #step0: check OS (cpu and mem) ################# #################clear log rm -rf ./log &> /dev/null ################################################################################# ######## step0: clean user and group and delete directory ############ ################################################################################# ##clean users for user in oracle grid do id $user &> /dev/null if [ $? -eq 0 ]; then userdel -r $user echo "step0_1 :: deleted existed $user" >> ./log fi done ##clean groups for group in dba oinstall oper asmadmin asmdba asmoper do egrep "^$group" /etc/group &>/dev/null if [ $? -eq 0 ]; then groupdel $group echo "step0_2 :: deleted existed $group" >> ./log fi done ##clean directories rm -rf $ORACLE_BASE rm -rf $ORACLE_BASE_GRID rm -rf $ORACLE_HOME_GRID echo "Successful finished...step0 : cleaned users,groups and directories" | tee -a ./log ################################################################################# ############### step1: create groups and users ####################### ################################################################################# #create groups groupadd -g 1100 oinstall group_oinstall=$? groupadd -g 1101 dba group_dba=$? groupadd -g 1102 oper group_oper=$? #----------------------------------# groupadd -g 1200 asmadmin group_asmadmin=$? groupadd -g 1201 asmdba group_asmdba=$? groupadd -g 1202 asmoper group_asmoper=$? #create users useradd -m -u 1100 -g oinstall -G dba,oper,asmdba -d /home/oracle -s /bin/bash -c "Oracle Software Owner" oracle user_oracle=$? echo "oracle" | passwd --stdin oracle >/dev/null user_oracle_p=$? #----------------------------------------------------------------------# useradd -m -u 1200 -g oinstall -G asmadmin,asmdba,asmoper -d /home/grid -s /bin/bash -c "Grid Infrastructure Owner" grid user_grid=$? echo "grid" | passwd --stdin grid >/dev/null user_grid_P=$? if [ $group_oinstall == 0 -a $group_asmadmin == 0 -a $group_asmdba == 0 -a $group_asmoper == 0 \ -a $user_grid == 0 -a $user_grid_P == 0 -a $group_dba == 0 -a $group_oper == 0 \ -a $user_oracle == 0 -a $user_oracle_p == 0 ];then echo "step1_1 :: created groups and users" >> ./log else echo "create groups and users failed" exit 1 fi echo "Successful finished...step1 : created users and groups" | tee -a ./log #################################################################################### ############# step2: create directory ##################### #################################################################################### #step2 : create directory if [ ! -d $ORACLE_BASE_GRID -a ! -d $ORACLE_HOME_GRID ]; then mkdir -p $ORACLE_BASE_GRID mkdir -p $ORACLE_HOME_GRID chown -R grid:oinstall $ORACLE_BASE_HEAD echo "step2_1 ::directory for grid finished" >> ./log else echo "step2_1 ::directory for grid create failed" >> ./log exit 2 fi if [ ! -d $ORACLE_BASE ]; then mkdir -p $ORACLE_BASE chown oracle:oinstall $ORACLE_BASE chmod -R 775 $ORACLE_BASE_HEAD echo "step2_2::directory for oracle finished" >> ./log else echo "step2_2::directory for oracle is already OK" >> ./log exit 2 fi echo "Successful finished...step2 : The necessary directory has been finished" | tee -a ./log #################################################################################### ############# step3: Set the Environment ~/.bash_profile ##################### #################################################################################### ##oracle .bash_profile sed -i '/TMP/d' /home/oracle/.bash_profile echo "export TMP=/tmp">> /home/oracle/.bash_profile sed -i '/TMPDIR/d' /home/oracle/.bash_profile echo 'export TMPDIR=$TMP'>>/home/oracle/.bash_profile sed -i '/ORACLE_HOSTNAME/d' /home/oracle/.bash_profile echo "export ORACLE_HOSTNAME=${ORACLE_HOSTNAME}">> /home/oracle/.bash_profile sed -i '/ORACLE_SID/d' /home/oracle/.bash_profile echo "export ORACLE_SID=${ORACLE_SID}">> /home/oracle/.bash_profile sed -i '/PS1/d' /home/oracle/.bash_profile echo 'export PS1="[\u@${ORACLE_SID}@\h:\W]"' >> /home/oracle/.bash_profile sed -i '/ORACLE_BASE/d' /home/oracle/.bash_profile echo "export ORACLE_BASE=${ORACLE_BASE}">> /home/oracle/.bash_profile sed -i '/ORACLE_HOME/d' /home/oracle/.bash_profile echo "export ORACLE_HOME=${ORACLE_HOME}">> /home/oracle/.bash_profile sed -i '/ORACLE_UNQNAME/d' /home/oracle/.bash_profile echo "export ORACLE_UNQNAME=${ORACLE_UNQNAME}">> /home/oracle/.bash_profile sed -i '/TNS_ADMIN/d' /home/oracle/.bash_profile echo "export TNS_ADMIN=${ORACLE_HOME}/network/admin" >> /home/oracle/.bash_profile sed -i '/ORACLE_TERM/d' /home/oracle/.bash_profile echo "export ORACLE_TERM=xterm">> /home/oracle/.bash_profile sed -i '/PATH/d' /home/oracle/.bash_profile #echo "export PATH=/usr/sbin:$PATH">> /home/oracle/.bash_profile echo "export PATH=${ORACLE_HOME}/bin:$PATH">> /home/oracle/.bash_profile sed -i '/LD_LIBRARY_PATH/d' /home/oracle/.bash_profile echo "export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib">> /home/oracle/.bash_profile sed -i '/CLASSPATH/d' /home/oracle/.bash_profile echo "export CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib">> /home/oracle/.bash_profile sed -i '/EDITOR/d' /home/oracle/.bash_profile echo "export EDITOR=vim" >> /home/oracle/.bash_profile sed -i '/LANG=en_US/d' /home/oracle/.bash_profile echo "export" >> /home/oracle/.bash_profile sed -i '/NLS/d' /home/oracle/.bash_profile echo "export NLS_LANG=american_america.AL32UTF8" >> /home/oracle/.bash_profile echo "export NLS_DATE_FORMAT='yyyy/mm/dd hh34:mi:ss'" >> /home/oracle/.bash_profile sed -i '/umask/d' /home/oracle/.bash_profile echo "umask 022">> /home/oracle/.bash_profile echo "modify the /home/oracle/.bash_profile had been succeed." >> ./log ##grid .bash_profile sed -i '/TMP/d' /home/grid/.bash_profile echo "export TMP=/tmp">> /home/grid/.bash_profile sed -i '/TMPDIR/d' /home/grid/.bash_profile echo "export TMPDIR=$TMP">>/home/grid/.bash_profile sed -i '/ORACLE_SID/d' /home/grid/.bash_profile echo "export ORACLE_SID=$ORACLE_SID_GRID">> /home/grid/.bash_profile sed -i '/PS1/d' /home/oracle/.bash_profile echo 'export PS1="[\u@${ORACLE_SID}@\h:\W]"' >> /home/oracle/.bash_profile sed -i '/ORACLE_BASE/d' /home/grid/.bash_profile echo "export ORACLE_BASE=$ORACLE_BASE_GRID">> /home/grid/.bash_profile sed -i '/ORACLE_HOME/d' /home/grid/.bash_profile echo "export ORACLE_HOME=$ORACLE_HOME_GRID">> /home/grid/.bash_profile sed -i '/ORACLE_TERM/d' /home/grid/.bash_profile echo "export ORACLE_TERM=xterm">> /home/grid/.bash_profile sed -i '/NLS/d' /home/grid/.bash_profile echo "export NLS_DATE_FORMAT='yyyy/mm/dd hh34:mi:ss'" >> /home/grid/.bash_profile echo "export TNS_ADMIN=$ORACLE_HOME_GRID/network/admin" >> /home/grid/.bash_profile sed -i '/PATH/d' /home/grid/.bash_profile echo "export PATH=$ORACLE_HOME_GRID/bin:$PATH">> /home/grid/.bash_profile echo "export LD_LIBRARY_PATH=$ORACLE_HOME_GRID/lib:/lib:/usr/lib">> /home/grid/.bash_profile sed -i '/CLASSPATH/d' /home/grid/.bash_profile echo "export CLASSPATH=$ORACLE_HOME_GRID/JRE:$ORACLE_HOME_GRID/jlib:$ORACLE_HOME_GRID/rdbms/jlib">> /home/grid/.bash_profile sed -i '/EDITOR/d' /home/grid/.bash_profile echo "export EDITOR=vim" >> /home/grid/.bash_profile sed -i '/LANG/d' /home/grid/.bash_profile echo "export" >> /home/grid/.bash_profile echo "export NLS_LANG=american_america.AL32UTF8" >> /home/grid/.bash_profile sed -i '/umask/d' /home/grid/.bash_profile echo "umask 022">> /home/grid/.bash_profile echo "modify the /home/grid/.bash_profile had been succeed." >> ./log echo "Successful finished...step3 : The Environment(~/.bash_profile ) has been set successfully" | tee -a ./log ##################################################################################################### ################ step4 : modify the /etc/security/limits.conf ####################### ##################################################################################################### #backup firstly \cp /etc/security/limits.conf /etc/security/limits.conf.bak sed -i '/oracle/d' /etc/security/limits.conf sed -i '/grid/d' /etc/security/limits.conf echo "oracle soft nproc 2047" >>/etc/security/limits.conf echo "oracle hard nproc 16384" >>/etc/security/limits.conf echo "oracle soft nofile 1024" >>/etc/security/limits.conf echo "oracle hard nofile 65536" >>/etc/security/limits.conf echo "grid soft nproc 2047" >>/etc/security/limits.conf echo "grid hard nproc 16384" >>/etc/security/limits.conf echo "grid soft nofile 1024" >>/etc/security/limits.conf echo "grid hard nofile 65536" >>/etc/security/limits.conf echo "Successful finished...step4 : Modified the /etc/security/limits.conf has been succeed." | tee -a ./log ##################################################################################################### ################# step5 : modify the /etc/pam.d/login ################################ ##################################################################################################### #step5: #backup firstly \cp /etc/pam.d/login /etc/pam.d/login.bak sed -i '/pam_limits.so/d' /etc/pam.d/login echo "session required /lib/security/pam_limits.so" >>/etc/pam.d/login echo "session required pam_limits.so" >>/etc/pam.d/login echo "Successful finished...step5 : Modified the /etc/pam.d/login has been succeed." | tee -a ./log ##################################################################################################### ################# step6 : modify the /etc/profile ################################ ##################################################################################################### #backup firstly \cp /etc/profile /etc/profile.bak rown=`grep -n "oracle" /etc/profile | head -1 | cut -d: -f1` if [ $rown ];then sed -i ''"$rown"',$d' /etc/profile fi echo 'if [ $USER = "oracle" ]||[ $USER = "grid" ]; then' >> /etc/profile echo 'if [ $SHELL = "/bin/ksh" ]; then' >> /etc/profile echo 'ulimit -p 16384' >> /etc/profile echo 'ulimit -n 65536' >> /etc/profile echo 'else' >> /etc/profile echo 'ulimit -u 16384 -n 65536' >> /etc/profile echo 'fi' >> /etc/profile echo 'fi' >> /etc/profile echo "Successful finished...step6 : Modified the /etc/profile has been succeed." | tee -a ./log ##################################################################################################### ################# step7 : modify the /etc/sysctl.conf and make the changes take effect ########## ##################################################################################################### #backup firstly \cp /etc/sysctl.conf /etc/sysctl.conf.bak rown=`grep -n "fs.aio-max-nr" /etc/sysctl.conf|head -1|cut -d: -f1` if [ $rown ];then sed -i ''"$rown"',$d' /etc/sysctl.conf fi echo "fs.aio-max-nr = 1048576" >> /etc/sysctl.conf echo "fs.file-max = 6815744" >> /etc/sysctl.conf echo "kernel.shmall = 2097152" >> /etc/sysctl.conf echo "kernel.shmmax = 8363284480" >> /etc/sysctl.conf echo "kernel.shmmni = 4096" >> /etc/sysctl.conf echo "kernel.sem = 250 32000 100 128" >> /etc/sysctl.conf echo "net.ipv4.ip_local_port_range = 9000 65500" >> /etc/sysctl.conf echo "net.core.rmem_default = 262144" >> /etc/sysctl.conf echo "net.core.rmem_max = 4194304" >> /etc/sysctl.conf echo "net.core.wmem_default = 262144" >> /etc/sysctl.conf echo "net.core.wmem_max = 1048586" >> /etc/sysctl.conf echo "net.ipv4.tcp_wmem = 262144 262144 262144" >> /etc/sysctl.conf echo "net.ipv4.tcp_rmem = 4194304 4194304 4194304" >> /etc/sysctl.conf sysctl -p &> /dev/null echo "Successful finished...step6 : Modified the /etc/sysctl.conf has been succeed." | tee -a ./log
rpm.sh 脚本如下,同样在四个主机上执行:
#!/bin/bash # /usr/bin/yum install binutils -y -q /usr/bin/yum install compat-libstdc++* -y -q /usr/bin/yum install compat-libcap1* -y -q /usr/bin/yum install gcc -y -q /usr/bin/yum install glibc -y -q /usr/bin/yum install glibc-devel -y -q /usr/bin/yum install ksh -y -q /usr/bin/yum install libaio -y -q /usr/bin/yum install libaio-devel -y -q /usr/bin/yum install libgcc -y -q /usr/bin/yum install libstdc++ -y -q /usr/bin/yum install libstdc++-devel -y -q /usr/bin/yum install libXext -y -q /usr/bin/yum install libXtst -y -q /usr/bin/yum install libX11 -y -q /usr/bin/yum install libXau -y -q /usr/bin/yum install libXi -y -q /usr/bin/yum install make -y -q /usr/bin/yum install sysstat -y -q
执行结果如下:
到此,相信大家对“Oracle RAC+DG环境搭建的方法是什么”有了更深的了解,不妨来实际操作一番吧!这里是创新互联网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!