Oracle 11g DG Broker start and configuration
Oracle 11g opens db broker to achieve the purpose of managing dg
Ensure that the following parameters are set on both sides:
1.SQL> alter system set LOG_ARCHIVE_DEST_1='LOCATION=/data/u01/app/oracle/archive/ VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=db1';
System altered.
2.SQL> ALTER SYSTEM SET LOG_ARCHIVE_DEST_2='SERVICE=db1 LGWR aSYNC VALID_FOR=(ONLINE_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=db1';
System altered.
3.SQL> ALTER SYSTEM SET LOG_FILE_NAME_CONVERT='/data/u01/app/oracle/oradata/db2/', '/data/u01/app/oracle/oradata/db1/' scope =spfile;
System altered.
4.SQL> ALTER SYSTEM SET DB_FILE_NAME_CONVERT= '/data/u01/app/oracle/oradata/db2/', '/data/u01/app/oracle/oradata/db1/' scope =spfile;
System altered.
5.SQL> ALTER SYSTEM SET STANDBY_FILE_MANAGEMENT=AUTO SCOPE=SPFILE;
System altered.
6.SQL> ALTER SYSTEM SET FAL_CLIENT = db1 SCOPE=SPFILE;
System altered.
7.SQL> ALTER SYSTEM SET FAL_SERVER = db2 SCOPE=SPFILE;
System altered.
8.The standby logfile is added to the main library and the standby library
9.SQL> alter database force logging;
Database altered.
Prerequisite: main database db2 standby database db1
One: open db broker
Set to true on the main and standby databases
SQL> alter system set dg_broker_start=true;
Primary and standby libraries: parameter dg_broker_config_file, the default is fine! When you create configuration later and enable
The corresponding files will be generated in this directory!
SQL> show parameter dg_broker_config_file;
NAME TYPE VALUE
------------------------------------ ----------- --- ---------------------------
dg_broker_config_file1 string /data/u01/app/oracle/product/1
1.2.0/dbhome_1/dbs/dr1db2.dat
dg_broker_config_file2 string /data/u01/app/oracle/product/1
1.2.0/dbhome_1/dbs/dr2db2.dat
Modify the dg_broker_config_file parameter. The default path is used here, or you can specify it yourself. If it is in a RAC environment, put this file on the shared storage, if there is ASM, it can be put in ASM.
2.The main and standby library listener.ora adds the monitoring service used by the db broker to switch, because the service name used by the dg broker is db_unique_name_DGMGRL.Note: If you do not modify the monitoring, you can use the original monitoring.This method will be introduced below!
2.1 vim listener.ora, add the red part below! Be sure to pay attention to the format and strictly align
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.9.21.178)(PORT = 1521))
)
)
SID_LIST_LISTENER=
(SID_LIST=
(SID_DESC =
(GLOBAL_DBNAME=db2)
(ORACLE_HOME=/data/u01/app/oracle/product/11.2.0/dbhome_1)
(SID_NAME=db2))
(SID_DESC =
(GLOBAL_DBNAME=db2_DGMGRL)
(ORACLE_HOME=/data/u01/app/oracle/product/11.2.0/dbhome_1)
(SID_NAME=db2)))
ADR_BASE_LISTENER = /data/u01/app/oracle
2.2 Reload the monitor:
[oracle@beijing-fuli-Hadoop-02 admin]$ lsnrctl reload
Three.Configure db broker
3.1.Connect to the main library
[oracle@beijing-fuli-hadoop-02 admin]$ dgmgrl sys/oracle@db2
3.2.Create configuration
DGMGRL> help
The following commands are available:
add Adds a standby database to the broker configuration
connect Connects to an Oracle database instance
convert Converts a database from one type to another
create Creates a broker configuration
disable Disables a configuration, a database, or fast-start failover
edit Edits a configuration, database, or instance
enable Enables a configuration, a database, or fast-start failover
exit Exits the program
failover Changes a standby database to be the primary database
help Displays description and syntax for a command
quit Exits the program
reinstate Changes a database marked for reinstatement into a viable standby
rem Comment to be ignored by DGMGRL
remove Removes a configuration, database, or instance
show Displays information about a configuration, database, or instance
shutdown Shuts down a currently running Oracle database instance
sql Executes a SQL statement
start Starts the fast-start failover observer
startup Starts an Oracle database instance
stop Stops the fast-start failover observer
switchover Switches roles between a primary and standby database
DGMGRL> help create
Creates a broker configuration
Syntax:
CREATE CONFIGURATION <configuration name> AS
PRIMARY DATABASE IS <database name>
CONNECT IDENTIFIER IS <connect identifier>;
DGMGRL> CREATE CONFIGURATION dbha_c AS PRIMARY DATABASE IS db2 CONNECT IDENTIFIER IS db2;
(Explanation: where dbha_c is a random name, db2 is the unique name of the main database, and identifier is the network service name of tnsnames.ora! Then you can use the following to delete the created configuration!
DGMGRL> REMOVE CONFIGURATION;)
3.3 Add the information of the standby database
DGMGRL> help add
DGMGRL> add database 'db1' as connect identifier is 'db1' maintained as physical;
Database "db1" added
Note that identifier is'db1' where db1 is the name of the standby database in your tnsnames.ora!
After adding
3.4 Start the CONFIGURATION of this db broker!
DGMGRL> help enable
DGMGRL> ENABLE CONFIGURATION;
3.5 View the relevant configuration of db broker
DGMGRL> help show
DGMGRL> SHOW CONFIGURATION;
The following error is reported:
DGMGRL> show configuration
Configuration - dbha_c
Protection Mode: MaxPerformance
Databases:
db2 - Primary database
db1 - Physical standby database (disabled)
Fast-Start Failover: DISABLED
Configuration Status:
SUCCESS
Solution:
Delete the files in this directory of the master-slave library, and then create configuration again, you can!
SQL> show parameter dg_broker_config_file;
NAME TYPE VALUE
------------------------------------ ----------- --- ---------------------------
dg_broker_config_file1 string /data/u01/app/oracle/product/1
1.2.0/dbhome_1/dbs/dr1db2.dat
dg_broker_config_file2 string /data/u01/app/oracle/product/1
1.2.0/dbhome_1/dbs/dr2db2.dat
Explanation: What are the functions of these two files?
The following display means normal!!!
DGMGRL> show configuration
Configuration - dbha_c
Protection Mode: MaxPerformance
Databases:
db2 - Primary database
db1 - Physical standby database
Fast-Start Failover: DISABLED
Configuration Status:
SUCCESS
View the status of the database:
DGMGRL> show database verbose db1;
#Be careful here. The service_name of the connection in the broker is <db_unique_name>_DGMGRL, so we need to modify the monitoring above!
If you do not modify the listening file, you can also execute the following command to modify the StaticConnectIdentifier:
DGMGRL>edit database db1 set property StaticConnectIdentifier= '(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=beijing-fuli-hadoop-01)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=db1)(INSTANCE_NAME=db1)(SERVER=DEDICATED)))';
DGMGRL> edit database db2 set property StaticConnectIdentifier='(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=beijing-fuli-hadoop-02)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=db2)(INSTANCE_NAME=db2)(SERVER=DEDICATED)))';
Four: Related commands about db broker:
4.1: Switch master and slave!
DGMGRL> help switchover
DGMGRL> switchover to db1
Performing switchover NOW, please wait...
Operation requires a connection to instance "db1" on database "db1"
Connecting to instance "db1"...
Connected.
New primary database "db1" is opening...
Operation requires startup of instance "db2" on database "db2"
Starting instance "db2"...
ORACLE instance started.
Database mounted.
Database opened.
Switchover succeeded, new primary is "db1"
DGMGRL>
4.2:把从库切换成snapshot状态!(前提是开启了flashback database)
主库操作
DGMGRL> SHOW CONFIGURATION
DGMGRL> help convert
DGMGRL> CONVERT DATABASE db1 TO SNAPSHOT STANDBY;
DGMGRL> SHOW CONFIGURATION;
4.3: 修改下dg同步redo的方式,以及保护模式!
DGMGRL> help edit
DGMGRL> EDIT DATABASE db2 SET PROPERTY LogXptMode=SYNC; ---主库
DGMGRL> EDIT DATABASE db1 SET PROPERTY LogXptMode=SYNC; ---备库
DGMGRL> EDIT CONFIGURATION SET PROTECTION MODE AS MaxAvailability; ---主库
DGMGRL> EDIT CONFIGURATION SET PROTECTION MODE AS MaxAvailability; ---备库
0 Comments