標籤:oracle shell指令碼
平時要搭建大量的oracle的測試環境,重複多了也感覺的到麻煩了,乾脆整個指令碼來建立安裝oracle之前的一些環境變數等相關配置,提高安裝oracle 10g效率,也可以稍改改用於11g的安裝前環境配置,整理自用。本文出自:http://koumm.blog.51cto.com
本文適用環境:RHEL/CentOS/OEL5.8 X64安裝過程中選中圖形介面,開發包,開發庫,老的軟體開發包等。
指令碼如下:
#!/bin/bash # author: koumm # desc: RHEL/CentOS/OEL5.8 x64 oracle 10g(10.2.0.5) install script # date: 2014-07-28 # version: v1.0 # modify:ORACLE_BASE="/u01/app/oracle" ORACLE_HOME="/u01/app/oracle/product/10.2.0/db_1" ORACLE_SID="orcl"# cat << EOF +--------------------------------------------------------------+ | === Welcome to RUN oracle auto configure script === | | PWD /root/oracle10g_install.sh | +----------------------Author:koumm----------------------------+ EOFcd oracle_install/ora_install_rpm rpm -ivh compat-db-4.2.52-5.1.i386.rpm compat-db-4.2.52-5.1.x86_64.rpm rpm -ivh libaio-devel-0.3.106-5.x86_64.rpm libaio-devel-0.3.106-5.i386.rpm rpm -ivh sysstat-7.0.2-11.el5.x86_64.rpm numactl-devel-0.9.8-12.0.1.el5_6.x86_64.rpm rpm -ivh unixODBC-2.2.11-10.el5.x86_64.rpm unixODBC-devel-2.2.11-10.el5.x86_64.rpm unixODBC-libs-2.2.11-10.el5.x86_64.rpm rpm -ivh unixODBC-2.2.11-10.el5.i386.rpm unixODBC-devel-2.2.11-10.el5.i386.rpm unixODBC-libs-2.2.11-10.el5.i386.rpm rpm -ivh libXp-1.0.0-8.1.el5.i386.rpm libXp-1.0.0-8.1.el5.x86_64.rpm rpm -ivh openmotif22-2.2.3-20.x86_64.rpm openmotif-2.3.1-6.el5.x86_64.rpm rpm -ivh rlwrap-0.37-1.el5.x86_64.rpmif [ $? ];then cat << EOF +--------------------------------------------------------------+ | === 1. oracle rpm package installed successfully. === | +--------------------------------------------------------------+ EOF fiORACLE_USER=`cat /etc/passwd |grep oracle |awk -F ":" ‘{print $1}‘`if [ "$ORACLE_USER" != "oracle" ]; then groupadd oinstall groupadd dba useradd -g oinstall -G dba oracle echo "abc123" | passwd --stdin oracle fiif [ $? ];then cat << EOF +--------------------------------------------------------------+ | === 2. oracle user group installed successfully. === | +--------------------------------------------------------------+ EOFfiif [ ! -d $ORACLE_HOME ]; then mkdir -p $ORACLE_HOME chmod -R 775 /u01/app chown -R oracle:oinstall /u01 fiif [ $? ];then cat << EOF +--------------------------------------------------------------+ | === 3. oracle HOME directory created successfully. === | +--------------------------------------------------------------+ EOF fi# cd root home directory /root/ if [ -e /root/oracle_install/10201_database_linux_x86_64.cpio.gz -a -e /root/oracle_install/p8202632_10205_Linux-x86-64.zip ];then echo " === now moving database file database,pack to /u01/app ..." chown oracle:oinstall /root/oracle_install/10201_database_linux_x86_64.cpio.gz chown oracle:oinstall /root/oracle_install/p8202632_10205_Linux-x86-64.zip mv /root/oracle_install/10201_database_linux_x86_64.cpio.gz /u01/app/ mv /root/oracle_install/p8202632_10205_Linux-x86-64.zip /u01/app/ cd /u01/app echo " === now unziping /u01/app/10201_database_linux_x86_64.cpio.gz to /u01/app ..." gunzip /u01/app/10201_database_linux_x86_64.cpio.gz cpio -idm < /u01/app/10201_database_linux_x86_64.cpio echo " === now unziping /u01/app/p8202632_10205_Linux-x86-64.zip to /u01/app ..." unzip -qo /u01/app/p8202632_10205_Linux-x86-64.zip -d /u01/app chown -R oracle:oinstall /u01/app/database chown -R oracle:oinstall /u01/app/Disk1 echo -e "\033[32;49;1m === oracle database unzip successfull ...\033[39;49;0m" else echo -e "\033[41;36m no oracle database soft and pack file ... \033[0m" fised -i ‘/kernel.shmmax/d‘ /etc/sysctl.conf sed -i ‘/kernel.shmall/d‘ /etc/sysctl.confcat >> /etc/sysctl.conf << EOF kernel.shmall = 2097152 kernel.shmmax = 2147483648 kernel.shmmni = 4096 kernel.sem = 250 32000 100 128 fs.file-max = 359670 net.ipv4.ip_local_port_range = 9000 65500 net.core.rmem_default = 1048576 net.core.rmem_max = 1048576 net.core.wmem_default = 262144 net.core.wmem_max = 262144 EOFsysctl -pif [ $? ];then cat << EOF +--------------------------------------------------------------+ | === 4. linux core updated successfully. === | +--------------------------------------------------------------+ EOFfisleep 1cat >> /etc/security/limits.conf << EOF oracle soft nproc 2047 oracle hard nproc 16384 oracle soft nofile 1024 oracle hard nofile 65536 EOFif [ $? ];then cat << EOF +--------------------------------------------------------------+ | === 5. oracle source limite configured successfully=== | +--------------------------------------------------------------+ EOFfisleep 1cat >> /etc/pam.d/login << EOF session required /lib64/security/pam_limits.so EOFif [ $? ];then cat << EOF +--------------------------------------------------------------+ | === 6. linux login configured successfully. === | +--------------------------------------------------------------+ EOF fisleep 1cat >> /etc/profile << EOF if [ \$USER = "oracle" ]; then if [ \$SHELL = "/bin/ksh" ]; then ulimit -p 16384 ulimit -n 65536 else ulimit -u 16384 -n 65536 fi fi EOFif [ $? ];then cat << EOF +--------------------------------------------------------------+ | === 7. linux system env configured successfully. === | +--------------------------------------------------------------+ EOFfisleep 1cat >> /etc/rc.local << EOF # Oracle service start su - oracle -c "lsnrctl start" su - oracle -c "dbstart" EOFif [ $? ];then cat << EOF +--------------------------------------------------------------+ | === 8. oracle db autostart configured successfully.=== | +--------------------------------------------------------------+ EOFfisleep 1cat >> /home/oracle/.bash_profile << EOF export EDITOR=vi export ORACLE_BASE=/u01/app/oracle export ORACLE_HOME=\$ORACLE_BASE/product/10.2.0/db_1 export ORACLE_SID=orcl export PATH=\$ORACLE_HOME/bin:\$PATH export NLS_LANG="Simplified Chinese_china.ZHS16GBK" export LANG=en_US export LC_ALL=en_US export LD_LIBRARY_PATH=/lib:/usr/lib:\$ORACLE_HOME/lib alias sqlplus="rlwrap sqlplus" alias rman="rlwrap rman" umask 022 EOFif [ $? ];then cat << EOF +--------------------------------------------------------------+ | === 9. oracle user env configured successfully. === | +--------------------------------------------------------------+ EOF fisleep 1cat << EOF +--------------------------------------------------------------+ | **********************next **************************** | | # xhost + | | $ su - oracle | | $ cd /u01/app/database | | $ ./runInstaller -ignoresysprereqs | | ******************************************************* | +--------------------------------------------------------------+ EOF
運行效果:
650) this.width=650;" style="border-bottom:0px;border-left:0px;border-top:0px;border-right:0px;" title="image" border="0" alt="image" src="http://img1.51cto.com/attachment/201407/28/703525_1406564333lsIK.png" height="525" />
650) this.width=650;" style="border-bottom:0px;border-left:0px;border-top:0px;border-right:0px;" title="image" border="0" alt="image" src="http://img1.51cto.com/attachment/201407/28/703525_1406564350IXSI.png" height="639" />
650) this.width=650;" style="border-bottom:0px;border-left:0px;border-top:0px;border-right:0px;" title="image" border="0" alt="image" src="http://img1.51cto.com/attachment/201407/28/703525_14065643599y44.png" height="685" />
本文出自 “koumm的linux技術部落格” 部落格,請務必保留此出處http://koumm.blog.51cto.com/703525/1531819