Oracle常用脚本——安装前的配置脚本
Oracle常用脚本——安装前的配置脚本
安装前, 一些配置很讨厌. 每次都要做这些事情.
整理了一个脚本. 共享之.
[sql] #!/bin/bash # functions: This file contain some system and oracle configure preparing from oracle install. # author: huangxw 2010.8.16 ##################################### ### 1. Create User and group ##################################### /usr/sbin/groupadd oinstall /usr/sbin/groupadd dba if [ -z "$(id oracle &> /dev/null)" ]; then /usr/sbin/useradd -g oinstall -G dba oracle else /usr/sbin/usermod -g oinstall -G dba oracle fi echo "oracle" | passwd --stdin oracle ##################################### ### 2. Make direction ##################################### mkdir -p /u01/app/oracle/product/10.2.0/db_1 mkdir -p /u01/app/oracle/oraInventory mkdir -p /u01/app/oracle/oradata mkdir -p /u01/app/oracle/flash_recovery_area chown -R oracle:oinstall /u01/app/oracle chmod -R 775 /u01/app/oracle ##################################### ### 3. Configure system ### 3.1 /etc/sysctl.conf ##################################### # 536870912 1073741824 parastr=( "kernel.shmall=2097152" "kernel.shmmax=1073741824" "kernel.shmmni=4096" "kernel.sem=250 32000 100 128" "fs.file-max=65536" "net.ipv4.ip_local_port_range=1024 65000" "net.core.rmem_default=262144" "net.core.rmem_max=262144" "net.core.wmem_default=262144" "net.core.wmem_max=262144" ) if [ -z "$(grep "\# Added for Oracle" /etc/sysctl.conf)" ]; then echo "" >> /etc/sysctl.conf echo "# Added for Oracle" >> /etc/sysctl.conf echo "" >> /etc/sysctl.conf size=${#parastr[@]}; for ((i=0;i<$size;i++)) do eval tmp=\${parastr[i][@]} echo $tmp >> /etc/sysctl.conf done fi # take affect after restart /sbin/sysctl -p ##################################### ### 3. Configure system ### 3.2 /etc/redhat-release ##################################### echo "Red Hat Enterprise Linux Server release 4 (Tikanga)" > /etc/redhat-release ##################################### ### 3. Configure system ### 3.3 /etc/pam.d/login ##################################### if [ -z "$(grep "\# Added for Oracle" /etc/security/limits.conf)" ]; then echo "" >> /etc/security/limits.conf echo "# Added for Oracle" >> /etc/security/limits.conf echo "" >> /etc/security/limits.conf 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 ##################################### ### 3. Configure system ### 3.4 /etc/pam.d/login ##################################### [ -z "$(grep "session required /lib/security/pam_limits.so" /etc/security/limits.conf)" ] && echo "session required /lib/security/pam_limits.so" >> /etc/pam.d/login [ -z "$(grep "session required pam_limits.so" /etc/security/limits.conf)" ] && echo "session required pam_limits.so" >> /etc/pam.d/login ##################################### ### 3. Configure system ### 3.5 /etc/selinux/config ##################################### sed -i 's/^SELINUXTYPE=targeted/SELINUXTYPE=disabled/g' /etc/selinux/config ##################################### ### 4. Configure oracle ##################################### parastr=( 'export ORACLE_BASE=/u01/app/oracle' 'export ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_1' 'export ORACLE_SID=orcl' 'export LD_LIBRARY_PATH=$ORACLE_HOME/lib' 'export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib:/usr/X11R6/lib' 'export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/jdk/jre/lib/i386' 'export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/jdk/jre/lib/i386/server' 'export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/rdbms/lib' 'export CLASS_PATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib' 'export CLASS_PATH=$CLASS_PATH:$ORACLE_HOME/rdbms/jlib' 'export CLASS_PATH=$CLASS_PATH:$ORACLE_HOME/network/jlib' 'export TNS_ADMIN=$ORACLE_HOME/network/admin' 'export PATH=$ORACLE_HOME/bin:$PATH' 'export NLS_DATE_FORMAT="YYYY-MM-DD:HH24:MI:SS"' 'export NLS_LANG=american_america.AL32UTF8' 'export LANG=en_US' 'export ORACLE_TERM=xterm' 'export EDITOR=vi' ) if [ -z "$(grep "\# Added for Oracle" /home/oracle/.bash_profile)" ]; then echo "" >> /home/oracle/.bash_profile echo "# Added for Oracle" >> /home/oracle/.bash_profile echo "" >> /home/oracle/.bash_profile size=${#parastr[@]}; for ((i=0;i<$size;i++)) do eval tmp=\${parastr[i][@]} echo $tmp >> /home/oracle/.bash_profile done fi