首页 > 代码库 > linux下oracle11G DG搭建(三):环绕备库搭建操作

linux下oracle11G DG搭建(三):环绕备库搭建操作

linux下oracle11G DG搭建(三):环绕备库搭建操作


环境

名称

主库

备库

主机名

bjsrv

shsrv

软件版本号

RedHat Enterprise5.5、Oracle 11g 11.2.0.1

RedHat Enterprise5.5、Oracle 11g 11.2.0.1



三、环绕备库操作:

1、备库-改动初始化參数文件

$cd$ORACLE_HOME/dbs

$df -h


技术分享


$vi initshdb.ora

改动简要说明:

*.audit_file_dest=‘/u01/app/oracle/admin/sh/adump‘

//审计文件存放的路径

*.audit_trail=‘db‘

*.compatible=‘11.2.0.0.0‘

*.control_files=‘/u01/app/oracle/oradata/sh/sh_control01.ctl

*.db_block_size=8192

*.db_name=‘TestDB12‘

*.db_recovery_file_dest=‘/u01/app/oracle/fast_recovery_area‘

*.db_recovery_file_dest_size=4322230272

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

*.dispatchers=‘(PROTOCOL=TCP) (SERVICE=TestDB12XDB)‘//用于共享,删除

*.log_archive_format=‘arch_%t_%s_%r.log‘

*.memory_target=642006528

*.open_cursors=300

*.processes=150

*.remote_login_passwordfile=‘EXCLUSIVE‘

*.undo_tablespace=‘UNDOTBS1‘

 

DB_UNIQUE_NAME=shdb

LOG_ARCHIVE_CONFIG=‘DG_CONFIG=(bjdb,shdb)‘

 

LOG_ARCHIVE_DEST_1=

 ‘LOCATION=/dsk4/arch_sh

 VALID_FOR=(ALL_LOGFILES,ALL_ROLES)

 DB_UNIQUE_NAME=shdb‘

 

LOG_ARCHIVE_DEST_2=

 ‘SERVICE=bjdbASYNC             //应该是对方

 VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE)

 DB_UNIQUE_NAME=bjdb

 

LOG_ARCHIVE_DEST_STATE_1=ENABLE

LOG_ARCHIVE_DEST_STATE_2=ENABLE

 

LOG_ARCHIVE_MAX_PROCESSES=3

 

FAL_SERVER=bjdb

DB_FILE_NAME_CONVERT=‘/u01/app/oracle/oradata/TestDB12‘,‘/u01/app/oracle/oradata/sh‘                             //先对方,后自己

LOG_FILE_NAME_CONVERT=

 ‘/dsk1/oradata/bj‘,‘/dsk1/oradata/sh‘,‘/dsk2/oradata/bj‘,‘/dsk2/oradata/sh‘

STANDBY_FILE_MANAGEMENT=AUTO          //先对方,后自己

 

參考例子:

*.audit_file_dest=‘/u01/app/oracle/admin/sh/adump‘

*.audit_trail=‘db‘

*.compatible=‘11.2.0.0.0‘

*.control_files=‘/u01/app/oracle/oradata/sh/sh_control01.ctl

*.db_block_size=8192

*.db_name=‘TestDB12‘

*.db_recovery_file_dest=‘/u01/app/oracle/fast_recovery_area‘

*.db_recovery_file_dest_size=4322230272

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

*.log_archive_format=‘arch_%t_%s_%r.log‘

*.memory_target=642006528

*.open_cursors=300

*.processes=150

*.remote_login_passwordfile=‘EXCLUSIVE‘

*.undo_tablespace=‘UNDOTBS1‘

 

DB_UNIQUE_NAME=shdb

LOG_ARCHIVE_CONFIG=‘DG_CONFIG=(bjdb,shdb)‘

 

LOG_ARCHIVE_DEST_1=

 ‘LOCATION=/dsk4/arch_sh

 VALID_FOR=(ALL_LOGFILES,ALL_ROLES)

 DB_UNIQUE_NAME=shdb‘

 

LOG_ARCHIVE_DEST_2=

 ‘SERVICE=bjdbASYNC            

 VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE)

 DB_UNIQUE_NAME=bjdb

 

LOG_ARCHIVE_DEST_STATE_1=ENABLE

LOG_ARCHIVE_DEST_STATE_2=ENABLE

 

LOG_ARCHIVE_MAX_PROCESSES=3

 

FAL_SERVER=bjdb

DB_FILE_NAME_CONVERT=‘/u01/app/oracle/oradata/TestDB12‘,‘/u01/app/oracle/oradata/sh‘                               

LOG_FILE_NAME_CONVERT=

 ‘/dsk1/oradata/bj‘,‘/dsk1/oradata/sh‘,‘/dsk2/oradata/bj‘,‘/dsk2/oradata/sh‘

STANDBY_FILE_MANAGEMENT=AUTO         

2、主库-启备库前主库备份

备库启动之前。给主库做一个备份。

注意:DG下。养成在启动备库前为主库做备份的习惯。以供应对启动备库后产生的未知情况。

主库处于mount状态下:

SQL>selectstatus from v$instance;


技术分享


$mkdir/dsk4/backup

$rmantarget /


技术分享


RMAN> backupdatabase format ‘/dsk4/backup/%d_%s.bak‘;


技术分享


3、主库、备库-网络配置

主库下:

$ lsnrctlstart         //启动监听

$cd/u01/app/oracle/product/11.2.0/dbhome_1/network/admin

$ vilistener.ora

# listener.oraNetwork Configuration File: /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora

# Generated byOracle configuration tools.

 

LISTENER =

  (DESCRIPTION =

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

  )

 

ADR_BASE_LISTENER =/u01/app/oracle

$vi tnsnames.ora //手工创建tnsnames文件

# tnsnames.oraNetwork Configuration File:/u01/app/oracle/product/11.2.0/dbhome_1/network/admin/tnsnames.ora

# Generated byOracle configuration tools.

 

bjdb =

  (DESCRIPTION =

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

    (CONNECT_DATA =http://www.mamicode.com/

      (SERVER = DEDICATED)

      (SERVICE_NAME =bjdb)

    )

  )

 

shdb =

  (DESCRIPTION =

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

    (CONNECT_DATA =http://www.mamicode.com/

      (SERVER = DEDICATED)

      (SERVICE_NAME = shdb)

    )

  )

备库下:

$ lsnrctlstart        //启动监听

$cd/u01/app/oracle/product/11.2.0/dbhome_1/network/admin

$ vilistener.ora      //编辑监听

# listener.oraNetwork Configuration File: /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora

# Generated byOracle configuration tools.

 

LISTENER =

  (DESCRIPTION =

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

  )

 

ADR_BASE_LISTENER =/u01/app/oracle

 

$vi tnsnames.ora    //手工创建tnsnames文件

BJDB =

  (DESCRIPTION =

(ADDRESS_LIST =

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

    )

(CONNECT_DATA = http://www.mamicode.com/(SERVER = DEDICATED)

      (SERVICE_NAME = bjdb)

    )

  )

 SHDB =

  (DESCRIPTION =

(ADDRESS_LIST =

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

    )

(CONNECT_DATA = http://www.mamicode.com/(SERVER = DEDICATED)

      (SERVICE_NAME = shdb)

    )

  )

4、备库-网络測试:

$sqlplussys/oracle@bjdb as sysdba


技术分享


【补充】:oraclepassword改动

若oraclepassword未知。能够例如以下改动oraclepassword:

$cd /u01/app/oracle/product/11.2.0/dbhome_1/dbs

$orapwd file=orapwTestDB12 password=oracle entries=3 force=y

$scp orapwTestDB12 shsrv:$ORACLE_HOME/dbs/orapwshdb

//把主库改动完的password文件复制到备库中


技术分享


SQL>showparameter name


技术分享


主库监听状态:

$lsnrctlstatus


技术分享


备库监听状态:

$lsnrctlstatus


技术分享


測试主库是否能ping通备库

$ tnsping shdb


技术分享


备库启动实例

$exportORACLE_SID=shdb

//或改动.bash_profile

$sqlplus ‘/assysdba’

SQL>startupnomount;

SQL>showparameter pfile;             //备库使用pfile启动


技术分享



SQL>showparameter name            //看一下数据库參数是否正确


技术分享


SQL>showparameter archive            //查询一下归档设置是否正确


技术分享


技术分享


********************未完待续**************************

声明:
         原创作品,出自 “深蓝的blog” 博客。同意转载。转载时请务必注明出处(http://blog.csdn.net/huangyanlong)。

         关于涉及版权事宜,作者有权追究法律责任。



linux下oracle11G DG搭建(三):环绕备库搭建操作