本篇主要介绍oracle环境部署的准备工作,主要包括oracle11g依赖包安装、用户和组创建、内核参数配置、配置资源配置,环境变量配置等,具有一定的参考借鉴价值,需要的朋友可以作为参考,也可进行部署测试,实际生产环境的要依赖主机的硬件配置,这个一键部署Oracle安装环境脚本是通用设置,可支持大部分环境。
准备工作:
1.脚本上传至服务器
2.准备好依赖包即/tmp/Package.lst文件内容
3.部署产生的日志在/tmp/ora_init.log
一键部署脚本
#!/bin/bash ############################################ ###功能:ORACLE部署参数设置 ###参数:SID BASE ###其中,SID指的是ORACLE_SID, 数据库实例名即可 ###其中,BASE指的是ORACLE_BASE的一级目录,如ORACLE_BASE=/u01/app/oracle,则BASE为/u01 ############################################ #检查参数个数是否正确 if [ $# -ne 2 ];then echo "$0 SID BASE" exit fi SID="$1" BASE="$2" #主机名绑定 IP=`ifconfig |awk -F'[: ]+' 'NR==2{print $4'}` HOST=`hostname` sed -i '$a'$IP' '$HOST'' /etc/hosts #检查包装要求 #将需要安装的表的列表贴在Package_list文件中 awk -F'-[0-9]' '{print $1}' /tmp/Package_list |awk '{print $1}' |uniq |xargs yum install -y > /tmp/ora_init.log 2>&1 #创建所需的操作系统用户和组 groupadd -g 800 oinstall groupadd -g 801 dba groupadd -g 802 oper useradd -g oinstall -G dba,oper oracle echo oracle | passwd --stdin oracle >> /tmp/ora_init.log 2>&1 #配置内核参数设置 sed -i '$a\fs.aio-max-nr = 1048576' /etc/sysctl.conf sed -i '$a\fs.file-max = 6815744' /etc/sysctl.conf sed -i '$a\kernel.shmall = 2097152' /etc/sysctl.conf sed -i '$a\kernel.shmmax = 536870912' /etc/sysctl.conf sed -i '$a\kernel.shmmni = 4096' /etc/sysctl.conf sed -i '$a\kernel.sem = 250 32000 100 128' /etc/sysctl.conf sed -i '$a\net.ipv4.ip_local_port_range = 9000 65500' /etc/sysctl.conf sed -i '$a\net.core.rmem_default = 262144' /etc/sysctl.conf sed -i '$a\net.core.rmem_max = 4194304' /etc/sysctl.conf sed -i '$a\net.core.wmem_default = 262144' /etc/sysctl.conf sed -i '$a\net.core.wmem_max = 1048586' /etc/sysctl.conf sysctl -p >> /tmp/ora_init.log 2>&1 #配置资源设置 sed -i '$a\oracle soft nproc 2048' /etc/security/limits.conf sed -i '$a\oracle hard nproc 16384' /etc/security/limits.conf sed -i '$a\oracle soft nofile 2048' /etc/security/limits.conf sed -i '$a\oracle hard nofile 65536' /etc/security/limits.conf #如果/etc/pam.d/login文件不存在,请将以下行添加到该文件中: sed -i '$a\session required pam_limits.so' /etc/pam.d/login #将以下行添加到/etc/profile sed -i '$a\if [[ $USER = "oracle" ]]; then' /etc/profile sed -i '$a\ if [[ $SHELL = "/bin/ksh" ]]; then' /etc/profile sed -i '$a\ ulimit -p 16384' /etc/profile sed -i '$a\ ulimit -n 65536' /etc/profile sed -i '$a\ else' /etc/profile sed -i '$a\ ulimit -u 16384 -n 65536' /etc/profile sed -i '$a\ fi' /etc/profile sed -i '$a\fi' /etc/profile source /etc/profile #配置oracle用户的环境 sed -i '$a\export LANG=en_US' /home/oracle/.bash_profile sed -i '$a\export ORACLE_SID='$SID'' /home/oracle/.bash_profile sed -i '$a\export ORACLE_BASE='$BASE'/app/oracle' /home/oracle/.bash_profile sed -i '$a\export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1' /home/oracle/.bash_profile sed -i '$a\NLS_LANG=AMERICAN_AMERICA.ZHS16GBK;export NLS_LANG' /home/oracle/.bash_profile sed -i '$a\export PATH=$ORACLE_HOME/bin:$PATH' /home/oracle/.bash_profile source /home/oracle/.bash_profile #创建所需目录 mkdir -p $ORACLE_HOME chown -R oracle.oinstall $BASE/app chmod -R 775 $BASE/app echo "Oracle安装的准备工作已经结束!"
oracle11g依赖包
/tmp/Package.lst内容需要添加oracle的依赖包,提灯小生整理了oracle11g的依赖包,可将下面内容添加到Package.lst中
binutils-2.17.50.0.6 compat-libstdc++-33-3.2.3 elfutils-libelf-0.125 elfutils-libelf-devel-0.125 elfutils-libelf-devel-static-0.125 gcc-4.1.2 gcc-c++-4.1.2 glibc-2.5-24 glibc-common-2.5 glibc-devel-2.5 glibc-headers-2.5 kernel-headers-2.6.18 ksh-20060214 libaio-0.3.106 libaio-devel-0.3.106 libgcc-4.1.2 libgomp-4.1.2 libstdc++-4.1.2 libstdc++-devel-4.1.2 make-3.81 sysstat-7.0.2 unixODBC-2.2.11 unixODBC-devel-2.2.11 binutils-2.17.50.0.6 compat-libstdc++-33-3.2.3 elfutils-libelf-0.125 elfutils-libelf-devel-0.125 elfutils-libelf-devel-static-0.125 gcc-4.1.2 gcc-c++-4.1.2 glibc-2.5-24 glibc-common-2.5 glibc-devel-2.5 glibc-headers-2.5 kernel-headers-2.6.18 ksh-20060214 libaio-0.3.106 libaio-devel-0.3.106 libgcc-4.1.2 libgomp-4.1.2 libstdc++-4.1.2 libstdc++-devel-4.1.2 make-3.81 sysstat-7.0.2 unixODBC-2.2.11 unixODBC-devel-2.2.11
总结
至此,oracle安装环境的准备工作即全部完成,可以执行一键部署oracle安装环境脚本,希望对大家有所帮助,如果大家有任何疑问请给我留言,提灯小生会及时回复大家的。
继续阅读
评论