Oracle 11R2+RAC+DG安装记录

一、安装规划

 

1、硬件环境

主机 CPU 内存 存储 网卡

dg1 24  Intel(R) Xeon(R) CPU           E7450  @ 2.40GHz    16G /           29G 

/dev/shm    13G  

/boot       194M

/u01        90G   

/rmanbak    3.9T  

    Eth0

Eth1

dg2 24  Intel(R) Xeon(R) CPU           E7450  @ 2.40GHz    16G /           29G 

/dev/shm    13G  

/boot       194M

/u01        90G   Eth0

Eth1

 

2、软件环境

Red Hat Enterprise Linux Server release 6.4 (Santiago)

Oracle 11g Database Release 2 

Oracle 11g Grid Release 2

 

3、IP地址规划

主机 IP地址       别名  用途

dg1    10.1.1.65 dg1 公共ip

       10.1.1.51 dg1-vip 虚拟ip

       11.1.1.1      dg1-priv    内部通讯(心跳)

dg2    10.1.1.66 dg2 公共ip

       10.1.1.52 dg2-vip 虚拟ip

       11.1.1.2      dg2-priv 内部通讯(心跳)

scan   10.1.1.50 scan    数据库全局接入

 

4、共享存储分配

用途 DG名称   说明 设备路径(需现场填写)

OCR/VOTE盘  OCR 20G     /dev/mapper/sharedisk1

LOG日志盘    LOG 1800G   /dev/mapper/sharedisk2

DATA数据盘   DATA    1900G   /dev/mapper/sharedisk3

 

 

二、主库配置

 

1、参数文件修改

SQL> create pfile from spfile;

File created.

SQL> alter database force logging;

Database altered.

SQL> alter system set db_unique_name='orcl' scope=spfile;

System altered.

SQL> alter system set log_archive_config='DG_CONFIG=(orcl,orcldg)';

System altered.

SQL> alter system set log_archive_dest_1='LOCATION=+LOG valid_for=(all_logfiles,all_roles) db_unique_name=orcl' scope=spfile;

System altered.

SQL> alter system set log_archive_dest_2='SERVICE=orcldg lgwr sync valid_for=(online_logfiles,primary_roles) db_unique_name=orcldg';

System altered.

SQL> alter system set fal_client='orcl';

System altered.

SQL> alter system set fal_server='orcldg';

System altered.

SQL> alter system set standby_file_management=auto;

System altered.

 

SQL> shutdown immediate

SQL> startup

 

修改后参数文件如下:

[oracle@rac1 dbs]$ cat pfile0906pb.ora

orcl1.__db_cache_size=37849399296

orcl3.__db_cache_size=33017561088

orcl2.__db_cache_size=32480690176

orcl4.__db_cache_size=29259464704

orcl3.__java_pool_size=1879048192

orcl1.__java_pool_size=1879048192

orcl4.__java_pool_size=1879048192

orcl2.__java_pool_size=1879048192

orcl1.__large_pool_size=2147483648

orcl3.__large_pool_size=2147483648

orcl4.__large_pool_size=2147483648

orcl2.__large_pool_size=2147483648

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

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

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

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

orcl3.__pga_aggregate_target=32480690176

orcl1.__pga_aggregate_target=28454158336

orcl2.__pga_aggregate_target=32749125632

orcl4.__pga_aggregate_target=34896609280

orcl3.__sga_target=48855252992

orcl1.__sga_target=52881784832

orcl2.__sga_target=48586817536

orcl4.__sga_target=46439333888

orcl3.__shared_io_pool_size=0

orcl1.__shared_io_pool_size=0

orcl4.__shared_io_pool_size=0

orcl2.__shared_io_pool_size=0

orcl4.__shared_pool_size=12616466432

orcl1.__shared_pool_size=10468982784

orcl3.__shared_pool_size=11274289152

orcl2.__shared_pool_size=11542724608

orcl3.__streams_pool_size=0

orcl1.__streams_pool_size=0

orcl4.__streams_pool_size=0

orcl2.__streams_pool_size=0

*.audit_file_dest='/u01/app/oracle/admin/orcl/adump'

*.audit_trail='NONE'

*.cluster_database=true

*.compatible='11.2.0.4.0'

*.control_files='+DATA/orcl/controlfile/current.260.921272105','+LOG/orcl/controlfile/current.256.921272105'

*.db_block_size=8192

*.db_create_file_dest='+DATA'

*.db_domain=''

*.db_file_name_convert='+DATA/orcldg/','+DATA/orcl/'

*.db_name='orcl'

*.db_recovery_file_dest='+LOG'

*.db_recovery_file_dest_size=1048576000000

*.db_unique_name='orcl'

*.deferred_segment_creation=FALSE

*.diagnostic_dest='/u01/app/oracle'

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

*.fal_client='orcl'

*.fal_server='orcldg1','orcldg2'

orcl1.instance_number=1

orcl2.instance_number=2

orcl3.instance_number=3

orcl4.instance_number=4

*.log_archive_config='DG_CONFIG=(orcl,orcldg)'

*.log_archive_dest_1='LOCATION=+LOG valid_for=(all_logfiles,all_roles) db_unique_name=orcl'

*.log_archive_dest_2='SERVICE=orcldg lgwr sync valid_for=(online_logfiles,primary_roles) db_unique_name=orcldg'

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

*.log_file_name_convert='+LOG/orcldg/','+LOG/orcl/'

*.memory_target=81180753920

*.open_cursors=300

*.processes=5000

*.remote_listener='scan:1521'

*.remote_login_passwordfile='exclusive'

*.sec_case_sensitive_logon=FALSE

*.sessions=3305

*.standby_file_management='AUTO'

orcl2.thread=2

orcl3.thread=3

orcl4.thread=4

orcl1.thread=1

orcl3.undo_tablespace='UNDOTBS3'

orcl1.undo_tablespace='UNDOTBS1'

orcl2.undo_tablespace='UNDOTBS2'

orcl4.undo_tablespace='UNDOTBS4'

 

 

三、备库的配置

1、装好RAC集群grid

注意的是groupdisk和原来一样

 

2、装好数据库软件

这个没有特殊要求

 

3、安装一个实例

实例名是ORCLDG,其他设置随意,主要为了得到spfile的模板和建好目录。

 

4、配置备库的spfile

先得到模板的pfile,并修改

[oracle@dg1 dbs]$ cat pfile0906.ora

orcldg2.__db_cache_size=4093640704

orcldg1.__db_cache_size=4194304000

orcldg2.__java_pool_size=201326592

orcldg1.__java_pool_size=201326592

orcldg1.__large_pool_size=134217728

orcldg2.__large_pool_size=234881024

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

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

orcldg2.__pga_aggregate_target=4026531840

orcldg1.__pga_aggregate_target=4026531840

orcldg2.__sga_target=6039797760

orcldg1.__sga_target=6039797760

orcldg2.__shared_io_pool_size=0

orcldg1.__shared_io_pool_size=0

orcldg2.__shared_pool_size=1442840576

orcldg1.__shared_pool_size=1442840576

orcldg2.__streams_pool_size=0

orcldg1.__streams_pool_size=0

*.audit_file_dest='/u01/app/oracle/admin/orcldg/adump'

*.audit_trail='NONE'

*.cluster_database=true

*.compatible='11.2.0.4.0'

*.control_files='+DATA/orcldg/controlfile/current.292.953920965','+LOG/orcldg/controlfile/current.281.953920965'#Set by RMAN

*.db_block_size=8192

*.db_create_file_dest='+DATA'

*.db_domain=''

*.db_file_name_convert='+DATA/orcl/','+DATA/orcldg/'

*.db_name='orcl'

*.db_recovery_file_dest='+LOG'

*.db_recovery_file_dest_size=462107443200

*.db_unique_name='orcldg'

*.deferred_segment_creation=FALSE

*.diagnostic_dest='/u01/app/oracle'

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

*.fal_client='orcldg'

*.fal_server='orcl1','orcl2','orcl3','orcl4'

orcldg2.instance_number=2

orcldg1.instance_number=1

*.log_archive_config='DG_CONFIG=(orcl,orcldg)'

*.log_archive_dest_1='LOCATION=+LOG valid_for=(all_logfiles,all_roles) db_unique_name=orcldg'

*.log_archive_dest_2='SERVICE=orcl lgwr sync valid_for=(online_logfiles,primary_roles) db_unique_name=orcl'

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

*.log_file_name_convert='+LOG/orcl/','+LOG/orcldg/'

*.memory_target=10066329600

*.open_cursors=300

*.processes=1500

*.remote_listener='scan:1521'

*.remote_login_passwordfile='exclusive'

*.sec_case_sensitive_logon=FALSE

*.sessions=1655

*.standby_file_management='AUTO'

orcldg2.thread=2

orcldg1.thread=1

orcldg2.undo_tablespace='UNDOTBS2'

orcldg1.undo_tablespace='UNDOTBS1'

SQL> shutdown immediate

SQL> create spfile='+DATA/orcldg/spfileorcl.ora' from pfile='$ORACLE_HOME/dbs/pfile0906.ora';

 

5、统一密码文件

在两个节点执行这个语句,password和主库一直,可以直接复制过来,文件名是orapworcl1和orapworcl2

主库备库每个节点都添加一个orapwdorcl

 

6、修改监听文件

[grid@dg1 admin]$ ls

endpoints_listener.ora      listener.ora          samples     sqlnet.ora

listener17090410AM5705.bak  listener.ora.bak.dg1  shrept.lst

[grid@dg1 admin]$ cat listener.ora

LISTENER=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER))))   # line added by Agent

LISTENER_SCAN1=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER_SCAN1))))                # line added by Agent

ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER_SCAN1=ON                # line added by Agent

ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER=ON              # line added by Agent

SID_LIST_LISTENER =

  (SID_LIST =

    (SID_DESC =

      (GLOBAL_DBNAME = orcldg)

        (ORACLE_HOME = /u01/app/oracle/product/11.2.0/db_1)

        (SID_NAME = orcldg1)

    )

  )

[grid@dg2 admin]$ cat listener.ora

LISTENER=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER))))   # line added by Agent

LISTENER_SCAN1=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER_SCAN1))))                # line added by Agent

ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER_SCAN1=ON                # line added by Agent

ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER=ON              # line added by Agent

SID_LIST_LISTENER =

  (SID_LIST =

    (SID_DESC =

      (GLOBAL_DBNAME = orcldg)

        (ORACLE_HOME = /u01/app/oracle/product/11.2.0/db_1)

        (SID_NAME = orcldg2)

    )

  )

7、修改tnsnames.ora

[oracle@dg1 admin]$ cat tnsnames.ora

# tnsnames.ora Network Configuration File: /u01/app/oracle/product/11.2.0/db_1/network/admin/tnsnames.ora

# Generated by Oracle configuration tools.

ORCLSCAN =

  (DESCRIPTION =

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

    (CONNECT_DATA =

      (SERVER = DEDICATED)

      (SERVICE_NAME = orcl)

    )

  )

ZFDXC =

  (DESCRIPTION =

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

    (CONNECT_DATA =

      (SERVER = DEDICATED)

      (SERVICE_NAME = zfdxc)

    )

  )

ORCL =

  (DESCRIPTION =

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

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

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

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

    (CONNECT_DATA =

      (SERVER = DEDICATED)

      (SERVICE_NAME = orcl)

    )

  )

 

ORCL1 =

  (DESCRIPTION =

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

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

    (CONNECT_DATA =

      (SERVER = DEDICATED)

      (SERVICE_NAME = orcl)

    )

  )

ORCL2 =

  (DESCRIPTION =

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

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

    (CONNECT_DATA =

      (SERVER = DEDICATED)

      (SERVICE_NAME = orcl)

    )

  )

  

ORCL3 =

  (DESCRIPTION =

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

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

    (CONNECT_DATA =

      (SERVER = DEDICATED)

      (SERVICE_NAME = orcl)

    )

  )

 

ORCL4 =

  (DESCRIPTION =

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

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

    (CONNECT_DATA =

      (SERVER = DEDICATED)

      (SERVICE_NAME = orcl)

    )

  )

  

ORCLDG =

  (DESCRIPTION =

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

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

    (CONNECT_DATA =

      (SERVER = DEDICATED)

      (SERVICE_NAME = orcldg)

    )

  )

 

ORCLDG1 =

  (DESCRIPTION =

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

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

    (CONNECT_DATA =

      (SERVER = DEDICATED)

      (SERVICE_NAME = orcldg)

    )

  )

 

ORCLDG2 =

  (DESCRIPTION =

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

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

    (CONNECT_DATA =

      (SERVER = DEDICATED)

      (SERVICE_NAME = orcldg)

    )

  )

主备库的所有tnsnames.ora都是这个文件

 

8、利用duplicate同步库

[oracle@dg1 dbs]$ rman target sys/ORACLE_ORCL@orcl auxiliary sys/ORACLE_ORCL@orcldg

RMAN> duplicate target database for standby nofilenamecheck from active database;

 

9、创建standby redo文件

alter database add standby logfile thread 1 group 11 ('+DATA/ORCLDG/ONLINELOG/standby11.log','+LOG/ORCLDG/ONLINELOG/standby11.log') size 1000m;

alter database add standby logfile thread 1 group 12 ('+DATA/ORCLDG/ONLINELOG/standby12.log','+LOG/ORCLDG/ONLINELOG/standby12.log') size 1000m;

alter database add standby logfile thread 1 group 13 ('+DATA/ORCLDG/ONLINELOG/standby13.log','+LOG/ORCLDG/ONLINELOG/standby13.log') size 1000m;

alter database add standby logfile thread 2 group 14 ('+DATA/ORCLDG/ONLINELOG/standby14.log','+LOG/ORCLDG/ONLINELOG/standby14.log') size 1000m;

alter database add standby logfile thread 2 group 15 ('+DATA/ORCLDG/ONLINELOG/standby15.log','+LOG/ORCLDG/ONLINELOG/standby15.log') size 1000m;

alter database add standby logfile thread 2 group 16 ('+DATA/ORCLDG/ONLINELOG/standby16.log','+LOG/ORCLDG/ONLINELOG/standby16.log') size 1000m;

alter database add standby logfile thread 3 group 17 ('+DATA/ORCLDG/ONLINELOG/standby17.log','+LOG/ORCLDG/ONLINELOG/standby17.log') size 1000m;

alter database add standby logfile thread 3 group 18 ('+DATA/ORCLDG/ONLINELOG/standby18.log','+LOG/ORCLDG/ONLINELOG/standby18.log') size 1000m;

alter database add standby logfile thread 3 group 19 ('+DATA/ORCLDG/ONLINELOG/standby19.log','+LOG/ORCLDG/ONLINELOG/standby19.log') size 1000m;

alter database add standby logfile thread 4 group 20 ('+DATA/ORCLDG/ONLINELOG/standby20.log','+LOG/ORCLDG/ONLINELOG/standby20.log') size 1000m;

alter database add standby logfile thread 4 group 21 ('+DATA/ORCLDG/ONLINELOG/standby21.log','+LOG/ORCLDG/ONLINELOG/standby21.log') size 1000m;

alter database add standby logfile thread 4 group 22 ('+DATA/ORCLDG/ONLINELOG/standby22.log','+LOG/ORCLDG/ONLINELOG/standby22.log') size 1000m;

 

10、在主库创建standby redo日志,以便主备切换

alter database add standby logfile thread 1 group 11 ('+DATA/ORCL/ONLINELOG/standby11.log','+LOG/ORCL/ONLINELOG/standby11.log') size 1000m;

alter database add standby logfile thread 1 group 12 ('+DATA/ORCL/ONLINELOG/standby12.log','+LOG/ORCL/ONLINELOG/standby12.log') size 1000m;

alter database add standby logfile thread 1 group 13 ('+DATA/ORCL/ONLINELOG/standby13.log','+LOG/ORCL/ONLINELOG/standby13.log') size 1000m;

alter database add standby logfile thread 2 group 14 ('+DATA/ORCL/ONLINELOG/standby14.log','+LOG/ORCL/ONLINELOG/standby14.log') size 1000m;

alter database add standby logfile thread 2 group 15 ('+DATA/ORCL/ONLINELOG/standby15.log','+LOG/ORCL/ONLINELOG/standby15.log') size 1000m;

alter database add standby logfile thread 2 group 16 ('+DATA/ORCL/ONLINELOG/standby16.log','+LOG/ORCL/ONLINELOG/standby16.log') size 1000m;

alter database add standby logfile thread 3 group 17 ('+DATA/ORCL/ONLINELOG/standby17.log','+LOG/ORCL/ONLINELOG/standby17.log') size 1000m;

alter database add standby logfile thread 3 group 18 ('+DATA/ORCL/ONLINELOG/standby18.log','+LOG/ORCL/ONLINELOG/standby18.log') size 1000m;

alter database add standby logfile thread 3 group 19 ('+DATA/ORCL/ONLINELOG/standby19.log','+LOG/ORCL/ONLINELOG/standby19.log') size 1000m;

alter database add standby logfile thread 4 group 20 ('+DATA/ORCL/ONLINELOG/standby20.log','+LOG/ORCL/ONLINELOG/standby20.log') size 1000m;

alter database add standby logfile thread 4 group 21 ('+DATA/ORCL/ONLINELOG/standby21.log','+LOG/ORCL/ONLINELOG/standby21.log') size 1000m;

alter database add standby logfile thread 4 group 22 ('+DATA/ORCL/ONLINELOG/standby22.log','+LOG/ORCL/ONLINELOG/standby22.log') size 1000m;

 

四、主备库切换

 

1、主备切换,RAC主备切换需要停止实例到只有一台启动

主库节点2:[grid@rac2 ~]$ srvctl stop instance -d orcl -i orcl2

主库节点3:[grid@rac3 ~]$ srvctl stop instance -d orcl -i orcl3

主库节点4:[grid@rac4 ~]$ srvctl stop instance -d orcl -i orcl4

备库节点2:[grid@dg2 ~]$ srvctl stop instance -d orcldg -i orcldg2

 

2、主库切换

[grid@rac1 ~]$ lsnrctl stop listener

SQL> alter database commit to switchover to physical standby with session shutdown;

startup

alter database recover managed standby database using current logfile disconnect from session;

[grid@rac1 ~]$ lsnrctl start listener

 

3、备库切换

[grid@dg1 ~]$ lsnrctl stop listener

SQL> alter database recover managed standby database cancel;

SQL> alter database commit to switchover to primary with session shutdown;

SQL> alter database open;

[grid@dg1 ~]$ lsnrctl start listener

 

4、启动所有服务器

主库节点2:[grid@rac2 ~]$ srvctl start instance -d orcl -i orcl2

主库节点3:[grid@rac3 ~]$ srvctl start instance -d orcl -i orcl3

主库节点4:[grid@rac4 ~]$ srvctl start instance -d orcl -i orcl4

备库节点2:[grid@dg2 ~]$ srvctl start instance -d orcldg -i orcldg2

你可能感兴趣的:(Oracle,日常管理)