21 脚本附录
1preuser_dir.sh
[root@node1 shell]# cat 1preuser_dir.sh
#!/bin/bash
#Purpose:Create two groups named ‘oinstall’ and ‘dba’, plus a user named ‘oracle’.Also setting the Environment
#variable for oracle user.
#Usage:Log on as the superuser(‘root’),and then execute the command:#./1preuser.sh
#Author:Asher Huang
echo “Now create two groups named ‘oinstall’ and ‘dba’, plus a user named ‘oracle’.Also setting the Environment”
groupadd oinstall
groupadd dba
echo “Now create the necessary directory for oracle user and change the authention to oracle user…”
useradd -d /home/oracle -g oinstall -G dba -c “Oracle software owner” oracle
echo “oracle” | passwd –stdin oracle
echo ‘export PS1=”`/bin/hostname -s`-> “‘>>/home/oracle/.bash_profile
echo “export EDITOR=vi” >> /home/oracle/.bash_profile
echo “export ORACLE_SID=devdb1” >> /home/oracle/.bash_profile
echo “export ORACLE_BASE=/u01/app/oracle” >> /home/oracle/.bash_profile
echo ‘export ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_1’ >> /home/oracle/.bash_profile
echo ‘export ORA_CRS_HOME=$ORACLE_BASE/product/10.2.0/crs_1’ >> /home/oracle/.bash_profile
echo ‘export LD_LIBRARY_PATH=$ORACLE_HOME/lib’ >> /home/oracle/.bash_profile
echo ‘export PATH=$ORACLE_HOME/bin:$ORA_CRS_HOME/bin:/bin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/X11R6/bin’>> /home/oracle/.bash_profile
echo “umask 022”>>/home/oracle/.bash_profile
echo “export NLS_LANG=american_america.AL32UTF8” >> /home/oracle/.bash_profile
echo “export LANG=en_US” >> /home/oracle/.bash_profile
echo “The two groups named ‘oinstall’ and ‘dba’ plus the oracle user has been created.”
echo “The Environment variable for oracle user also has been setted sussessfully.”
[root@node1 shell]#
2predir.sh
[root@node1 shell]# cat 2predir.sh
#!/bin/bash
#Purpose:Create the necessary directory for oracle user and change the authention to oracle user.
#Usage:Log on as the superuser(‘root’),and then execute the command:#./2predir.sh
#Author:Asher Huang
echo “Now create the necessary directory for oracle user and change the authention to oracle user…”
mkdir -p /u01/app/oracle
chown -R oracle:oinstall /u01
echo “The necessary directory for oracle user and change the authention to oracle user has been finished”
[root@node1 shell]#
3prelimits.sh
[root@node1 shell]# cat 3prelimits.sh
#!/bin/bash
#Purpose:Change the /etc/security/limits.conf.
#Usage:Log on as the superuser(‘root’),and then execute the command:#./3prelimits.sh
#Author:Asher Huang
echo “Now modify the /etc/security/limits.conf,but backup it named /etc/security/limits.conf.bak before”
cp /etc/security/limits.conf /etc/security/limits.conf.bak
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 “Modifing the /etc/security/limits.conf has been succeed.”
[root@node1 shell]#
4prelogin.sh
[root@node1 shell]# cat 4prelogin.sh
#!/bin/bash
#Purpose:Modify the /etc/pam.d/login.
#Usage:Log on as the superuser(‘root’),and then execute the command:#./4prelimits.sh
#Author:Asher Huang
echo “Now modify the /etc/pam.d/login,but with a backup named /etc/pam.d/login.bak”
cp /etc/pam.d/login /etc/pam.d/login.bak
echo “session required /lib/security/pam_limits.so” >>/etc/pam.d/login
echo “session required pam_limits.so” >>/etc/pam.d/login
echo “Modifing the /etc/pam.d/login has been succeed.”
[root@node1 shell]#
5preprofile.sh
[root@node1 shell]# cat 5preprofile.sh
#!/bin/bash
#Purpose:Modify the /etc/profile.
#Usage:Log on as the superuser(‘root’),and then execute the command:#./5preprofile.sh
#Author:Asher Huang
echo “Now modify the /etc/profile,but with a backup named /etc/profile.bak”
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 “Modifing the /etc/profile has been succeed.”
[root@node1 shell]#
6presysctl.sh
[root@node1 shell]# cat 6presysctl.sh
#!/bin/bash
#Purpose:Modify the /etc/sysctl.conf.
#Usage:Log on as the superuser(‘root’),and then execute the command:#./6presysctl.sh
#Author:Asher Huang
echo “Now modify the /etc/sysctl.conf,but with a backup named /etc/sysctl.bak”
cp /etc/sysctl.conf /etc/sysctl.conf.bak
echo “fs.file-max = 65536” >> /etc/sysctl.conf
echo “kernel.sem = 250 32000 100 128” >> /etc/sysctl.conf
echo “kernel.shmall = 2097152” >> /etc/sysctl.conf
echo “kernel.shmmni = 4096” >> /etc/sysctl.conf
echo “kernel.shmmax = 2147483648” >> /etc/sysctl.conf
echo “net.core.rmem_default=1048576” >> /etc/sysctl.conf
echo “net.core.rmem_max=1048576” >> /etc/sysctl.conf
echo “net.core.wmem_default=262144” >> /etc/sysctl.conf
echo “net.core.wmem_max=262144” >> /etc/sysctl.conf
echo “net.ipv4.ip_local_port_range = 1024 65000” >> /etc/sysctl.conf
echo “Modifing the /etc/sysctl.conf has been succeed.”
echo “Now make the changes take effect…..”
sysctl -p
[root@node1 shell]#