码迷,mamicode.com
首页 > 系统相关 > 详细

Linux 12C DG安装文档

时间:2017-09-15 23:13:21      阅读:318      评论:0      收藏:0      [点我收藏+]

标签:datafile   des   state   inux   media   option   imm   修改   space   

 

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安装文档

标签:datafile   des   state   inux   media   option   imm   修改   space   

原文地址:http://www.cnblogs.com/liang545621/p/7529040.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!