Chinaunix首页 | 论坛 | 博客
  • 博客访问: 54426
  • 博文数量: 6
  • 博客积分: 175
  • 博客等级: 入伍新兵
  • 技术积分: 105
  • 用 户 组: 普通用户
  • 注册时间: 2011-01-17 14:53
文章分类
文章存档

2012年(6)

我的朋友

分类: Oracle

2012-05-08 11:18:00

Oracle 11g r2 DataGuard安装配置

  

 

安装环境

1.       ORACLE服务器硬件配置

硬盘 146*4

内存 16G

IP地址&机器名:

XXX. XXX. XXX. XXX         platformdb01      #primary

XXX. XXX. XXX. XXX         platformdb02      #standby

 

2.       Oracle服务器分区

-------------------

分区           SIZE

/boot          100M               #主分区

/u01           100G               #主分区

/u02           150G               #主分区

/              60G                #扩展分区

swap           16G                #扩展分区

/rman          剩下的所有空间     #扩展分区 #250G

-------------------

 

3.       RPM安装包选择

#安装包

| Desktop Environments

|---  GNOME Desktop Environment        #all

|Applications

|---Editors                             #vi

|---Text-based Internet                   #all

|Development

|---Development Libraries                #all

|---Development Tools                   #all java nocheck

|---GNOME Software Development         #all

|---Legacy Software Development          #all

|---X Software Development              #all

|Servers

|---Legacy Network Server               #all

|---Server Configuration Tools            #all

|Base System

|---Administration Tools                #all

|---Base                             #all

|---Legacy Software Support            #all

|---System Tools                      #all

|---X Window System                  #all

|Languages

|---Chinese Support                   #

 

4.       配置图形界面环境(Xmanager

a. 启动本地X服务器

安装Xmanager以后, 开始菜单 -> 程序 -> Xmanager3 -> Xmanager Passive

b. 服务器端配置: /etc/ssh/sshd_config

确保有这行: X11Forwarding yes

c. root执行 #export DISPLAY=192.168.186.1:0.0    #本地客户端的IP地址

d. root执行 #xhost +

e. root执行 #xclock   #本地应该有图形界面的钟出现

 

5.       rlwrap安装(可选)

 

安装前准备

#检查OS

[root@platformdb01 ~]# grep MemTotal /proc/meminfo

MemTotal:     16429744 kB

 

[root@platformdb01 ~]# grep "model name" /proc/cpuinfo

model name      : Intel(R) Xeon(R) CPU           E5620  @ 2.40GHz

model name      : Intel(R) Xeon(R) CPU           E5620  @ 2.40GHz

model name      : Intel(R) Xeon(R) CPU           E5620  @ 2.40GHz

model name      : Intel(R) Xeon(R) CPU           E5620  @ 2.40GHz

model name      : Intel(R) Xeon(R) CPU           E5620  @ 2.40GHz

model name      : Intel(R) Xeon(R) CPU           E5620  @ 2.40GHz

model name      : Intel(R) Xeon(R) CPU           E5620  @ 2.40GHz

model name      : Intel(R) Xeon(R) CPU           E5620  @ 2.40GHz

model name      : Intel(R) Xeon(R) CPU           E5620  @ 2.40GHz

model name      : Intel(R) Xeon(R) CPU           E5620  @ 2.40GHz

model name      : Intel(R) Xeon(R) CPU           E5620  @ 2.40GHz

model name      : Intel(R) Xeon(R) CPU           E5620  @ 2.40GHz

model name      : Intel(R) Xeon(R) CPU           E5620  @ 2.40GHz

model name      : Intel(R) Xeon(R) CPU           E5620  @ 2.40GHz

model name      : Intel(R) Xeon(R) CPU           E5620  @ 2.40GHz

model name      : Intel(R) Xeon(R) CPU           E5620  @ 2.40GHz

 

[root@platformdb01 ~]# grep SwapTotal /proc/meminfo

SwapTotal:    16386260 kB

 

[root@platformdb01 ~]# free

             total       used       free     shared    buffers     cached

Mem:      16429744    1333208   15096536          0      96244     960936

-/+ buffers/cache:     276028   16153716

Swap:     16386260          0   16386260

 

[root@platformdb01 ~]# df -h /dev/shm/

Filesystem            Size  Used Avail Use% Mounted on

tmpfs                 7.9G     0  7.9G   0% /dev/shm

 

[root@platformdb01 ~]# uname -a

Linux platformdb01.yz.online.dream2.cc 2.6.18-164.el5 #1 SMP Thu Sep 3 03:28:30 EDT 2009 x86_64 x86_64 x86_64 GNU/Linux

 

[root@platformdb01 ~]# df -h /tmp

Filesystem            Size  Used Avail Use% Mounted on

/dev/sda7              59G  3.5G   52G   7% /

 

[root@platformdb01 ~]# df -h

Filesystem            Size  Used Avail Use% Mounted on

/dev/sda7              59G  3.5G   52G   7% /

/dev/sda5              95G  188M   90G   1% /u01

/dev/sda3             142G  188M  135G   1% /u02

/dev/sda1              99M   12M   82M  13% /boot

tmpfs                 7.9G     0  7.9G   0% /dev/shm

/dev/sda2             218G  188M  207G   1% /rman

 

[root@platformdb01 ~]# cat /proc/version

Linux version 2.6.18-164.el5 (mockbuild@builder10.centos.org) (gcc version 4.1.2 20080704 (Red Hat 4.1.2-46)) #1 SMP Thu Sep 3 03:28:30 EDT 2009

 

 

[root@platformdb01 ~]# cat /etc/issue

CentOS release 5.4 (Final)

Kernel \r on an \m

 

#检查RPM

[root@platformdb01 ~]# rpm -qa | grep binutils

binutils-2.17.50.0.6-12.el5

 

[root@platformdb01 ~]# rpm -qa | grep compat-libstdc++

compat-libstdc++-296-2.96-138

compat-libstdc++-33-3.2.3-61

compat-libstdc++-33-3.2.3-61

 

[root@platformdb01 ~]# rpm -qa | grep elfutils-libelf

elfutils-libelf-devel-0.137-3.el5

elfutils-libelf-0.137-3.el5

elfutils-libelf-devel-static-0.137-3.el5

elfutils-libelf-0.137-3.el5

 

[root@platformdb01 ~]# rpm -qa | grep gcc

gcc44-gfortran-4.4.0-6.el5

gcc-4.1.2-46.el5

gcc44-4.4.0-6.el5

gcc-gnat-4.1.2-46.el5

gcc-gfortran-4.1.2-46.el5

compat-libgcc-296-2.96-138

libgcc-4.1.2-46.el5

libgcc-4.1.2-46.el5

gcc44-c++-4.4.0-6.el5

gcc-c++-4.1.2-46.el5

compat-gcc-34-c++-3.4.6-4

compat-gcc-34-3.4.6-4

gcc-objc-4.1.2-46.el5

compat-gcc-34-g77-3.4.6-4

 

[root@platformdb01 ~]# rpm -qa | grep glibc

glibc-common-2.5-42

glibc-2.5-42

glibc-headers-2.5-42

compat-glibc-headers-2.3.4-2.26

glibc-2.5-42

compat-glibc-2.3.4-2.26

compat-glibc-2.3.4-2.26

glibc-devel-2.5-42

glibc-devel-2.5-42

 

[root@platformdb01 ~]# rpm -qa | grep ksh

ksh-20080202-14.el5

 

[root@platformdb01 ~]# rpm -qa | grep libaio

libaio-0.3.106-3.2

libaio-0.3.106-3.2

 

[root@platformdb01 ~]# rpm -qa | grep libgcc

compat-libgcc-296-2.96-138

libgcc-4.1.2-46.el5

libgcc-4.1.2-46.el5

 

[root@platformdb01 ~]# rpm -qa | grep libstdc++

libstdc++-4.1.2-46.el5

libstdc++-devel-4.1.2-46.el5

compat-libstdc++-296-2.96-138

libstdc++44-devel-4.4.0-6.el5

libstdc++44-devel-4.4.0-6.el5

compat-libstdc++-33-3.2.3-61

compat-libstdc++-33-3.2.3-61

libstdc++-4.1.2-46.el5

 

[root@platformdb01 ~]# rpm -qa | grep make

automake15-1.5-16

imake-1.0.2-3

automake14-1.4p6-13

automake-1.9.6-2.1

make-3.81-3.el5

automake16-1.6.3-8

automake17-1.7.9-7

 

[root@platformdb01 ~]# rpm -qa | grep numactl-devel

 

[root@platformdb01 ~]# rpm -qa | grep sysstat

sysstat-7.0.2-3.el5

 

[root@platformdb01 ~]# rpm -qa | grep unixODBC

 

#安装缺少的RPM

[root@platformdb01 ~]# rpm -ivh  *.rpm

warning: libaio-devel-0.3.106-3.2.i386.rpm: Header V3 DSA signature: NOKEY, key ID e8562897

Preparing...                  ########################################### [100%]

   1:unixODBC               ########################################### [ 11%]

   2:pdksh                  ########################################### [ 22%]

   3:unixODBC-devel         ########################################### [ 33%]

   4:numactl-devel           ########################################### [ 44%]

   5:numactl-devel          ########################################### [ 56%]

   6:libaio-devel            ########################################### [ 67%]

   7:libaio-devel            ########################################### [ 78%]

   8:unixODBC              ########################################### [ 89%]

   9:unixODBC-devel         ########################################### [100%]

 

#创建oracle用户

[root@platformdb01 ~]# groupadd oinstall

[root@platformdb01 ~]# groupadd dba

[root@platformdb01 ~]# useradd -g oinstall -G dba oracle

[root@platformdb01 ~]# passwd oracle

Changing password for user oracle.

New UNIX password:

Retype new UNIX password:

passwd: all authentication tokens updated successfully.

 

#修改sysctl.conf

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

#for oracle

fs.aio-max-nr = 1048576

fs.file-max = 6815744

kernel.shmall = 2097152

kernel.shmmax = 536870912

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@platformdb01 ~]# sysctl -p

 

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

#for oracle

oracle           soft    nproc   2047

oracle           hard    nproc   16384

oracle           soft    nofile  1024

oracle           hard    nofile  65536

oracle           hard    stack   10240

 

#创建目录

[root@platformdb01 u01]# mkdir -p /u01/oracle/oracle11g

[root@platformdb01 u01]# chown -R oracle:oinstall /u01/

[root@platformdb01 u01]# chmod -R 775 /u01/

 

[root@platformdb01 /]# mkdir -p /u02/oracle/oracle11g

[root@platformdb01 /]# chown -R oracle:oinstall /u02/

[root@platformdb01 /]# chmod -R 775 /u02/

 

[root@platformdb01 /]# mkdir -p /rman/arch

[root@platformdb01 /]# chown -R oracle:oinstall /rman/

[root@platformdb01 /]# chmod -R 775 /rman/

 

#设置环境变量

[root@platformdb01 ~]# su - oracle

[oracle@platformdb01 ~]$ vi .bash_profile

#for oracle

ORACLE_BASE=/u01/oracle

ORACLE_HOME=$ORACLE_BASE/oracle11g

ORACLE_SID=jmcentr

PATH=$ORACLE_HOME/bin:$PATH

NLS_DATE_FORMAT="YYYY-MM-DD HH24:MI:SS"

NLS_LANG=American_america.AL32UTF8

EDITOR=vi

 

export ORACLE_BASE ORACLE_HOME ORACLE_SID PATH NLS_DATE_FORMAT NLS_LANG EDITOR

 

alias sqlplus="rlwrap sqlplus"

alias rman="rlwrap rman"

alias lsnrctl="rlwrap lsnrctl"

 

#配置hosts

[root@platformdb01 /]# vi /etc/hosts

127.0.0.1               localhost

222.189.228.152         platformdb01.yz.online.dream2.cc platformdb01

222.189.228.153         platformdb02.yz.online.dream2.cc platformdb02

 

 

[root@platformdb01 /]# echo "redhat-release-5Server-5" > /tmp/.linux_release

[root@platformdb01 /]# chattr +i /tmp/.linux_release

 

注:platformdb01platformdb02都按照以上步骤执行

开始安装oracle11gr2软件

在客户端打开:Xmanager Passive

Oracle数据库服务器执行以下命令:

[root@platformdb01 ~]# export DISPLAY=192.168.186.1:0.0

[root@platformdb01 ~]# xhost +

access control disabled, clients can connect from any host

[oracle@platformdb01 ~]$ unzip linux.x64_11gR2_database_1of2.zip

[oracle@platformdb01 ~]$ unzip linux.x64_11gR2_database_2of2.zip

[oracle@platformdb01 ~]$ cd database/

[oracle@platformdb01 database]$ ls

doc  install  response  rpm  runInstaller  sshsetup  stage  welcome.html

[oracle@platformdb01 database]$ ./runInstaller

注:tail -f /tmp/OraInstall2010-08-24_03-25-30PM/installActions2010-08-24_03-25-30PM.log查看oracle检查安装的log

去掉对号,点击“Next

点击“Yes

选择“Install database software only”,点击“Next

点击“Next

选择“English”和“Simplified Chinese”,点击“Next

点击“Next

点击“Next

点击“Next

点击“Next

选择“Ignore All”,点击“Next

可以选择保存响应文件

点击“Save

点击“Finish

 

注:可以通过tail -f /u01/oraInventory/logs/installActions2010-08-24_03-25-30PM.log查看oracle安装的log

 

使用root用户按顺序执行2个脚本,然后点击“OK

[root@platformdb01 ~]# /u01/oraInventory/orainstRoot.sh

Changing permissions of /u01/oraInventory.

Adding read,write permissions for group.

Removing read,write,execute permissions for world.

 

Changing groupname of /u01/oraInventory to oinstall.

The execution of the script is complete.

 

[root@platformdb01 ~]# /u01/oracle/oracle11g/root.sh

Running Oracle 11g root.sh script...

 

The following environment variables are set as:

    ORACLE_OWNER= oracle

    ORACLE_HOME=  /u01/oracle/oracle11g

 

Enter the full pathname of the local bin directory: [/usr/local/bin]:

   Copying dbhome to /usr/local/bin ...

   Copying oraenv to /usr/local/bin ...

   Copying coraenv to /usr/local/bin ...

 

Creating /etc/oratab file...

Entries will be added to the /etc/oratab file as needed by

Database Configuration Assistant when a database is created

Finished running generic part of root.sh script.

Now product-specific root actions will be performed.

Finished product-specific root actions.

 

点击“Close”,完成oracle软件的安装。

 

注:platformdb01platformdb02都按照以上步骤执行

 

安装后配置监听、创建oracle数据库(只在platformdb01执行)

a.       创建监听

[oracle@platformdb01 admin]$ netca

点击“Next

点击“Next

点击“Next

点击“Next

点击“Next

点击“Next

点击“Next

点击“Finish”,完成listener的配置。

 

注:可以通过lsnrctl status查看监听的状态

[oracle@platformdb01 ~]$ lsnrctl status

 

LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 24-AUG-2010 16:13:22

 

Copyright (c) 1991, 2009, Oracle.  All rights reserved.

 

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=platformdb01)(PORT=1521)))

STATUS of the LISTENER

------------------------

Alias                     LISTENER

Version                   TNSLSNR for Linux: Version 11.2.0.1.0 - Production

Start Date                24-AUG-2010 16:10:25

Uptime                    0 days 0 hr. 2 min. 57 sec

Trace Level               off

Security                  ON: Local OS Authentication

SNMP                      OFF

Listener Parameter File   /u01/oracle/oracle11g/network/admin/listener.ora

Listener Log File         /u01/oracle/diag/tnslsnr/platformdb01/listener/alert/log.xml

Listening Endpoints Summary...

  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=platformdb01)(PORT=1521)))

The listener supports no services

The command completed successfully

 

修改listener.ora文件

[oracle@platformdb01 ~]$ cd /u01/oracle/oracle11g/network/admin

[oracle@platformdb01 admin]$ vi listener.ora

-------------------------------------------------

# listener.ora Network Configuration File: /u01/oracle/oracle11g/network/admin/listener.ora

# Generated by Oracle configuration tools.

 

SID_LIST_LISTENER =

  (SID_LIST =

    (SID_DESC =

      (GLOBAL_DBNAME = jmcentr)

      (ORACLE_HOME = /u01/oracle/oracle11g)

      (SID_NAME = jmcentr)

    )

  )

 

LISTENER =

  (DESCRIPTION_LIST =

    (DESCRIPTION =

      (ADDRESS = (PROTOCOL = TCP)(HOST = platformdb01)(PORT = 1521))

    )

  )

 

ADR_BASE_LISTENER = /u01/oracle

-------------------------------------------------

重新启动监听

[oracle@platformdb01 admin]$ lsnrctl stop

[oracle@platformdb01 admin]$ lsnrctl start

 

b.       创建oracle数据库

[oracle@platformdb01 ~]$ dbca

点击“Next

点击“Next

点击“Next

输入“Global Database Name”和“SID”,点击“Next

点击“Next

输入密码,点击“Next

选择“Use Common Location for All Database Files”,输入“{ORACLE_BASE}/oradata”点击“Next

选择“Enable Archiving”,点击“Edit Archive Mode Parameters

输入“/rman/arch”,点击“OK”,然后点击“Next

点击“Next

可以按照服务器配置设置SGAPGA大小(本图片是内存为1020MB的配置),点击“Sizing

可以根据需要设置“Processes”大小,点击“Character Sets

选择“AL32UTF8”,点击“Next

点击“Next

选择“Save as a Database Template”和“Generate Database Creation Scripts”,点击“Finish

点击“OK

点击“OK

点击“OK

 

注:可以使用tail -f /u01/oracle/cfgtoollogs/dbca/jmcentr/trace.log查看创建数据库log

 

点击“Exit”,完成oracle数据库的创建。

 

备份emkey.ora文件

[oracle@platformdb01 ~]$ cd /u01/oracle/oracle11g/platformdb01_jmcentr/sysman/config

[oracle@platformdb01 config]$ cp emkey.ora ~

 

配置Dataguard

a.       修改platformdb01tnsnames.ora文件

[oracle@platformdb01 admin]$ cd /u01/oracle/oracle11g/network/admin

[oracle@platformdb01 admin]$ vi tnsnames.ora

----------------------------------------

# tnsnames.ora Network Configuration File: /u01/oracle/oracle11g/network/admin/tnsnames.ora

# Generated by Oracle configuration tools.

 

JMCENTR2 =

  (DESCRIPTION =

    (ADDRESS = (PROTOCOL = TCP)(HOST = platformdb02)(PORT = 1521))

    (CONNECT_DATA =

      (SERVER = DEDICATED)

      (SERVICE_NAME = jmcentr)

    )

  )

 

JMCENTR1 =

  (DESCRIPTION =

    (ADDRESS = (PROTOCOL = TCP)(HOST = platformdb01)(PORT = 1521))

    (CONNECT_DATA =

      (SERVER = DEDICATED)

      (SERVICE_NAME = jmcentr)

    )

  )

 

JMCENTR =

  (DESCRIPTION =

    (ADDRESS = (PROTOCOL = TCP)(HOST = platformdb01)(PORT = 1521))

    (CONNECT_DATA =

      (SERVER = DEDICATED)

      (SERVICE_NAME = jmcentr)

    )

  )

----------------------------------------

 

b.       拷贝platformdb01listener.oratnsnames.ora及密码文件orapwjmcentrplatformdb02,并修改listener.oratnsnames.ora文件

[oracle@platformdb01 admin]$ cd /u01/oracle/oracle11g/network/admin

$ scp listener.ora platformdb02:/u01/oracle/oracle11g/network/admin/

$ scp tnsnames.ora platformdb02:/u01/oracle/oracle11g/network/admin/

[oracle@platformdb01 admin]$ cd /u01/oracle/oracle11g/dbs/

[oracle@platformdb01 dbs]$ scp orapwjmcentr platformdb02:/u01/oracle/oracle11g/dbs/

 

[oracle@platformdb02 admin]$ vi listener.ora

---------------------------------------

# listener.ora Network Configuration File: /u01/oracle/oracle11g/network/admin/listener.ora

# Generated by Oracle configuration tools.

 

SID_LIST_LISTENER =

  (SID_LIST =

    (SID_DESC =

      (GLOBAL_DBNAME = jmcentr)

      (ORACLE_HOME = /u01/oracle/oracle11g)

      (SID_NAME = jmcentr)

    )

  )

 

LISTENER =

  (DESCRIPTION_LIST =

    (DESCRIPTION =

      (ADDRESS = (PROTOCOL = TCP)(HOST = platformdb02)(PORT = 1521))

    )

  )

 

ADR_BASE_LISTENER = /u01/oracle

----------------------------------------

 

[oracle@platformdb02 admin]$ vi tnsnames.ora

-----------------------------------------

# tnsnames.ora Network Configuration File: /u01/oracle/oracle11g/network/admin/tnsnames.ora

# Generated by Oracle configuration tools.

 

JMCENTR2 =

  (DESCRIPTION =

    (ADDRESS = (PROTOCOL = TCP)(HOST = platformdb02)(PORT = 1521))

    (CONNECT_DATA =

      (SERVER = DEDICATED)

      (SERVICE_NAME = jmcentr)

    )

  )

 

JMCENTR1 =

  (DESCRIPTION =

    (ADDRESS = (PROTOCOL = TCP)(HOST = platformdb01)(PORT = 1521))

    (CONNECT_DATA =

      (SERVER = DEDICATED)

      (SERVICE_NAME = jmcentr)

    )

  )

 

JMCENTR =

  (DESCRIPTION =

    (ADDRESS = (PROTOCOL = TCP)(HOST = platformdb02)(PORT = 1521))

    (CONNECT_DATA =

      (SERVER = DEDICATED)

      (SERVICE_NAME = jmcentr)

    )

  )

-----------------------------------------

 

c.       启动platformdb02的监听

[oracle@platformdb02 dbs]$ lsnrctl start

 

d.       创建oracle目录

# platformdb01

[oracle@platformdb01 jmcentr]$ mkdir -p /u02/oracle/oradata/jmcentr

 

#platformdb02

[oracle@platformdb02 oracle]$ mkdir -p /u01/oracle/oradata/jmcentr

[oracle@platformdb02 oracle]$ mkdir -p /u01/oracle/flash_recovery_area/JMCENTR/onlinelog

[oracle@platformdb02 oracle]$ mkdir -p /u01/oracle/admin/jmcentr/adump

[oracle@platformdb02 oracle]$ mkdir -p /u01/oracle/admin/jmcentr/dpdump

[oracle@platformdb02 oracle]$ mkdir -p /u01/oracle/admin/jmcentr/pfile

[oracle@platformdb02 oracle]$ mkdir -p /u01/oracle/admin/jmcentr/scripts

[oracle@platformdb02 oracle]$ mkdir -p /u02/oracle/oradata/jmcentr

 

 

e.       配置DataGuard

e.1.  配置primary platformdb01)数据库的参数

[oracle@platformdb01 oracle]$ sqlplus /nolog

 

SQL*Plus: Release 11.2.0.1.0 Production on Tue Aug 24 21:06:50 2010

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

 

SQL> conn /as sysdba

Connected.

SQL> alter database force logging;

Database altered.

SQL> create pfile from spfile;

File created.

 

[oracle@platformdb01 ~]$ cd /u01/oracle/oracle11g/dbs

[oracle@platformdb01 dbs]$ mv spfilejmcentr.ora spfilejmcentr.ora.bak

[oracle@platformdb01 dbs]$ vi initjmcentr.ora

-------------------------------------------

jmcentr.__db_cache_size=75497472

jmcentr.__java_pool_size=4194304

jmcentr.__large_pool_size=4194304

jmcentr.__oracle_base='/u01/oracle'#ORACLE_BASE set from environment

jmcentr.__pga_aggregate_target=163577856

jmcentr.__sga_target=264241152

jmcentr.__shared_io_pool_size=0

jmcentr.__shared_pool_size=167772160

jmcentr.__streams_pool_size=4194304

*.audit_file_dest='/u01/oracle/admin/jmcentr/adump'

*.audit_trail='db'

*.compatible='11.2.0.0.0'

*.control_files='/u01/oracle/oradata/jmcentr/control01.ctl','/u01/oracle/oradata/jmcentr/control02.ctl','/u01/oracle/oradata/jmcentr/control03.ctl'

*.db_block_size=8192

*.db_domain=''

*.db_name='jmcentr'

*.db_recovery_file_dest='/u01/oracle/flash_recovery_area'

*.db_recovery_file_dest_size=4070572032

*.diagnostic_dest='/u01/oracle'

*.dispatchers='(PROTOCOL=TCP) (SERVICE=jmcentrXDB)'

#*.log_archive_dest_1='LOCATION=/rman/arch'

*.log_archive_format='%t_%s_%r.dbf'

*.memory_target=427819008

*.open_cursors=300

*.processes=500

*.remote_login_passwordfile='EXCLUSIVE'

*.sessions=555

*.undo_tablespace='UNDOTBS1'

 

*.db_unique_name=uqn_jmcentr1

*.log_archive_config='DG_CONFIG=(uqn_jmcentr1,uqn_jmcentr2)'

*.log_archive_dest_1='LOCATION=/rman/arch noreopen optional VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=uqn_jmcentr1'

*.log_archive_dest_2='SERVICE=jmcentr2 VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=uqn_jmcentr2 ARCH SYNC REOPEN=10'

*.log_archive_dest_state_1=ENABLE

*.log_archive_dest_state_2=ENABLE

*.FAL_SERVER='jmcentr2'

*.FAL_CLIENT='jmcentr1'

*.STANDBY_FILE_MANAGEMENT='AUTO'

*.log_file_name_convert='/u01/oracle/oradata/jmcentr/','/u01/oracle/oradata/jmcentr/'

-------------------------------------------

 

SQL> shutdown immediate

Database closed.

Database dismounted.

ORACLE instance shut down.

 

SQL> startup

ORACLE instance started.

 

Total System Global Area  425897984 bytes

Fixed Size                  2214016 bytes

Variable Size             343934848 bytes

Database Buffers           75497472 bytes

Redo Buffers                4251648 bytes

Database mounted.

Database opened.

 

e.2. 拷贝参数文件到standby platformdb02

[oracle@platformdb01 ~]$ cd /u01/oracle/oracle11g/dbs

[oracle@platformdb01 dbs]$ scp initjmcentr.ora platformdb02:/u01/oracle/oracle11g/dbs/

 

 

e.3.  修改standbyplatformdb02)参数文件

[oracle@platformdb02 ~]$ cd /u01/oracle/oracle11g/dbs

[oracle@platformdb02 dbs]$ vi initjmcentr.ora

-----------------------------------------

jmcentr.__db_cache_size=75497472

jmcentr.__java_pool_size=4194304

jmcentr.__large_pool_size=4194304

jmcentr.__oracle_base='/u01/oracle'#ORACLE_BASE set from environment

jmcentr.__pga_aggregate_target=163577856

jmcentr.__sga_target=264241152

jmcentr.__shared_io_pool_size=0

jmcentr.__shared_pool_size=167772160

jmcentr.__streams_pool_size=4194304

*.audit_file_dest='/u01/oracle/admin/jmcentr/adump'

*.audit_trail='db'

*.compatible='11.2.0.0.0'

*.control_files='/u01/oracle/oradata/jmcentr/control01.ctl','/u01/oracle/oradata/jmcentr/control02.ctl','/u01/oracle/oradata/jmcentr/control03.ctl'

*.db_block_size=8192

*.db_domain=''

*.db_name='jmcentr'

*.db_recovery_file_dest='/u01/oracle/flash_recovery_area'

*.db_recovery_file_dest_size=4070572032

*.diagnostic_dest='/u01/oracle'

*.dispatchers='(PROTOCOL=TCP) (SERVICE=jmcentrXDB)'

#*.log_archive_dest_1='LOCATION=/rman/arch'

*.log_archive_format='%t_%s_%r.dbf'

*.memory_target=427819008

*.open_cursors=300

*.processes=500

*.remote_login_passwordfile='EXCLUSIVE'

*.sessions=555

*.undo_tablespace='UNDOTBS1'

 

*.db_unique_name=uqn_jmcentr2

*.log_archive_config='DG_CONFIG=(uqn_jmcentr1,uqn_jmcentr2)'

*.log_archive_dest_1='LOCATION=/rman/arch noreopen optional VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=uqn_jmcentr2'

*.log_archive_dest_2='SERVICE=jmcentr1 VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=uqn_jmcentr1 ARCH SYNC REOPEN=10'

*.log_archive_dest_state_1=ENABLE

*.log_archive_dest_state_2=ENABLE

*.FAL_SERVER='jmcentr1'

*.FAL_CLIENT='jmcentr2'

*.STANDBY_FILE_MANAGEMENT='AUTO'

*.log_file_name_convert='/u01/oracle/oradata/jmcentr/','/u01/oracle/oradata/jmcentr/'

-----------------------------------------

 

e.4  standbyplatformdb02)启动到nomount状态

[oracle@platformdb02 ~]$ sqlplus /nolog

 

SQL*Plus: Release 11.2.0.1.0 Production on Wed Aug 25 10:30:39 2010

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

 

SQL> conn /as sysdba

Connected to an idle instance.

SQL> startup nomount

ORACLE instance started.

 

Total System Global Area  425897984 bytes

Fixed Size                  2214016 bytes

Variable Size             343934848 bytes

Database Buffers           75497472 bytes

Redo Buffers                4251648 bytes

 

 

e.5 备份primary主库(platformdb01上)

[oracle@platformdb01 rman]$ rman target /

 

Recovery Manager: Release 11.2.0.1.0 - Production on Wed Aug 25 10:35:30 2010

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

 

connected to target database: JMCENTR (DBID=614620766)

 

RMAN> run {

2>  allocate channel d1 device type disk;

3>  backup as compressed backupset

4>  incremental level=0 format='/rman/inc0_%d_%T_%s_%p'

5>  tag='inc0' channel=d1 database;

6>  sql "alter system archive log current";

7>  backup as compressed backupset

8>  format='/rman/arch_%d_%T_%s_%p'

9>  tag='arch' channel=d1 archivelog all delete input;

10>  backup as compressed backupset

11>  format='/rman/ctl_%d_%T_%s_%p'

12>  tag='ctl' channel=d1 current controlfile for standby reuse;

13>  }

 

 

e.6 拷贝primaryplatformdb01)备份文件到standbyplatformdb02

[oracle@platformdb01 ~]$ cd /rman/

[oracle@platformdb01 rman]$ scp inc0_JMCENTR_20100825_* platformdb02:/rman/

[oracle@platformdb01 rman]$ scp ctl_JMCENTR_20100825_4_1 platformdb02:/rman/

[oracle@platformdb01 rman]$ scp arch_JMCENTR_20100825_3_1 platformdb02:/rman/

 

e.7  duplicate primary数据库

RMAN> connect auxiliary sys/XXXX@jmcentr2

connected to auxiliary database: JMCENTR (not mounted)

 

RMAN> duplicate target database for standby nofilenamecheck;

 

 

e.8 恢复standby数据库 platformdb02

SQL> recover managed standby database disconnect from session;

Media recovery complete.

 

e.9 standby数据库启动到open read only状态

SQL> recover managed standby database cancel;

Media recovery complete.

SQL> alter database open read only;

Database altered.

SQL> recover managed standby database disconnect from session;

Media recovery complete.

 

e.10 测试DataGuard

# primary数据库(platformdb01

SQL> alter system archive log current;

System altered.

 

# platformdb02

通过命令查看是否有归档日志恢复

[oracle@platformdb02 ~]$ tail -f /u01/oracle/diag/rdbms/uqn_jmcentr2/jmcentr/trace/alert_jmcentr.log

 

 

e.11 使用LGWR进程进行primarystandby之间的归档日志传输

#添加standby logfile

e.11.1  standby 添加standby logfile

SQL> recover managed standby database cancel;

Media recovery complete.

SQL> alter database add standby logfile group 6 ('/u02/oracle/oradata/jmcentr/stb_redo01.dbf') size 104448000 reuse;

Database altered.

 

SQL> alter database add standby logfile group 7 ('/u02/oracle/oradata/jmcentr/stb_redo02.dbf') size 104448000 reuse;

Database altered.

 

SQL> alter database add standby logfile group 8 ('/u02/oracle/oradata/jmcentr/stb_redo03.dbf') size 104448000 reuse;

Database altered.

 

SQL> alter database add standby logfile group 9 ('/u02/oracle/oradata/jmcentr/stb_redo04.dbf') size 104448000 reuse;

Database altered.

 

#查看standby logfile

SQL> select * from v$standby_log;

 

e.11.2 primary 添加standby logfile

SQL> alter database add standby logfile group 6 ('/u02/oracle/oradata/jmcentr/stb_redo01.dbf') size 104448000 reuse;

Database altered.

 

SQL> alter database add standby logfile group 7 ('/u02/oracle/oradata/jmcentr/stb_redo02.dbf') size 104448000 reuse;

Database altered.

 

SQL> alter database add standby logfile group 8 ('/u02/oracle/oradata/jmcentr/stb_redo03.dbf') size 104448000 reuse;

Database altered.

 

SQL> alter database add standby logfile group 9 ('/u02/oracle/oradata/jmcentr/stb_redo04.dbf') size 104448000 reuse;

Database altered.

 

#查看standby logfile

SQL> select * from v$standby_log;

 

 

e.11.3 修改primarystandby的初始化参数log_archive_dest_2

#primaryplatformdb01

[oracle@platformdb01 arch]$ vi /u01/oracle/oracle11g/dbs/initjmcentr.ora

------------------------------------------------

*.log_archive_dest_2='SERVICE=jmcentr2 VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=uqn_jmcentr2 LGWR SYNC REOPEN=10'

------------------------------------------------

 

#standbyplatformdb02

[oracle@platformdb02 rman]$ vi /u01/oracle/oracle11g/dbs/initjmcentr.ora

------------------------------------------------

*.log_archive_dest_2='SERVICE=jmcentr1 VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=uqn_jmcentr1 LGWR SYNC REOPEN=10'

------------------------------------------------

 

 

e.11.4 重启primarystandby数据库

#shutdown

#primary platformdb01

SQL> shutdown immediate

Database closed.

Database dismounted.

ORACLE instance shut down.

 

#standby platformdb02

SQL> recover managed standby database cancel;

Media recovery complete.

SQL> shutdown immediate

Database closed.

Database dismounted.

ORACLE instance shut down.

 

#startup

#primary platformdb01

SQL> startup

ORACLE instance started.

 

Total System Global Area  425897984 bytes

Fixed Size                  2214016 bytes

Variable Size             343934848 bytes

Database Buffers           75497472 bytes

Redo Buffers                4251648 bytes

Database mounted.

Database opened.

 

#standby platformdb02

SQL> startup nomount

ORACLE instance started.

 

Total System Global Area  425897984 bytes

Fixed Size                  2214016 bytes

Variable Size             343934848 bytes

Database Buffers           75497472 bytes

Redo Buffers                4251648 bytes

 

SQL> alter database mount standby database;

Database altered.

 

SQL> alter database open read only;

Database altered.

 

SQL> recover managed standby database disconnect from session;

Media recovery complete.

 

e.12 修改参数文件为spfile

e.12.1创建spfile文件

#primary platformdb01

SQL> create spfile from pfile;

File created.

 

#standby platformdb02

SQL> create spfile from pfile;

File created.

 

 

e.12.2重启primarystandby数据库

同上

 

 

 

 

 

 

 

 

####################################################################

#测试DataGuard数据

#primary

SQL> create table dg_test(sno number,sname varchar(20));

Table created.

 

SQL> insert into dg_test values(1,'DataGuard');

1 row created.

 

SQL> insert into dg_test values(2,'primary');

1 row created.

 

SQL> insert into dg_test values(3,'standby');

1 row created.

 

SQL> commit;

Commit complete.

 

SQL> alter system archive log current;

System altered.

 

#standby

SQL> select * from dg_test;

  SNO SNAME

---------- --------------------

     1 DataGuard

     2 primary

     3 standby

 

 

 

 

 

 

 

####################################################################

#switchover

a.       Primary操作

#停止企业管理器

[oracle@platformdb01 arch]$ emctl stop dbconsole

Oracle Enterprise Manager 11g Database Control Release 11.2.0.1.0

Copyright (c) 1996, 2009 Oracle Corporation.  All rights reserved.

https://platformdb01:1158/em/console/aboutApplication

Stopping Oracle Enterprise Manager 11g Database Control ...

 ...  Stopped.

 

SQL> select open_mode,database_role,switchover_status from v$database;

OPEN_MODE          DATABASE_ROLE    SWITCHOVER_STATUS

--------------------         ----------------       --------------------

READ WRITE           PRIMARY          TO STANDBY

注:switchover_status 应为TO STANDBY ,如果不为此状态,就archive log

 

SQL> select count(*) from v$session where username is not null;

  COUNT(*)

----------

      1

注:只有自己

 

#切换primarystandby

SQL> alter database commit to switchover to physical standby;

Database altered.

 

SQL> shutdown immediate

ORA-01507: database not mounted

ORACLE instance shut down.

 

SQL> startup nomount

ORACLE instance started.

Total System Global Area  425897984 bytes

Fixed Size                  2214016 bytes

Variable Size             369100672 bytes

Database Buffers           50331648 bytes

Redo Buffers                4251648 bytes

 

SQL> alter database mount standby database;

Database altered.

 

b.       Standby操作

#切换standbyprimary

SQL> select open_mode,database_role,switchover_status from v$database;

OPEN_MODE          DATABASE_ROLE     SWITCHOVER_STATUS

--------------------          ----------------        --------------------

READ ONLY            PHYSICAL STANDBY   TO PRIMARY

 

SQL> alter database commit to switchover to primary;

Database altered.

 

SQL> shutdown immediate

ORA-01109: database not open

Database dismounted.

ORACLE instance shut down.

 

SQL> startup

ORACLE instance started.

Total System Global Area  425897984 bytes

Fixed Size                  2214016 bytes

Variable Size             348129152 bytes

Database Buffers           71303168 bytes

Redo Buffers                4251648 bytes

Database mounted.

Database opened.

 

 

c.       Primary操作

#primary恢复数据,并且open read only

SQL> select open_mode,switchover_status,database_role from v$database;

OPEN_MODE            SWITCHOVER_STATUS    DATABASE_ROLE

--------------------           --------------------          ----------------

MOUNTED              RECOVERY NEEDED      PHYSICAL STANDBY

 

SQL> recover managed standby database disconnect from session;

Media recovery complete.

 

SQL> recover managed standby database cancel;

Media recovery complete.

 

SQL> select open_mode,switchover_status,database_role from v$database;

OPEN_MODE            SWITCHOVER_STATUS    DATABASE_ROLE

--------------------           --------------------          ----------------

MOUNTED              NOT ALLOWED          PHYSICAL STANDBY

 

SQL> alter database open read only;

Database altered.

 

SQL> recover managed standby database disconnect from session;

Media recovery complete.

 

 

 

 

 

 

###########################################################

#failover

#standby操作

a.       standby切换为primary

SQL> select thread#,low_sequence#,high_sequence# from v$archive_gap;

no rows selected

 

SQL> recover managed standby database cancel;

Media recovery complete.

SQL> recover managed standby database finish;

Media recovery complete.

SQL> select open_mode,switchover_status,database_role from v$database;

OPEN_MODE          SWITCHOVER_STATUS    DATABASE_ROLE

--------------------         --------------------          ----------------

READ ONLY            TO PRIMARY           PHYSICAL STANDBY

 

SQL> alter database commit to switchover to primary;

Database altered.

 

SQL> shutdown immediate

ORA-01109: database not open

Database dismounted.

ORACLE instance shut down.

 

b.       修改参数文件

[oracle@platformdb01 dbs]$ vi initjmcentr.ora

----------------------------------------------

jmcentr.__db_cache_size=75497472

jmcentr.__java_pool_size=4194304

jmcentr.__large_pool_size=4194304

jmcentr.__oracle_base='/u01/oracle'#ORACLE_BASE set from environment

jmcentr.__pga_aggregate_target=163577856

jmcentr.__sga_target=264241152

jmcentr.__shared_io_pool_size=0

jmcentr.__shared_pool_size=167772160

jmcentr.__streams_pool_size=4194304

*.audit_file_dest='/u01/oracle/admin/jmcentr/adump'

*.audit_trail='db'

*.compatible='11.2.0.0.0'

*.control_files='/u01/oracle/oradata/jmcentr/control01.ctl','/u01/oracle/oradata/jmcentr/control02.ctl','/u01/oracle/oradata/jmcentr/control03.ctl'

*.db_block_size=8192

*.db_domain=''

*.db_name='jmcentr'

*.db_recovery_file_dest='/u01/oracle/flash_recovery_area'

*.db_recovery_file_dest_size=4070572032

*.diagnostic_dest='/u01/oracle'

*.dispatchers='(PROTOCOL=TCP) (SERVICE=jmcentrXDB)'

*.log_archive_dest_1='LOCATION=/rman/arch'

*.log_archive_format='%t_%s_%r.dbf'

*.memory_target=427819008

*.open_cursors=300

*.processes=500

*.remote_login_passwordfile='EXCLUSIVE'

*.sessions=555

*.undo_tablespace='UNDOTBS1'

 

#*.db_unique_name=uqn_jmcentr1

#*.log_archive_config='DG_CONFIG=(uqn_jmcentr1,uqn_jmcentr2)'

#*.log_archive_dest_1='LOCATION=/rman/arch noreopen optional VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=uqn_jmcentr1'

#*.log_archive_dest_2='SERVICE=jmcentr2 VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=uqn_jmcentr2 LGWR SYNC REOPEN=10'

*.log_archive_dest_state_1=ENABLE

*.log_archive_dest_state_2=ENABLE

#*.FAL_SERVER='jmcentr2'

#*.FAL_CLIENT='jmcentr1'

#*.STANDBY_FILE_MANAGEMENT='AUTO'

#*.log_file_name_convert='/u01/oracle/oradata/jmcentr/','/u01/oracle/oradata/jmcentr/'

----------------------------------------------

 

c.       启动数据库

SQL> startup pfile='/u01/oracle/oracle11g/dbs/initjmcentr.ora'

ORACLE instance started.

Total System Global Area  425897984 bytes

Fixed Size                  2214016 bytes

Variable Size             343934848 bytes

Database Buffers           75497472 bytes

Redo Buffers                4251648 bytes

Database mounted.

Database opened.

 

SQL> create spfile from pfile;

File created.

 

SQL> shutdown immediate

Database closed.

Database dismounted.

ORACLE instance shut down.

 

SQL> startup

ORACLE instance started.

Total System Global Area  425897984 bytes

Fixed Size                  2214016 bytes

Variable Size             343934848 bytes

Database Buffers           75497472 bytes

Redo Buffers                4251648 bytes

Database mounted.

Database opened.

 

SQL> select open_mode,switchover_status,database_role from v$database;

OPEN_MODE          SWITCHOVER_STATUS    DATABASE_ROLE

--------------------         --------------------          ----------------

READ WRITE           NOT ALLOWED          PRIMARY

 

阅读(6763) | 评论(10) | 转发(2) |
给主人留下些什么吧!~~

lht11112013-03-12 11:25:56

lht1111:e.7  duplicate primary数据库

RMAN> connect auxiliary sys/XXXX@jmcentr2

connected to auxiliary database: JMCENTR (not mounted)

 

RMAN> duplicate target database for standby nofilenamecheck;
到这一步报错了
duplicate without target and catalog connections requires that backup location is specified

RMAN> duplicate target database for standby nofilenamecheck;

Starting Duplicate Db at 2013-03-11 22:59:12
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of Duplicate&n

回复 | 举报

lht11112013-03-12 11:25:14

e.7  duplicate primary数据库

RMAN> connect auxiliary sys/XXXX@jmcentr2

connected to auxiliary database: JMCENTR (not mounted)

 

RMAN> duplicate target database for standby nofilenamecheck;
到这一步报错了
duplicate without target and catalog connections requires that backup location is specified

lht11112013-03-08 13:58:51

终于让我找到一个完整的教程了。待我来亲自测试下

坏坏小丸子2012-05-17 21:25:50

e.11.3 修改primary和standby的初始化参数log_archive_dest_2

娃哈哈8752012-05-16 21:28:21

呵呵,很不错嘛~顶一个吧