方便部署一个单实例环境的oracle,事情太多了!还是脚本方便,下一步准备用perl写个通用的
如果在windows 下改了shell 换行不一样的哦
sed -i “s/\r//” 可以解决
#!/bin/bash
######create by Li Hua########
SYSTEM=`uname -s`
if [ $SYSTEM != "Linux" ] ; then
echo "Must be ON Linux"
exit
fi
##############判断用户是否为root#################
if [ `whoami` != root ]; then
echo "must be run root this script."
exit
fi
##############关闭不常用的服务#################
for i in `ls /etc/rc3.d/S*`
do
SERVICES=`echo $i|cut -c 15-`
echo $SERVICES
case $SERVICES in
crond | irqbalance | microcode_ctl | network | random | sendmail | sshd | syslog | local|lvm2-monitor )
echo "Base services, Skip!"
;;
*)
echo "change $SERVICES to off"
chkconfig --level 235 $SERVICES off
service $SERVICES stop
;;
esac
done
################关闭selinux#################
oracle is user ; done
sed -i '/SELINUX/s/enforcing/disabled/' /etc/selinux/config
##############创建用户#################
#for i in ` awk -F: '{print $1}'/etc/passwd';do [[ $i == oracle ]] && echo
/usr/sbin/groupadd oinstall
/usr/sbin/groupadd dba
/usr/sbin/useradd -m -g oinstall -G dba oracle
echo oracle|passwd --stdin oracle
####################创建目录####################
mkdir -p /u01/oracle
###################添加环境变量#################
echo "export ORACLE_BASE=/u01/oracle" >>/home/oracle/.bash_profile
echo "export ORACLE_HOME=\$ORACLE_BASE/product/10.2.0/db_1" >>/home/oracle/.bash_profile
echo "export PATH=$PATH:$ORACLE_HOME/bin" >>/home/oracle/.bash_profile
echo "export CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib" >>/home/oracle/.bash_profile
chown -R oracle:oinstall /u01/oracle
chmod -R 775 /u01/oracle
sleep 5
#################修改内核参数#####################
cat >> /etc/sysctl.conf <<EOF
net.ipv4.ip_forward = 0
net.ipv4.conf.default.rp_filter = 1
net.ipv4.conf.default.accept_source_route = 0
kernel.sysrq = 0
kernel.core_uses_pid = 1
net.ipv4.tcp_syncookies = 1
kernel.msgmnb = 65536
kernel.msgmax = 65536
kernel.shmmax = 4294967295
kernel.shmall = 268435456
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
EOF
/sbin/sysctl -p
sleep 5
cat >> /etc/security/limits.conf <<EOF
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
EOF
cat >> /etc/pam.d/login <<EOF
session required /lib/security/pam_limits.so
EOF
cat >> /etc/pam.d/login <<EOF
session required /lib/security/pam_limits.so
EOF
cat >> /etc/profile <<EOF
if [ \$USER = "oracle" ]; then
if [ \$SHELL = "/bin/ksh" ]; then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
umask 022
fi
EOF
sleep 5
##################关闭防火墙######################
chkconfig --level 2345 iptables off
service iptables stop
sleep 3
##################结束############################
echo "END!!!!"
|
阅读(1733) | 评论(0) | 转发(0) |