Oracle Master/Slave database configuration process

Source: Internet
Author: User
Experiment environment operating system: RHELAS4 Database: Version10.2.0.1.0 on one machine, install two databases for master-slave switchover experiment. Multiple machines share the same principle.

Experiment environment operating system: RHEL AS4 Database: Version 10.2.0.1.0 on one machine, two databases are installed for master-slave switchover experiment. Multiple machines share the same principle.

Lab Environment
Operating System: RHEL AS4
Database: Version 10.2.0.1.0
On one machine, two databases are installed to perform the master-slave switchover experiment. Multiple machines share the same principle.
After the experiment is successful, sort it out based on memory. If any omission exists, correct it.

I. Detailed installation and Setting Process
If a database is installed normally, you can use DBCA or manually create a database, and manually create a database with a smaller data file and faster experiment speed.
Database Name: beijing, initial master database, backup database name: shanghai

1. Generate a pfile and modify the parameters according to the requirements of the master and slave databases.
SQL> create pfile = '/dbfile/initbeijing. ora' from spfile;
# Default parameters
*. Compatible = '10. 2.0.1.0'
*. Db_block_size = 8192
*. Db_domain =''
*. Db_file_multiblock_read_count = 16
*. Db_name = 'beijing'
*. Db_recovery_file_dest = '/Oracle/flash_recovery_area'
*. Db_recovery_file_dest_size = 2147483648
*. Job_queue_processes = 10
*. Open_cursors = 300
*. Pga_aggregate_target = 94371840
*. Processses = 150
*. Remote_login_passwordfile = 'clusive'
*. Sga_target = 285212672
*. Undo_management = 'auto'
*. Undo_tablespace = 'undotbs1'
Log_archive_format = % t _ % s _ % r. arc

# DUMP directory, which is also included by default and needs to be modified
*. Audit_file_dest = '/oracle/admin/beijing/adump'
*. Background_dump_dest = '/oracle/admin/beijing/bdump'
*. User_dump_dest = '/oracle/admin/beijing/udump'
*. Core_dump_dest = '/oracle/admin/beijing/cdump'

# Parameters to be added for master-slave switchover
Db_unique_name = beijing
Log_archive_config = 'dg _ config = (beijing, shanghai )'
Control_files = '/dbfile/datafile/beijing/control01.ctl ',
'/Dbfile/datafile/beijing/control02.ctl ',
'/Dbfile/datafile/beijing/control03.ctl'
Log_archive_dest_1 =
'Location =/dbfile/logfile/beijing/valid_for = (all_logfiles, all_roles) db_unique_name = beijing'
Log_archive_dest_2 =
'Service = shanghai lgwr async valid_for = (online_logfiles, primary_role) db_unique_name = Shanghai'
Log_archive_dest_state_1 = enable
Log_archive_dest_state_2 = enable
Standby_file_management = auto

# Some settings during switchover
Fal_server = shanghai
Fal_client = beijing
Db_file_name_convert = 'shanghai', 'beijing'
Log_file_name_convert = 'shanghai', 'beijing'

2. Generate spfile, which must be performed when the database is closed
SQL> create spfile from pfile = '/dbfile/initbeijing. ora ';

3. Enable mount and archive mode.
SQL> alter database mount;
SQL> alter database archivelog;

4. Create a control file for the standby Database
SQL> alter database create standby controlfile as '/dbfile/beijing. ctl ';

5. Close the database, prepare the files required for the slave database, replace the control file, and start the master database (beijing)
SQL> shutdown immediate;
Copying data files is equivalent to cold backup, replacing Control Files
[Oracle @ linux ~] $ Cp-r/dbfile/datafile/beijing/dbfile/datafile/shanghai
[Oracle @ linux ~] $ Cp/dbfile/beijing. ctl/dbfile/datafile/shanghai/control01.ctl
[Oracle @ linux ~] $ Cp/dbfile/beijing. ctl/dbfile/datafile/shanghai/control02.ctl
[Oracle @ linux ~] $ Cp/dbfile/beijing. ctl/dbfile/datafile/shanghai/control03.ctl
Create an archive log directory
[Oracle @ linux ~] $ Mkdir-p/dbfile/datafile/shanghai
Create a dump directory. For simplicity, copy it because there are several dump directories.
[Oracle @ linux ~] $ Cp-r $ ORACLE_BASE/admin/beijing $ ORACLE_BASE/admin/shanghai
Start master database
SQL> startup

6. Modify tnsnames. ora. In the $ ORACLE_HOME/network/admin directory, create
Add the following content to the file, that is, the alias of the two libraries.
Shanghai =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP) (HOST = 127.0.0.1) (PORT = 1521 ))
)
(CONNECT_DATA =
(SID = shanghai)
)
)
Beijing =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP) (HOST = 127.0.0.1) (PORT = 1521 ))
)
(CONNECT_DATA =
(SID = beijing)
)
)

7. Start the listener and test the alias.
[Oracle @ linux ~] $ Lsnrctrl start
[Oracle @ linux ~] $ Tnsping beijing
[Oracle @ linux ~] $ Tnsping shanghai

8. Create a password file for the standby database. The database name is shanghai.
[Oracle @ linux ~] $ Orapwd $ ORACLE_HOME/dbs/orapwshanghai password = oracle

9. Use the data file of the master database (copied just now) to create the parameter file of the slave database.
Modify the parameter file initbeijing. ora of the master database and save it as initshanghai. ora.
*. Compatible = '10. 2.0.1.0'
*. Db_block_size = 8192
*. Db_domain =''
*. Db_file_multiblock_read_count = 16
*. Db_name = 'beijing'
*. Db_recovery_file_dest = '/oracle/flash_recovery_area'
*. Db_recovery_file_dest_size = 2147483648
*. Job_queue_processes = 10
*. Open_cursors = 300
*. Pga_aggregate_target = 94371840
*. Processses = 150
*. Remote_login_passwordfile = 'clusive'
*. Sga_target = 285212672
*. Undo_management = 'auto'
*. Undo_tablespace = 'undotbs1'
Log_archive_format = % t _ % s _ % r. arc

*. Audit_file_dest = '/oracle/admin/shanghai/adump'
*. Background_dump_dest = '/oracle/admin/shanghai/bdump'
*. User_dump_dest = '/oracle/admin/shanghai/udump'
*. Core_dump_dest = '/oracle/admin/shanghai/cdump'

Db_unique_name = shanghai
Log_archive_config = 'dg _ config = (beijing, shanghai )'
Control_files = '/dbfile/datafile/shanghai/control01.ctl ',
'/Dbfile/datafile/shanghai/control02.ctl ',
'/Dbfile/datafile/shanghai/control03.ctl'
Log_archive_dest_1 =
'Location =/dbfile/logfile/shanghai/valid_for = (all_logfiles, all_roles) db_unique_name = Shanghai'
Log_archive_dest_2 =
'Service = beijing lgwr async valid_for = (online_logfiles, primary_role) db_unique_name = beijing'
Log_archive_dest_state_1 = enable
Log_archive_dest_state_2 = enable

Fal_server = beijing
Fal_client = shanghai
Db_file_name_convert = 'beijing', 'shanghai'
Log_file_name_convert = 'beijing', 'shanghai'
Standby_file_management = auto

10. Start the slave database (shanghai) and use pfile to generate the spfile.
[Oracle @ linux ~] $ Export ORACLE_SID = shanghai
[Oracle @ linux ~] $ Sqlplus/as sysdba
SQL> create spfile from pfile = '/dbfile/initshanghai. ora ';

11. Start the slave database to the mount state, and then start the redo application.
SQL> startup mount
SQL> alter database recover managed standby database disconnect from session

12. Check the log to see if the setting is successful.
Master database switch log
SQL> alter system switch logfile;
Slave database to check for new logs
SQL> select sequence #, first_time, next_time from v $ archived_log order by 1;

SEQUENCE # FIRST_TIME NEXT_TIME
------------------------------------------------
16 08:51:41 08:51:45
16 08:51:41 08:51:45
17 08:51:45 08:51:48
17 08:51:45 08:51:48
18 08:51:48 08:52:26
18 08:51:48 08:52:26
19 08:52:26 08:53:57
19 08:52:26 08:53:57
20 08:53:57 08:54:06
20 08:53:57 08:54:06
You can also go to the/dbfile/logfile/shanghai directory to check whether there are any archived log files.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.