#!/bin/bash echo "修改主機名" hostnamectl set-hostname wangxfa hostname sleep 1 echo "查看並關閉防火牆" systemctl status firewalld systemctl stop firewalld systemctl disable firewalld systemctl status firewalld sleep 1 echo "禁用Selinux" sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config #add user and group echo "建立安裝oracle所需的用戶和組" groupadd -g 1030 oinstall groupadd -g 1031 dba useradd -u 54321 -g oinstall -G dba oracle echo "oracle" | passwd --stdin "oracle" echo "建立oracle相關目錄" sleep 1 mkdir –p /u01/app/oracle/product/11.2.0 chmod -R 775 /u01 chown -R oracle:oinstall /u01 echo "備份並修改/etc/securitylimits.conf" sleep 1 cp /etc/security/limits.conf /etc/security/limits_bake.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 echo "備份並修改/etc/sysctl.conf文件" sleep 1 cp /etc/sysctl.conf /etc/sysctl_bak.conf echo "fs.file-max = 6815744" >>/etc/sysctl.conf echo "fs.aio-max-nr = 1048576" >>/etc/sysctl.conf echo "kernel.shmall = 1677721" >>/etc/sysctl.conf (注:此處須要根據shmmax大小來計算,shmmax/PAGESIZE 則計算爲 6871947673/4K=1677721) echo "kernel.shmmax = 6871947673" >>/etc/sysctl.conf (注:此處須要根據實際內存大小來計算,加入內存大小爲8G,將內存的80%用於數據庫,計算方法:1024*1024*1024*8*08=6871947673) 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 = 4194304" >>/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 = 1048576" >>/etc/sysctl.conf echo "使sysctl.conf當即生效" sysctl -p sleep 1 echo "備份並修改/etc/profile文件" cp /etc/profile /etc/profile_bak echo "if [ \$USER = \"oracle\" ]; then" >>/etc/profile echo "if [ \$SHELL = \"/bin/ksh\" ]; then" >>/etc/profile echo "ulimit -p 16384" >>/etc/profile echo "ulimit -n 65536" >>/etc/profile echo "else " >>/etc/profile echo "ulimit -u 16384 -n 65536" >>/etc/profile echo "fi" >>/etc/profile echo "fi" >>/etc/profile echo "設置oracle用戶環境變量" su - oracle cp /home/oracle/.bash_profile /home/oracle/.bash_profile_bak echo "export ORACLE_BASE=/u01/app/oracle" >>/home/oracle/.bash_profile echo "export ORACLE_HOME=$ORACLE_BASE/product/11.2.0" >>/home/oracle/.bash_profile echo "export PATH=$ORACLE_HOME/bin:$ORACLE_HOME/bin:$PATH" >>/home/oracle/.bash_profile echo "export LD_LIBRARY_PATH=$ORACLE_HOME/lib" >>/home/oracle/.bash_profile echo "#export ORACLE_SID=hisdb1" >>/home/oracle/.bash_profile echo "export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK" >>/home/oracle/.bash_profile echo "export EDITOR=vi" >>/home/oracle/.bash_profile echo "set -o vi" >>/home/oracle/.bash_profile echo "umask 022" >>/home/oracle/.bash_profile