适用CentOS7下Oracle database 11g预安装脚本
在执行脚本之前,将CentOS7的iso镜像文件以及数据库的两个zip包(p13390677_112040_Linux-x86-64_*.zip)放入/opt目录即可,此脚本实现环境参数的自动调整以及不能联网时本地YUM源的依赖包安装
#!/bin/bash
#Oracle DataBase 11g preinstall Enviroment
#Usage:Log on as the superuser('root'),and then execute the command
#echo "Now start change HOSTS and backup hosts /etc/hosts.bak"
#cp /etc/hosts /etc/hosts.bak
#echo "#public ip ent0" >>/etc/hosts
#echo "172.16.16.10 orcl" >>/etc/hosts
#echo "change hosts succeed"
#echo "make local yum"
mkdir /mnt/iso
mkdir /mnt/cdrom
mv /opt/CentOS*.iso /mnt/iso
mount -o loop /mnt/iso/*.iso /mnt/cdrom
echo "Now rename /etc/yum.repos.d/public-yum-ol6.repo123"
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo123
echo "make local YUM succeed"
touch /etc/yum.repos.d/local.repo
echo "[local]" >> /etc/yum.repos.d/local.repo
echo "name =Linux7 yum" >> /etc/yum.repos.d/local.repo
echo "baseurl=file:///mnt/cdrom" >> /etc/yum.repos.d/local.repo
echo "gpgcheck=0" >> /etc/yum.repos.d/local.repo
echo "enabled=1" >> /etc/yum.repos.d/local.repo
yum clean all
groupadd oinstall
groupadd dba
groupadd oper
useradd -g oinstall -G dba,oper -d /home/oracle -s /bin/bash -c "oracle" oracle
echo "oracle" | passwd --stdin oracle
echo "The Groups and users has been created"
echo "Now create the necessary directory for oracle,grid users and change the authention to oracle,grid users..."
mkdir -p /u01/app/oracle
chown -R oracle:oinstall /u01
chmod -R 775 /u01
echo "The necessary directory for oracle,grid users and change the authention to oracle,grid users has been finished"
echo "Now modify the /etc/security/limits.conf,but backup it named /etc/security/limits.conf.bak before"
cp /etc/security/limits.conf /etc/security/limits.conf.bak
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 "oracle soft stack 10240" >>/etc/security/limits.conf
echo "oracle hard stack 32768" >>/etc/security/limits.conf
echo "Modifing the /etc/security/limits.conf has been succeed."
echo "Now modify the /etc/security/limits.d/20-nproc.conf,but with a backup named /etc/security/limits.d/20-nproc.conf.bak"
cp /etc/security/limits.d/20-nproc.conf /etc/security/limits.d/20-nproc.conf.bak
echo "# Default limit for number of user's processes to prevent" > /etc/security/limits.d/20-nproc.conf
echo "# accidental fork bombs." >> /etc/security/limits.d/20-nproc.conf
echo "# See rhbz #432903 for reasoning." >> /etc/security/limits.d/20-nproc.conf
echo "root soft nproc unlimited" >> /etc/security/limits.d/20-nproc.conf
echo "* - nproc 16384" >> /etc/security/limits.d/20-nproc.conf
echo "Modifing the /etc/security/limits.d/20-nproc.conf has been succeed."
echo "Now modify the /etc/pam.d/login,but with a backup named /etc/pam.d/login.bak"
cp /etc/pam.d/login /etc/pam.d/login.bak
echo "session required pam_limits.so" >>/etc/pam.d/login
echo "Modifing the /etc/pam.d/login has been succeed."
echo "Now modify the /etc/sysctl.conf,but with a backup named /etc/sysctl.bak"
cp /etc/sysctl.conf /etc/sysctl.conf.bak
#mem 16g
echo "fs.aio-max-nr = 1048576" >> /etc/sysctl.conf
echo "fs.file-max = 6815744" >> /etc/sysctl.conf
echo "kernel.shmmax = 15461882265" >> /etc/sysctl.conf
echo "kernel.shmall = 3774873" >> /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 "Modifing the /etc/sysctl.conf has been succeed."
echo "Now make the changes take effect....."
sysctl -p
echo "Now modify the /home/oracle/.bash_profile,but with a backup named /home/oracle/.bash_profile.bak"
cp /home/oracle/.bash_profile /home/oracle/.bash_profile.bak
echo "export TMP=/tmp">> /home/oracle/.bash_profile
echo 'export TMPDIR=$TMP'>>/home/oracle/.bash_profile
echo "export ORACLE_HOSTNAME=localhost">> /home/oracle/.bash_profile
echo "export ORACLE_SID=orcl">> /home/oracle/.bash_profile
echo "export ORACLE_BASE=/u01/app/oracle">> /home/oracle/.bash_profile
echo 'export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1'>> /home/oracle/.bash_profile
echo "export ORACLE_UNQNAME=orcl">> /home/oracle/.bash_profile
echo 'export TNS_ADMIN=$ORACLE_HOME/network/admin' >> /home/oracle/.bash_profile
echo "export ORACLE_TERM=xterm">> /home/oracle/.bash_profile
echo 'export PATH=.:$PATH:$HOME/bin:$ORACLE_BASE/product/11.2.0/db_1/bin:$ORACLE_HOME/bin'>> /home/oracle/.bash_profile
echo 'export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib'>> /home/oracle/.bash_profile
echo 'export CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib'>> /home/oracle/.bash_profile
echo "export THREADS_FLAG=native" >> /home/oracle/.bash_profile
echo "export LANG=en_US" >> /home/oracle/.bash_profile
echo "export NLS_LANG=american_america.AL32UTF8" >> /home/oracle/.bash_profile
echo "export NLS_DATE_FORMAT='yyyy/mm/dd hh24:mi:ss'" >> /home/oracle/.bash_profile
echo 'if [ $USER = "oracle" ]||[ $USER = "grid" ]; then' >> /home/oracle/.bash_profile
echo 'if [ $SHELL = "/bin/ksh" ]; then' >> /home/oracle/.bash_profile
echo 'ulimit -p 16384' >> /home/oracle/.bash_profile
echo 'ulimit -n 65536' >> /home/oracle/.bash_profile
echo 'else' >> /home/oracle/.bash_profile
echo 'ulimit -u 16384 -n 65536' >> /home/oracle/.bash_profile
echo 'fi' >> /home/oracle/.bash_profile
echo 'umask 022' >> /home/oracle/.bash_profile
echo 'fi' >> /home/oracle/.bash_profile
echo "Modifing the /home/oracle/.bash_profile has been succeed."
yum install binutils -y
yum install compat-libcap1 -y
yum install compat-libstdc++-33 -y
yum install gcc -y
yum install gcc-c++ -y
yum install glibc -y
yum install glibc-devel -y
yum install ksh -y
yum install libaio -y
yum install libaio-devel -y
yum install libgcc -y
yum install libstdc++- -y
yum install libstdc++-devel -y
yum install libXi -y
yum install libXtst -y
yum install make -y
yum install sysstat -y
yum install zlib-devel -y
yum install elfutils-libelf-devel -y
mkdir /opt/ora_soft
mv p13390677_112040_Linux-x86-64_*.zip /opt/ora_soft
chown -R oracle:oinstall /opt/ora_soft