1. 程式人生 > >Linux 12C DG安裝文檔

Linux 12C DG安裝文檔

row nes name scope desc nag edi _id undo

1.查看主機和數據庫信息

$ sqlplus / as sysdba

Connected to:

Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production

With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,

Advanced Analytics and Real Application Testing options

SQL>

SQL> select * from v$version;

BANNER CON_ID

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

Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production 0

PL/SQL Release 12.1.0.2.0 - Production 0

CORE 12.1.0.2.0 Production 0

TNS for Linux: Version 12.1.0.2.0 - Production 0

NLSRTL Version 12.1.0.2.0 - Production 0

SQL> set linesize 140

set pagesize 999

col name for a25

col value for a60

select name,value from v$parameter where name like ‘%dump%‘;

NAME VALUE

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

shadow_core_dump partial

background_core_dump partial

background_dump_dest /oracle/app/oracle/product/12.1.0/dbhome_1/rdbms/log

user_dump_dest /oracle/app/oracle/product/12.1.0/dbhome_1/rdbms/log

core_dump_dest /oracle/app/oracle/diag/rdbms/g_xshis/gxshis1/cdump

max_dump_file_size unlimited

6 rows selected.

SQL> col value for a60

select name,value from v$parameter where name like ‘%pfile%‘;

NAME VALUE

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

spfile +DATA/g_xshis/parameterfile/spfilegxshis.ora

SQL> col name for a50

select name from v$controlfile;

NAME

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

+DATA/G_XSHIS/CONTROLFILE/current.261.922142579

+FLASH/G_XSHIS/CONTROLFILE/current.256.922142579

SQL> col member for a50

select member from v$logfile;

MEMBER

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

+DATA/G_XSHIS/ONLINELOG/group_2.347.927043957

+FLASH/G_XSHIS/ONLINELOG/group_2.4021.927043957

+DATA/G_XSHIS/ONLINELOG/group_1.346.927043955

+FLASH/G_XSHIS/ONLINELOG/group_1.259.927043955

+DATA/G_XSHIS/ONLINELOG/group_3.348.927043957

+FLASH/G_XSHIS/ONLINELOG/group_3.258.927043957

+DATA/G_XSHIS/ONLINELOG/group_4.267.927043957

+FLASH/G_XSHIS/ONLINELOG/group_4.260.927043957

+DATA/G_XSHIS/ONLINELOG/group_5.349.927576115

+DATA/G_XSHIS/ONLINELOG/group_6.350.927576115

+DATA/G_XSHIS/ONLINELOG/group_7.351.927576115

+DATA/G_XSHIS/ONLINELOG/group_8.352.927576123

+DATA/G_XSHIS/ONLINELOG/group_9.353.927576123

+DATA/G_XSHIS/ONLINELOG/group_10.354.927576123

SQL> select name from v$datafile;

+DATA/G_XSHIS/DATAFILE/system.258.922142465

+DATA/g_xshis/tablespaces/tsp_acct.dbf

+DATA/G_XSHIS/DATAFILE/sysaux.257.922142419

+DATA/G_XSHIS/DATAFILE/undotbs1.260.922142521

+DATA/G_XSHIS/DATAFILE/undotbs2.265.922142785

+DATA/G_XSHIS/DATAFILE/users.259.922142519

+DATA/g_xshis/tablespaces/tsp_bldbank.dbf

+DATA/g_xshis/tablespaces/tsp_clinpath.dbf

+DATA/g_xshis/tablespaces/tsp_comm.dbf

+DATA/g_xshis/tablespaces/tsp_cpr.dbf

+DATA/g_xshis/tablespaces/tsp_healthcare.dbf

+DATA/g_xshis/tablespaces/tsp_hisuser.dbf

+DATA/g_xshis/tablespaces/tsp_infect.dbf

+DATA/g_xshis/tablespaces/tsp_inpadm.dbf

+DATA/g_xshis/tablespaces/tsp_inpbill.dbf

+DATA/g_xshis/tablespaces/tsp_inquire.dbf

+DATA/g_xshis/tablespaces/tsp_insurance.dbf

+DATA/g_xshis/tablespaces/tsp_interface.dbf

+DATA/g_xshis/tablespaces/tsp_lab.dbf

+DATA/g_xshis/tablespaces/tsp_medadm.dbf

+DATA/g_xshis/tablespaces/tsp_medrec.dbf

+DATA/g_xshis/tablespaces/tsp_mobile.dbf

+DATA/g_xshis/tablespaces/tsp_nursing.dbf

+DATA/g_xshis/tablespaces/tsp_ordadm.dbf

+DATA/g_xshis/tablespaces/tsp_outpadm.dbf

+DATA/g_xshis/tablespaces/tsp_outpbill.dbf

+DATA/g_xshis/tablespaces/tsp_outpdoct.dbf

+DATA/g_xshis/tablespaces/tsp_pharmacy.dbf

+DATA/g_xshis/tablespaces/tsp_phyexam.dbf

+DATA/g_xshis/tablespaces/tsp_report.dbf

+DATA/g_xshis/tablespaces/tsp_surgery.dbf

+DATA/g_xshis/tablespaces/tsp_tj.dbf

+DATA/g_xshis/tablespaces/tsp_tjhisrpt.dbf

+DATA/g_xshis/tablespaces/tsp_wsyy.dbf

+DATA/g_xshis/tablespaces/tsp_exam.dbf

+DATA/g_xshis/tablespaces/tsp_equipment.dbf

+DATA/g_xshis/tablespaces/tsp_econstat.dbf

+DATA/g_xshis/tablespaces/tsp_others.dbf

+DATA/g_xshis/tablespaces/tsp_emr.dbf

+DATA/g_xshis/tablespaces/tsp_nsm.dbf

+DATA/G_XSHIS/DATAFILE/tsp_clinicpath.331.925047179

41 rows selected.

SQL> select name from v$tempfile;

NAME

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

+DATA/G_XSHIS/TEMPFILE/temp.264.922142585

+DATA/g_xshis/tablespaces/tsp_tmp.dbf

SQL> select * from nls_database_parameters where parameter=‘NLS_CHARACTERSET‘;

PARAMETER VALUE

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

NLS_CHARACTERSET ZHS16GBK

$ echo $ORACLE_BASE

/oracle/app/oracle

$ echo $ORACLE_HOME

/oracle/app/oracle/product/12.1.0/dbhome_1

2.準備工作

實施前需要準備事情:災備端安裝好數據庫軟件,為避免不必要的麻煩,軟件目錄和數據文件目錄結構與主庫的一致。如果兩端的數據文件結構不一致,則需要重啟數據庫。

修改主備庫/etc/hosts文件。

3.確定主庫處於歸檔模式

SQL> archive log list;

Database log mode Archive Mode

Automatic archival Enabled

Archive destination +DATA

Oldest online log sequence 2314

Next log sequence to archive 2315

Current log sequence 2315

如果處於非歸檔模式需要修改為歸檔模式。

4.修改主庫為強日誌模式

SQL> select force_logging from v$database;

FOR

---

NO

經檢查不是強日誌模式,先修改為強日誌模式,命令如下:

SQL> alter database force logging;

5.備庫創建相同的目錄結構

步驟省略,參考前面輸出內容創建

6.主備份庫修改參數

主庫修改參數

SQL>

alter system set standby_file_management=auto scope=both sid=‘*‘;

alter system set fal_server=g_xshis scope=both sid=‘*‘;

alter system set log_archive_config=‘dg_config=(g_xshis,standby)‘ scope=both sid=‘*‘;

alter system set log_archive_dest_1=‘location=+DATA valid_for=(all_logfiles,all_roles) db_unique_name=g_xshis‘ sid=‘*‘;

alter system set log_archive_dest_2=‘service=standby lgwr async COMPRESSION=ENABLE valid_for=(online_logfiles,primary_role) db_unique_name=standby‘ scope=both;

alter system set log_file_name_convert=‘+DATA/standby‘,‘+DATA/g_xshis‘ scope=spfile sid=‘*‘;

註意:上面的設置默認主庫和備庫兩邊的數據文件和日誌文件兩端一致,如果不一致則需要修改參數db_file_name_convert 、log_file_name_convert,轉換兩邊的目錄,並且修改這兩個參數需要重啟數據庫。

7.配置tnsnames.ora

orcl =

(DESCRIPTION =

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

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

(CONNECT_DATA =

(SERVER = DEDICATED)

(SERVICE_NAME = g_xshis)

)

)

STANDBY =

(DESCRIPTION =

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

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

(CONNECT_DATA =

(SERVER = DEDICATED)

(SERVICE_NAME = standby)

)

)

8.傳送參數文件和密碼文件至備庫

9.主庫使用RMAN備份

RMAN> run{

allocate channel ch1 type disk;

allocate channel ch2 type disk;

backup database format ‘/data/backup/dbf_%d_%T_%s_%p‘;

sql ‘alter system archive log current‘;

backup archivelog all format ‘/data/backup/arc_%d_%T_%s_%p‘ delete input;

backup current controlfile for standby format ‘/data/backup/control01.ctl‘;

}

傳送備份文件至備庫。

10.啟動備庫至nomount狀態

SQL> startup nomount;

修改DB_UNIQUE_NAME

SQL> ALTER SYSTEM SET DB_UNIQUE_NAME= standby scope=spfile;

註意:主備庫兩邊的db_name必須一致,db_unique_name必須不一致。

重新啟動,使參數生效:

SQL> shutdown immediate;

SQL> startup nomount;

11.恢復控制文件

RMAN> restore standby controlfile from ‘/data/backup/control01.ctl‘;

12.啟動備庫至mount狀態

RMAN> alter database mount;

13.恢復備庫

RMAN> restore database;

RMAN> restore archivelog all;

RMAN> recover database;

14.添加standby logfiles

檢查當前環境logfile

SQL> set lines 200 pages 300

col member for a60

select a.thread#,a.group#,b.member,b.type,a.bytes/1024/1024 MB from v$log a,v$logfile b where a.group#=b.group#

union all

select a.thread#,a.group#,b.member,b.type,a.bytes/1024/1024 MB from v$standby_log a,v$logfile b where a.group#=b.group#;

THREAD#GROUP# MEMBER TYPE MB

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

1 3 /data/orcl/redo03.log ONLINE 50

1 2 /data/orcl/redo02.log ONLINE 50

1 1 /data/orcl/redo01.log ONLINE 50

SQL> alter database add standby logfile

group 4 ‘ +DATA‘ size 50M,

group 5 ‘ +DATA‘ size 50M,

group 6 ‘ +DATA‘ size 50M,

group 7 ‘ +DATA‘ size 50M;

15.在主庫恢復打開

SQL> alter system set log_archive_dest_2=‘ service=standby lgwr async COMPRESSION=ENABLE valid_for=(online_logfiles,primary_role) db_unique_name=standby‘ scope=both;

註意:檢查log_archive_dest_state_1和log_archive_dest_state_2 參數是否設置為enable ,如果沒有設置為enable ,切換的時候可能會出問題.

16.在備庫打開

備庫修改參數

alter system set log_archive_dest_1=‘location=+DATA valid_for=(all_logfiles,all_roles) db_unique_name=standby‘ sid=‘*‘;

SQL> alter database open read only;

recover managed standby database using current logfile disconnect;

17.在主庫上切歸檔

SQL> alter system archive log current;

SQL> alter system archive log current;

SQL> archive log list;

Database log mode Archive Mode

Automatic archival Enabled

Archive destination /data/arch

Oldest online log sequence 32

Next log sequence to archive 34

Current log sequence 34

18.檢查備庫alert日誌

$ tail -n 9 /u01/app/oracle/admin/laugh/bdump/alert_laugh.log

Tue Sep 15 19:04:50 2015

RFS[1]: No standby redo logfiles created

RFS[1]: Archived Log: ‘/oradata/arch/1_32_885635743.dbf‘

RFS[1]: No standby redo logfiles created

RFS[1]: Archived Log: ‘/oradata/arch/1_33_885635743.dbf‘

Tue Sep 15 19:04:53 2015

Media Recovery Log /oradata/arch/1_32_885635743.dbf

Media Recovery Log /oradata/arch/1_33_885635743.dbf

Media Recovery Waiting for thread 1 sequence 34

說明已經搭建成功。

Linux 12C DG安裝文檔