Full manual for Oracle for Linux dual-host hot standby

Source: Internet
Author: User
10.0.0.11 is the IP address of my master server, 10.0.0.111 is the IP address of my slave server, and testdbase is the SID number of the database,
The operating system version is RedHat Linux 8.0. The database version is Oracle 9.2.0.1.

1. Create an oracle user
[Root @ Test2 etc] # groupadd oinstall
[Root @ Test2 etc] # groupadd DBA
[Root @ Test2 etc] # useradd-G oinstall-g dba Oracle

2. Set Oracle user environment variables # The environment variables of the master and slave servers should be consistent
The following is an oracle user environment variable template.
[Oracle @ Test2 Oracle] $ more. bash_profile
Export ld_assume_kernel = 2.4.1 # This parameter must be added to Redhat as 3.0.
Export oracle_base =/opt/Oracle # Set oracle_base according to the actual situation
Export ORACLE_HOME =/opt/Oracle/product/9.2.0 # Set ORACLE_HOME according to the actual situation
Export oracle_sid = testdbase
Export oracle_term = xterm
Export nls_lang = american_america. zhs16gbk; # the traditional Chinese character set is zht16big5
Export ora_nls33 = $ ORACLE_HOME/ocommon/NLS/admin/Data
LD_LIBRARY_PATH = $ ORACLE_HOME/lib:/usr/lib
LD_LIBRARY_PATH = $ LD_LIBRARY_PATH:/usr/local/lib
Export LD_LIBRARY_PATH
Export Path = $ path: $ ORACLE_HOME/bin
Classpath = $ ORACLE_HOME/JRE: $ ORACLE_HOME/jlib: $ ORACLE_HOME/rdbms/jlib
Classpath = $ classpath: $ ORACLE_HOME/Network/jlib: $ ORACLE_HOME/jdbc/lib/classes12.jar
Export classpath
Java_home =/usr/Java/j2sdk1.4.1 _ 02 # Set the java_home path based on the actual situation
Export java_home
Path = $ path: $ java_home/bin: $ java_home/JRE: $ ORACLE_HOME/bin
Export path
Umask 022

3. install Java
4. create. bash_profile related folders
[root @ Test2 etc] # chown oracle. oinstall-RF/OPT # change the owner of the/OPT directory to Oracle. oinstall
[root @ Test2 etc] # Su-Oracle
[Oracle @ Test2 Oracle] $ mkdir-P/opt/Oracle/product/9.2.0/ocommon/NLS/ admin/Data
[Oracle @ Test2 Oracle] $ mkdir-P/opt/Oracle/product/9.2.0/lib
[Oracle @ Test2 Oracle] $ mkdir-P/ OPT/Oracle/product/9.2.0/Network/jlib
[Oracle @ Test2 Oracle] $ mkdir-P/opt/Oracle/product/9.2.0/jdbc/lib/

5. Install oracle on the backup server
The backup server does not need to create a database during installation. You only need to install software.
If oracle9201 is installed, when it is installed to 84%, A compilation error "error in invoking target install of makefile/opt/Oracle/product/9.2.0/CTX/lib/ins_ctx.mk" appears.
Pieces: $ ORACLE_HOME/CTX/lib/env_ctx.mk, add "$ (ldlibflag) DL" to the following position:
Inso_link =-L $ (ctxlib) $ (ldlibflag) M $ (ldlibflag) dL $ (ldlibflag) SC _ca
$ (Ldlibflag) SC _fa $ (ldlibflag) SC _ex $ (ldlibflag) SC _da $ (ldlibflag) SC _ut
$ (Ldlibflag) SC _ch $ (ldlibflag) SC _fi $ (llibctxhx) $ (ldlibflag) c
-Wl,-rpath, $ (ctxhome) Lib $ (corelibs) and then press retry to continue the installation...
If the operating system version and directory structure of the master server are the same as those of the backup server, and the Oracle database of the master server is not created, you can directly copy the $ oracle_base and $ ORACLE_HOME of the master server to the backup server.
6. Check whether the master server database uses spfile # This step is optional.
[Oracle @ cqcncdb Oracle] $ sqlplus/nolog

SQL * Plus: Release 9.2.0.1.0-production on Wed Jul 21 11:54:42 2004

Copyright (c) 1982,200 2, Oracle Corporation. All rights reserved.

SQL> Conn/As sysdba;
Connected.
SQL> show parameter spfile

Name type value
-----------------------------------------------------------------------------
Spfile string? /Dbs/spfile @. ora

7. copy the data files, redo logs, and temp files of the primary database to the backup server on the primary server (cold backup mode)
[Oracle @ cqcncdb Oracle] $ sqlplus/nolog

SQL * Plus: Release 9.2.0.1.0-production on Wed Jul 21 12:03:58 2004

Copyright (c) 1982,200 2, Oracle Corporation. All rights reserved.

SQL> Conn/As sysdba;
Connected.
SQL> select * from V $ dbfile;
File # ---------- name --------------------------------------------------------------------------------
10
/Opt/Oracle/oradata/testdbase/xdb01.dbf
9
/Opt/Oracle/oradata/testdbase/users01.dbf
2
/Opt/Oracle/oradata/testdbase/undotbs01.dbf
File # ---------- name --------------------------------------------------------------------------------
8
/Opt/Oracle/oradata/testdbase/tools01.dbf
1
/Opt/Oracle/oradata/testdbase/system01.dbf
7
/Opt/Oracle/oradata/testdbase/odm01.dbf

File # ---------- name --------------------------------------------------------------------------------
6
/Opt/Oracle/oradata/testdbase/indx01.dbf
5
/Opt/Oracle/oradata/testdbase/example01.dbf
4
/Opt/Oracle/oradata/testdbase/drsys01.dbf
File # ---------- name --------------------------------------------------------------------------------
3
/Opt/Oracle/oradata/testdbase/cwmlite01.dbf
11
/Opt/Oracle/oradata/testdbase/Tong. DBF
12
/Opt/Oracle/oradata/testdbase/spapp. DBF
File # ---------- name --------------------------------------------------------------------------------
13
/Opt/Oracle/oradata/testdbase/wtspall. DBF
14
/Opt/Oracle/oradata/testdbase/szjlt. DBF
15
/Opt/Oracle/oradata/testdbase/jltgame. DBF
15 rows selected.
SQL> select * from V $ logfile;
Group # status type ---------- ------- Member
--------------------------------------------------------------------------------
3 online
/Opt/Oracle/oradata/testdbase/redo03.log
2 online
/Opt/Oracle/oradata/testdbase/redo02.log
1 online
/Opt/Oracle/oradata/testdbase/redo01.log

SQL> select * from V $ tempfile;
File # creation_change # creation _ TS # rfile # status enabled
------------------------------------------------------------------------
Bytes blocks create_bytes block_size
------------------------------------------
Name
--------------------------------------------------------------------------------
1 0 2 1 online read write
225443840 27520 41943040 8192
/Opt/Oracle/oradata/testdbase/temp01.dbf

SQL> shutdown immediate;
Database closed.
Database dismounted.
Oracle instance shut down.
SQL> exit
Disconnected from Oracle9i Enterprise Edition Release 9.2.0.1.0-Production
With the partitioning, OLAP and Oracle Data Mining options
Jserver release 9.2.0.1.0-Production
Copy the files listed above to the corresponding directory of the backup server, you can also directly copy all the files in the/opt/Oracle/oradata/testdbase/directory to the/opt/Oracle/oradata/testdbase/directory of the backup server.

8. Open the master database on the master server and change it to the archive mode (if the master database is already archived, you do not need to modify it)
Manually create an archive directory on the master server
$ CD $ oracle_base # The Directory pointed to by $ oracle_base is/opt/Oracle/. For details, see the specific settings of Oracle user environment variables in step 1.
$ Mkdir-P oradata/testdbase/archive
[Oracle @ cqcncdb testdbase] $ sqlplus/nolog
SQL> Conn/As sysdba;
Connected.
SQL> startup Mount;
SQL> alter database archivelog;
SQL> archive log start;
SQL> archive log list;
SQL> alter database open;
SQL> alter system set log_archive_dest_1 = 'location =/opt/Oracle/oradata/testdbase/archive ';
SQL> alter system set log_archive_format = '% T _ % S. dbf' scope = spfile;
SQL> alter system set log_archive_start = true scope = spfile;
Restart the database to make the modification take effect.
SQL> shutdown immediate;
View archiving Mode
SQL> startup
SQL> archive log list;
Database Log mode archive Mode
Automatic Archival Enabled
Archive destination/opt/Oracle/oradata/testdbase/archive
Oldest online log sequence 565
Next log sequence to archive 567
Current Log sequence 567

9. Create a slave Database Control file on the master database
SQL> alter database create standby controlfile as '/opt/Oracle/product/9.2.0/dbs/control01.ctl ';
Database altered.
Copy/opt/Oracle/product/9.2.0/dbs/control01.ctl to the/opt/Oracle/oradata/testdbase/directory of the backup server,
10. Configure tnsnames. ora for the master database and slave Database
Copy tnsnames. ora of the master database to the corresponding directory of the slave database.
[Oracle @ Test2 admin] $ VI tnsnames. ora # edit slave library tnsnames. ora
My master database and slave database tnsnames. ora are as follows:
# Tnsnames. ora network configuration file:/opt/Oracle/product/9.2.0/Network/admin/tnsnames. ora
# Generated by Oracle configuration tools.

Dbstandby =
(Description =
(Address_list =
(Address = (Protocol = TCP) (host = 10.0.0.111) (Port = 1521 ))
)
(CONNECT_DATA =
(Server = dedicated)
(SERVICE_NAME = testdbase)
)
)

Dbprimary =
(Description =
(Address_list =
(Address = (Protocol = TCP) (host = 10.0.0.11) (Port = 1521 ))
)
(CONNECT_DATA =
(Server = dedicated)
(SERVICE_NAME = testdbase)
)
)

Testdbase =
(Description =
(Address_list =
(Address = (Protocol = TCP) (host = 10.0.0.11) (Port = 1521 ))
)
(CONNECT_DATA =
(Server = dedicated)
(SERVICE_NAME = testdbase)
)
)
10.0.0.11 is the IP address of my master server, 10.0.0.111 is the IP address of my slave server, and testdbase is the SID number of the database,

11. Configure listener. ora of the slave Database
Copy the listener. ora of the master database to the corresponding directory of the slave database.
The listener. ora file of my slave database is as follows:
# Listener. ora network configuration file:/opt/Oracle/product/9.2.0/Network/admin/listener. ora
# Generated by Oracle configuration tools.

Listener =
(Description_list =
(Description =
(Address_list =
(Address = (Protocol = IPC) (Key = EXTPROC ))
)
(Address_list =
(Address = (Protocol = TCP) (host = 10.0.0.111) (Port = 1521 ))
)
)
)

Sid_list_listener =
(Sid_list =
(Sid_desc =
(Sid_name = plsextproc)
(ORACLE_HOME =/opt/Oracle/product/9.2.0)
(Program = EXTPROC)
)
(Sid_desc =
(Global_dbname = testdbase)
(ORACLE_HOME =/opt/Oracle/product/9.2.0)
(Sid_name = testdbase)
)
)

The content of listener. ora in the master database and slave database is identical except for the IP address.

12. Start the slave Database Listener.
[Oracle @ Test2 admin] $ LSNRCTL start

Linux: Version 9.2.0.1.0-production on 21-jul-2004 14:30:46

Copyright (c) 1991,200 2, Oracle Corporation. All rights reserved.

Starting/opt/Oracle/product/9.2.0/bin/tnslsnr: Please wait...

tnslsnr for Linux: Version 9.2.0.1.0-production
system parameter file is/opt/Oracle/product/9.2.0/Network/admin/listener. ora
log messages written to/opt/Oracle/product/9.2.0/Network/log/listener. log
listening on: (description = (address = (Protocol = IPC) (Key = EXTPROC)
listening on: (description = (address = (Protocol = TCP) (host = 10.0.0.111) (Port = 1521)

connecting to (description = (address = (Protocol = IPC) (Key = EXTPROC )))
Status of the listener
----------------------
alias listener
Version tnslsnr for Linux: version 9.2.0.1.0-production
Start Date 21-jul-2004 14:30:46
uptime 0 days 0 HR. 0 min. 0 sec
Trace Level off
Security off
SNMP off
listener parameter file/opt/Oracle/product/9.2.0/Network/admin/listener. ora
listener log file/opt/Oracle/product/9.2.0/Network/log/listener. log
listening endpoints summary...
(description = (address = (Protocol = IPC) (Key = EXTPROC)
(description = (address = (Protocol = TCP) (host = 10.0.0.111) (Port = 1521)
services summary...
service "plsextproc" has 1 instance (s ).
instance "plsextproc", status unknown, has 1 handler (s) for this service...
service "testdbase" has 1 instance (s ).
instance "testdbase", status unknown, has 1 handler (s) for this service...
the command completed successfully

13. Create pfile on the master database because 9i uses spfile by default.
Sqlplus/nolog
SQL> Conn/As sysdba;
Connected.
SQL> Create pfile = '/opt/inittestdbase. ora' from spfile;
14. Copy the/opt/inittestdbase. ora file generated by the master server to the $ ORACLE_HOME directory of the slave database.

15. Modify the slave database $ ORACLE_HOME/dbs/inittestdbase. ora File
Add the following parameter at the end of the $ ORACLE_HOME/dbs/inittestdbase. ora File
*. Standby_file_management = auto
*. Remote_archive_enable = true
*. Standby_archive_dest = '/opt/Oracle/oradata/testdbase/standbyarchive'
*. Fal_server = 'dbprimary'
*. Fal_client = 'dbstandby'
16. Copy the orapwtestdbase of the master database to the corresponding directory of the slave database.

17. Start the slave database and load the slave database to the standby database mode.
[Oracle @ Test2 standbyarchive] $ sqlplus/nolog
SQL * Plus: Release 9.2.0.1.0-production on Wed Jul 21 15:00:49 2004
Copyright (c) 1982,200 2, Oracle Corporation. All rights reserved.
SQL> Conn/As sysdba
Connected to an idle instance.
SQL> startup nomount pfile =? /Dbs/inittestdbase. ora
Oracle instance started.
Total system global area 235999352 bytes
Fixed size 450680 bytes
Variable Size 201326592 bytes
Database buffers 33554432 bytes
Redo buffers 667648 bytes
SQL> alter database Mount standby database;
Database altered.
SQL> alter database recover managed standby database disconnect from session;

18. Set the archive from the master database to the slave database on the master server
SQL> alter system set log_archive_dest_2 = 'service = dbstandby mandatory reopen = 60 ';

19. Verify whether logs of the master database are transmitted from the slave database.
Operate on the master database
SQL> select * from V $ log;
Group # thread # sequence # bytes members arc status
---------------------------------------------------------------------
First_change # first_tim
----------------------
1 1 572 104857600 1 no current
128255951 21-jul-04

2 1 571 104857600 1 Yes active
128255339 21-jul-04

3 1 570 104857600 1 Yes inactive
128255209 21-jul-04

SQL> alter system switch logfile;

System altered.
View the slave database logs on the slave server.
[Oracle @ Test2 bdump] $ tail-F/opt/Oracle/admin/testdbase/bdump/alert_testdbase.log
Completed: Alter database recover managed standby database di
Wed Jul 21 15:36:39 2004
Media recovery log/opt/Oracle/oradata/testdbase/standbyarchive/410566.dbf
Media recovery log/opt/Oracle/oradata/testdbase/standbyarchive/410567.dbf
Media recovery log/opt/Oracle/oradata/testdbase/standbyarchive/410568.dbf
Media recovery log/opt/Oracle/oradata/testdbase/standbyarchive/410569.dbf
Media recovery log/opt/Oracle/oradata/testdbase/standbyarchive/nvi570.dbf
Media recovery log/opt/Oracle/oradata/testdbase/standbyarchive/nvi571.dbf
Media recovery log/opt/Oracle/oradata/testdbase/standbyarchive/410572.dbf
Media recovery log/opt/Oracle/oradata/testdbase/standbyarchive/ipv573.dbf
Media recovery log/opt/Oracle/oradata/testdbase/standbyarchive/410574.dbf
Media recovery log/opt/Oracle/oradata/testdbase/standbyarchive/410575.dbf
Media recovery log/opt/Oracle/oradata/testdbase/standbyarchive/nvi576.dbf
Media recovery waiting for thread 1 seq #577

20. maximum performance mode for transmitting archived logs using arch Processes
Operate on the primary database
SQL> alter system set log_archive_dest_2 = 'service = dbstandby reopen = 300 'scope = both;
System altered.
SQL> alter system set log_archive_dest_state_2 = Enable scope = both;
System altered.
SQL> alter system archive log current;
System altered.

21. Test
Operate on the primary database
SQL> create user test3 identified by test;
User Created.
SQL> grant connect, resource to test3;
Grant succeeded.
SQL> conn test3/test @ dbprimary;
Connected.
SQL> Create Table test3 (name varchar2 (20 ));
Table created.
SQL> insert into test3 values ('sadf ');
1 row created.
SQL> commit;
Commit complete.
SQL> Conn/As sysdba
Connected.
SQL> alter system switch logfile;
System altered.

open the slave database in read-only mode to check whether the insert into test3 values ('sadf') operation has taken effect;
operate on the slave database
[Oracle @ Test2 standbyarchive] $ sqlplus/nolog
SQL * Plus: release 9.2.0.1.0-production on Wed Jul 21 16:11:29 2004
copyright (c) 1982,200 2, Oracle Corporation. all rights reserved.
SQL> Conn/As sysdba
connected.
SQL> alter database recover managed standby database cancel;
database altered.
SQL> alter database open read only;
database altered.
SQL> conn test3/test
connected.
SQL> select * From test3;
name
------------------
SADF
SQL> Conn/As sysdba
connected.
SQL> alter database recover managed standby database disconnect from session;
database altered.

Related Article

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.