大橙子网站建设,新征程启航

为企业提供网站建设、域名注册、服务器等服务

Oracle在一台机器上搭建dataguard

这两天找了台机器搭建dataguard。
1. 环境准备。
操作系统
[oracle ~]$ lsb_release -a 
LSB Version:    :base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch
Distributor ID: RedHatEnterpriseServer
Description:    Red Hat Enterprise Linux Server release 6.8 (Santiago)
Release:        6.8
Codename:       Santiago
数据库版本
SQL> select instance_name,version from v$instance;
INSTANCE_NAME    VERSION
---------------- -----------------
dgtest1          11.2.0.4.0
在机器上新建实例为dgtest1的数据库。
2. 主库上强记日志。
alter database force logging;
3. 给standby 数据库创建密码文件,由于是在一台机器上,可以直接将主库的密码文件copy 来用。
[oracle@bdev dbs]$ ls -l orapwdg*
-rw-r----- 1 oracle oinstall 1536 Oct 18 17:08 orapwdgtest1
-rw-r----- 1 oracle oinstall 1536 Oct 19 13:51 orapwdgtest2

4. 在主库创建pfile。
create pfile='/home/oracle/pfiledgtest1.ora' from spfile;

5.编辑pfiledgtest.ora文件。
[oracle ~]$ more pfiledgtest1.ora 
dgtest1.__db_cache_size=3338665984
dgtest1.__java_pool_size=67108864
dgtest1.__large_pool_size=83886080
dgtest1.__oracle_base='/ulic/app/oracle'#ORACLE_BASE set from environment
dgtest1.__pga_aggregate_target=2147483648
dgtest1.__sga_target=4294967296
dgtest1.__shared_io_pool_size=0
dgtest1.__shared_pool_size=771751936
dgtest1.__streams_pool_size=0
*.audit_file_dest='/ulic/app/oracle/admin/dgtest1/adump'
*.audit_trail='db'
*.compatible='11.2.0.4.0'
*.control_files='/ulic/oradata/dgtest1/control01.ctl','/ulic/app/oracle/fast_recovery_area/dgtest1/control02.ctl'
*.db_block_size=8192
*.db_domain=''
*.db_name='dgtest1'
*.db_recovery_file_dest='/ulic/app/oracle/fast_recovery_area'
*.db_recovery_file_dest_size=4385144832
*.diagnostic_dest='/ulic/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=dgtest1XDB)'
*.log_archive_format='%t_%s_%r.arc'
*.open_cursors=300
*.pga_aggregate_target=2147483648
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.sga_target=4294967296
*.undo_tablespace='UNDOTBS1'

#######需要添加的内容
DB_NAME=dgtest1
DB_UNIQUE_NAME=dgtest1
LOG_ARCHIVE_CONFIG='DG_CONFIG=(dgtest1,dgtest2)'
LOG_ARCHIVE_DEST_1=
 'LOCATION=/ulic/archivelog/dgtest1/
  VALID_FOR=(ALL_LOGFILES,ALL_ROLES)
  DB_UNIQUE_NAME=dgtest1'
LOG_ARCHIVE_DEST_2=
 'SERVICE=dgtest2 ARCH ASYNC NOAFFIRM
  VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) 
  DB_UNIQUE_NAME=dgtest2'
LOG_ARCHIVE_DEST_STATE_1=ENABLE
LOG_ARCHIVE_DEST_STATE_2=ENABLE
[oracle~]$ 

6. 修改完成后将主库起来
SQL> startup pfile='/home/oracle/pfiledgtest1.ora';
ORACLE instance started.
Total System Global Area 4275781632 bytes
Fixed Size                  2260088 bytes
Variable Size             939525000 bytes
Database Buffers         3321888768 bytes
Redo Buffers               12107776 bytes
Database mounted.
Database opened.
SQL>

7. 确定修改完pfile,数据库还能正常起来后将数据库给down下来。(这里用来给数据库做冷备)测试环境,所以能直接起停。

8. 创建standby数据库,在oradata目录下新建dgtest2目录。
[oracle@oradata]$ pwd
/ulic/oradata
[oracle@bdev oradata]$ ls -l
total 8
drwxr-x--- 2 oracle oinstall 4096 Oct 18 17:07 dgtest1
drwxr-xr-x 2 oracle oinstall 4096 Oct 19 11:10 dgtest2

9. 将dgtest1目录下的datafile和log复制到dgtest2目录下。
[oracle@bdev dgtest2]$ ls -l
total 1561220
-rw-r----- 1 oracle oinstall  52429312 Oct 19 13:53 redo01.log
-rw-r----- 1 oracle oinstall  52429312 Oct 19 13:53 redo02.log
-rw-r----- 1 oracle oinstall  52429312 Oct 19 13:53 redo03.log
-rw-r----- 1 oracle oinstall 555753472 Oct 19 14:19 sysaux01.dbf
-rw-r----- 1 oracle oinstall 775954432 Oct 19 14:19 system01.dbf
-rw-r----- 1 oracle oinstall  30416896 Oct 19 11:05 temp01.dbf
-rw-r----- 1 oracle oinstall  73408512 Oct 19 14:19 undotbs01.dbf
-rw-r----- 1 oracle oinstall   5251072 Oct 19 14:19 users01.dbf

10. 主库开库生成standby 控制文件,并copy到dgtest2目录下,并复制两份到control01.ctl, control02.ctl。
alter database create standby controlfile as '/ulic/oradata/dgtest2/control.std';
[oracle@dgtest2]$ ls -l 
total 1561220
-rw-r----- 1 oracle oinstall   9748480 Oct 19 15:48 control01.ctl
-rw-r----- 1 oracle oinstall   9748480 Oct 19 15:48 control02.ctl
-rw-r----- 1 oracle asmadmin   9748480 Oct 19 11:08 control.std
-rw-r----- 1 oracle oinstall  52429312 Oct 19 13:53 redo01.log
-rw-r----- 1 oracle oinstall  52429312 Oct 19 13:53 redo02.log
-rw-r----- 1 oracle oinstall  52429312 Oct 19 13:53 redo03.log
-rw-r----- 1 oracle oinstall 555753472 Oct 19 14:19 sysaux01.dbf
-rw-r----- 1 oracle oinstall 775954432 Oct 19 14:19 system01.dbf
-rw-r----- 1 oracle oinstall  30416896 Oct 19 11:05 temp01.dbf
-rw-r----- 1 oracle oinstall  73408512 Oct 19 14:19 undotbs01.dbf
-rw-r----- 1 oracle oinstall   5251072 Oct 19 14:19 users01.dbf

11. 复制一份pfiledgtest1.ora到pfiledgtest2.ora,并修改内容。
[oracle@~]$ more pfiledgtest2.ora
dgtest2.__db_cache_size=3338665984
dgtest2.__java_pool_size=67108864
dgtest2.__large_pool_size=83886080
dgtest2.__oracle_base='/ulic/app/oracle'#ORACLE_BASE set from environment
dgtest2.__pga_aggregate_target=2147483648
dgtest2.__sga_target=4294967296
dgtest2.__shared_io_pool_size=0
dgtest2.__shared_pool_size=771751936
dgtest2.__streams_pool_size=0
*.audit_file_dest='/ulic/app/oracle/admin/dgtest2/adump'
*.audit_trail='db'
*.compatible='11.2.0.4.0'
*.control_files='/ulic/oradata/dgtest2/control01.ctl','/ulic/oradata/dgtest2/control02.ctl'
*.db_block_size=8192
*.db_domain=''
*.db_recovery_file_dest='/ulic/app/oracle/fast_recovery_area'
*.db_recovery_file_dest_size=4385144832
*.diagnostic_dest='/ulic/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=dgtest2XDB)'
*.log_archive_format='%t_%s_%r.arc'
*.open_cursors=300
*.pga_aggregate_target=2147483648
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.sga_target=4294967296
*.undo_tablespace='UNDOTBS1'


DB_NAME=dgtest1
DB_UNIQUE_NAME=dgtest2
LOG_ARCHIVE_CONFIG='DG_CONFIG=(dgtest1,dgtest2)'
LOG_ARCHIVE_DEST_1=
 'LOCATION=/ulic/archivelog/dgtest2/
  VALID_FOR=(ALL_LOGFILES,ALL_ROLES)
  DB_UNIQUE_NAME=dgtest2'
LOG_ARCHIVE_DEST_STATE_1=ENABLE


FAL_SERVER=dgtest1
FAL_CLIENT=dgtest2
DB_FILE_NAME_CONVERT='/ulic/oradata/dgtest1','/ulic/oradata/dgtest2'
LOG_FILE_NAME_CONVERT='/ulic/oradata/dgtest1','/ulic/oradata/dgtest2' 
STANDBY_FILE_MANAGEMENT=AUTO

12. 配置监听。
DGTEST1 =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = bdev)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = dgtest1)
    )
  )
DGTEST2 =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 10.18.1.123)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = dgtest2)
    )
  )

13.启动备库到mount状态。
SQL> startup mount pfile='/home/oracle/pfiledgtest2.ora';
ORACLE instance started.
Total System Global Area 4275781632 bytes
Fixed Size                  2260088 bytes
Variable Size             939525000 bytes
Database Buffers         3321888768 bytes
Redo Buffers               12107776 bytes
Database mounted.
查看备库身份
SQL> select database_role from v$database;
DATABASE_ROLE
----------------
PHYSICAL STANDBY
查看主库身份
SQL> select database_role from v$database;
DATABASE_ROLE
----------------
PRIMARY
14. 从库进行standby recover开始应用日志。
alter database recover managed standby database disconnect from session;
15.切换日志验证是否能正常传输。







当前标题:Oracle在一台机器上搭建dataguard
URL网址:http://dzwzjz.com/article/jegchi.html
在线咨询
服务热线
服务热线:028-86922220
TOP