Physical Volume uard dummies practice I. Environment 1. Virtual Machine connection method for Environment preparation: Pay attention to virtual machine net connection method, and click edit to view the Virtual Machine network segment operating system: red Hat Enterprise Linux Server release 5.1 (Tikanga) master database address: 192.168.220.3 -- virtual machine, install database backup database address: 192.168.220.4 -- virtual machine, no database is installed, only install software check database version must be consistent: select * from v $ version; BANNER ---------------------------------------------------------------- Oracle Database 10g Enterprise Edition Release 10.2.0.1.0-ProdPL/SQL Release 10.2.0.1.0-ProductionCORE 10. 2.0.1.0 ProductionTNS for Linux: Version 10.2.0.1.0-ProductionNLSRTL Version 10.2.0.1.0-Production check that db_name and sid must be consistent with select instance_name from v $ instance; INSTANCE_NAME ---------------- orclSQL> show parameter db_name name type value ------------- mongodb_name string ice 2. master database configuration 1. open database, SQL> alter database force logging; 2. Confirm Archiving: SQL> archive Log list; Database log mode archive mode automatic archiving enable the oldest online log sequence 6 next archive log sequence 10 current log sequence 103, modify master database tnsnames (add slave Database Service name to modify only ip address, the database name is consistent with the master database) # tnsnames. ora Network Configuration File:/home/app/oracle10/product/10.2.0.1/network/admin/tnsnames. ora # Generated by Oracle configuration tools. orcl = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP) (HOST = 192.168.220.3) (PORT = 1521) (CONNECT_DATA = (SERVICE_NAME = orcl) orcl2204 = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP) (HOST = 192.168.220.4) (PORT = 1521) (CONNECT_DATA = (SERVICE_NAME = orcl ))) EXTPROC_CONNECTION_DATA = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = IPC) (KEY = EXTPROC0) (CONNECT_DATA = (SID = PLSExtProc) (PRESENTATION = RO ))) 4. listener Configuration: # listener. ora Network Configuration File:/home/app/oracle10/product/10.2.0.1/network/ad Min/listener. ora # Generated by Oracle configuration tools. SID_LIST_LISTENER = (SID_LIST = (SID_DESC = (SID_NAME = PLSExtProc) (ORACLE_HOME =/home/app/oracle10/product/10.2.0.1) (PROGRAM = extproc )) (SID_DESC = (SID_NAME = orcl) (ORACLE_HOME =/home/app/oracle10/product/10.2.0.1) LISTENER = (DESCRIPTION_LIST = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP) (HOST = 192.168.220.3) (PORT = 1521) (AD DRESS = (PROTOCOL = IPC) (KEY = EXTPROC0) 5. test whether the master database can be connected to the VM. Note that the connection mode is VM net, and click edit, view the Virtual Machine network segment. ip address of this virtual machine: 192.168.220.3 [oracle @ localhost ~] $ Sqlplus/nolog SQL * Plus: Release 10.2.0.1.0-Production on Fri May 3 08:24:19 2013 Copyright (c) 1982,200 5, Oracle. all rights reserved. SQL> conn system/orcl @ orcl1Connected. 6. Create pfile -- the master database SQL> conn sys/orcl @ orcl1 as sysdba is connected. SQL> create pfile = '/home/app/oracle10/initorcl. ora' from spfile; the file has been created. 7. Modify the parameter file: [oracle @ localhost dbs] $ cat initorcl. oraorcl. _ db_cache_size = 92274688orcl. _ java_pool_size = 4192134orcl. _ large_pool_size = 4192134orcl. _ shared_pool_size = 62914560orcl. _ streams_pool_size = 0 *. audit_file_dest = '/home/app/oracle10/admin/ice/adump '*. background_dump_dest = '/home/app/oracle10/admin/ice/bdump '*. compatible = '10. 2.0.1.0 '*. control_files = '/home/app/oracle10/oradata/ice/control01.ctl', '/ho Me/app/oracle10/oradata/ice/control02.ctl ','/home/app/oracle10/oradata/ice/control03.ctl '*. core_dump_dest = '/home/app/oracle10/admin/ice/cdump '*. db_block_size = 8192 *. db_domain = 'orcl '*. db_file_multiblock_read_count = 16 *. db_name = 'ice '*. db_recovery_file_dest = '/home/app/oracle10/flash_recovery_area '*. db_recovery_file_dest_size = 2147483648 *. dispatchers = '(PROTOCOL = TCP) (SERVICE = orclXDB )'*. job_queue_processe S = 10 *. open_cursors = 300 *. pga_aggregate_target = 16777216 *. processes = 150 *. remote_login_passwordfile = 'clusive '*. sga_target = 167772160 *. undo_management = 'auto '*. undo_tablespace = 'undotbs1 '*. user_dump_dest = '/home/app/oracle10/admin/ice/udump '*. LOG_ARCHIVE_CONFIG = 'dg _ CONFIG = (orcl, orcl2204) 'log _ archive_dest_1 = 'location =/home/app/oracle10/archive01 VALID_FOR = (ALL_LOGFILES, ALL_ROLES) DB_UNIQUE_NAME = orcl 'Log _ Archive_dest_state_1 = enablelog_archive_dest_2 = 'service = orcl2204 lgwr async = 40960 VALID_FOR = (ONLINE_LOGFILES, PRIMARY_ROLE) DB_UNIQUE_NAME = orcl2204 'Log _ archive_dest_state_2 = enablelog_archive_start = truelog_archive_format = '% t _ % s _ % r. arc 'Log _ clients = 2fal_server = orcl2204fal_client = orcldb_unique_name = orcl8, create a password file-master database orapwd file =/home/app/oracle10/orapworcl password = oracle entries = 5 9, start master database to mo Unt, create control file SQL> startup mountORA-32004: the obsolete and/or deprecated parameter (s) specifiedORACLE routine has started. Total System Global Area 612368384 bytesFixed Size 1292036 bytesVariable Size 411044092 bytesDatabase Buffers 192937984 bytesRedo Buffers 7094272 bytes database loaded. SQL> alter database create standby controlfile as '/home/app/oracle10/oradata/ice/standby. ctl'; the database has been changed. SQL> alter database open; the database has been changed. SQL> shutdown immediate; the database has been closed. The database has been detached. The ORACLE routine has been disabled. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~ The above master database configuration is complete !!!!!!!!!!! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~ 3. Configure the slave database to copy the master database file to the slave database, and modify the parameter file [root @ localhost ~] # Service vsftpd restart with oracle Account Login slave database 1 upload oradata directory scp-r root@192.168.220.3: /home/app/oracle10/oradata/ice/*/home/app/oracle10/oradata/ice2 upload the root@192.168.220.3 of the admim directory scp-r: /home/app/oracle10/admin/ice/*/home/app/oracle10/admin/ice3 upload the created password file and parameter file to the dbs directory of the standby database. 4. Control File rename standby. 3 copies of ctl, renamed as control01.ctl, control02, control035, listener: # listener. ora Network Configuration File:/home/app/oracle10/product/10. 2.0.1/network/admin/listener. ora # Generated by Oracle configuration tools. SID_LIST_LISTENER = (SID_LIST = (SID_DESC = (SID_NAME = PLSExtProc) (ORACLE_HOME =/home/app/oracle10/product/10.2.0.1) (PROGRAM = extproc )) (SID_DESC = (SID_NAME = orcl) (ORACLE_HOME =/home/app/oracle10/product/10.2.0.1) LISTENER = (DESCRIPTION_LIST = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP) (HOST = 192.168.220.4 )( PORT = 1521) (ADDRESS = (PROTOCOL = IPC) (KEY = EXTPROC0) 6. tnsnames: ORCL = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP) (HOST = 192.168.220.3) (PORT = 1521) (CONNECT_DATA = (SERVICE_NAME = orcl ))) orcl2204 = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP) (HOST = 192.168.220.4) (PORT = 1521) (CONNECT_DATA = (SERVICE_NAME = orcl ))) 7. Modify the pfile file of the standby database. [oracle @ loc] Alhost admin] $ cd/home/app/oracle10/product/10.2.0.1/dbs [oracle @ localhost dbs] $ cat initorcl. ora orcl. _ db_cache_size = 92274688orcl. _ java_pool_size = 4192134orcl. _ large_pool_size = 4192134orcl. _ shared_pool_size = 62914560orcl. _ streams_pool_size = 0 *. audit_file_dest = '/home/app/oracle10/admin/ice/adump '*. background_dump_dest = '/home/app/oracle10/admin/ice/bdump '*. compatible = '10. 2.0.1.0 '*. control_files = '/ Home/app/oracle10/oradata/ice/control01.ctl ','/home/app/oracle10/oradata/ice/control02.ctl ', '/home/app/oracle10/oradata/ice/control03.ctl '*. core_dump_dest = '/home/app/oracle10/admin/ice/cdump '*. db_block_size = 8192 *. db_domain = 'orcl '*. db_file_multiblock_read_count = 16 *. db_name = 'ice '*. db_recovery_file_dest = '/home/app/oracle10/flash_recovery_area '*. db_recovery_file_dest_size = 2147483648 *. dispatchers = '(PRO TOCOL = TCP) (SERVICE = orclXDB )'*. job_queue_processes = 10 *. open_cursors = 300 *. pga_aggregate_target = 16777216 *. processes = 150 *. remote_login_passwordfile = 'clusive '*. sga_target = 167772160 *. undo_management = 'auto '*. undo_tablespace = 'undotbs1 '*. user_dump_dest = '/home/app/oracle10/admin/ice/udump '*. LOG_ARCHIVE_CONFIG = 'dg _ CONFIG = (orcl, orcl2204) 'log _ archive_dest_1 = 'location =/home/app/oracle10/archive VALID_FOR = (AL L_LOGFILES, ALL_ROLES) DB_UNIQUE_NAME = orcl2204 'Log _ archive_dest_state_1 = region = 'service = orcl2204 lgwr async VALID_FOR = (ONLINE_LOGFILES, PRIMARY_ROLE) DB_UNIQUE_NAME = ORCL 'Log _ archive_dest_state_2 = enablelog_archive_start = truelog_archive_format = '% t _ % s _ % r. arc 'Log _ archive_max_processes = 2fal_server = orclfal_client = orcl2204db_unique_name = orcl2204. Final work master database: 1. Delete SPFILEORCL. ORA2, SQL> conn/ S sysdba is connected to the idle routine. SQL> create spfile from pfile; the file has been created. Startup slave Database: [oracle @ localhost dbs] $ lsnrctl start [oracle @ localhost dbs] $ sqlplus system/orcl @ orcl1 ensure that the master database can be connected, and then quit [oracle @ localhost ~] $ Sqlplus/nologSQL> conn/as sysdbaConnected to an idle instance. SQL> create spfile from pfile; File created. 5. Start dataguard. First, start the master database. open the master database by referring to the following steps: SQL> conn/as sysdbaConnected to an idle instance. SQL & gt; startup nomountORA-32004: obsolete and/or deprecated parameter (s) specifiedORACLE instance started. total System Global Area 612368384 bytesFixed Size 1220868 bytesVariable Size 167775996 bytesDatabas E Buffers 440401920 bytesRedo Buffers 2969600 bytes SQL> alter database mount standby database; SQL> select name, database_role from v $ database; NAME DATABASE_ROLE ------- -------------- ORCL PHYSICAL STANDBY begin to accept logs; -- physical standby database SQL> alter database recover managed standby database disconnect from session; Database altered. 6. Verify that the external uard is successful: create a table in the master database, insert one piece of data, and submit SQL> create table test (id Int); Table created. SQL> insert into test values (1); 1 row created. SQL> commit; Commit complete. SQL> alter system switch logfile; System altered. SQL> alter system switch logfile; System altered. SQL> select sequence #, applied from v $ archived_log order by sequence #; -- view the log status SEQUENCE # APP ---------- --- 36 NO 36 NO 37 NO 59 rows selected. SQL> insert into test values (2); 1 row created. SQL> Commit; Commit complete. slave Database: SQL> select sequence #, applied from v $ archived_log order by sequence #; -- view the status SEQUENCE # APP ---------- --- 35 NO 36 NO 37 NO 36 rows selected. SQL> alter database recover managed standby database cancel; -- end receiving log Database altered. SQL> alter database open read only; --------- open Database altered. SQL> select * from test; ID ---------- 1 now the deployment of dataguard is complete. The following are common commands: 1. Start --- open the slave database in read-only mode: Start the master database first: slave database: startup nomount; SQL> alter database recover managed standby database disconnect from session; ---- receive log SQL> select sequence #, applied from v $ archived_log order by sequence #; -- View status SQL> alter database recover managed standby database cancel; -- terminate the SQL statement for receiving logs> alter database open read only; --------- open database 2. Switch the standby database from the open status back to the recovery status: alter database recover managed standby database disconnec T from session; 3. Slave Database: Check whether there is an archive interrupted SQL> select thread #, low_sequence #, high_sequence # from v $ archive_gap; no rows selected 4. Start and close: start: the standby Database listener starts the standby database. Then, the listener of the master database is disabled when the master database is started: Shut down the master database first, and then shut down the slave database. 5. Check whether the log size is consistent. The select sequence # Is synchronized #, applied from v $ archived_log order by sequence #; 6. switch the archive log of the master database (synchronize to the slave database) alter system switch logfile; 7 \ QUERY the log transmission mode currently in which the DataGuard is located: SQL> select process, CLIENT_PROCESS from v $ managed_standby; PROCESS CLIENT_P --------- -------- ARCH ARCHARCH ARCHRFS LGWRRFS UNKNOWN