Oracle数据库: 11.2.0.3
OS版本: CentOS 6.6
注: 由于CentOS 6.3以后oracle不再提供oracleasm包,所以使用了raw。
-
#!/bin/bash
-
-
###################################################################################
-
-
# params & functions define
-
-
function f_arch {
-
for v_flist in $*
-
do
-
cp $v_flist ${v_flist}'.'$(date "+%Y%m%d%H%M%S")
-
done
-
}
-
-
-
v_oracle_release='11.2.0.4'
-
v_iso_path='mnt' #OS DVD path
-
v_oracle_mountpoint='opt'
-
v_oracle_pwd='oracle'
-
v_grid_pwd='grid'
-
v_oracle_sid='linora'
-
-
v_verify_log="/root/ora_setup.$(date '+%Y%m%d%H%M%S')"
-
v_display='192.168.36.1:0.0' #Display define
-
v_votedisk_raw='sdc1'
-
v_datadisk_raw='sdb1'
-
-
v_rpmlist='ntp
-
sysstat
-
binutils
-
compat-libcap1
-
compat-libstdc++-33
-
gcc
-
gcc-c++
-
glibc
-
glibc-devel
-
ksh
-
libgcc
-
libstdc++
-
libstdc++-devel
-
libaio
-
libXp
-
libaio-devel
-
make
-
man
-
elfutils-libelf-devel
-
unzip
-
bc'
-
-
-
###################################################################################
-
-
# raw configuration
-
f_arch /etc/udev/rules.d/60-raw.rules
-
if [ $(grep AddForOracle /etc/udev/rules.d/60-raw.rules | wc -l) -eq 0 ]
-
then
-
-
cat >> /etc/udev/rules.d/60-raw.rules <
-
# AddForOracle
-
ACTION=="add", KERNEL=="${v_votedisk_raw}", RUN+="/bin/raw /dev/raw/raw1 %N"
-
ACTION=="add", KERNEL=="${v_datadisk_raw}", RUN+="/bin/raw /dev/raw/raw2 %N"
-
ACTION=="add", KERNEL=="raw*", OWNER=="oracle", GROUP=="oinstall", MODE=="0664"
-
EOF
-
fi
-
-
start_udev
-
-
# host modify
-
v_ipaddr=$(awk -F'=' '{if($0 ~ "(ipaddr|IPADDR)") {print $2}}' /etc/sysconfig/network-scripts/ifcfg-eth0)
-
-
f_arch /etc/hosts
-
-
cat > /etc/hosts <
-
127.0.0.1 localhost
-
${v_ipaddr} $(hostname)
-
EOF
-
-
# kernel params modify
-
-
v_totalmem_kb=$(free -k | grep Mem | awk '{print $2}')
-
v_orashmmem=$(awk "BEGIN{printf(\"%.0f\",${v_totalmem_kb}* 1024 * 0.8)}")
-
-
if [ $(grep 'AddForOracle' /etc/sysctl.conf|wc -l) -eq 0 ]
-
then
-
-
f_arch /etc/sysctl.conf
-
-
cat >> /etc/sysctl.conf <
-
#AddForOracle
-
kernel.shmmni = 4096
-
kernel.sem = 250 32000 100 128
-
kernel.shmall = 62500000
-
kernel.shmmax = ${v_orashmmem}
-
fs.file-max = 6815744
-
net.ipv4.ip_local_port_range = 9000 65500
-
fs.aio-max-nr = 1048576
-
net.core.rmem_default = 4194304
-
net.core.wmem_default = 262144
-
net.core.rmem_max = 4194304
-
net.core.wmem_max = 2097152
-
EOF
-
-
fi
-
-
sysctl -p
-
-
-
# install rpms
-
-
cat > /etc/yum.repos.d/CentOS-Media.repo <
-
[localyum]
-
name=localyum
-
baseurl=file:///${v_iso_path}/
-
gpgcheck=1
-
enabled=0
-
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
-
EOF
-
-
for idx_rpm in $v_rpmlist
-
do
-
yum --disablerepo=\* --enablerepo=localyum install -y $idx_rpm
-
done
-
-
# close iptables
-
-
service iptables stop
-
chkconfig iptables off
-
-
-
# groupadd
-
-
\userdel oracle
-
\userdel grid
-
-
v_grp_list='oinstall dba oper asmadmin asmoper asmdba'
-
v_start_gid=1000
-
-
for idx_grp_list in $v_grp_list
-
do
-
\groupdel ${idx_grp_list}
-
\groupadd -g ${v_start_gid} ${idx_grp_list}
-
v_start_gid=$((${v_start_gid}+1))
-
done
-
-
-
# useradd
-
-
\useradd -u 1000 -g oinstall -G dba,asmdba,oper oracle
-
\useradd -u 1001 -g oinstall -G asmadmin,asmdba,asmoper,oper,dba grid
-
-
-
# user permissions configuration
-
-
if [ $(grep grid /etc/security/limits.conf|wc -l) -eq 0 ]
-
then
-
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
-
fi
-
-
if [ $(grep oracle /etc/security/limits.conf|wc -l) -eq 0 ]
-
then
-
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
-
fi
-
-
if [ $(grep oracle /etc/profile|wc -l) -eq 0 ]
-
then
-
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
-
fi
-
-
-
# create oracle install directory
-
-
-
v_grid_home="/${v_oracle_mountpoint}/app/grid"
-
mkdir -p ${v_grid_home}
-
chown -R grid:oinstall ${v_grid_home}
-
chmod -R 775 ${v_grid_home}
-
-
v_invetory="/${v_oracle_mountpoint}/app/oraInventory"
-
mkdir -p ${v_invetory}
-
chown -R grid:oinstall ${v_invetory}
-
chmod -R 775 ${v_invetory}
-
-
v_crs_home="/${v_oracle_mountpoint}/app/$v_oracle_release"
-
mkdir -p ${v_crs_home}
-
chown -R grid:oinstall ${v_crs_home}
-
chmod -R 775 ${v_crs_home}
-
-
v_db_home="/${v_oracle_mountpoint}/app/oracle"
-
mkdir -p ${v_db_home}
-
chown -R oracle:oinstall ${v_db_home}
-
chmod -R 775 ${v_db_home}
-
-
-
# user env configuration
-
-
if [ $(grep ORACLE /home/oracle/.bash_profile|wc -l) -eq 0 ]
-
then
-
echo "umask 022" >> /home/oracle/.bash_profile
-
echo "export ORACLE_BASE=/${v_oracle_mountpoint}/app/oracle" >> /home/oracle/.bash_profile
-
echo "export ORACLE_HOME=\$ORACLE_BASE/product/"$v_oracle_release >> /home/oracle/.bash_profile
-
echo "export ORACLE_SID=${v_oracle_sid}" >> /home/oracle/.bash_profile
-
echo "export LD_LIBRARY_PATH=\$ORACLE_HOME/lib:/lib:/usr/lib:\$ORACLE_HOME/rdbms/lib" >> /home/oracle/.bash_profile
-
echo "export PATH=\$ORACLE_HOME/bin:\$CRS_HOME/bin:/usr/bin:/usr/sbin:/usr/local/bin:\$PATH" >> /home/oracle/.bash_profile
-
echo "export DISPLAY="$v_display >> /home/oracle/.bash_profile
-
fi
-
-
if [ $(grep ORACLE /home/grid/.bash_profile|wc -l) -eq 0 ]
-
then
-
echo "" >> /home/grid/.bash_profile
-
echo "umask 022" >> /home/grid/.bash_profile
-
echo "export ORACLE_BASE=/${v_oracle_mountpoint}/app/grid" >> /home/grid/.bash_profile
-
echo "export ORACLE_HOME=/${v_oracle_mountpoint}/app/$v_oracle_release/grid" >> /home/grid/.bash_profile
-
echo "export ORACLE_SID=+ASM"$NODE_ID >> /home/grid/.bash_profile
-
echo "export LD_LIBRARY_PATH=\$ORACLE_HOME/lib:/lib:/usr/lib:\$ORACLE_HOME/rdbms/lib" >> /home/grid/.bash_profile
-
echo "export PATH=\$ORACLE_HOME/bin:/usr/bin:/usr/sbin:/usr/local/bin:\$PATH" >> /home/grid/.bash_profile
-
echo "export DISPLAY="$v_display >> /home/grid/.bash_profile
-
fi
-
-
passwd oracle <
-
${v_oracle_pwd}
-
${v_oracle_pwd}
-
EOF
-
-
passwd grid <
-
${v_grid_pwd}
-
${v_grid_pwd}
-
EOF
-
-
echo '1.sysctl' >>${v_verify_log}
-
sysctl -p >>${v_verify_log} 2>>${v_verify_log}
-
echo '2.yum repos' >>${v_verify_log}
-
cat /etc/yum.repos.d/CentOS-Media.repo >>${v_verify_log} 2>>${v_verify_log}
-
echo '3.iptables status' >>${v_verify_log}
-
service iptables status >>${v_verify_log} 2>>${v_verify_log}
-
echo '4.oracle user info' >>${v_verify_log}
-
id oracle >>${v_verify_log} 2>>${v_verify_log}
-
echo '5.grid user info' >>${v_verify_log}
-
id grid >>${v_verify_log} 2>>${v_verify_log}
-
echo '6.grid user limits' >>${v_verify_log}
-
grep grid /etc/security/limits.conf >>${v_verify_log} 2>>${v_verify_log}
-
echo '7.oracle user limits' >>${v_verify_log}
-
grep oracle /etc/security/limits.conf >>${v_verify_log} 2>>${v_verify_log}
-
echo '8.oracle user configure info in /etc/profile' >>${v_verify_log}
-
grep -A8 'oracle' /etc/profile >>${v_verify_log} 2>>${v_verify_log}
-
echo '9.dir info' >>${v_verify_log}
-
ls -l "/${v_oracle_mountpoint}/app" >>${v_verify_log} 2>>${v_verify_log}
-
echo '10.oracle user env' >>${v_verify_log}
-
grep ORACLE /home/oracle/.bash_profile >>${v_verify_log} 2>>${v_verify_log}
-
echo '11.grid user env' >>${v_verify_log}
-
grep ORACLE /home/grid/.bash_profile >>${v_verify_log} 2>>${v_verify_log}
-
echo '12.hosts check' >>${v_verify_log}
-
cat /etc/hosts >>${v_verify_log} 2>>${v_verify_log}
-
echo >>${v_verify_log}
-
echo >>${v_verify_log}
-
echo 'Please ensure the 11 options is all correct.' >> ${v_verify_log}
-
-
echo
-
echo
-
echo "All done,please check the ${v_verify_log} log file to verify."
阅读(1636) | 评论(0) | 转发(0) |