- #!/bin/bash
- oracle_passwd=123
- install_path=/oracle
- #--------------------------yum install--------------
- yum -y install binutils compat-db control-center gcc gcc-c++ glibc libXp-1.0.0 libstdc++ libstdc++-devel make openmotif
- if ! [ $? -eq 0 ];then
- clear
- echo "err please setup packup"
- exit
- fi
- #--------------------------------------------
- grep oracle /etc/passwd &> /dev/null
- if [ $? -eq 0 ]
- then
- clear
- echo "oracle user is already exist!"
- exit 1
- fi
- #################langrauge info##################
- cat >> /etc/sysconfig/i18n << !
- LANG="en_US.UTF-8"
- SYSFONT="latarcyrheb-sun16"
- !
- ###################设置核心参数#############################
- sed -i -r '/kernel.shmall/ s/= [0-9]{,15}/= 2097152/' /etc/sysctl.conf
- sed -i -r '/kernel.shmmax/ s/= [0-9]{,15}/= 2147483648/' /etc/sysctl.conf
- cat >> /etc/sysctl.conf << !
- kernel.sem = 250 32000 100 128
- fs.file-max = 65546
- net.ipv4.ip_local_port_range = 1024 65000
- net.core.rmem_default = 1048576
- net.core.rmem_max = 1048576
- net.core.wmem_default = 1048576
- net.core.wmem_max = 1048576
- !
- /sbin/sysctl -p # 使内核生效
- #####################用户环境变量######################################
- #off Selinux
- groupadd dba && groupadd oinstall
- useradd -g oinstall -G dba oracle
- echo $oracle_passwd | passwd oracle --stdin #auto input password
- mkdir -p $install_to_path/app
- chmod 777 $install_to_path
- chown -R oracle.oinstall $install_to_path
- #==================limits.conf是pam_limits.so的配置文件============
- # Add content for oracle install
- cat >> /etc/pam.d/login << !
- session required pam_limits.so
- !
- # turn on limits for oracle 10g
- cat >> /etc/security/limits.conf << !
- oracle soft nproc 2047
- oracle hard nproc 16384
- oracle soft nofile 1024
- oracle hard nofile 65535
- !
- ##=============================================
- echo 'Red Hat Enterprise Linux Server release 3 (Tikanga)' > /etc/redhat-release
- #================== Set for Oracle10g Install==========
- echo '
- ORACLE_BASE=/oracle/app
- ORACLE_HOME=$ORACLE_BASE/oracle/product/10.2.0/db_1
- ORACLE_SID=TEST
- PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin
- LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib
- LANG=en_US.UTF-8
- export ORACLE_BASE ORACLE_HOME ORACLE_SID PATH LD_LIBRARY_PATH LANG
- ' >> /home/oracle/.bash_profile
- source /home/oracle/.bash_profile
- #=====ping hostname================
- /bin/hostname sql
- echo '192.168.0.178 sq1' >> /etc/hosts
- sed -i 's/127.0.0.1/127.0.0.1 sql/' /etc/hosts
- ##=============================================
- clear
- echo "you can logout! oracle in X and run runInstaller to install oracle now!"
在网上借鉴前辈写的文档又稍加修改了一番,这个脚本只要根据自身需求稍加修改,一点即可无需其他任何手动设置即可安装oracle
上面是一次性安装,下面这个可以N次性覆盖安装,不过配置文件删除了很多注释
- #!/bin/bash
- #------------------------------------------------------------------------
- oracle_passwd=123
- install_to_path=/oracle
- #--------------------------yum install--------------
- yum -y install binutils compat-db control-center gcc gcc-c++ glibc libXp-1.0.0 libstdc++ libstdc++-devel make openmotif
- if ! [ $? -eq 0 ];then
- clear
- echo "err please setup packup"
- exit
- fi
- #################langrauge info##################
- echo '
- LANG="zh_CN.UTF-8"
- LANG="en_US.UTF-8"
- SYSFONT="latarcyrheb-sun16"
- ' > /etc/sysconfig/i18n
- ###################璋冩暣鍐呮牳鍙傛暟#############################
- echo '
- net.ipv4.ip_forward = 0
- net.ipv4.conf.default.rp_filter = 1
- net.ipv4.conf.default.accept_source_route = 0
- kernel.sysrq = 0
- kernel.core_uses_pid = 1
- nen.npv4.tcp_syncookies = 1
- kernel.msgmnb = 65536
- kernel.msgmax = 65536
- kernel.shmmax = 2147483648
- kernel.shmall = 2097152
- kernel.sem = 250 32000 100 128
- fs.file-max = 65546
- net.ipv4.ip_local_port_range = 1024 65000
- net.core.rmem_default = 1048576
- net.core.rmem_max = 1048576
- net.core.wmem_default = 1048576
- net.core.wmem_max = 1048576
- ' > /etc/sysctl.conf
- /sbin/sysctl -p
- ###########################################################
- groupadd dba && groupadd oinstall
- useradd -g oinstall -G dba oracle
- echo $oracle_passwd | passwd oracle --stdin
- mkdir -p $install_to_path/app
- chmod 777 $install_to_path
- chown -R oracle.oinstall $install_to_path
- ##=============================================
- # Add content for oracle install
- echo '
- #%PAM-1.0
- auth [user_unknown=ignore success=ok ignore=ignore default=bad] pam_securetty.so
- auth include system-auth
- account required pam_nologin.so
- account include system-auth
- password include system-auth
- # pam_selinux.so close should be the first session rule
- session required pam_selinux.so close
- session include system-auth
- session required pam_loginuid.so
- session optional pam_console.so
- # pam_selinux.so open should only be followed by sessions to be executed in the user context
- session required pam_selinux.so open
- session optional pam_keyinit.so force revoke
- session required pam_limits.so
- ' > /etc/pam.d/login
- # ddturn on limits for oracle 10g
- echo '
- oracle soft nproc 2047
- oracle hard nproc 16384
- oracle soft nofile 1024
- oracle hard nofile 65535
- ' > /etc/security/limits.conf
- ##=============================================
- echo 'Red Hat Enterprise Linux Server release 3 (Tikanga)' > /etc/redhat-release
- #================== Set for Oracle10g Install=========
- echo '
- if [ -f ~/.bashrc ]; then
- . ~/.bashrc
- fi
- PATH=$PATH:$HOME/bin
- export PATH
- ORACLE_BASE=/oracle/app
- ORACLE_HOME=$ORACLE_BASE/oracle/product/10.2.0/db_1
- ORACLE_SID=TEST
- PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin
- LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib
- LANG=en_US.UTF-8
- export ORACLE_BASE ORACLE_HOME ORACLE_SID PATH LD_LIBRARY_PATH LANG
- ' > /home/oracle/.bash_profile
- source /home/oracle/.bash_profile
- /bin/hostname sql
- echo '192.168.0.178 sq1' >> /etc/hosts
- echo "127.0.0.1 sql" >>/etc/hosts
- ##=============================================
- clear
- echo "you can su - oracle in X and run runInstaller to install oracle now!"