#!/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