In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly explains "how to build Data Guard". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn how to build Data Guard.
I. Planning
Description: in Data Guard
-db_name: master and backup databases must be consistent
-db_unique_name: master and backup databases must be inconsistent
-service_names and instance_name can be consistent or inconsistent.
Second, DG environment requirements 1. Hardware and operating system requirements
Data Guard allows the primary and secondary libraries to have different CPU models, different operating systems (such as windows & linux), different operating system bits (32-bit/64-bit), or different database bits (32-bit/64-bit).
2. Oracle software requirements
Data Guard only supports Oracle database Enterprise Edition, not the standard version.
In the physical slave library, the compatiable parameters of the Oracle master and slave libraries must be consistent (usually, we refer to the physical slave database by Data Guard). In a logical standby library, the compatiable of the standby library must be greater than or equal to the primary library parameter.
The primary library can be a single instance library or RAC, and the standby library can be a single instance or RAC.
If the operating system of the master / slave library is the same, then the storage path of the master / slave library must be different, otherwise, the standby library may overwrite the main library file.
If both the primary and secondary libraries are RAC, and the primary library is managed using ASM and OMF (Oracle managed files) naming, then the standby library should also be managed using ASM and OMF.
Third, clear thinking
Step1: force logging is enabled in the main database
Step2: preparing the library configuration listener.ora file
Step3: master / slave library configuration tnsnames.ora file
Step4: add standby logfile to the main library
Step5: modify parameter files for master and slave libraries
Step6: RMAN replication database
Step7: DG check, application log
Step8: enable repository and real-time application log
Fourth, the preparatory work 1. Turn off the firewall (active and standby library)
# systemctl stop firewalld
# systemctl disable firewalld
two。 Disable selinux (primary and standby libraries)
# vi / etc/selinux/config
Selinux=disabled
3. Check the main library archive settings
SQL > archive log list
Database log mode Archive Mode
Automatic archival Enabled
Archive destination / archivelog/ORCL
Oldest online log sequence 26
Next log sequence to archive 28
Current log sequence 28
4. Configuration / etc/hosts file (master / standby library)
# vi / etc/hosts
# Primary IP
172.16.70.178 primary
# Standby IP
172.16.70.179 standby
Fifth, set up DG1. Turn on mandatory log mode (main library)
SQL > alter database force logging
two。 Configure listener.ora file (standby library)
(Oracle users)
Add static listening to the standby library
$vi $ORACLE_HOME/network/admin/listener.ora
(add the following)
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = SBDB)
(ORACLE_HOME = / u01/app/oracle/product/11.2.0/db_1)
(SID_NAME = SBDB)
)
)
Turn on monitoring
$lsnrctl start
3. Modify tnsnames.ora file (master / standby library)
(the master and backup databases are the same)
$vi $ORACLE_HOME/network/admin/tnsnames.ora
ORCL =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP) (HOST = primary) (PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = ORCL)
)
)
SBDB =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP) (HOST = standby) (PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = SBDB)
)
)
Tns connectivity detection
$tnsping ORCL
$tnsping SBDB
4. Add standby logfile to the main library
SQL > select group#,thread#,bytes/1024/1024 Mpart status from v$log
SQL > select member from v$logfile
SQL > alter database add standby logfile'/ u01 size size 50m
SQL > alter database add standby logfile'/ u01 size size 50m
SQL > alter database add standby logfile'/ u01 size size 50m
SQL > alter database add standby logfile'/ u01 size size 50m
View log group status
SQL > select group#,status,type,member from v$logfile
5. Modify parameter file
(main library modifies parameters)
1) generate parameter files
SQL > create pfile from spfile
2) modify the parameter file
$cd / u01/app/oracle/product/11.2.0/db_1/dbs
$vi initORCL.ora
Add the following:
Db_unique_name=ORCL
Log_archive_config='dg_config= (ORCL,SBDB)'
Log_archive_dest_1='location=/archivelog/ORCL valid_for= (all_logfiles,all_roles) db_unique_name=ORCL'
Log_archive_dest_2='service=SBDB lgwr async valid_for= (online_logfiles,primary_roles) db_unique_name=SBDB'
Log_archive_dest_state_1=enable
Log_archive_dest_state_2=enable
Db_file_name_convert='/u01/app/oracle/oradata/SBDB','/u01/app/oracle/oradata/ORCL'
Log_file_name_convert='/u01/app/oracle/oradata/SBDB','/u01/app/oracle/oradata/ORCL'
Fal_server=SBDB
Fal_client=ORCL
Standby_file_management=auto
3) generate spfile, restart the library to make the parameters take effect
SQL > shutdown immediate
SQL > create spfile from pfile
SQL > startup
(ready for library modification)
1) transfer the main library pfile to the slave database
$scp initORCL.ora standby:$ORACLE_HOME/dbs/initSBDB.ora
2) modify the parameter file
$cd / u01/app/oracle/product/11.2.0/db_1/dbs
$vi initSBDB.ora
Execute the following command
:% s/ORCL/AAAA/g
:% s/SBDB/ORCL/g
:% s/AAAA/SBDB/g
Finally, modify db_name back to ORCL
The final results are as follows:
* .audit_file_dest='/u01/app/oracle/admin/SBDB/adump'
* .audit_trail='db'
* .compatible='11.2.0.4.0'
* .control_files='/u01/app/oracle/oradata/SBDB/control01.ctl','/u01/app/oracle/oradata/SBDB/control02.ctl'
* .db_block_size=8192
* .db_domain=''
* .db_name='ORCL'
* .diagnostic_dest='/u01/app/oracle'
* .dispatchers=' (PROTOCOL=TCP) (SERVICE=SBDBXDB)'
* .log_archive_dest_1='LOCATION=/archivelog/SBDB'
* .log_archive_format='%t_%s_%r.dbf'
* .memory_target=769654784
* .open_cursors=300
* .processes=150
* .remote_login_passwordfile='EXCLUSIVE'
* .undo_tablespace='UNDOTBS1'
Db_unique_name=SBDB
Log_archive_config='dg_config= (SBDB,ORCL)'
Log_archive_dest_1='location=/archivelog/SBDB valid_for= (all_logfiles,all_roles) db_unique_name=SBDB'
Log_archive_dest_2='service=ORCL lgwr async valid_for= (online_logfiles,primary_roles) db_unique_name=ORCL'
Log_archive_dest_state_1=enable
Log_archive_dest_state_2=enable
Db_file_name_convert='/u01/app/oracle/oradata/ORCL','/u01/app/oracle/oradata/SBDB'
Log_file_name_convert='/u01/app/oracle/oradata/ORCL','/u01/app/oracle/oradata/SBDB'
Fal_server=ORCL
Fal_client=SBDB
Standby_file_management=auto
3) create the above directory for the standby library
$mkdir-p / u01/app/oracle/admin/SBDB/adump
$mkdir-p / u01/app/oracle/oradata/SBDB
$mkdir-p / archivelog/SBDB
4) prepare the library to create a password file
$cd $ORACLE_HOME/dbs/
$orapwd file=orapwSBDB password=oracle
6. Copy database
1) enable slave database to nomount status
SQL > create spfile from pfile
SQL > startup nomount
2) RMAN replication database (main database execution)
$rman target / auxiliary sys/oracle@SBDB
RMAN > duplicate target database for standby from active database
At this point, the Data Guard build part has been completed!
6. Configure ADG
1) query the status of master and slave databases
(main library)
SQL > col db_unique_name for A15
SQL > select db_unique_name,open_mode,database_role,switchover_status from v$database
DB_UNIQUE_NAME OPEN_MODE DATABASE_ROLE SWITCHOVER_STATUS
--
ORCL READ WRITE PRIMARY FAILED DESTINATION
(ready for storage)
DB_UNIQUE_NAME OPEN_MODE DATABASE_ROLE SWITCHOVER_STATUS
--
SBDB MOUNTED PHYSICAL STANDBY SESSIONS ACTIVE
2) prepare database application log
SQL > alter database recover managed standby database using current logfile disconnect from session
Check the slave SWITCHOVER_STATUS status until SWITCHOVER_STATUS is NOT ALLOWED and it is normal.
3) prepare the database to cancel the application log
SQL > alter database recover managed standby database cancel
4) Open the reserve database
SQL > alter database open
5) enable real-time applications for standby database
SQL > alter database recover managed standby database using current logfile disconnect from session
6) check the status of the standby database again
SQL > select db_unique_name,open_mode,database_role,switchover_status from v$database
DB_UNIQUE_NAME OPEN_MODE DATABASE_ROLE SWITCHOVER_STATUS
--
SBDB READ ONLY WITH APPLY PHYSICAL STANDBY NOT ALLOWED
7) View the status of the repository process
SQL > select process, pid, status, client_process from v$managed_standby
PROCESS PID STATUS CLIENT_P
--
ARCH 24183 CONNECTED ARCH
ARCH 24186 CONNECTED ARCH
ARCH 24188 CLOSING ARCH
ARCH 24190 CONNECTED ARCH
RFS 24533 IDLE LGWR
RFS 24527 IDLE UNKNOWN
RFS 24529 IDLE ARCH
RFS 24707 IDLE UNKNOWN
MRP0 24918 APPLYING_LOG N/A
At this point, the slave database is in real-time application status (Active Data Guard).
Thank you for your reading, the above is the content of "how to build Data Guard", after the study of this article, I believe you have a deeper understanding of how to build Data Guard, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.