平时要搭建大量的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----------------------------+ EOF cd 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.rpm if [ $? ];then cat << EOF +--------------------------------------------------------------+ | === 1. oracle rpm package installed successfully. === | +--------------------------------------------------------------+ EOF fi ORACLE_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 fi if [ $? ];then cat << EOF +--------------------------------------------------------------+ | === 2. oracle user group installed successfully. === | +--------------------------------------------------------------+ EOF fi if [ ! -d $ORACLE_HOME ]; then mkdir -p $ORACLE_HOME chmod -R 775 /u01/app chown -R oracle:oinstall /u01 fi if [ $? ];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" fi sed -i '/kernel.shmmax/d' /etc/sysctl.conf sed -i '/kernel.shmall/d' /etc/sysctl.conf cat >> /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 EOF sysctl -p if [ $? ];then cat << EOF +--------------------------------------------------------------+ | === 4. linux core updated successfully. === | +--------------------------------------------------------------+ EOF fi sleep 1 cat >> /etc/security/limits.conf << EOF oracle soft nproc 2047 oracle hard nproc 16384 oracle soft nofile 1024 oracle hard nofile 65536 EOF if [ $? ];then cat << EOF +--------------------------------------------------------------+ | === 5. oracle source limite configured successfully=== | +--------------------------------------------------------------+ EOF fi sleep 1 cat >> /etc/pam.d/login << EOF session required /lib64/security/pam_limits.so EOF if [ $? ];then cat << EOF +--------------------------------------------------------------+ | === 6. linux login configured successfully. === | +--------------------------------------------------------------+ EOF fi sleep 1 cat >> /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 EOF if [ $? ];then cat << EOF +--------------------------------------------------------------+ | === 7. linux system env configured successfully. === | +--------------------------------------------------------------+ EOF fi sleep 1 cat >> /etc/rc.local << EOF # Oracle service start su - oracle -c "lsnrctl start" su - oracle -c "dbstart" EOF if [ $? ];then cat << EOF +--------------------------------------------------------------+ | === 8. oracle db autostart configured successfully.=== | +--------------------------------------------------------------+ EOF fi sleep 1 cat >> /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 EOF if [ $? ];then cat << EOF +--------------------------------------------------------------+ | === 9. oracle user env configured successfully. === | +--------------------------------------------------------------+ EOF fi sleep 1 cat << EOF +--------------------------------------------------------------+ | **********************next **************************** | | # xhost + | | $ su - oracle | | $ cd /u01/app/database | | $ ./runInstaller -ignoresysprereqs | | ******************************************************* | +--------------------------------------------------------------+ EOF