欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

shell 一键配置单实例oracle基础环境变量(linux7)

程序员文章站 2022-03-03 22:54:07
#!/bin/bash echo "修改主机名" hostnamectl set-hostname wangxfa hostname sleep 1 echo "查看并关闭防火墙" systemctl status firewalld systemctl stop firewalld systemc ......
#!/bin/bash
echo "修改主机名"
hostnamectl set-hostname wangxfa
hostname
sleep 1
echo "查看并关闭防火墙"
systemctl status firewalld
systemctl stop firewalld
systemctl disable firewalld
systemctl status firewalld
sleep 1

echo "禁用selinux"
sed -i "s/selinux=enforcing/selinux=disabled/g" /etc/selinux/config


#add user and group
echo "创建安装oracle所需的用户和组"
groupadd -g 1030 oinstall
groupadd -g 1031 dba
useradd -u 54321 -g oinstall -g dba oracle
echo "oracle" | passwd --stdin "oracle"


echo "创建oracle相关目录"
sleep 1
mkdir –p /u01/app/oracle/product/11.2.0
chmod -r 775 /u01
chown -r oracle:oinstall /u01

echo "备份并修改/etc/securitylimits.conf"
sleep 1
cp /etc/security/limits.conf /etc/security/limits_bake.conf 
echo "oracle soft nproc 2047" >>/etc/security/limits.conf
echo "oracle hard nproc 16384" >>/etc/security/limits.conf
echo "oracle soft nofile 1024" >>/etc/security/limits.conf
echo "oracle hard nofile 65536" >>/etc/security/limits.conf


echo "备份并修改/etc/sysctl.conf文件"
sleep 1
cp /etc/sysctl.conf /etc/sysctl_bak.conf
echo "fs.file-max = 6815744" >>/etc/sysctl.conf
echo "fs.aio-max-nr = 1048576" >>/etc/sysctl.conf
echo "kernel.shmall = ‭1677721" >>/etc/sysctl.conf (注:此处需要根据shmmax大小来计算,shmmax/pagesize 则计算为 ‭6871947673/4k=‭1677721) 
echo "kernel.shmmax = 6871947673" >>/etc/sysctl.conf (注:此处需要根据实际内存大小来计算,加入内存大小为8g,将内存的80%用于数据库,计算方法:1024*1024*1024*8*08=‭‭6871947673‬) 
echo "kernel.shmmni = 4096" >>/etc/sysctl.conf echo "kernel.sem = 250 32000 100 128" >>/etc/sysctl.conf 
echo "net.ipv4.ip_local_port_range = 9000 65500" >>/etc/sysctl.conf 
echo "net.core.rmem_default = 4194304" >>/etc/sysctl.conf 
echo "net.core.rmem_max = 4194304" >>/etc/sysctl.conf 
echo "net.core.wmem_default = 262144" >>/etc/sysctl.conf 
echo "net.core.wmem_max = 1048576" >>/etc/sysctl.conf

echo "使sysctl.conf立即生效" 
sysctl -p 
sleep 1

echo "备份并修改/etc/profile文件" 
cp /etc/profile /etc/profile_bak echo "if [ \$user = \"oracle\" ]; then" >>/etc/profile 
echo "if [ \$shell = \"/bin/ksh\" ]; then" >>/etc/profile 
echo "ulimit -p 16384" >>/etc/profile 
echo "ulimit -n 65536" >>/etc/profile 
echo "else " >>/etc/profile 
echo "ulimit -u 16384 -n 65536" >>/etc/profile echo "fi" >>/etc/profile 
echo "fi" >>/etc/profile


echo "设置oracle用户环境变量" 
su - oracle 
cp /home/oracle/.bash_profile /home/oracle/.bash_profile_bak 
echo "export oracle_base=/u01/app/oracle" >>/home/oracle/.bash_profile 
echo "export oracle_home=$oracle_base/product/11.2.0" >>/home/oracle/.bash_profile 
echo "export path=$oracle_home/bin:$oracle_home/bin:$path" >>/home/oracle/.bash_profile 
echo "export ld_library_path=$oracle_home/lib" >>/home/oracle/.bash_profile 
echo "#export oracle_sid=hisdb1" >>/home/oracle/.bash_profile 
echo "export nls_lang=american_america.zhs16gbk" >>/home/oracle/.bash_profile 
echo "export editor=vi" >>/home/oracle/.bash_profile 
echo "set -o vi" >>/home/oracle/.bash_profile 
echo "umask 022" >>/home/oracle/.bash_profile