再做 Oracle 11gR2 RAC+DG1

在https://www.roamway.com/1273.html 中,已配置好RAC数据库, 这次在RAC双机基础上配置DataGuard服务,

可以实现主库和备库之间快速切换, 提供容灾备份能力.

这一部分,我们需要部署好dataguard系统平台, 配置好ASM服务,然后安装单节点grid, 最后安装好oracle软件.

详情如下:

1. 安装操作系统, 这次依旧采用OEL5.5 x64 , 本地磁盘20GB, 主机名dg.localdomain ,

ip地址 192.168.137.159 ,不启用iptables和selinux.

定制时选择如下安装包:

Desktop Environments:

GNOME Desktop Environment

Applications:

Editors

Development:

Development Libraries

Development Tools

GNOME Software Development

Legacy Software Development

X software Development

Base System :

Administration Tools

Base

Legacy Software Support

System Tools

X Window System

然后,执行真正安装,重启数次后安装完成.

下图是配置好的主机名和ip地址.

dg1

 

2. 建用户,建目录,赋权限 ,改口令,改用户配置文件,内核参数, 资源限制等

建立grid用户和oracle用户

groupadd -g 1000 oinstall

groupadd -g 1200 asmadmin

groupadd -g 1201 asmdba

groupadd -g 1202 asmoper

useradd -u 1100 -g oinstall -G asmadmin,asmdba,asmoper -d /home/grid -s /bin/bash -c ”

grid Infrastructure Owner” grid

echo “grid” | passwd –stdin grid

echo ‘export PS1=”`/bin/hostname -s` -> “‘ >> /home/grid/.bash_profile

echo “export ORACLE_SID=+ASM” >> /home/grid/.bash_profile

echo “export ORACLE_BASE=/u01/app/grid” >> /home/grid/.bash_profile

echo “export ORACLE_HOME=/u01/app/11.2.0/grid” >> /home/grid/.bash_profile

echo “export ORACLE_TERM=xterm” >> /home/grid/.bash_profile

echo “export NLS_DATE_FORMAT=’yyyy/mm/dd hh24:mi:ss'” >> /home/grid/.bash_profile

echo ‘export TNS_ADMIN=$ORACLE_HOME/network/admin’ >> /home/grid/.bash_profile

echo ‘export PATH=/usr/sbin:$PATH’ >> /home/grid/.bash_profile

echo ‘export PATH=$ORACLE_HOME/bin:$PATH’ >> /home/grid/.bash_profile

echo ‘export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib’ >> /home/grid/.bash_profile

echo ‘export CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib’ >>

/home/grid/.bash_profile

echo “export LANG=en_US” >> /home/grid/.bash_profile

echo “export NLS_LANG=american_america.AL32UTF8” >> /home/grid/.bash_profile

echo “umask 022” >> /home/grid/.bash_profile

groupadd -g 1300 dba

groupadd -g 1301 oper

useradd -u 1101 -g oinstall -G dba,oper,asmdba -d /home/oracle/ -s /bin/bash -c

“Oracle Software Owner” oracle

echo “oracle” | passwd –stdin oracle

echo ‘export PS1=”`/bin/hostname -s` -> “‘ >> /home/oracle/.bash_profile

echo “export TMP=/tmp” >> /home/oracle/.bash_profile

echo ‘export TMPDIR=$TMP’ >> /home/oracle/.bash_profile

echo “export ORACLE_HOSTNAME=dg.localdomain” >> /home/oracle/.bash_profile

echo “export ORACLE_SID=devdb” >> /home/oracle/.bash_profile

echo “export ORACLE_BASE=/u01/app/oracle” >> /home/oracle/.bash_profile

echo ‘export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1’ >> /home/oracle/.bash_profile

echo “export ORACLE_UNQNAME=devdb” >> /home/oracle/.bash_profile

echo ‘export TNS_ADMIN=$ORACLE_HOME/network/admin’ >> /home/oracle/.bash_profile

echo ‘export PATH=$ORACLE_HOME/bin:$PATH’ >> /home/oracle/.bash_profile

echo ‘export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib’ >> /home/oracle/.bash_profile

echo ‘export CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib’ >>

/home/oracle/.bash_profile

echo “export LANG=en_US” >> /home/oracle/.bash_profile

echo “export NLS_LANG=american_america.AL32UTF8” >> /home/oracle/.bash_profile

echo “export NLS_DATE_FORMAT=’yyyy/mm/dd hh24:mi:ss'” >> /home/oracle/.bash_profile

 

建立grid和oracle目录路径,修改权限

mkdir -p /u01/app/grid

mkdir -p /u01/app/11.2.0/grid

mkdir -p /u01/app/oracle

chown -R oracle:oinstall /u01

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

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

 

修改/etc/security/limits.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 “grid hard nproc 16384” >> /etc/security/limits.conf

echo “grid soft nofile 1024” >> /etc/security/limits.conf

echo “grid hard nofile 65536” >> /etc/security/limits.conf

 

修改/etc/profile文件

echo ‘if [ $USER = “oracle” ] || [ $USER = “grid” ] ; 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 “fs.aio-max-nr = 1048576” >> /etc/sysctl.conf

echo “fs.file-max = 6815744” >> /etc/sysctl.conf

echo “kernel.shmall = 2097152” >> /etc/sysctl.conf

echo “kernel.shmmax = 1054472192” >> /etc/sysctl.conf

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 = 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 “net.ipv4.tcp_wmem = 262144 262144 262144” >> /etc/sysctl.conf

echo “net.ipv4.tcp_rmem = 4194304 4194304 4194304” >> /etc/sysctl.conf

 

3. 为ASM创建可用磁盘

关闭dg服务器添加4块磁盘,大小分别是1GB,5GB,5GB,10GB,这4块盘分别作为

GRIDDG,DATA,FLASH,RMAN备份盘使用。

我们以创建1GB盘为例

dg3

dg4

dg5

dg6

 

这样GRIDDG盘就添加好了,然后用同样的办法添加DATA,FLASH,RMAN备份盘即可。

 

4.配置好ASM服务

准备好asm安装包

oracleasm-support-2.1.3-1.el5.x86_64.rpm

oracleasm-2.6.18-194.el5-2.0.5-1.el5.x86_64.rpm

oracleasmlib-2.0.4-1.el5.x86_64.rpm

用rpm -ivh安装这3个asm包即可

 

配置ASM驱动服务

/usr/sbin/oracleasm configure -i

/usr/sbin/oracleasm init

/usr/sbin/oracleasm configure

/usr/sbin/oracleasm status

这时发现asm服务已经运行

dg7

格式化新磁盘,并创建ASM磁盘组

用fdisk命令查看一下刚才创建的磁盘,分别为/dev/sdb/ ,dev/sdc 和/dev/sdd 大小分别是1GB,5GB,5GB

dg8

dg9

接着使用fdisk 命令格式化这些磁盘,以/dev/sdb为例:

Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel

Building a new DOS disklabel with disk identifier 0x33318f33.

Changes will remain in memory only, until you decide to write them.

After that, of course, the previous content won’t be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

WARNING: DOS-compatible mode is deprecated. It’s strongly recommended to

switch off the mode (command ‘c’) and change display units to

sectors (command ‘u’).

Command (m for help): n

Command action

e extended

p primary partition (1-4)

n

Partition number (1-4):

Value out of range.

Partition number (1-4): 1

First cylinder (1-130, default 1):

Using default value 1

Last cylinder, +cylinders or +size{K,M,G} (1-130, default 130): 130

Command (m for help): w

The partition table has been altered!

Calling ioctl() to re-read partition table.

Syncing disks.

这样/dev/sdb就格式化好了,如下:

dg10

 

用同样的方法格式化dev/sdc 和/dev/sdd,/dev/sde/,不再一一演示了。

接着配置/dev/sdb , /dev/sdc , /dev/sdd 为ASM盘,方法如下:

/usr/sbin/oracleasm createdisk VOL1 /dev/sdb1

/usr/sbin/oracleasm createdisk VOL2 /dev/sdc1

/usr/sbin/oracleasm createdisk VOL3/dev/sdd1

对于/dev/sde不作为asm盘,而是格式化成ext3分区,然后挂载到/rman_backup目录下即可

至此,磁盘方面准备完成。

将grid软件,oracle软件分别上传到/home/grid和/home/oracle下

然后用unzip命令解压,将会得到grid安装目录和database安装目录

5. grid安装

dg12

dg13

dg14

dg15

dg16

安装前检查,没有报错. 点击Finish开始安装

dg17

然后等待安装即可

在最后阶段,执行两个脚本,orainstRoot.sh和root.sh

如果执行没有问题,则grid宣布安装完成。

dg18

 

看一下grid进程

切换到grid用户 , 执行crs_stat -t 发现grid进程出现了。

dg19

 

7. 安装oracle软件

切换到oracle用户,执行runInstaller,安装过程和RAC中大体相同,不同部分如下:

dg20

dg21

接着安装前检查,正式安装,执行脚本即可完成oracle安装

dg22

关于ASM磁盘组配置,RAC主库,DG备库会放到后面演示。

Leave a Reply