一步一步搭建oracle 11gR2 rac+dg之环境准备(二)

 一步一步在RHEL6.5+VMware Workstation 10上搭建 oracle 11gR2 rac + dg 之环境准备 (二)

本篇目录结构:

一步一步搭建oracle 11gR2 rac+dg之环境准备(二)

 

  1. Linux 环境准备

    安装linux的环境,我就不介绍了,这一部分如果不会的童鞋就去百度吧,一百度一大堆,如果还是不会的话就直接下载我已经安装好的系统吧,下载下来直接可用(http://yunpan.cn/cgkEsf8wpHC2G (提取码:90f5)),复制3份,直接命名为rac1、rac2和dg即可,如图:

    一步一步搭建oracle 11gR2 rac+dg之环境准备(二)

     

 

  1. 前期环境准备

    1. 关闭防火墙

在rac1 和rac2 2个节点上分别执行如下语句:

 

[root@rac01 ~]# service iptables stop

[root@rac01 ~]# chkconfig iptables off

[root@rac01 ~]# chkconfig iptables --list

iptables 0:off 1:off 2:off 3:off 4:off 5:off 6:off

 

chkconfig iptables off ---永久

service iptables stop ---临时

/etc/init.d/iptables status ----会得到一系列信息,说明防火墙开着。

/etc/rc.d/init.d/iptables stop ----------关闭防火墙

 

 

  1. 修改主机名

 

#vi /etc/sysconfig/network

HOSTNAME=rac1

 

# hostname rac1

 

 

Rac 2 上同样执行

 

  1. 修改hosts文件--网络配置(网卡配置)

hosts文件:

[grid@rac1 ~]$ more /etc/hosts

127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4

::1 localhost localhost.localdomain localhost6 localhost6.localdomain6

 

 

#Public IP

192.168.59.135 rac1

192.168.59.136 rac2

 

#Private IP

192.168.116.133 rac1-priv

192.168.116.134 rac2-priv

 

#Virtual IP

192.168.59.137 rac1-vip

192.168.59.138 rac2-vip

 

#Scan IP

192.168.59.139 rac-scan

 

 

 

 

  1. 配置内核参数

    1. 修改/etc/sysctl.conf文件

[root@rac01 ~]# vi /etc/sysctl.conf

# for oracle 11g

fs.aio-max-nr = 1048576

fs.file-max = 6815744

kernel.shmall = 2147483648

kernel.shmmax = 68719476736

kernel.shmmni = 4096

kernel.sem = 250 32000 100 128

net.ipv4.ip_local_port_range = 9000 65500

net.core.rmem_default = 262144

net.core.rmem_max = 4194304

net.core.wmem_default = 262144

net.core.wmem_max = 1048586

 

使修改参数立即生效:

[root@rac01 ~]# /sbin/sysctl -p

 

  1. 修改limits文件

[root@rac01 ~]# vi /etc/security/limits.conf

grid soft nproc 2047

grid hard nproc 16384

grid soft nofile 1024

grid hard nofile 65536

oracle soft nproc 2047

oracle hard nproc 16384

oracle soft nofile 1024

oracle hard nofile 65536

 

  1. 修改/etc/pam.d/login文件

[root@rac01 ~]# vi /etc/pam.d/login

session required pam_limits.so

 

  1. 修改/etc/profile文件

[root@rac01 ~]# vi /etc/profile

if [ $USER = "oracle" ] || [ $USER = "grid" ]; then

if [ $SHELL = "/bin/ksh" ]; then

ulimit -p 16384

ulimit -n 65536

else

ulimit -u 16384 -n 65536

fi

umask 022

fi

 

  1. 禁用 selinux

[root@rac01 ~]# vi /etc/selinux/config

# This file controls the state of SELinux on the system.

# SELINUX= can take one of these three values:

# enforcing - SELinux security policy is enforced.

# permissive - SELinux prints warnings instead of enforcing.

# disabled - No SELinux policy is loaded.

SELINUX=disabled

# SELINUXTYPE= can take one of these two values:

# targeted - Targeted processes are protected,

# mls - Multi Level Security protection.

SELINUXTYPE=targeted

 

一步一步搭建oracle 11gR2 rac+dg之环境准备(二)

getsebool

getsebool: SELinux is disabled

 

 

 

 

  1. 停止 ntp 服务,11gR2 新增的检查项

root 用户双节点运行:

 

gird时间同步所需要的设置(11gR2新增检查项)

#Network Time Protocol Setting

/sbin/service ntpd stop

mv /etc/ntp.conf /etc/ntp.conf.bak (这时候oracle会自动启用自己的NTP服务)

 

[root@node1 ~]# service ntpd status

ntpd is stopped

[root@node1 ~]# chkconfig ntpd stop

[root@node1 ~]# cat /etc/ntp

ntp/ ntp.conf

[root@node1 ~]# cp /etc/ntp.conf /etc/ntp.conf.bak

[root@node1 ~]# rm -rf /etc/ntp.conf

[root@node1 ~]#

 

 

 

  1. /dev/shm 共享内存不足的处理

解决方法:

例如:为了将/dev/shm的大小增加到1GB,修改/etc/fstab的这行:默认的:

none /dev/shm tmpfs defaults 0 0

改成:

none /dev/shm tmpfs defaults,size=1024m 0 0

size参数也可以用G作单位:size=1G。

或者使用命令: mount -o remount,size=4G /dev/shm  

重新mount /dev/shm使之生效:

# mount -o remount /dev/shm

或者:

# umount /dev/shm

# mount -a

马上可以用"df -h"命令检查变化。

 

  1. 添加组和用户

    1. 添加oracle和grid用户

groupadd -g 501 oinstall

groupadd -g 502 dba

groupadd -g 503 oper

groupadd -g 504 asmadmin

groupadd -g 505 asmoper

groupadd -g 506 asmdba

useradd -g oinstall -G dba,asmdba,oper oracle

useradd -g oinstall -G asmadmin,asmdba,asmoper,oper,dba grid

 

 

为oracle和grid用户设密码:

[root@rac01 ~]# passwd oracle

[root@rac01 ~]# passwd grid

 

 

检查:

[root@ora1 ~]# id oracle

uid=501(oracle) gid=501(oinstall) groups=501(oinstall),502(dba),503(oper),506(asmdba)

[root@ora1 ~]# id grid

uid=502(grid) gid=501(oinstall)

groups=501(oinstall),502(dba),503(oper),504(asmadmin),505(asmoper),506(asmdba)

 

一步一步搭建oracle 11gR2 rac+dg之环境准备(二)

  1. 创建目录并且配置 grid 和 oracle 用户的环境变量文件

? GRID 软件的 ORACLE_HOME 不能是 ORACLE_BASE 的子目录

 

 

--在2个节点均创建,root用户下创建目录:

mkdir -p /u01/app/oracle

mkdir -p /u01/app/grid

mkdir -p /u01/app/11.2.0/grid

chown -R grid:oinstall /u01/app/grid

chown -R grid:oinstall /u01/app/11.2.0

chown -R oracle:oinstall /u01/app/oracle

chmod -R 775 /u01

 

mkdir -p /u01/app/oraInventory

chown -R grid:oinstall /u01/app/oraInventory

chmod -R 775 /u01/app/oraInventory

 

 

 

 

修改gird、oracle用户的.bash_profile文件,以oracle账号登陆,编辑.bash_profile

或者在root直接编辑:

vi /home/oracle/.bash_profile

vi /home/grid/.bash_profile

 

 

--------Oracle User----切换到Oracle用户下------

[root@rhel_linux_asm ~]# su - oracle

[oracle@rhel_linux_asm ~]$ vi ~/.bash_profile

export ORACLE_SID=rac1  

export ORACLE_BASE=/u01/app/oracle

export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1

export LD_LIBRARY_PATH=$ORACLE_HOME/lib

export NLS_DATE_FORMAT="yyyy-mm-dd HH24:MI:SS"

export TMP=/tmp

export TMPDIR=$TMP

export PATH=$PATH:$ORACLE_HOME/bin

 

--------Grid User-----切换到grid用户下-----

[grid@rhel_linux_asm ~]$ vim .bash_profile

export ORACLE_SID=+ASM1  

export ORACLE_BASE=/u01/app/grid

export ORACLE_HOME=/u01/app/11.2.0/grid

export LD_LIBRARY_PATH=$ORACLE_HOME/lib

export NLS_DATE_FORMAT="yyyy-mm-dd HH24:MI:SS"

export PATH=$ORACLE_HOME/bin:$PATH

 

注意:另外一台数据库实例名须做相应修改:

Oracle:export ORACLE_SID=rac2

grid:export ORACLE_SID=+ASM2

 

 

  1. 软件包的检查

依据官方文档要求,Red Hat Enterprise Linux 5须安装如下软件包

 

  1. binutils-2.17.50.0.6

  2. compat-libstdc++-33-3.2.3

  3. compat-libstdc++-33-3.2.3(32 位)

  4. elfutils-libelf-0.125

  5. elfutils-libelf-devel-0.125

  6. elfutils-libelf-devel-static-0.125

  7. gcc-4.1.2

  8. gcc-c++-4.1.2

  9. glibc-2.5-24

  10. glibc-2.5-24(32 位)

  11. glibc-common-2.5

  12. glibc-devel-2.5

  13. glibc-devel-2.5(32 位)

  14. glibc-headers-2.5

  15. ksh-20060214

  16. libaio-0.3.106

  17. libaio-0.3.106(32 位)

  18. libaio-devel-0.3.106

  19. libaio-devel-0.3.106(32 位)

  20. libgcc-4.1.2

  21. libgcc-4.1.2(32 位)

  22. libstdc++-4.1.2

  23. libstdc++-4.1.2(32 位)

  24. libstdc++-devel 4.1.2

  25. make-3.81

  26. sysstat-7.0.2

  27. unixODBC-2.2.11

  28. unixODBC-2.2.11(32 位)

  29. unixODBC-devel-2.2.11

  30. unixODBC-devel-2.2.11(32 位)

 

一般情况下除了compat的一些包没有安装外,其他的包都已经安装了,可以使用rpm –qa |grep 命令进行查询,注意一定要与操作系统版本相符

 

 

rpm -qa | grep binutils-

rpm -qa | grep compat-libstdc++-

rpm -qa | grep elfutils-libelf-

rpm -qa | grep elfutils-libelf-devel-

rpm -qa | grep glibc-

rpm -qa | grep glibc-common-

rpm -qa | grep glibc-devel-

rpm -qa | grep gcc-

rpm -qa | grep gcc-c++-

rpm -qa | grep libaio-

rpm -qa | grep libaio-devel-

rpm -qa | grep libgcc-

rpm -qa | grep libstdc++-

rpm -qa | grep libstdc++-devel-

rpm -qa | grep make-

rpm -qa | grep sysstat-

rpm -qa | grep unixODBC-

rpm -qa | grep unixODBC-devel-

 

一步一步搭建oracle 11gR2 rac+dg之环境准备(二)

 

rpm -ivh compat-libstdc++-33-3.2.3-69.el6.i686.rpm --force --nodeps

rpm -ivh unixODBC-* --force --nodeps

 

rhel6 还应该安装一个包:compat-libcap1-1.10-1.x86_64.rpm

 

  1. 关闭不需要的服务

chkconfig autofs off

chkconfig acpid off

chkconfig sendmail off

chkconfig cups-config-daemon off

chkconfig cpus off

chkconfig xfs off

chkconfig lm_sensors off

chkconfig gpm off

chkconfig openibd off

chkconfig pcmcia off

chkconfig cpuspeed off

chkconfig nfslock off

chkconfig ip6tables off

chkconfig rpcidmapd off

chkconfig apmd off

chkconfig sendmail off

chkconfig arptables_jf off

chkconifg microcode_ctl off

chkconfig rpcgssd off

chkconfig ntpd off

 

 

 

  1. 配SSH互信,建立 ssh 等效性--11G不用配置

虽然在安装软件的过程中,oracle 会自动配置 SSH 对等性,建议在安装软件之前手工配置。

 

以oracle身份在每个节点执行

 

为ssh和scp创建连接,检验是否存在:

ls -l /usr/local/bin/ssh

ls -l /usr/local/bin/scp

不存在则创建

/bin/ln -s /usr/bin/ssh /usr/local/bin/ssh

/bin/ln -s /usr/bin/scp /usr/local/bin/scp

 

[root@rac01 ~]# /bin/ln -s /usr/bin/ssh /usr/local/bin/ssh

[root@rac01 ~]# /bin/ln -s /usr/bin/scp /usr/local/bin/scp

 

为oracle用户配置SSH:

生成用户的公匙和私匙,在每个节点上:

[root@rac01 ~]# su – oracle

[oracle@rac01 ~]# mkdir ~/.ssh

[oracle@rac01 ~]#cd .ssh

[oracle@rac01 ~]# ssh-keygen -t rsa

[oracle@rac01 ~]# ssh-keygen -t dsa

 

在节点1上,把所有节点的authorized_keys文件合成一个,再用这个文件覆盖各个节点.ssh下的同名文件:

[oracle@rac01 ~]# touch authorized_keys

[oracle@rac01 ~]# ssh rac01 cat /home/oracle/.ssh/id_rsa.pub >> authorized_keys

[oracle@rac01 ~]# ssh rac02 cat /home/oracle/.ssh/id_rsa.pub >> authorized_keys

[oracle@rac01 ~]# ssh rac01 cat /home/oracle/.ssh/id_dsa.pub >> authorized_keys

[oracle@rac01 ~]# ssh rac02 cat /home/oracle/.ssh/id_dsa.pub >> authorized_keys

[oracle@rac01 ~]# scp authorized_keys rac02:/home/oracle/.ssh/

 

分别在每个节点上执行检验操作:

[oracle@rac01 ~]# ssh rac01 date

[oracle@rac01 ~]# ssh rac02 date

 

[oracle@rac01 ~]# ssh-agent $SHELL

[oracle@rac01 ~]# ssh-add

 

 

为grid用户配置SSH:

在每个节点上:

[root@rac01 ~]# su – grid

[grid@rac01 ~]# mkdir ~/.ssh

[grid@rac01 ~]#cd .ssh

[grid@rac01 ~]# ssh-keygen -t rsa

[grid@rac01 ~]# ssh-keygen -t dsa

 

在节点1上

[grid@rac01 ~]# touch authorized_keys

[grid@rac01 ~]# ssh rac01 cat /home/grid/.ssh/id_rsa.pub >> authorized_keys

[grid@rac01 ~]# ssh rac02 cat /home/grid/.ssh/id_rsa.pub >> authorized_keys

[grid@rac01 ~]# ssh rac01 cat /home/grid/.ssh/id_dsa.pub >> authorized_keys

[grid@rac01 ~]# ssh rac02 cat /home/grid/.ssh/id_dsa.pub >> authorized_keys

[grid@rac01 ~]# scp authorized_keys rac02:/home/grid/.ssh/

 

 

分别在每个节点上:

[grid@rac01 ~]# ssh rac01 date

[grid@rac01 ~]# ssh rac02 date

 

[grid@rac01 ~]# ssh-agent $SHELL

[grid@rac01 ~]# ssh-add

 

--------------------------------------------------------------------------------------自己:

为Oracle用户配置SSH:

以oracle身份在每个节点执行以下代码

su - oracle

mkdir ~/.ssh

cd .ssh

ssh-keygen -t rsa

ssh-keygen -t dsa

cat *rsa.pub >> authorized_keys

cat *dsa.pub >> authorized_keys

 

然后在rac1下:

ssh rac2 cat /home/oracle/.ssh/authorized_keys >> authorized_keys

scp authorized_keys rac2:/home/oracle/.ssh/

 

然后分别在每个节点上执行检验操作:

ssh rac1 date

ssh rac2 date

ssh-agent $SHELL

ssh-add

 

为grid用户配置SSH:

以grid身份在每个节点执行

su - grid

mkdir ~/.ssh

cd ~/.ssh

ssh-keygen -t rsa

ssh-keygen -t dsa

cat *rsa.pub >> authorized_keys

cat *dsa.pub >> authorized_keys

 

然后在rac1节点下执行:

ssh rac2 cat /home/grid/.ssh/authorized_keys >> authorized_keys

scp authorized_keys rac2:/home/grid/.ssh/

 

然后分别在每个节点上执行检验操作:  

ssh rac1 date

ssh rac2 date

ssh rac1-priv date

ssh rac2-priv date

 

第二次执行时不再提示输入口令,并且可以成功执行命令,则表示 oracle 用户 SSH 对等性

配置成功,至此,Oracle 用户 SSH 对等性配置完成!重复上述步骤,以 grid 用户配置对等性。

 

 

ssh-agent $SHELL

ssh-add

 

注意: 该步骤可以不配置然后在安装的过程中有如下的界面可以来配置:

一步一步搭建oracle 11gR2 rac+dg之环境准备(二)

  1. 配置NTP

root用户下执行:

  1. rac1执行

A. sed -i 's/OPTIONS/#OPTIONS/g' /etc/sysconfig/ntpd

B.

cat >> /etc/sysconfig/ntpd << EOF

OPTIONS="-x -u ntp:ntp -p /var/run/ntpd.pid"

EOF

C.

mv /etc/ntp.conf /etc/ntp.confbak

D.

cat > /etc/ntp.conf << EOF

restrict 0.0.0.0 mask 0.0.0.0 nomodify

server 127.127.1.0

fudge 127.127.1.0 stratum 10

driftfile /var/lib/ntp/drift

broadcastdelay 0.008

authenticate no

keys /etc/ntp/keys

EOF

  1. rac2执行

A.

sed -i 's/OPTIONS/#OPTIONS/g' /etc/sysconfig/ntpd

B.

cat >> /etc/sysconfig/ntpd << EOF

OPTIONS="-x -u ntp:ntp -p /var/run/ntpd.pid"

EOF

C.

mv /etc/ntp.conf /etc/ntp.confbak

D.

cat >> /etc/ntp.conf << XL

restrict default kod nomodify notrap nopeer noquery

restrict 182.168.8.0 mask 255.255.255.0 nomodify notrap

restrict 127.0.0.1

server 182.168.8.61

server 127.127.1.0 # local clock

fudge 127.127.1.0 stratum 10

driftfile /var/lib/ntp/drift

broadcastdelay 0.008

authenticate no

keys /etc/ntp/keys

XL

  1. 启动服务(双节点执行)

#service ntpd restart

#chkconfig ntpd on


上一篇:【架构】OpenResty相关资料


下一篇:如果一列数据有变化如何让另一列重新生成序列?