CentOS 5.11下Oracle 11G R2 DataGuard搭建(2)


并拷贝一个作为备机db2的启动参数文件
[oracle@db1 ~]$ cp /tmp/member.pfile /tmp/db2.pfile
[oracle@db1 ~]$ vim /tmp/db2.pfile
则将上面增加的部分修改为
*.db_unique_name='db2'
*.archive_lag_target=1800
*.fal_client='db2'
*.fal_server='db1'
*.log_archive_config='DG_CONFIG=(db1,db2)'
*.log_archive_dest_1='location=/opt/oracle/flash_recovery_area/ VALID_FOR=(all_logfiles,all_roles) db_unique_name=db2'
*.log_archive_dest_2='service=db1 lgwr async valid_for=(online_logfiles,primary_role) db_unique_name=db1'
*.log_archive_dest_state_1='enable'
*.log_archive_dest_state_2='enable'
*.log_archive_format='%t_%s_%r.dbf'
*.standby_file_management='auto'
*.db_file_name_convert='/opt/oracle/flash_recovery_area',' /opt/oracle/flash_recovery_area'
*.log_file_name_convert='/opt/oracle/flash_recovery_area ','/opt/oracle/flash_recovery_area'


在db1上以修改过的/tmp/member.pfile启动
(db1)SQL >shutdown immediate;
(db1)SQL> startup pfile='/tmp/member.pfile' nomount;
(db1)SQL> create spfile from pfile='/tmp/member.pfile';
(db1)SQL >shutdown immediate;
(db1)SQL> startup;


4.主库密码文件:
[1]存在密码文件
[oracle@db1 dbs]$ ls $ORACLE_HOME/dbs
hc_DBUA0.dat  hc_member.dat  init.ora  lkDB1  lkMEMBER  orapwmember  spfilemember.ora
看到上面有一个密码文件orapwmember,在建库的时候默认会创建一个
=================================================================================
[2]不存在密码文件
如果没有的话可以手动创建一个。
[oracle@db1 dbs]$ cd $ORACLE_HOME/dbs
[oracle@db1 dbs]$ orapwd file=orapwmember password=123456 entries=3
#注意以上需要根据SID名建立的,file=orapwSID
===================================================================================


5.修改监听
[oracle@db1 dbs]$ cd $ORACLE_HOME/network/admin
[oracle@db1 admin]$ mv listener.ora listener.ora.default
[oracle@db1 admin]$ vim listener.ora
LISTENER =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = db1)(PORT = 1521))
  )
 
SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (GLOBAL_DBNAME = member)
      (ORACLE_HOME = /opt/oracle/product/11.2.0/db_1)
      (SID_NAME = member)
    )
  )
#注意以上的HOST,就是HOSTNAME
[oracle@db1 admin]$ vim tnsnames.ora
MEMBER =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = localhost.localdomain)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = member)
    )
  )
db1 =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = db1)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = db1)
    )
  )
db2 =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = db2)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = db2)
    )
  )

重启下监听
[oracle@db1 admin]$ lsnrctl stop
[oracle@db1 admin]$ lsnrctl start

6.复制监听文件、参数文件、密码文件到备库
#注意一下我这边$ORACLE_HOME
[oracle@db1 ~]$ echo $ORACLE_HOME
/opt/oracle/product/11.2.0/db_1
#传输启动参数文件
[oracle@db1 ~]$ scp /tmp/db2.pfile db2:~
#传输密码文件
[oracle@db1 ~]$ scp /opt/oracle/product/11.2.0/db_1/dbs/orapwmember db2:/opt/oracle/product/11.2.0/db_1/dbs/orapwmember
#传输监听文件
[oracle@db1 ~]$ scp -r /opt/oracle/product/11.2.0/db_1/network/admin/{listener.ora,tnsnames.ora} db2:/opt/oracle/product/11.2.0/db_1/network/admin/


在db2上修改/opt/oracle/product/11.2.0/db_1/network/admin/listener.ora,将db1修改为db2
[oracle@db2 ~]$ vim /opt/oracle/product/11.2.0/db_1/network/admin/listener.ora
LISTENER =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = db2)(PORT = 1521))
  )
SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (GLOBAL_DBNAME = member)
      (ORACLE_HOME = /opt/oracle/product/11.2.0/db_1)
      (SID_NAME = member)
    )
  )
#只需要修改listener.ora即可,tnsnames.ora不需要动

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/aa696af0a864dc12dde30f3378078e3c.html