oracle11g RAC+单实例DataGuard+OGG目标库搭建记录

第一部分  搭建oracle11g RAC

一、安装操作系统

系统一:RHEL5.8(两张网卡,分别配置public IP和private IP;两个磁盘,一个用于安装系统本身以及grid和oracle软件,另一个作为共享磁盘,做ASM磁盘组,存放数据)
系统二:RHEL5.8(两张网卡,分别配置public IP和private IP;一个磁盘用于安装系统本身以及grid和oracle软件)

备注:两个系统都禁用防火墙和SElinux

二、配置环境

1、存储规划

  使用ASM+裸设备来存储数据
  三个ASM磁盘组:OCR(raw1,raw2,raw3)磁盘组
         DATA(raw4,raw5)磁盘组
         FLASH(raw6,raw7)磁盘组

配置iscsi

iscsi 服务端配置:rac1
yum -y install scsi-target-utils
yum -y install iscsi-initiator-utils

[root@rac1 ~]# vim /etc/tgt/targets.conf


backing-store /dev/sdb
#backing-store /dev/sdc
initiator-address 192.168.200.1/24



查看iscsi,iscsid,tgtd这三个服务状态,如果没有启动就将其start,并使用chkconfig命令设置为开机自启动

chkconfig iscsi --list
chkconfig iscsid --list
chkconfig tgtd --list

service iscsi status
service iscsid status
service tgtd status

service iscsi start
service iscsid start
service tgtd start

chkconfig iscsi on
chkconfig iscsid on
chkconfig tgtd on

tgtadm --lld iscsi --op bind --mode target --tid 1 -I ALL     --导出共享磁盘设备

iscsiadm -m discovery -t sendtargets -p 192.168.200.11 -l    --导入共享磁盘设备

节点二(rac2)上做如下操作

yum -y install iscsi-initiator-utils
service iscsi start
iscsiadm -m discovery -t sendtargets -p 192.168.200.11 -l    --导入共享磁盘设备

这样两个节点都导入了磁盘到本地(rac1上映射为/dev/sdc,rac2上映射为/dev/sdb)

不过为了能够保证系统重启后,能够自动将共享磁盘映射到本地,需要将上面的命令添加到/etc/rc.local文件中
[root@rac1 ~]# cat /etc/rc.local
#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.

touch /var/lock/subsys/local
tgtadm --lld iscsi --op bind --mode target --tid 1 -I ALL
iscsiadm -m discovery -t sendtargets -p 192.168.200.11 -l


[root@rac2 ~]# cat /etc/rc.local
#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.

touch /var/lock/subsys/local
iscsiadm -m discovery -t sendtargets -p 192.168.200.11 -l
while [ $? -ne 0 ]
do
  iscsiadm -m discovery -t sendtargets -p 192.168.200.11 -l
done

这样系统重启后会执行tgtadm和iscsiadm命令,节点一导出共享磁盘设备,RAC两节点导入共享磁盘到本地,并且如果节点二先启动,没有发现共享设备,就会一直执行iscsisdm命令,直到成功。


在节点1上将映射到本地的共享磁盘分区(节点二上使用partprobe /dev/sdb命令),然后在两个节点上分别做成裸设备
[root@rac1 ~]# fdisk -l /dev/sdc

Disk /dev/sdc: 42.9 GB, 42949672960 bytes
64 heads, 32 sectors/track, 40960 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1               1         955      977904   83  Linux
/dev/sdc2             956        1910      977920   83  Linux
/dev/sdc3            1911        2865      977920   83  Linux
/dev/sdc4            2866       40960    39009280    5  Extended
/dev/sdc5            2866        7634     4883440   83  Linux
/dev/sdc6            7635       12403     4883440   83  Linux
/dev/sdc7           12404       17172     4883440   83  Linux
/dev/sdc8           17173       21941     4883440   83  Linux

[root@rac1 ~]# cat /etc/udev/rules.d/60-raw.rules
# Enter raw device bindings here.
#
# An example would be:
#   ACTION=="add", KERNEL=="sda", RUN+="/bin/raw /dev/raw/raw1 %N"
# to bind /dev/raw/raw1 to /dev/sda, or
#   ACTION=="add", ENV{MAJOR}=="8", ENV{MINOR}=="1", RUN+="/bin/raw /dev/raw/raw2 %M %m"
# to bind /dev/raw/raw2 to the device with major 8, minor 1.
#
ACTION=="add", KERNEL=="sdc1", RUN+="/bin/raw /dev/raw/raw1 %N"
ACTION=="add", KERNEL=="sdc2", RUN+="/bin/raw /dev/raw/raw2 %N"
ACTION=="add", KERNEL=="sdc3", RUN+="/bin/raw /dev/raw/raw3 %N"
ACTION=="add", KERNEL=="sdc5", RUN+="/bin/raw /dev/raw/raw4 %N"
ACTION=="add", KERNEL=="sdc6", RUN+="/bin/raw /dev/raw/raw5 %N"
ACTION=="add", KERNEL=="sdc7", RUN+="/bin/raw /dev/raw/raw6 %N"
ACTION=="add", KERNEL=="sdc8", RUN+="/bin/raw /dev/raw/raw7 %N"
ACTION=="add",KERNEL=="raw[1-7]", OWNER="grid", GROUP="asmadmin", MODE="660"

[root@rac2 ~]# cat /etc/udev/rules.d/60-raw.rules
# Enter raw device bindings here.
#
# An example would be:
#   ACTION=="add", KERNEL=="sda", RUN+="/bin/raw /dev/raw/raw1 %N"
# to bind /dev/raw/raw1 to /dev/sda, or
#   ACTION=="add", ENV{MAJOR}=="8", ENV{MINOR}=="1", RUN+="/bin/raw /dev/raw/raw2 %M %m"
# to bind /dev/raw/raw2 to the device with major 8, minor 1.
ACTION=="add", KERNEL=="sdb1", RUN+="/bin/raw /dev/raw/raw1 %N"
ACTION=="add", KERNEL=="sdb2", RUN+="/bin/raw /dev/raw/raw2 %N"
ACTION=="add", KERNEL=="sdb3", RUN+="/bin/raw /dev/raw/raw3 %N"
ACTION=="add", KERNEL=="sdb5", RUN+="/bin/raw /dev/raw/raw4 %N"
ACTION=="add", KERNEL=="sdb6", RUN+="/bin/raw /dev/raw/raw5 %N"
ACTION=="add", KERNEL=="sdb7", RUN+="/bin/raw /dev/raw/raw6 %N"
ACTION=="add", KERNEL=="sdb8", RUN+="/bin/raw /dev/raw/raw7 %N"
ACTION=="add",KERNEL=="raw[1-7]", OWNER="grid", GROUP="asmadmin", MODE="660"


start_udev

生成裸设备用于ASM磁盘

备注:上面方法映射到本地的磁盘设备名称是由内核自动命名的,如果系统在添加磁盘,可能导致原来iscsi映射到本地的磁盘设备名称改变,可使用下面的方法解决(该方法本次实验未使用)
[root@rac1 ~]# cat /etc/udev/rules.d/55-openiscsi.rules
KERNEL=="sd*", BUS=="scsi", PROGRAM="/etc/udev/scripts/iscsidev.sh %b",SYMLINK+="iscsi/%c/part%n"
[root@rac1 ~]# cat /etc/udev/scripts/iscsidev.sh
#!/bin/sh
# FILE: /etc/udev/scripts/iscsidev.sh
BUS=${1}
HOST=${BUS%%:*}
[ -e /sys/class/iscsi_host ] || exit 1
file="/sys/class/iscsi_host/host${HOST}/device/session*/iscsi_session*/targetname"
target_name=$(cat ${file})
# This is not an open-scsi drive
if [ -z "${target_name}" ]; then
   exit 1
fi
echo "${target_name##*.}"
[root@rac1 ~]# ls /dev/iscsi/storage/
part  part1  part2  part3  part4  part5  part6  part7  part8

生成的part1-8设备可以做成ASM磁盘,然后实验grid创建ASM磁盘组

2、网络规划

(1)每个节点上有一个public IP,private IP和virtual IP,另外配置三个scan IP(使用DNS解析对应同一个主机名)用于客户端访问

  node1         public IP:192.168.200.11
        private IP:10.0.0.1
        virtual IP:192.168.200.101

  node2        public IP:192.168.200.12
        private IP:10.0.0.2
        virtual IP:192.168.200.102

    scan IP:    192.168.200.111
        192.168.200.112      
        192.168.200.113


(2)配置DNS服务器(选择node1节点)
yum -y install bind bind-chroot caching-nameserver
cp -p /var/named/chroot/etc/named.caching-nameserver.conf /var/named/chroot/etc/named.conf
sed -i 's/127\.0\.0\.1/any/' /var/named/chroot/etc/named.conf
sed -i 's/localhost/any/' /var/named/chroot/etc/named.conf

vi /etc/named.rfc1912.zones
#zone "." IN {
#    type hint;
#    file "named.ca";
#};

zone "." IN {           
    type hint;
    file "/dev/null";
};

zone "alvin.com" IN {
    type master;
    file "alvin.com.zone";
    allow-update { none; };
};
zone "200.168.192.in-addr.arpa" IN {
    type master;
    file "200.168.192.local";
    allow-update { none; };
};


cp -p /var/named/chroot/var/named/named.zero /var/named/chroot/var/named/alvin.com.zone
cp -p /var/named/chroot/var/named/named.local /var/named/chroot/var/named/200.168.192.local

[root@rac1 ~]# cat /var/named/chroot/var/named/alvin.com.zone
$TTL    86400
@               IN SOA  dns.alvin.com.      root.alvin.com. (
                                        42              ; serial (d. adams)
                                        3H              ; refresh
                                        15M             ; retry
                                        1W              ; expiry
                                        1D )            ; minimum
@    IN    NS    dns.alvin.com.
rac1    IN    A    192.168.200.11
rac2    IN    A    192.168.200.12
scan    IN    A    192.168.200.111
scan    IN      A       192.168.200.112
scan    IN      A       192.168.200.113
[root@rac1 ~]# cat /var/named/chroot/var/named/200.168.192.local
$TTL    86400
@       IN      SOA     dns.alvin.com. root.alvin.com.  (
                                      1997022700 ; Serial
                                      28800      ; Refresh
                                      14400      ; Retry
                                      3600000    ; Expire
                                      86400 )    ; Minimum
@       IN      NS      dns.alvin.com.
11      IN      PTR     rac1.alvin.com.
12    IN    PTR    rac2.alvin.com.
111    IN    PTR    scan.alvin.com.
112     IN      PTR     scan.alvin.com.
113     IN      PTR     scan.alvin.com.

重新启动DNS服务器
service named restart
chkconfig named on


配置解析文件(两个节点上都要配置)
[root@rac1 ~]# cat /etc/resolv.conf
search alvin.com
nameserver 192.168.200.11


最后使用nslookup在两个节点上进行正反向解析测试
[root@rac1 ~]# nslookup scan.alvin.com
Server:        192.168.200.11
Address:    192.168.200.11#53

Name:    scan.alvin.com
Address: 192.168.200.113
Name:    scan.alvin.com
Address: 192.168.200.111
Name:    scan.alvin.com
Address: 192.168.200.112

[root@rac1 ~]# nslookup 192.168.200.111
Server:        192.168.200.11
Address:    192.168.200.11#53

111.200.168.192.in-addr.arpa    name = scan.alvin.com.

[root@rac1 ~]# nslookup 192.168.200.112
Server:        192.168.200.11
Address:    192.168.200.11#53

112.200.168.192.in-addr.arpa    name = scan.alvin.com.

[root@rac1 ~]# nslookup 192.168.200.113
Server:        192.168.200.11
Address:    192.168.200.11#53

113.200.168.192.in-addr.arpa    name = scan.alvin.com.


(3)配置/etc/hosts文件
[root@rac1 ~]# cat /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1         localhost.localdomain localhost
::1        localhost6.localdomain6 localhost6

# Public Network - (eth0)
192.168.200.11 rac1.alvin.com rac1
192.168.200.12 rac2.alvin.com rac2

# Private Interconnect (eth0:0)
10.0.0.1 rac1-priv.alvin.com rac1-priv
10.0.0.2 rac2-priv.alvin.com rac2-priv

# Public Virtual IP
192.168.200.101 rac1-vip.alvin.com rac1-vip
192.168.200.102 rac2-vip.alvin.com rac2-vip



[root@rac2 ~]# cat /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1         localhost.localdomain localhost
::1        localhost6.localdomain6 localhost6

# Public Network - (eth0)
192.168.200.11 rac1.alvin.com rac1
192.168.200.12 rac2.alvin.com rac2

# Private Interconnect (eth0:0)
10.0.0.1 rac1-priv.alvin.com rac1-priv
10.0.0.2 rac2-priv.alvin.com rac2-priv

# Public Virtual IP
192.168.200.101 rac1-vip.alvin.com rac1-vip
192.168.200.102 rac2-vip.alvin.com rac2-vip


3、创建用户,目录以及修改系统文件(分别在两个节点上执行以下脚本)
[root@rac1 scripts]# cat preusers.sh
#!/bin/bash
#Purpose:Create 6 groups named 'oinstall','dba','asmadmin','asmdba','asmoper','oper', plus 2 users named 'oracle','grid'.
#Also setting the Environment
#variable for oracle user.
#variable for grid user.
#Usage:Log on as the superuser('root'),and then execute the command:#./1preusers.sh

echo "Now create 6 groups named 'oinstall','dba','asmadmin','asmdba','asmoper','oper'"
echo "Plus 2 users named 'oracle','grid',Also setting the Environment"

groupadd -g 1000 oinstall
groupadd -g 1200 asmadmin
groupadd -g 1201 asmdba
groupadd -g 1202 asmoper
groupadd -g 1300 dba
groupadd -g 1301 oper

useradd -u 1100 -g oinstall -G asmadmin,asmdba,asmoper,dba -d /home/grid -s /bin/bash -c "grid Infrastructure Owner" grid
echo "grid" | passwd --stdin grid

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/grid/.bash_profile
echo "export TMP=/tmp">> /home/grid/.bash_profile
echo 'export TMPDIR=$TMP'>>/home/grid/.bash_profile
echo "export ORACLE_SID=+ASM1">> /home/grid/.bash_profile    --节点二上为ORACLE_SID=+ASM2
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 EDITOR=vi" >> /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

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=rac1">> /home/oracle/.bash_profile     --节点二上为ORACLE_HOSTNAME=rac2
echo "export ORACLE_SID=eisoo1">> /home/oracle/.bash_profile         --节点二上为ORACLE_SID=eisoo2
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=eisoo">> /home/oracle/.bash_profile
echo 'export TNS_ADMIN=$ORACLE_HOME/network/admin' >> /home/oracle/.bash_profile
echo "export ORACLE_TERM=xterm">> /home/oracle/.bash_profile
echo 'export PATH=/usr/sbin:$PATH'>> /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 EDITOR=vi" >> /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
echo "umask 022">> /home/oracle/.bash_profile

echo "The Groups and users has been created"
echo "The Environment for grid,oracle also has been set successfully"


[root@rac1 scripts]# cat predir.sh
#!/bin/bash
#Purpose:Createthenecessarydirectoryfororacle,gridusersandchange the authention to oracle,grid users.
#Usage:Log on as the superuser('root'),and then execute the command:#./2predir.sh  

echo "Now create the necessary directory for oracle,grid users and change the authention to oracle,grid users..."
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
chmod -R 775 /u01
echo "The necessary directory for oracle,grid users and change the authention to oracle,grid users has been finished"


[root@rac1 scripts]# cat prelimits.sh
#!/bin/bash
#Purpose:Change the /etc/security/limits.conf.
#Usage:Log on as the superuser('root'),and then execute the command:#./3prelimits.sh

echo "Now modify the /etc/security/limits.conf,but backup it named /etc/security/limits.conf.bak before"
cp /etc/security/limits.conf /etc/security/limits.conf.bak
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 soft nproc 2047" >>/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
echo "Modifing the /etc/security/limits.conf has been succeed."


[root@rac1 scripts]# cat prelogin.sh
#!/bin/bash
#Purpose:Modify the /etc/pam.d/login.
#Usage:Log on as the superuser('root'),and then execute the command:#./4prelimits.sh

echo "Now modify the /etc/pam.d/login,but with a backup named /etc/pam.d/login.bak"
cp /etc/pam.d/login /etc/pam.d/login.bak

echo "session required /lib/security/pam_limits.so" >>/etc/pam.d/login
echo "session required pam_limits.so" >>/etc/pam.d/login

echo "Modifing the /etc/pam.d/login has been succeed."


[root@rac1 scripts]# cat preprofile.sh
#!/bin/bash
#Purpose:Modify the /etc/profile.
#Usage:Log on as the superuser('root'),and then execute the command:#./5preprofile.sh

echo "Now modify the /etc/profile,but with a backup named /etc/profile.bak"
cp /etc/profile /etc/profile.bak
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 "Modifing the /etc/profile has been succeed."


[root@rac1 scripts]# cat presysctl.sh
#!/bin/bash
#Purpose:Modify the /etc/sysctl.conf.
#Usage:Log on as the superuser('root'),and then execute the command:#./6presysctl.sh

echo "Now modify the /etc/sysctl.conf,but with a backup named /etc/sysctl.bak"
cp /etc/sysctl.conf /etc/sysctl.conf.bak

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

echo "Modifing the /etc/sysctl.conf has been succeed."
echo "Now make the changes take effect....."
sysctl -p


4、停止ntp服务器(也可以参照网络上进行配置)

[root@rac1 ~]# service ntpd status
ntpd is stopped
[root@rac1 ~]# chkconfig ntpd off
[root@rac1 ~]# cat /etc/ntp
ntp/       ntp.conf
[root@rac1 ~]# cp /etc/ntp.conf /etc/ntp.conf.bak
[root@rac1 ~]# rm -rf /etc/ntp.conf


三、安装前预检查
[grid@rac1 grid]$ ./runcluvfy.sh stage -pre crsinst -n rac1,rac2 -fixup -verbose

仔细检查每一个failed项,一一进行修正

四、开始安装grid软件
[grid@rac1 grid]$ ./runInstaller

图像界面安装,由于没有截图,此处我就不做详细步骤展示,只做几点说明:
1、oracle11g RAC安装可以在grid安装图形过程中配置grid用户的SSH信任关系(oracle用户信任关系在安装数据库软件时可以配置)
   在Cluster Node Information界面时,添加第二个节点信息后,点击SSH Connectivity...按钮,输入grid用户密码(两节点grid密码相同),点击setup即可自动配置。

2、Create ASM Disk Group界面时创建一个磁盘组ORC,用于表决磁盘

3、安装最后执行脚本时,要按提示逐个执行


五、安装oracle数据库软件
[oracle@rac1 database]$ ./runInstaller

六、创建ASM磁盘组
[grid@rac1 ~]$ asmca

七、创建RAC数据库
[oracle@rac1 ~]$ dbca

至此,RAC环境搭建完成!



第二部分  搭建DATAGUARD物理备库服务器

一、安装操作系统
系统:RHEL5.8(一张网;两个磁盘,一个用于安装系统本身以及grid和oracle软件,另一个做ASM磁盘组,存放数据)

二、环境设置

1、参照RAC环境设置

注意:存储直接使用本地磁盘/dev/asb做成裸设备,然后添加到ASM磁盘组
      创建用户的脚本做相应修改(ORACLE_SID,ORACLE_UNQNAME,ORACLE_HOSTNAME)

2、安装grid软件

注意:在Installation Option界面选择“Configure Oracle Grid Infrastructure for a Standalone Server”

3、安装oracle软件(只安装软件不需要创建数据库)



第三部分  RAC主库配置单实例Active Dataguard

一、RAC主库准备工作

1、RAC主库配置为归档模式(默认归档路径放置在闪回区)
[grid@rac1 ~]$ srvctl stop database -d eisoo
[grid@rac1 ~]$ srvctl start database -d eisoo -o mount
SQL> alter database archivelog;
[grid@rac1 ~]$ srvctl stop database -d eisoo
[grid@rac1 ~]$ srvctl start database -d eisoo
SQL> select log_mode from gv$database;

2、RAC主库置为Force logging模式
SQL> alter database force logging;  --只需要在数据库open状态在任一节点上执行
SQL> select force_logging from gv$database;

3、RAC主库执行全库备份
run
{
  allocate channel c1 type disk;
  allocate channel c2 type disk;
  allocate channel c3 type disk;
  allocate channel c4 type disk;
  backup database format '/rman_backup/Full_%U.bak';
  release channel c1;
  release channel c2;
  release channel c3;
  release channel c4;
}

backup archivelog all format '/rman_backup/ARC_%U.bak';

4、RAC主库执行创建物理备库控制文件
backup device type disk format '/rman_backup/standby_%U.ctl' current controlfile for standby;

5、RAC主库创建物理备库初始化参数文件
SQL> create pfile='/rman_backup/initphydb.ora' from spfile;

6、RAC主库修改口令文件,使双节点SYS用户口令一致

7、RAC主库配置tnsnames.ora文件
EISOO =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = scan.alvin.com)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = eisoo)
    )
  )

EISOO2 =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.200.12)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = eisoo)
      (INSTANCE_NAME = eisoo2)
    )
  )

EISOO1 =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.200.11)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = eisoo)
      (INSTANCE_NAME = eisoo1)
    )
  )

PHYDB =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.200.20)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = phydb)
    )
  )

8、将所有备份文件传到物理备库上

scp /rman_backup/* 192.168.200.20:/rman_backup/    --使用oracle用户

二、物理备库准备工作

1、物理备库口令文件
从RAC主库任一节点上拷贝

2、物理备库pfile文件
[oracle@dg dbs]$ cat ~/initphydb.ora
phydb.__db_cache_size=289406976
phydb.__java_pool_size=4194304
phydb.__large_pool_size=8388608
phydb.__pga_aggregate_target=339738624
phydb.__sga_target=503316480
phydb.__shared_io_pool_size=0
phydb.__shared_pool_size=192937984
phydb.__streams_pool_size=0
*.audit_file_dest='/u01/app/oracle/admin/phydb/adump'
*.audit_trail='db'
*.cluster_database=false
*.compatible='11.2.0.4.0'
*.control_files='+DATA'        --指定磁盘组,具体路径由ASM管理,恢复控制文件后,修改该参数指向控制文件,然后创建spfile文件
*.db_block_size=8192
*.db_create_file_dest='+DATA'
*.db_domain=''
*.db_file_name_convert='+DATA/eisoo/','+DATA/phydb/'
*.db_name='eisoo'
*.db_recovery_file_dest='+FLASH'
*.db_recovery_file_dest_size=4621074432
*.db_unique_name='phydb'
*.diagnostic_dest='/u01/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=phydbXDB)'
*.fal_client='phydb'
*.fal_server='eisoo1','eisoo2'
*.log_archive_config='dg_config=(phydb,eisoo)'
*.log_archive_dest_1='location=USE_DB_RECOVERY_FILE_DEST
valid_for=(all_logfiles,all_roles) db_unique_name=phydb'
*.log_archive_dest_2='service=eisoo1
valid_for=(online_logfiles,primary_role) db_unique_name=eisoo'
*.log_archive_format='ARC_%t_%S_%r.arc'
*.log_file_name_convert='+DATA/eisoo/','+DATA/phydb/'
*.memory_target=842006528
*.open_cursors=300
*.processes=150
*.remote_login_passwordfile='exclusive'
*.service_names='phydb'
*.standby_file_management='auto'
*.thread=1
*.undo_tablespace='UNDOTBS1'

2、物理备库配置tnsnames.ora文件
EISOO =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = scan.alvin.com)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = eisoo)
    )
  )

EISOO2 =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.200.12)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = eisoo)
      (INSTANCE_NAME = eisoo2)
    )
  )

EISOO1 =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.200.11)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = eisoo)
      (INSTANCE_NAME = eisoo1)
    )
  )

PHYDB =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.200.20)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = phydb)
    )
  )

三、创建物理备库

1、创建spfile文件
SQL> create spfile='+DATA/PHYDB/PARAMETERFILE/spfilephydb.ora' from pfile='/home/oracle/initphydb.ora';
[oracle@dg dbs]$ cat initphydb.ora
SPFILE='+DATA/PHYDB/PARAMETERFILE/spfilephydb.ora'

2、启动物理备库到nomount状态,恢复控制文件
RMAN> restore standby controlfile from '/rman_backup/standby_07r7kjhh_1_1.ctl';

3、启动物理备库到mount,恢复数据文件
run
{
  allocate channel c1 type disk;
  allocate channel c2 type disk;
  allocate channel c3 type disk;
  allocate channel c4 type disk;
  restore database;
  release channel c1;
  release channel c2;
  release channel c3;
  release channel c4;
}

4、备库上创建standby logfile
select * from v$standby_log;
alter database add standby logfile thread 1 group 5 size 50m,group 6 size 50m,group 7 size 50m;
alter database add standby logfile thread 2 group 8 size 50m,group 9 size 50m,group 10 size 50m;

四、RAC主库参数修改
主库参数调整:
alter system set log_archive_dest_2='service=phydb lgwr sync valid_for=(online_logfiles,primary_role) db_unique_name=phydb' sid='*';
alter system set log_archive_dest_state_2=enable scope=both sid='*';
alter system set log_archive_config='dg_config=(eisoo,phydb)' sid='*';

五、备库接受、应用日志
备库接收日志:
select sequence#,name, applied from v$archived_log;    --如果没有接受到日志,查看主库以及备库监听文件,密码文件是否正确配置

备库开始应用日志:
alter database recover managed standby database using current logfile disconnect from session;
select sequence#,name, applied from v$archived_log;

备库以read only打开数据库
select dbid,name,switchover_status,db_unique_name,database_role,open_mode,current_scn from v$database;
alter database recover managed standby database cancel;
alter database open;   --read only方式打开
select dbid,name,switchover_status,db_unique_name,database_role,open_mode,current_scn from v$database;

alter database recover managed standby database using current logfile disconnect from session;    --启动实时恢复
select dbid,name,switchover_status,db_unique_name,database_role,open_mode,current_scn from v$database;
select sequence#,name, applied from v$archived_log;

至此,RAC主库配置单实例Active Dataguard完成!
可以做相应测试:在RAC主库上创建、删除表空间,表等,查看物理备库是否同步。



第四部分  主备库切换(DATAGUARD SWITCHOVER)

1、主库修改相关参数fal_client、fal_server

show parameter fal
alter system set fal_client='eisoo1' sid='eisoo1';
alter system set fal_client='eisoo2' sid='eisoo2';
alter system set fal_server='phydb' sid='*';

2、主库创建stanby logfile
select * from v$standby_log;
alter database add standby logfile thread 1 group 5 size 50m,group 6 size 50m,group 7 size 50m;
alter database add standby logfile thread 2 group 8 size 50m,group 9 size 50m,group 10 size 50m;

3、主库修改相关参数 standby_file_management、db_file_name_convert、log_file_name_convert
alter system set standby_file_management=auto scope=spfile;
alter system set db_file_name_convert='+DATA/phydb/','+DATA/eisoo/' sid='*' scope=spfile;
alter system set log_file_name_convert='+DATA/phydb/','+DATA/eisoo/' sid='*' scope=spfile;

4、停止RAC节点2(节点2上如下操作)
select dbid,name,current_scn,protection_mode,database_role,force_logging,open_mode,switchover_status from gv$database;
shutdown immediate;

5、RAC节点1切换原RAC主库到备库
select dbid,name,current_scn,protection_mode,database_role,force_logging,open_mode,switchover_status from gv$database;  --此时switchover_status的值为to standby
alter database commit to switchover to physical standby with session shutdown;

6、切换原物理备库到主库
select dbid,name,current_scn,protection_mode,database_role,force_logging,open_mode,switchover_status from gv$database;  --此时switchover_status的值为to primary
alter database commit to switchover to primary;
alter database open;
select dbid,name,current_scn,protection_mode,database_role,force_logging,open_mode,switchover_status from gv$database;

7、将原RAC主库2个实例都启动到MOUNT状态
使用grid用户执行
srvctl start database -d eisoo -o mount
select dbid,name,current_scn,protection_mode,database_role,force_logging,open_mode,switchover_status from gv$database;

8、原RAC主库启动redoapply
alter database recover managed standby database using current logfile disconnect from session;

9、原RAC主库停止redoapply,并将RAC主库所有节点以READ ONLY打开
alter database recover managed standby database cancel;
select dbid,name,current_scn,protection_mode,database_role,force_logging,open_mode,switchover_status from gv$database;
alter database open;
select dbid,name,current_scn,protection_mode,database_role,force_logging,open_mode,switchover_status from gv$database;
select inst_id,dbid,name,current_scn,protection_mode,database_role,force_logging,open_mode,switchover_status from gv$database;





第五部分  单实例主库,RAC备库角色切换

① 新主库(单实例库)状态查看
select dbid,name,current_scn,protection_mode,database_role,force_logging,open_mode,switchover_status from v$database;

② 新备库(RAC 库)状态查看:
select inst_id,dbid,name,current_scn,protection_mode,database_role,force_logging,open_mode,switchover_status from gv$database;  

③ 新备库(RAC 库)停止节点2
shutdown immediate;

④ 新主库(单实例库)切换到备库
select dbid,name,current_scn,protection_mode,database_role,force_logging,open_mode,switchover_status from v$database;   --此时switchover_status的值为to standby
alter database commit to switchover to physical standby with session shutdown;
select dbid,name,current_scn,protection_mode,database_role,force_logging,open_mode,switchover_status from v$database;

⑤ 新备库(RAC 库)节点1 切换到主库
alter database recover managed standby database using current logfile disconnect from session;
select dbid,name,current_scn,protection_mode,database_role,force_logging,open_mode,switchover_status from gv$database;   --此时switchover_status的值为to primary
alter database commit to switchover to primary;

⑥ 新主库(RAC 库)全部启动所有节点
srvctl stop database -d eisoo
srvctl start database -d eisoo

⑦ 新备库(单实例库)重新启动并开始redoapply
startup
select dbid,name,current_scn,protection_mode,database_role,force_logging,open_mode,switchover_status from v$database;
alter database recover managed standby database using current logfile disconnect from session;

至此,完成一次角色切换,即将新的备库(RAC 库)切换成主库,新的备库(单实例库)又重新切换为物理备库,回到最初的状态!!!

第六部分 RAC主库配置OGG目标库

磁盘规划:OGG安装在ACFS文件系统上,所有RAC节点共享。
      添加一个共享磁盘,做三个大小为2G的分区,做成ASM磁盘组,然后做成ACFS文件系统,用于安装OGG

一、创建ASM磁盘组
SQL> create diskgroup ogg external redundancy disk '/dev/raw/raw8','/dev/raw/raw9','/dev/raw/raw10';

Diskgroup created.

SQL> select name,state from v$asm_diskgroup;

NAME                                               STATE
------------------------------------------------------------------------------------------ ---------------------------------
DATA                                               MOUNTED
FLASH                                               MOUNTED
OCR                                               MOUNTED
OGG                                               MOUNTED

节点2上手动挂载OGG磁盘组
[grid@rac2 ~]$ sqlplus / as sysasm

SQL*Plus: Release 11.2.0.4.0 Production on Sun Oct 9 15:29:40 2016

Copyright (c) 1982, 2013, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Real Application Clusters and Automatic Storage Management options

SQL> select name,state from v$asm_diskgroup;

NAME                                               STATE
------------------------------------------------------------------------------------------ ---------------------------------
DATA                                               MOUNTED
FLASH                                               MOUNTED
OCR                                               MOUNTED
OGG                                               DISMOUNTED

SQL> alter diskgroup OGG mount;

Diskgroup altered.

SQL> select name,state from v$asm_diskgroup;

NAME                                               STATE
------------------------------------------------------------------------------------------ ---------------------------------
DATA                                               MOUNTED
FLASH                                               MOUNTED
OCR                                               MOUNTED
OGG                                               MOUNTED


二、使用命令创建ACFS:
1、创建OGG挂载目录(2个RAC节点上)
mkdir -p /home/oracle/ogg
chown -R oracle:asmadmin /home/oracle/ogg

2、以grid身份或者oracle身份使用运行asmcmd程序创建volume:

 [grid@rac1 ~]$ asmcmd
ASMCMD> volcreate -G OGG -s 5G vol01
ORA-15032: not all alterations performed
ORA-15221: ASM operation requires compatible.asm of 11.2.0.0.0 or higher (DBD ERROR: OCIStmtExecute)
ASMCMD> exit
[grid@rac1 ~]$ sqlplus / as sysasm

SQL*Plus: Release 11.2.0.4.0 Production on Sun Oct 9 15:55:32 2016

Copyright (c) 1982, 2013, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Real Application Clusters and Automatic Storage Management options

SQL> alter diskgroup OGG set attribute 'COMPATIBLE.ASM'='11.2';

Diskgroup altered.

SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Real Application Clusters and Automatic Storage Management options

如果出现下面报错:
ASMCMD> volcreate -G OGG -s 5G vol01
ORA-15032: not all alterations performed
ORA-15477: cannot communicate with the volume driver (DBD ERROR: OCIStmtExecute)
解决:所有节点手动加载ASM volume driver
[root@node1 ~]# /u01/app/11.2.0/grid/bin/acfsload start -s
[root@node2 ~]# /u01/app/11.2.0/grid/bin/acfsload start -s

[grid@rac1 ~]$ asmcmd
ASMCMD> volcreate -G OGG -s 5G vol01
ASMCMD> volinfo -G ogg vol01
Diskgroup Name: OGG

     Volume Name: VOL01
     Volume Device: /dev/asm/vol01-31
     State: ENABLED
     Size (MB): 5120
     Resize Unit (MB): 32
     Redundancy: UNPROT
     Stripe Columns: 4
     Stripe Width (K): 128
     Usage:
     Mountpath:

查看验证(节点1和节点2上都会生成对应设备):
SQL> select volume_name,volume_device,size_mb from v$asm_volume;

VOLUME_NAME         VOLUME_DEVICE         SIZE_MB
-------------------- -------------------- ----------
VOL01             /dev/asm/vol01-31        5120

[root@rac1 ~]# ll /dev/asm/
total 0
brwxrwx--- 1 root asmadmin 252, 15873 Oct  9 15:55 vol01-31

格式化vol01:
[root@rac1 ~]# mkfs -t acfs /dev/asm/vol01-31
mkfs.acfs: version                   = 11.2.0.4.0
mkfs.acfs: on-disk version           = 39.0
mkfs.acfs: volume                    = /dev/asm/vol01-31
mkfs.acfs: volume size               = 5368709120
mkfs.acfs: Format complete.

注册ACFS文件系统,相当于定义挂载点:
[root@rac1 ~]# acfsutil registry -a /dev/asm/vol01-31 /home/oracle/ogg
acfsutil registry: mount point /ogg successfully added to Oracle Registry

挂载ACFS文件系统:
[root@rac1 ~]# mount -t acfs /dev/asm/vol01-31 /home/oracle/ogg
[root@rac1 ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda3              35G   20G   14G  60% /
/dev/sda1              99M   12M   82M  13% /boot
tmpfs                1005M  590M  415M  59% /dev/shm
/dev/sr0              3.9G  3.9G     0 100% /media/yum
.host:/               170G   25G  146G  15% /mnt/hgfs
/dev/asm/vol01-31     5.0G   87M  5.0G   2% /home/oracle/ogg

这是一个集群文件系统,节点2上也应该自动挂载
[root@rac2 ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda3              35G   13G   21G  39% /
/dev/sda1              99M   12M   82M  13% /boot
tmpfs                1005M  433M  572M  44% /dev/shm
/dev/asm/vol01-31     5.0G   87M  5.0G   2% /home/oracle/ogg

三、安装OGG
1、在节点一上安装OGG
mkdir /home/oracle/ogg/

tar -xvf /tmp/fbo_ggs_Linux_x64_ora11g_64bit.tar -C /home/oracle/ogg

[oracle@rac1 ogg]$ ./ggsci

Oracle GoldenGate Command Interpreter for Oracle
Version 11.2.1.0.1 OGGCORE_11.2.1.0.1_PLATFORMS_120423.0230_FBO
Linux, x64, 64bit (optimized), Oracle 11g on Apr 23 2012 08:32:14

Copyright (C) 1995, 2012, Oracle and/or its affiliates. All rights reserved.



GGSCI (rac1) 1>

GGSCI (rac1) 1> create subdirs

Creating subdirectories under current directory /home/oracle/ogg

Parameter files                /home/oracle/ogg/dirprm: already exists
Report files                   /home/oracle/ogg/dirrpt: created
Checkpoint files               /home/oracle/ogg/dirchk: created
Process status files           /home/oracle/ogg/dirpcs: created
SQL script files               /home/oracle/ogg/dirsql: created
Database definitions files     /home/oracle/ogg/dirdef: created
Extract data files             /home/oracle/ogg/dirdat: created
Temporary files                /home/oracle/ogg/dirtmp: created
Stdout files                   /home/oracle/ogg/dirout: created


节点二测试:
[oracle@rac2 ogg]$ ./ggsci

Oracle GoldenGate Command Interpreter for Oracle
Version 11.2.1.0.1 OGGCORE_11.2.1.0.1_PLATFORMS_120423.0230_FBO
Linux, x64, 64bit (optimized), Oracle 11g on Apr 23 2012 08:32:14

Copyright (C) 1995, 2012, Oracle and/or its affiliates. All rights reserved.



GGSCI (rac2) 1>


2、目标端安装OGG
过程略.....

3、配置源端RAC数据库
(1)必须开启归档
(2)开启最小附加日志(节点一上执行)
SQL> alter database add supplemental log data;

Database altered.

SQL> select supplemental_log_data_min from v$database;

SUPPLEME
--------
YES
(3)For Oracle DB versions 11.2.0.4 and 12.1.0.2 there will be a new init.ora parameter called ENABLE_GOLDENGATE_REPLICATION.  In order for some of the Oracle GoldenGate functionality to work, this parameter must be set to true.
SQL> ALTER SYSTEM SET ENABLE_GOLDENGATE_REPLICATION = TRUE SCOPE=BOTH;
注:不设置该参数会导致产生下面的报错:
2016-10-11 10:15:57  ERROR   OGG-00446  Opening ASM file +FLASH/eisoo/archivelog/2016_10_10/thread_1_seq_101.305.924887813 in DBLOGREADER mode: (26947) ORA-26947: Oracle GoldenGate replication is not enabled.

(4)源端数据库创建GoldenGate数据库用户并授权
grant connect,
resource,
unlimited tablespace,
select any dictionary,
select any table,
alter any table,
flashback any table
to ggs
identified by ggs;

grant execute on dbms_flashback to ggs;
grant execute on utl_file to ggs;
grant insert any table,
update any table,
delete any table
to ggs;
grant select any transaction to ggs;   --针对抽取进程使用DBLOGREADER参数访问ASM磁盘组,用户需要添加该权限

(5)创建测试用表

create table fst.t1 as select * from scott.emp;

alter table fst.t1 add constraint pk_t1_empno primary key (empno);


exp fst/fst tables=e01 file=t1.dmp

imp fst/fts@25 full=y file=t1.dmp      --25是到目标库的TNS

(6)添加表级transdata

GGSCI (rac1) 1> dblogin userid ggs,password ggs
Successfully logged into database.

GGSCI (rac1) 2> add trandata fst.t1

Logging of supplemental redo data enabled for table FST.T1.

GGSCI (rac1) 27> info trandata fst.t1

Logging of supplemental redo log data is enabled for table FST.T1.

Columns supplementally logged for table FST.T1: EMPNO.

4、配置源端进程组
GGSCI (rac1) 4> edit param mgr
port 7788
userid ggs,password ggs
autorestart extract *,waitminutes 2,retries 5

GGSCI (rac1) 8> add extract extnd,tranlog,begin now,threads 2    --threads 2-----针对RAC模式的必选,代表是2个节点的双实例
EXTRACT added.

GGSCI (rac1) 9> ADD EXTTRAIL /home/oracle/ogg/dirdat/et, EXTRACT EXT1
EXTTRAIL added.

GGSCI (rac1) 10> edit params ext1
extract ext1
userid ggs@eisoo,password ggs
rmthost 192.168.200.25,mgrport 7788
exttrail /home/oracle/ogg/dirdat/et
setenv(NLS_LANG=AMERICAN_AMERICA.AL32UTF8)
--dynamicresolution
tranlogoptions dblogreader    --OGG11g提供一个新的参数:DBLOGREADER,用于抽取进程访问ASM磁盘组
table fst.t1;

GGSCI (rac1) 11> add extract pump1,exttrailsource /home/oracle/ogg/dirdat/et , begin now

GGSCI (rac1) 12> add rmttrail /home/oracle/ogg/dirdat/p1 ,extract pump1
RMTTRAIL added.

GGSCI (rac1) 13> edit params pump1

EXTRACT pump1
USERID fst, PASSWORD fst
RMTHOST 192.168.200.25, MGRPORT 7788
RMTTRAIL /home/oracle/ogg/dirdat/p1
TABLE fst.t1;

5、配置目标数据库
grant connect,
resource,
unlimited tablespace,
select any dictionary,
select any table,
alter any table,
flashback any table
to ggs
identified by ggs;

grant execute on dbms_flashback to ggs;
grant execute on utl_file to ggs;
grant insert any table,
update any table,
delete any table
to ggs;

GGSCI (ogg) 4> edit params GLOBALS
checkpointtable ggs.checkpoint

GGSCI (ogg) 5> dblogin userid ggs,password ggs
Successfully logged into database.

GGSCI (ogg) 6> add checkpointtable ggs.checkpoint

Successfully created checkpoint table ggs.checkpoint.


6、 配置目标端进程组

GGSCI (ogg) 8> edit params mgr
port 7788
userid ggs,password ggs
autorestart extract *,waitminutes 2,retries 5

GGSCI (ogg) 15> start mgr

Manager started.


GGSCI (ogg) 16> info all

Program     Status      Group       Lag at Chkpt  Time Since Chkpt

MANAGER     RUNNING                                           
REPLICAT    STOPPED     REPND       00:00:00      00:01:56

GGSCI (ogg) 9> add replicat rep1,exttrail /home/oracle/ogg/dirdat/p1 , nodbcheckpoint
REPLICAT added.


GGSCI (ogg) 10> edit params rep1
replicat rep1
userid ggs,password ggs
assumetargetdefs
discardfile /home/oracle/ogg/dirdat/rep1.dsc,append
MAP fst.t1, TARGET fst.t1;


所有需要的参数文件都配置完成,按照顺序启动各个进程:

1.启动源端的管理进程
start mgr

2.启动目标端的管理进程
start mgr

3.启动目标端的复制进程
start rep1

4.启动源端的抽取进程
start ext1

5.启动源端的投递进程
start pump1


测试OGG:
在RAC源数据库更新数据
SQL> update fst.t1 set ename='shark' where empno=7788;

目标库上查看:
SQL> select * from fst.t1 where empno=7788;

     EMPNO ENAME      JOB           MGR HIREDATE        SAL       COMM     DEPTNO
---------- ---------- --------- ---------- --------- ---------- ---------- ----------
      7788 shark      ANALYST          7566 19-APR-87       3000            20

同步成功!














来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/30373263/viewspace-2117760/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/30373263/viewspace-2117760/

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值