ICode9

精准搜索请尝试: 精确搜索
首页 > 数据库> 文章详细

Linux一键部署oracle安装环境脚本

2020-01-13 21:05:20  阅读:252  来源: 互联网

标签:profile sysctl 一键 etc sed conf Linux oracle


#!/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"
   exit
fi

SID="$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 Users
groupadd -g 800 oinstall
groupadd -g 801 dba
groupadd -g 802 oper
useradd -g oinstall -G dba,oper oracle
echo oracle | passwd --stdin oracle >> output.log 2>&1

#Configure Kernal Parameters
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 >> output.log 2>&1

#Configure Resource Limits
sed -i '$a\oracle           soft    nproc   2047' /etc/security/limits.conf
sed -i '$a\oracle           hard    nproc   16384' /etc/security/limits.conf
sed -i '$a\oracle           soft    nofile  1024' /etc/security/limits.conf
sed -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/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

#Configuring the oracle User's Environment
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\export PATH=$ORACLE_HOME/bin:$PATH' /home/oracle/.bash_profile
source /home/oracle/.bash_profile

#Creating Required Directories
mkdir -p $ORACLE_HOME
chown -R oracle.oinstall $BASE/app
chmod -R 775 $BASE/app

echo "Preparation For Oracle Installation Is Over!"
OldDriver6 发布了57 篇原创文章 · 获赞 85 · 访问量 9608 私信 关注

标签:profile,sysctl,一键,etc,sed,conf,Linux,oracle
来源: https://blog.csdn.net/qq_41944882/article/details/103964245

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有