oracle dataguard install

############################
station 1(primary database)
#############################
IPADDR:192.168.1.4
ORACLE_HOME=/u01/oracle/product/10.2.0/db_1
ORACLE_SID=primary
db_unique_name=primary

############################
station 2(standby database)
###########################
IPADDR:192.168.1.8
ORACLE_HOME=/u01/oracle/product/10.2.0/db1
db_unique_name=standby


[主库部分]
#主库安装instance(archive log mode),备库只安装软件
#SQL>ALTER DATABASE FORCE LOGGING;
#创建密码文件,如果有就不用创建了
[ORACLE]#orpwd file=orapw$ORACLE_SID password=oracle entries=5


#主库生成pfile
SQL>create pfile from spfile;

#主库修改pfile文件
log_archive_dest_1='LOCATION=/u01/archive'
log_archive_dest_state_1=enable
log_archive_dest_2='SERVICE=standby'
log_archive_dest_state_2=enable
log_archive_start=true
#Specify the Oracle Net service name
fal_server=standby
fal_client=primary
db_unique_name=primary

SQL>create spfile from pfile;

#主库中创建备库control file
SQL>shutdown immediate
SQL>startup mount;
SQL>alter database create standby controlfile as
    '/u01/oradata/primary/standby.ctl'
SQL>alter database open;
SQL>shutdown immediate

#copy 主库的数据到备库中
1.oradata/*(data file,control file, redo file)
scp -r /u01/oradata 192.168.1.4:/u01/oradata

2.admin/*(bdump,cdump,adump)
scp -r /u01/admin 192.168.1.4:/u01

3.dbs/*(listener.ora initprimary.ora)


#备库中删除主库拷贝过来的控制文件
#将之前生成的standby.ctl 复制成三份控制文件保存

[备库部分]
#修改备库的pfile文件
log_archive_dest_1='LOCATION=/u01/archive'
log_archive_dest_state_1=enable
log_archive_dest_2='SERVICE=primary'
log_archive_dest_state_2=enable
log_archive_start=true
#此处的fal_server,fal_client的值是tnsnames.ora文件里面的值
fal_server=primary
fal_client=standby
db_unique_name=standby


测试
#启动主库
#启动备库listener

SQL>create spfile from pfile;
SQL>startup nomount;
SQL>alter database mount standby database;
SQL>select name,database_role from v$database;
NAME      DATABASE_ROLE
--------- ----------------
PRIMARY   PHYSICAL STANDBY

SQL>alter database recover managed standby database disconnect from session;

SQL>select sequence#,first_time,next_time from v$archived_log order by sequence#;

SQL>select sequence#,applied from v$archived_log order by sequence#;


################
primary database
listener.ora
#################
SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (SID_NAME = PLSExtProc)
      (ORACLE_HOME = /u01/oracle/product/10.2.0/db_1)
      (PROGRAM = extproc)
    )
    (SID_DESC =
      (SID_NAME = primary)
      (ORACLE_HOME = /u01/oracle/product/10.2.0/db_1)
      (SERVICE_NAME = primary)
    )
  )

LISTENER01 =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = primary)(PORT = 1521))
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
    )
  )
LISTENER02 =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = standby)(PORT = 1521))
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
    )
  )


################
primary database
tnsnames.ora
#################
PRIMARY =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.4)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = primary)
    )
  )

STANDBY =
  (DESCRIPTION =
    (ADDRESS_LIST =
       (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.8)(PORT = 1521))
    )
   (CONNECT_DATA =
      (SERVICE_NAME = primary)
   )
)

EXTPROC_CONNECTION_DATA =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
    )
    (CONNECT_DATA =
      (SID = PLSExtProc)
      (PRESENTATION = RO)
    )
  )

#######################
standby database
listener.ora
#######################
SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (SID_NAME = PLSExtProc)
      (ORACLE_HOME = /u01/oracle/product/10.2.0/db_1)
      (PROGRAM = extproc)
    )
    (SID_DESC =
      (SID_NAME = primary)
      (ORACLE_HOME = /u01/oracle/product/10.2.0/db_1)
      (SERVICE_NAME = primary)
    )
  )

LISTENER01 =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = primary)(PORT = 1521))
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
    )
  )
LISTENER02 =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = standby)(PORT = 1521))
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
    )
  )

################
primary database
tnsnames.ora
#################

PRIMARY =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.4)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = primary)
    )
  )

STANDBY =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.4)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = primary)
    )
  )

EXTPROC_CONNECTION_DATA =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
    )
    (CONNECT_DATA =
      (SID = PLSExtProc)
      (PRESENTATION = RO)
    )
  )

你可能感兴趣的:(oracle,sql,.net,SQL Server,软件测试)