Oracle 11g DG Build

Source: Internet
Author: User
Tags failover sqlplus

Groupadd Oinstall

Groupadd dba

Groupadd Oper

Groupadd Asmadmin

Groupadd ASMDBA

Groupadd Asmoper

Useradd-g oinstall-g dba,asmdba,asmadmin,asmoper Grid

USERADD-G oinstall-g DBA,OPER,ASMDBA Oracle


passwd grid

passwd Oracle


Mkdir-p/u01/app/11.2.0/grid

Mkdir-p/u01/app/grid

Mkdir-p/u01/app/oracle

Chown Grid:oinstall/u01/app/11.2.0/grid

Chown Grid:oinstall/u01/app/grid

Chown-r oracle:oinstall/u01/app/oracle

Chmod-r 775/u01/

Chown-r grid:oinstall/u01



Sed-i ' s/kernel.shmmax/#kernel. shmmax/g '/etc/sysctl.conf

Sed-i ' s/kernel.shmall/#kernel. shmall/g '/etc/sysctl.conf


Vi/etc/sysctl.conf

Add the following content:


FS.AIO-MAX-NR = 1048576

Fs.file-max = 6815744

Kernel.shmall = 2097152

Kernel.shmmax = 1073741824

Kernel.shmmni = 4096

Kernel.sem = 250 32000 100 128

Net.ipv4.ip_local_port_range = 9000 65500

Net.core.rmem_default = 262144

Net.core.rmem_max = 4194304

Net.core.wmem_default = 262144

Net.core.wmem_max = 1048586


Sysctl-p


Vi/etc/security/limits.conf


Add the following content:


Oracle Soft Nproc 2047

Oracle Hard Nproc 16384

Oracle Soft Nofile 1024

Oracle Hard Nofile 65536

Oracle Soft Stack 10240

Grid Soft Nproc 2047

Grid hard Nproc 16384

Grid Soft Nofile 1024

Grid hard Nofile 65536

Grid Soft Stack 10240


Vi/etc/profile writes the following:


if [$USER = "Oracle"] | | [$USER = "Grid"]; Then

if [$SHELL = "/bin/ksh"]; Then

Ulimit-p 16384

Ulimit-n 65536

Else

Ulimit-u 16384-n 65536

Fi

Umask 022

Fi

Export path= $PATH:/u01/app/11.2.0/grid/bin



Configuration node Rac1


Grid users:


VI. bash_profile


Export Tmp=/tmp

Export tmpdir= $TMP

Export Oracle_hostname=

Export oracle_sid=

Export Oracle_base=/u01/app/grid

Export Oracle_home=/u01/app/11.2.0/grid

Export path= $ORACLE _home/bin: $PATH


Oracle Users:


VI. bash_profile


Export Tmp=/tmp

Export tmpdir= $TMP

Export Oracle_hostname=

Export Oracle_base=/u01/app/oracle

Export Oracle_home= $ORACLE _base/product/11.2.0/db_1

Export Oracle_unqname=

Export oracle_sid=

Export Oracle_term=xterm

Export Path=/usr/sbin: $PATH

Export path= $ORACLE _home/bin: $PATH

Export Ld_library_path= $ORACLE _home/lib:/lib:/usr/lib

Export classpath= $ORACLE _home/jre: $ORACLE _home/jlib: $ORACLE _home/rdbms/jlib





1. Install the database software separately

2. Main Library DBCA Build library

3. Main and prepared separately NETCA

4. Main Library Execution:

SELECT * from v$option where parameter = ' Managed Standby ';

Archive Log List

ALTER DATABASE force logging;

ALTER DATABASE ADD standby logfile Group 4 ('/u01/app/oracle/oradata/redo04.log ') size 50m;

ALTER DATABASE ADD standby logfile Group 5 ('/u01/app/oracle/oradata/redo05.log ') size 50m;

ALTER DATABASE ADD standby logfile Group 6 ('/u01/app/oracle/oradata/redo06.log ') size 50m;

ALTER DATABASE ADD standby logfile Group 7 ('/u01/app/oracle/oradata/redo07.log ') size 50m;


Create Pfile from SPFile;


Show parameter name;


Alter system set Db_unique_name= ' Ora11g_primary ' scope=spfile;

Alter system set log_archive_config= ' dg_config= (ora11g_primary,ora11g_standby) ';

Create Pfile from SPFile;

Shutdown immediate;

Cd/u01/app/oracle/product/11.2.0/db_1/dbs

See initora11g.org db_unique_name= ' ora11g_primary ' is there

Startup


Alter system set log_archive_dest_1= ' Location=/u01/app/oracle/archivelog valid_for= (all_logfiles,all_roles) db_ Unique_name=ora11g_primary ';

Alter system set log_archive_dest_2= ' Service=ora11g_standby lgwr SYNC valid_for= (online_logfiles,primary_role) db_ Unique_name=ora11g_standby ';

Alter system set log_archive_dest_state_1= ' Enable ';

Alter system set log_archive_dest_state_2= ' Enable ';

Alter system set remote_login_passwordfile= ' EXCLUSIVE ' scope=spfile;

Alter system set fal_server= ' Ora11g_standby ' scope=spfile;

Alter system set fal_client= ' Ora11g_primary ' scope=spfile;

Alter system set standby_file_management= ' AUTO ' scope=spfile;


Mkdir-p $ORACLE _base/archivelog


Create Pfile from SPFile;

Shutdown immediate;

Verify that the parameters are

startup Mount;

ALTER DATABASE create standby Controlfile as '/u01/standby_ctl02.ctl ';


Cd/u01/app/oracle/product/11.2.0/db_1/network/admin

Vim Listener.ora

Add to

Sid_list_listener =

(Sid_list =

(Sid_desc =

(Sid_name = ora11g)

(Oracle_home =/u01/app/oracle/product/11.2.0/db_1)

)

)


LISTENER =

(Description_list =

(DESCRIPTION =

(ADDRESS = (PROTOCOL = TCP) (HOST = cbfdb1) (PORT = 1521))

(ADDRESS = (PROTOCOL = IPC) (KEY = EXTPROC1521))

)

)


Adr_base_listener =/u01/app/oracle



Vim Tnsnames.ora

Ora11g_primary =

(DESCRIPTION =

(ADDRESS = (PROTOCOL = TCP) (HOST = 192.168.0.1) (PORT = 1521))

(Connect_data =

(SERVER = dedicated)

(service_name = ora11g)

)

)

Ora11g_standby =

(DESCRIPTION =

(ADDRESS = (PROTOCOL = TCP) (HOST = 192.168.0.2) (PORT = 1521))

(Connect_data =

(SERVER = dedicated)

(service_name = ora11g)

)

)


Close the primary database

Sql>shutdown Immediate

Generate SPFile

Sql> create SPFile from Pfile;



5. Execute in the standby section:


Mkdir-p $ORACLE _base/oradata/ora11g

Mkdir-p $ORACLE _base/admin/ora11g

Mkdir-p $ORACLE _base/admin/ora11g/adump

Mkdir-p $ORACLE _base/admin/ora11g/bdump

Mkdir-p $ORACLE _base/admin/ora11g/cdump

Mkdir-p $ORACLE _base/admin/ora11g/dpdump

Mkdir-p $ORACLE _base/admin/ora11g/pfile

Mkdir-p $ORACLE _base/admin/ora11g/udump

Mkdir-p $ORACLE _base/diag/rdbms

Mkdir-p $ORACLE _base/diag/tnslsnr

Mkdir-p $ORACLE _base/fast_recovery_area/ora11g

Mkdir-p $ORACLE _base/archivelog



The following SCP is performed in the main library

Scp-r $ORACLE _base/oradata/ora11g/*.dbf 192.168.0.2:/$ORACLE _base/oradata/ora11g

Scp-r $ORACLE _base/oradata/*.log 192.168.0.2:/$ORACLE _base/oradata

Scp-r/u01/standby_ctl01.ctl 192.168.0.2:/$ORACLE _base/oradata

Scp-r $ORACLE _home/dbs/initora11g.ora 192.168.0.2: $ORACLE _home/dbs/

Scp-r/u01/app/oracle/product/11.2.0/db_1/dbs/orapwora11g 192.168.0.2:/u01/app/oracle/product/11.2.0/db_1/dbs/



$ cd $ORACLE _base/oradata/ora11g

$ mv Standby_ctl01.ctl Control01.ctl

$ CP Control01.ctl Control02.ctl


Cd/u01/app/oracle/product/11.2.0/db_1/dbs

Modify Initora11g.ora


Db_unique_name=ora11g_standby

Log_archive_dest_1= ' Location=/u01/app/oracle/archivelog valid_for= (all_logfiles,all_roles) DB_UNIQUE_NAME=ora11g _standby '

Log_archive_dest_2= ' service=ora11g_primary lgwr SYNC valid_for= (online_logfiles,primary_role) DB_UNIQUE_NAME= Ora11g_primary '

Fal_server=ora11g_primary

Fal_client=ora11g_standby


Cd/u01/app/oracle/product/11.2.0/db_1/network/admin

Vim Listener.ora

Add to

Sid_list_listener =

(Sid_list =

(Sid_desc =

(Sid_name = ora11g)

(Oracle_home =/u01/app/oracle/product/11.2.0/db_1)

)

)


LISTENER =

(Description_list =

(DESCRIPTION =

(ADDRESS = (PROTOCOL = TCP) (HOST = cbfdb2) (PORT = 1521))

(ADDRESS = (PROTOCOL = IPC) (KEY = EXTPROC1521))

)

)


Adr_base_listener =/u01/app/oracle



Vim Tnsnames.ora

Ora11g_primary =

(DESCRIPTION =

(ADDRESS = (PROTOCOL = TCP) (HOST = 192.168.0.1) (PORT = 1521))

(Connect_data =

(SERVER = dedicated)

(service_name = ora11g)

)

)

Ora11g_standby =

(DESCRIPTION =

(ADDRESS = (PROTOCOL = TCP) (HOST = 192.168.0.2) (PORT = 1521))

(Connect_data =

(SERVER = dedicated)

(service_name = ora11g)

)

)


Startup Nomount

ALTER DATABASE mount standby database;




Main Library Execution:

Startup Mount

ALTER DATABASE set standby database to maximize availability; (set to highest availability mode)

ALTER DATABASE open;


Sql>alter database recover managed standby database disconnect from session;

# After this command is executed, the standby will switch to the automatic recovery mode






First, function switching

Switchover State switching

First, operate on the primary:

(1). Verify that the main library is able to perform role conversions to the standby repository (primary repository execution)

Sql> SELECT switchover_status from V$database;

Switchover_status

-----------------

To STANDBY

1 row selected

(2) Start to change the physical master library to a physical repository (primary repository execution)

Sql> ALTER DATABASE COMMIT to switchover to physical STANDBY;

Or

Sql> ALTER DATABASE COMMIT to switchover-physical STANDBY with session shutdown;

Note: If this option is available for an active session, the conversion encounters a ORA-01093 error or can be converted after an active session or an active session is killed

(3). Close and restart the main library (primary library execution)

sql> shutdown Immediate

Sql> Startup Nomount

Sql> ALTER DATABASE mount standby database; #让备库处于standby

sql> ALTER DATABASE recover managed standby database using current logfile disconnect from session; #开始实时同步

Then operate on the standby:

(1). Verify that the repository can perform role conversions to the main library (original repository execution)

Sql> SELECT switchover_status from V$database;

Switchover_status

-----------------

To_primary

1 row selected

(2). Start converting a physical repository to a physical master (original repository execution)

Sql> ALTER DATABASE COMMIT to switchover to PRIMARY;

--If the ora-16139:media recovery required is reported, it may be because the log is not applied, you can first execute

ALTER database RECOVER MANAGED STANDBY database DISCONNECT from SESSION;

(3) Open the standby, and then turn off the restart. (Original repository execution)

Sql> SHUTDOWN IMMEDIATE;

Sql> STARTUP;

(4) Verify the conversion is successful (original repository execution)

sql> ALTER SYSTEM SWITCH LOGFILE;

Start the Log app

(5) Apply archive log (performed on the primary repository)

sql> ALTER database RECOVER MANAGED STANDBY database USING current LOGFILE DISCONNECT from SESSION;

Tip: To implement switchover smoothly, it's a good idea to set some initialization parameters for primary and standby at the same time on each server, although some of these parameters only work on one of the primary or standby.




4. Start and close sequence

Boot order

(1). Boot from, the main library monitoring listener

From library Dg-standby:

$lsnrctl start

Main Library Dg-primary:

$lsnrctl start

(2). Start the repository database and do the following:

$sqlplus/nolog

Sql>conn/as SYSDBA

Sql> Startup Nomount

Sql> ALTER DATABASE mount standby database; #让备库处于standby

sql> ALTER DATABASE recover managed standby database using current logfile disconnect from session; #开始实时同步

(3). Start the main library

$sqlplus/nolog

Sql>conn/as SYSDBA

Sql> Startup

Toggle Standby Database to read only mode

sql> ALTER DATABASE recover managed standby database cancel; #首先取消备库的自动恢复模式

Sql>alter database open Read only;

If you want to switch back to recover Manage mode (Start log app or start log Live app)

sql> ALTER DATABASE recover managed standby database disconnect from session; Start the Log app

Sql>alter database recover managed standby database using current logfile disconnect from session; Launch log real-time application

(3). Start the main library database (after the second step above, you can execute the following command):

Sql>startup


Close Order

On the contrary, close the main library, and then close from the library.

(1). Close the main library

$su –oracle

Sql>sqlplus/nolog

Sql>conn/as SYSDBA

Sql>shutdown immediate;

(2). Close from library

Su–oracle

Sql>sqlplus/nolog

Sql>conn/as SYSDBA

Sql>alter database recover managed standby database cancel; #停止同步

Sql>shutdown Immediate



Emergency switching

(Note: Simulation of the main library due to failure is not normal switchover, need to perform failover, force the library->pridb and take over the business)

(1). Prepare the Library:

Since it is a failover, understanding the main library is not working properly at this time, only the standby library switches to PRIDB

Stop Applying recovery mode

ALTER DATABASE recover managed standby database finish;

Convert Standbydb to Primary db

ALTER DATABASE commit to switchover to primary;


Restart the database to resume normal business

Sql>shutdown Immediate

Sql>startup

Select Open_mode,database_role from V$database;


Open_mode Database_role

----------             ----------------

OPEN PRIMARY

Note: Failover will break the Dataguard mode, need to reconfigure the Dataguard, the web also said no need to configure, but has not been tested successfully



Select Dbid,name,protection_mode,protection_level from V$database;


This article is from the "linux_oracle" blog, make sure to keep this source http://pankuo.blog.51cto.com/8651697/1853504

Oracle 11g DG Build

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.