一键准备Oracle安装
来源:互联网 发布:淘宝客如何推广 编辑:程序博客网 时间:2024/04/30 02:28
在Linux下安装Oracle软件之前,有相当工作需要准备,包括建立用户、配置内核参数、配置资源限制参数、配置Oracle用户环境等,十分繁琐。即便十分熟悉,也需要花费一定的精力来准备。说白了,做这些事情有点类似于低水平重复建设,虽没有多大技术含量,却又不得不做。现在将这些准备工作做成脚本,这样可以近乎实现一键准备Oracle安装。
说明:
1> 该脚本的执行方式为sh Oracle_Setup_Prepare.sh orcl /u01,两个参数说明见脚本解释部分。
2> 该脚本中涉及到一个文本文件Package_list,是Oracle安装依赖包的列表。具体内容如下文所示。
3> 该脚本主要针对于单实例数据库安装。
4> 安装信息可参考生成的output.log文件
脚本内容如下:
[oracle@node3 ~]$ cat Oracle_Setup_Prepare.sh
#!/bin/bash###############################################功能:Preparation for Oracle Installation###参数:SID BASE###其中,sid指的是ORACLE_SID###BASE指的是ORACLE_BASE的一级目录,如ORACLE_BASE=/u01/app/oracle,则BASE为/u01#############################################检查参数个数是否正确if [ $# -ne 2 ];then echo "$0 SID BASE" exitfiSID="$1"BASE="$2"#主机名绑定IP=`ifconfig |awk -F'[: ]+' 'NR==2{print $4'}`HOST=`hostname`sed -i '$a'$IP' '$HOST'' /etc/hosts#Checking the Package Requirements#将需要安装的表的列表贴在Package_list文件中awk -F'-[0-9]' '{print $1}' Package_list |awk '{print $1}' |uniq |xargs yum install -y > output.log 2>&1#Creating Required Operating System Groups and Usersgroupadd -g 800 oinstallgroupadd -g 801 dbagroupadd -g 802 operuseradd -g oinstall -G dba,oper oracleecho oracle | passwd --stdin oracle >> output.log 2>&1#Configure Kernal Parameterssed -i '$a\fs.aio-max-nr = 1048576' /etc/sysctl.confsed -i '$a\fs.file-max = 6815744' /etc/sysctl.confsed -i '$a\kernel.shmall = 2097152' /etc/sysctl.confsed -i '$a\kernel.shmmax = 536870912' /etc/sysctl.confsed -i '$a\kernel.shmmni = 4096' /etc/sysctl.confsed -i '$a\kernel.sem = 250 32000 100 128' /etc/sysctl.confsed -i '$a\net.ipv4.ip_local_port_range = 9000 65500' /etc/sysctl.confsed -i '$a\net.core.rmem_default = 262144' /etc/sysctl.confsed -i '$a\net.core.rmem_max = 4194304' /etc/sysctl.confsed -i '$a\net.core.wmem_default = 262144' /etc/sysctl.confsed -i '$a\net.core.wmem_max = 1048586' /etc/sysctl.confsysctl -p >> output.log 2>&1#Configure Resource Limitssed -i '$a\oracle soft nproc 2047' /etc/security/limits.confsed -i '$a\oracle hard nproc 16384' /etc/security/limits.confsed -i '$a\oracle soft nofile 1024' /etc/security/limits.confsed -i '$a\oracle hard nofile 65536' /etc/security/limits.conf#Add the following line to the /etc/pam.d/login file, if it does not already exist:sed -i '$a\session required pam_limits.so' /etc/pam.d/login#Add the following line to the /etc/profilesed -i '$a\if [[ $USER = "oracle" ]]; then' /etc/profilesed -i '$a\ if [[ $SHELL = "/bin/ksh" ]]; then' /etc/profilesed -i '$a\ ulimit -p 16384' /etc/profilesed -i '$a\ ulimit -n 65536' /etc/profilesed -i '$a\ else' /etc/profilesed -i '$a\ ulimit -u 16384 -n 65536' /etc/profilesed -i '$a\ fi' /etc/profilesed -i '$a\fi' /etc/profilesource /etc/profile#Configuring the oracle User's Environmentsed -i '$a\export ORACLE_SID='$SID'' /home/oracle/.bash_profilesed -i '$a\export ORACLE_BASE='$BASE'/app/oracle' /home/oracle/.bash_profilesed -i '$a\export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1' /home/oracle/.bash_profilesed -i '$a\export PATH=$ORACLE_HOME/bin:$PATH' /home/oracle/.bash_profilesource /home/oracle/.bash_profile#Creating Required Directoriesmkdir -p $ORACLE_HOMEchown -R oracle.oinstall $BASE/appchmod -R 775 $BASE/appecho "Preparation For Oracle Installation Is Over!"
Package_list内容如下:
[oracle@node3 ~]$ cat Package_list
binutils-2.17.50.0.6compat-libstdc++-33-3.2.3compat-libstdc++-33-3.2.3 (32 bit)elfutils-libelf-0.125elfutils-libelf-devel-0.125gcc-4.1.2gcc-c++-4.1.2glibc-2.5-24glibc-2.5-24 (32 bit)glibc-common-2.5glibc-devel-2.5glibc-devel-2.5 (32 bit)glibc-headers-2.5ksh-20060214libaio-0.3.106libaio-0.3.106 (32 bit)libaio-devel-0.3.106libaio-devel-0.3.106 (32 bit)libgcc-4.1.2libgcc-4.1.2 (32 bit)libstdc++-4.1.2libstdc++-4.1.2 (32 bit)libstdc++-devel 4.1.2make-3.81sysstat-7.0.2unixODBC-2.2.11unixODBC-2.2.11 (32 bit)unixODBC-devel-2.2.11unixODBC-devel-2.2.11 (32 bit)
PS: 既然sed每次都是在最后一行追加,其实,用echo "***" >> filename即可实现。
0 0
- 一键准备Oracle安装
- oracle安装一(准备篇)
- Oracle Rac for RedHat6.6安装前准备一
- Oracle安装(图形界面)准备
- oracle在AIX安装准备
- hadoop(一) - 环境安装准备
- HDP安装前准备(一)
- AIX 6.1 安装 oracle 10gR2之(一)----硬件准备
- oracle 11g 静默安装----准备篇
- linux oracle 11g安装准备
- Oracle 11g安装前的准备
- Centos7安装Oracle前期环境准备
- Oracle安装——环境准备
- Fastdfs+nginx---(一) 安装前准备
- 一、DC/OS 安装前期准备
- OpenStack Ocata 安装(一)环境准备
- Linux安装维护(为安装Oracle做准备)
- 一. Oracle安装
- Oracle工具之DBNEWID
- 运算符重载
- Oracle常用函数汇总
- 序列sequence中的cache问题
- 教您修复mysql数据库的方法
- 一键准备Oracle安装
- 一键配置本地yum源
- Shell最多可以输入多少个参数?
- (转)Shell函数
- SQL Cookbook
- Qt5双缓冲机制
- [刷题]Ugly Number
- 主机巡检脚本
- Oracle身份认证方式