- 最近常在安装oracle10g,搞个脚本方便安装;在原有的基础上增加一些东西。
- #!/bin/bash
- # used for install oracle 10g
- # ctime: 2012/11/05
- # tun kernel
- echo 'fs.file-max = 6815744
- kernel.shmall = 2097152
- kernel.shmmax = 2147483648
- kernel.shmmni = 4096
- kernel.sem = 250 32000 100 128
- fs.aio-max-nr = 1048576
- net.ipv4.ip_local_port_range = 1024 65000
- net.core.rmem_default = 4194304
- net.core.rmem_max = 4194304
- net.core.wmem_default = 262144
- net.core.wmem_max = 1048576 ' >> /etc/sysctl.conf
- # tun file max
- echo 'oracle soft nproc 2047
- oracle hard nproc 16384
- oracle soft nofile 10000
- oracle hard nofile 65536 ' >> /etc/security/limits.conf
- # tun pam
- echo 'session required /lib/security/pam_limits.so' >> /etc/pam.d/login
- # install packge
- read -p "Make sure your yum is works. (yes/no): " ask
- if [ "$ask" = "yes" ] || [ "$ask" = "y" ] || [ "$ask" = "YES" ];then
- yum install -y compat-libstdc++* libaio-devel sysstat unixODBC-devel unixODBC unixODBC-libs pdksh libXp libXp-devel libXtst libXtst-devel
- yum grouplist | grep "Development Libraries" > /dev/null
- if [ "$?" = "0" ];then
- yum groupinstall -y "X Window System" "Development Tools" "Development Libraries"
- fi
- else
- echo "Sorry,you yum is note work. Please check"
- exit 10
- fi
- ~
- # create oracle group and user
- grep oinstall /etc/group ||groupadd oinstall
- grep dba /etc/group || groupadd dba
- useradd -g oinstall -G dba oracle
- echo "redhat" | passwd --stdin oracle
- # make oracle install dir
- mkdir -p /u01/app
- chown oracle:oinstall /u01 -R
- # add oracle env
- echo 'ORACLE_SID=ora11gR2
- ORACLE_BASE=/u01/app
- ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1
- export ORACLE_SID ORACLE_BASE ORACLE_HOME' >> /home/oracle/.bash_profile
- source /home/oracle/.bash_profile
- source /etc/profile
- sysctl -p
- #used for vnc
- echo 'VNCSERVERS="1:oracle"
- VNCSERVERARGS[1]="-geometry 800x600" ' >> /etc/sysconfig/vncservers
- echo "Now you can use "vncpasswd " set your vnc password"
- echo "And you can use "vncserver" start your vnc server"
- #iptables and selinux
- iptables -X
- iptables -Z
- iptables -F
- service iptables save
- # used for oracle service
- sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
- sed -i 's/:N/:Y/g' /etc/oratab
- sed -i -e '78c\ORACLE_HOME_LISTNER=/u01/app/product/10.2.0/db_1/' /u01/app/product/10.2.0/db_1/bin/dbstart
- echo '
- #!/bin/bash
- #/etc/init.d/oracle chmod +x oracle
- # oracle This shell script takes care of starting and stopping
- # chkconfig: - 90 10
- # description: Oracle database server.
- # processname: oracle
- ORA_HOME=/u01/app/product/10.2.0/db_1
- ORA_OWNER=oracle
- prog="Oracle"
- # Source function library.
- . /etc/rc.d/init.d/functions
- if [ ! -f $ORA_HOME/bin/dbstart ]
- then
- echo "Oracle startup: cannot start"
- exit
- fi
- start(){
- su - $ORA_OWNER -c $ORA_HOME/bin/dbstart >/dev/null 2>&1 &
- ret=$?
- if [ $ret -eq 0 ]; then
- action $"Starting $prog: " /bin/true
- else
- action $"Starting $prog: " /bin/false
- fi
- [ $ret -eq 0 ] && touch /var/lock/subsys/oracled
- return $ret
- }
- stop(){
- su - $ORA_OWNER -c $ORA_HOME/bin/dbshut >/dev/null 2>&1
- ret=$?
- if [ $ret -eq 0 ]; then
- action $"Stopping $prog: " /bin/true
- else
- action $"Stopping $prog: " /bin/false
- fi
- [ $ret -eq 0 ] && rm -f /var/lock/subsys/oracled
- return $ret
- }
- restart(){
- stop
- start
- }
- # See how we were called.
- case "$1" in
- start)
- start
- ;;
- stop)
- stop
- ;;
- restart)
- restart
- ;;
- condrestart)
- condrestart
- ;;
- *)
- echo $"Usage: $0 {start|stop|restart}"
- exit 1
- esac ' > /etc/init.d/oracle
- chmod u+x /etc/init.d/oracle
- chkconfig oracle on
本文出自 “潜入技术的海洋” 博客,请务必保留此出处http://myhat.blog.51cto.com/391263/1053690