Linux平台 Oracle 11g DG测试环境快速搭建参考(3)

GROUP_NUMBER NAME                                                        TYPE          TOTAL_MB    FREE_MB

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

1 DATA1                                                        EXTERN            30708      30654


至此,准备工作结束。

二、DG部署配置

1. primary database 配置


确保将数据库的force_logging打开,设置为归档模式,数据库闪回打开


SQL> select name from v$datafile;


NAME

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

+DATA1/jyzhao/datafile/system.256.874084601

+DATA1/jyzhao/datafile/sysaux.257.874084601

+DATA1/jyzhao/datafile/undotbs1.258.874084601

+DATA1/jyzhao/datafile/users.259.874084601

SQL> select force_logging from v$database;

FOR

---

NO

SQL> alter database force logging;

Database altered.

SQL> shutdown immediate;

Database closed.

Database dismounted.

ORACLE instance shut down.

SQL> startup mount

ORACLE instance started.

Total System Global Area 1620115456 bytes

Fixed Size                  2253704 bytes

Variable Size            1006636152 bytes

Database Buffers          603979776 bytes

Redo Buffers                7245824 bytes

Database mounted.

SQL> alter database archivelog;

Database altered.

SQL> alter database flashback on;

alter database flashback on

*

ERROR at line 1:

ORA-38706: Cannot turn on FLASHBACK DATABASE logging.

ORA-38709: Recovery Area is not enabled.

SQL> archive log list

Database log mode              Archive Mode

Automatic archival            Enabled

Archive destination            /u01/app/oracle/product/11.2.0/db_1/dbs/arch

Oldest online log sequence    12

Next log sequence to archive  14

Current log sequence          14

$ mkdir -p /u01/app/oracle/product/11.2.0/db_1/dbs/arch

SQL> alter database flashback on;

alter database flashback on

*

ERROR at line 1:

ORA-38706: Cannot turn on FLASHBACK DATABASE logging.

ORA-38709: Recovery Area is not enabled.

SQL> show parameter db_recover

NAME                                TYPE        VALUE

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

db_recovery_file_dest                string

db_recovery_file_dest_size          big integer 0

SQL> alter system set db_recovery_file_dest_size=5G;

System altered.

SQL> alter system set db_recovery_file_dest='/u01/app/oracle/product/11.2.0/db_1/dbs/arch';

System altered.

SQL> select status from v$instance;

STATUS

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

MOUNTED

SQL> alter database flashback on;

Database altered.


按之前的规划设置数据库的参数

主要是db_unique_name, log_archive_config, log_archive_dest_1,  log_archive_dest_2, log_archive_format, fal_server, fal_client, standby_file_management的设置,standby logfile的添加,密码文件的创建。


alter system set db_unique_name='jyzhao' scope=spfile; 

alter system set log_archive_config='DG_CONFIG=(jyzhao,jyzhao_s)'  scope=spfile;

alter system set log_archive_dest_1='LOCATION=/u01/app/oracle/product/11.2.0/db_1/dbs/arch VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=jyzhao' scope=spfile; 

alter system set log_archive_dest_2='SERVICE=jyzhao_s ASYNC LGWR VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=jyzhao_s' scope=spfile;<br>

alter system set log_archive_format='arch_%r_%t_%s.arc' scope=spfile;

alter system set fal_server=jyzhao_s scope=spfile;

alter system set fal_client=jyzhao scope=spfile;

alter system set standby_file_management=AUTO;

alter database add standby logfile group 4 size 50M;

alter database add standby logfile group 5 size 50M;

alter database add standby logfile group 6 size 50M;

alter database add standby logfile group 7 size 50M;

rm /u01/app/oracle/product/11.2.0/db_1/dbs/orapwjyzhao

orapwd file=$ORACLE_HOME/dbs/orapwjyzhao password=oracle entries=10 ignorecase=Y 


grid用户配置监听
--listener.ora

DGL =

(DESCRIPTION =

(ADDRESS = (PROTOCOL = TCP)(HOST = JY-DB)(PORT = 1521))

)

SID_LIST_DGL =

(SID_LIST =

(SID_DESC =

(GLOBAL_DBNAME = jyzhao)

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

(SID_NAME = jyzhao)   

)   

(SID_DESC =     

(GLOBAL_DBNAME = jyzhao_dgmgrl)     

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

(SID_NAME = jyzhao)

)     

ADR_BASE_DGL = /u01/app/grid


oracle用户配置tnsnames.ora
--tnsnames.ora
LINUXIDC =

(DESCRIPTION =

(ADDRESS = (PROTOCOL = TCP)(HOST = JY-DB)(PORT = 1521))

(CONNECT_DATA =

(SERVER = DEDICATED)

(SERVICE_NAME = jyzhao )

)

LINUXIDC_S =

(DESCRIPTION =   

(ADDRESS = (PROTOCOL = TCP)(HOST = JY-DBS)(PORT = 1521))   

(CONNECT_DATA =     

(SERVER = DEDICATED)     

(SERVICE_NAME = jyzhao_s)

)


grid用户重启监听:

lsnrctl stop dgl

lsnrctl start dgl


oracle用户测试连接:

sqlplus sys/oracle@jyzhao as sysdba

sqlplus sys/oracle@JY-DB/jyzhao_dgmgrl as sysdba

sqlplus sys/oracle@JY-DB/jyzhao as sysdba

SQL> show parameter audi

NAME                                TYPE        VALUE

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

audit_file_dest                      string      /u01/app/oracle/admin/jyzhao/a

dump

重启primary

shutdown immediate

startup


2.机器B:standby数据库配置:

grid用户配置监听
--listener.ora

DGL =

(DESCRIPTION =

(ADDRESS = (PROTOCOL = TCP)(HOST = JY-DBS)(PORT = 1521))

)

SID_LIST_DGL =

(SID_LIST =

(SID_DESC =

(GLOBAL_DBNAME = jyzhao_s)

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

(SID_NAME = jyzhao_s)   

)   

(SID_DESC =     

(GLOBAL_DBNAME = jyzhao_s_dgmgrl)     

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

(SID_NAME = jyzhao_s)<br>        ) 

)     

ADR_BASE_DGL = /u01/app/grid


grid用户启动监听
$ lsnrctl start dgl
 oracle用户配置tnsnames.ora
--tnsnames.ora

LINUXIDC =

(DESCRIPTION =

(ADDRESS = (PROTOCOL = TCP)(HOST = JY-DB)(PORT = 1521))

(CONNECT_DATA =

(SERVER = DEDICATED)

(SERVICE_NAME = jyzhao )

)

LINUXIDC_S =

(DESCRIPTION =   

(ADDRESS = (PROTOCOL = TCP)(HOST = JY-DBS)(PORT = 1521))   

(CONNECT_DATA =     

(SERVER = DEDICATED)     

(SERVICE_NAME = jyzhao_s)

)

echo "db_name=jyzhao" >> $ORACLE_HOME/dbs/initjyzhao_s.ora

echo $ORACLE_SID

sqlplus / as sysdba

startup nomount

oracle用户测试连接  :

sqlplus sys/oracle@jyzhao as sysdba

sqlplus sys/oracle@jyzhao_s as sysdba

sqlplus sys/oracle@JY-DBS/jyzhao_s_dgmgrl as sysdba

sqlplus sys/oracle@JY-DBS/jyzhao_s as sysdba 

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/3e8db39f3603081d372c77a371d3b5aa.html