#hosts文件配置
echo "# Public IP" >> /etc/hosts
echo "192.168.2.36 his36" >> /etc/hosts
echo "192.168.2.37 his37" >> /etc/hosts
echo "# Private IP" >> /etc/hosts
echo "10.0.2.36 his36prv" >> /etc/hosts
echo "10.0.2.37 his37prv" >> /etc/hosts
echo "# Virtual IP" >> /etc/hosts
echo "192.168.2.38 his36vip" >> /etc/hosts
echo "192.168.2.39 his37vip" >> /etc/hosts
echo "# Scan IP" >> /etc/hosts
echo "192.168.2.40 hisscan" >> /etc/hosts
#创建用户和组
groupadd -g 1001 oinstall
groupadd -g 1002 dba
groupadd -g 1003 oper
groupadd -g 1004 asmadmin
groupadd -g 1005 asmoper
groupadd -g 1006 asmdba
useradd -u 2001 -g oinstall -G dba,asmdba,oper oracle
useradd -u 2002 -g oinstall -G asmadmin,asmdba,asmoper,dba,oper grid
#设置oracle、grid账户密码
passwd oracle
passwd grid
#设置共享内存(删除原tmpfs行)
echo "tmpfs /dev/shm tmpfs defaults,size=12288m 0 0" >> /etc/fstab
#创建目录并授权
mkdir -p /u01/app/grid
mkdir -p /u01/app/11.2.0.4/grid
chown -R grid:oinstall /u01
mkdir -p /u01/app/oraInventory
chown -R grid:oinstall /u01/app/oraInventory
mkdir -p /u01/app/oracle
chown -R oracle:oinstall /u01/app/oracle
chmod -R 775 /u01
#挂载光驱,删除原repo文件
mount /dev/cdrom /mnt
cd /etc/yum.repos.d
rm -rf *.repo
#配置yum源
echo "[EL]">> /etc/yum.repos.d/oel.repo
echo "name=Linux 6.9 DVD">> /etc/yum.repos.d/oel.repo
echo "baseurl=file:///mnt">> /etc/yum.repos.d/oel.repo
echo "gpgcheck=0">> /etc/yum.repos.d/oel.repo
echo "enabled=1">> /etc/yum.repos.d/oel.repo
#安装软件包
yum install compat-libcap1 -y
yum install compat-libstdc++-33 -y
yum install gcc -y
yum install gcc-c++ -y
yum install ksh -y
yum install libaio-devel -y
yum install unixODBC -y
yum install unixODBC-devel -y
#修改资源限制参数
echo "#ORACLE SETTING">> /etc/security/limits.conf
echo "grid soft nproc 16384">> /etc/security/limits.conf
echo "grid hard nproc 16384">> /etc/security/limits.conf
echo "grid soft nofile 65536">> /etc/security/limits.conf
echo "grid hard nofile 65536">> /etc/security/limits.conf
echo "grid soft stack 32768">> /etc/security/limits.conf
echo "grid hard stack 32768">> /etc/security/limits.conf
echo "oracle soft nproc 16384">> /etc/security/limits.conf
echo "oracle hard nproc 16384">> /etc/security/limits.conf
echo "oracle soft nofile 65536">> /etc/security/limits.conf
echo "oracle hard nofile 65536">> /etc/security/limits.conf
echo "oracle soft stack 32768">> /etc/security/limits.conf
echo "oracle hard stack 32768">> /etc/security/limits.conf
echo "oracle hard memlock 16000000">> /etc/security/limits.conf #略低于物理内存,单位KB
echo "oracle soft memlock 16000000">> /etc/security/limits.conf #略低于物理内存,单位KB
#配置资源限制
echo > /etc/security/limits.d/90-nproc.conf
echo "* soft nproc 16384">> /etc/security/limits.d/90-nproc.conf
#控制用户分配资源
echo "session required pam_limits.so" >> /etc/pam.d/login
#修改内核参数,屏蔽原文件中kernel.shmmax和kernel.shmall
vi /etc/sysctl.conf
echo "#ORACLE SETTING" >> /etc/sysctl.conf
echo "fs.aio-max-nr = 1048576" >> /etc/sysctl.conf
echo "fs.file-max = 6815744" >> /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 = 262144" >> /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 = 1048586" >> /etc/sysctl.conf
echo "kernel.panic_on_oops = 1" >> /etc/sysctl.conf
echo "kernel.shmmax = 17179869183" >> /etc/sysctl.conf
echo "kernel.shmall = 4194304" >> /etc/sysctl.conf
echo "kernel.shmmni = 4096" >> /etc/sysctl.conf
echo "vm.nr_hugepages = 5120" >> /etc/sysctl.conf
#强制生效
sysctl -p
#关闭numa功能,在kernel(2行)末尾增加numa=off
vi /boot/grub/grub.conf
#配置安全,修改SELINUX参数disabled
vi /etc/selinux/config
#强制生效
setenforce 0
#关闭防火墙,开机不启动
service iptables stop
chkconfig --level 35 iptables off
#关闭透明页面
echo "if test -f /sys/kernel/mm/transparent_hugepage/enabled; then" >> /etc/rc.d/rc.local
echo "echo never > /sys/kernel/mm/transparent_hugepage/enabled" >> /etc/rc.d/rc.local
echo "fi" >> /etc/rc.d/rc.local
echo "if test -f /sys/kernel/mm/transparent_hugepage/defrag; then" >> /etc/rc.d/rc.local
echo "echo never > /sys/kernel/mm/transparent_hugepage/defrag" >> /etc/rc.d/rc.local
echo "fi" >> /etc/rc.d/rc.local
#强制生效
chmod +x /etc/rc.d/rc.local
#重启操作系统确认是否已关闭
cat /sys/kernel/mm/transparent_hugepage/defrag
#配置grid账号环境变量
su - grid
vi ~/.bash_profile
alias sqlplus='rlwrap sqlplus'
alias rman='rlwrap rman'
export LANG=en_US
export PS1="[`whoami`@`hostname`:"'$PWD]$'
export TMP=/tmp
export TMPDIR=$TMP
export ORACLE_SID=+ASM1 #节点1是+ASM1,后面的依次类推
export ORACLE_TERM=xterm
export ORACLE_BASE=/u01/app/grid
export ORACLE_HOME=/u01/app/11.2.0.4/grid
export NLS_DATE_FORMAT="yyyy-mm-dd HH24:MI:SS"
export PATH=.:$PATH:$HOME/bin:$ORACLE_HOME/bin:$ORACLE_HOME/OPatch
export THREADS_FLAG=native
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
export CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
umask 022
#配置oracle账号环境变量
su - oracle
vi ~/.bash_profile
alias sqlplus='rlwrap sqlplus'
alias rman='rlwrap rman'
export LANG=en_US
export PS1="[`whoami`@`hostname`:"'$PWD]$'
export TMP=/tmp
export TMPDIR=$TMP
export ORACLE_UNQNAME=hrdb #全局实例名
export ORACLE_SID=hrdb1 #节点实例名,从1开始
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0.4/db_home
export ORACLE_TERM=xterm
export NLS_DATE_FORMAT="yyyy-mm-dd HH24:MI:SS"
export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
export PATH=.:$PATH:$HOME/.local/bin:$HOME/bin:$ORACLE_HOME/OPatch:$ORACLE_HOME/bin
export THREADS_FLAG=native
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
export CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
umask 022
#2台节点机器时间要一样,禁止NTP
[root@his36 ~]# service ntpd stop
[root@his36 ~]# chkconfig ntpd off
#删除进程(如果有的话)
[root@his36 ~]# rm /var/run/ntpd.pid
#配置环境变量,互信。sshUserSetup.sh路径:grid安装包sshsetup目录下,在节点1上执行
[root@his36 ~]# /home/grid/grid/sshsetup/sshUserSetup.sh -user grid -hosts "his36 his37" -advanced -noPromptPassphrase
[root@his36 ~]# /home/grid/grid/sshsetup/sshUserSetup.sh -user oracle -hosts "his36 his37" -advanced -noPromptPassphrase
#分别在节点1和节点2验证gird、oracle用户互信
su - grid
ssh his36 date
ssh his37 date
ssh his36prv date
ssh his37prv date
su - oracle
ssh his36 date
ssh his37 date
ssh his36prv date
ssh his37prv date
#安装rlwrap(root用户执行)
yum install -y readline*
tar -zxvf rlwrap-0.43.tar.gz
cd rlwrap-0.43
./configure
make
make install
oracle用户环境变量中增加
alias sqlplus='rlwrap sqlplus'
alias rman='rlwrap rman'
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。




