??斗地主捕鱼电竞提现秒到 广告位招租 - 15元/月全站展示
??支付宝搜索579087183领大额红包 ??伍彩集团官网直营彩票
??好待遇→招代理 ??伍彩集团官网直营彩票
??络茄网 广告位招租 - 15元/月全站展示
Oracle DataGuard(rac-single)

转载   AMGYM   2018-11-14   浏览量:15


[[email protected] ~]$ sqlplus / as sysdba
SQL> alter database force logging;
Database altered.

SQL> col force_logging for a15
SQL> select force_logging from v$database;
FORCE_LOGGING
---------------
YES

SQL> archive log list;
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence     30
Next log sequence to archive   31
Current log sequence           31

SQL> alter system set db_unique_name='ambmdb' scope=spfile;
SQL> alter system set log_archive_config='dg_config=(ambmdb,ambsdb)' scope=spfile;
SQL> alter system set log_archive_dest_1='location=USE_DB_RECOVERY_FILE_DEST valid_for=(all_logfiles,all_roles) db_unique_name=ambmdb' scope=spfile;
SQL> alter system set log_archive_dest_2='service=ambsdb lgwr async valid_for=(online_logfiles,primary_role) db_unique_name=ambsdb' scope=spfile;
SQL> alter system set fal_server='ambsdb' scope=spfile;
SQL> alter system set standby_file_management='auto' scope=spfile;
SQL> alter system set log_archive_dest_state_2='defer' scope=spfile;
SQL> alter system set service_names=ambdb,ambmdb scope=spfile;


[[email protected] ~]$ mkdir -p /home/oracle/backup

[[email protected] ~]$ rman target /
RMAN> backup device type disk format '/home/oracle/backup/%U' database plus archivelog;
RMAN> backup device type disk format '/home/oracle/backup/%U' current controlfile for standby;

[[email protected] ~]$ scp /home/oracle/backup/*  192.168.1.203:/home/oracle/backup


[[email protected] ~]$ vi $ORACLE_HOME/network/admin/tnsnames.ora
ambmdb =
  (DESCRIPTION =
   (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.201)(PORT = 1521))
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.202)(PORT = 1521))
   )
    (CONNECT_DATA =
      (SERVICE_NAME = ambdb)
    )
  )
  
ambsdb =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.203)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = ambdb)
    )
  )
  
[[email protected] ~]$ vi $ORACLE_HOME/network/admin/tnsnames.ora
ambmdb =
  (DESCRIPTION =
   (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.201)(PORT = 1521))
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.202)(PORT = 1521))
   )
    (CONNECT_DATA =
      (SERVICE_NAME = ambdb)
    )
  )
  
ambsdb =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.203)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = ambdb)
    )
  )


[[email protected] ~]$ vi $ORACLE_HOME/network/admin/listener.ora
SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (GLOBAL_DBNAME = ambdb)
      (ORACLE_HOME = /u01/app/oracle/product/11.2.0/db_1)
      (SID_NAME = ambdb)
    )
  )
LISTENER =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = amb03)(PORT = 1521))
  )
ADR_BASE_LISTENER = /u01/app/oracle

[[email protected] ~]$ lsnrctl start
[[email protected] ~]$ lsnrctl status

[[email protected] ~]$ vi $ORACLE_HOME/network/admin/tnsnames.ora
ambmdb =
  (DESCRIPTION =
   (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.201)(PORT = 1521))
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.202)(PORT = 1521))
   )
    (CONNECT_DATA =
      (SERVICE_NAME = ambdb)
    )
  )
  
ambsdb =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.203)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = ambdb)
    )
  )


[[email protected] ~]$ tnsping ambsdb
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.203)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = ambdb)))
OK (110 msec)

[[email protected] ~]$ tnsping ambmdb
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.201)(PORT = 1521)) (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.202)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = ambdb)))
OK (0 msec)


[[email protected] ~]$ vi .bash_profile
export ORACLE_SID=ambdb
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1
export PATH=$ORACLE_HOME/bin:$PATH
export DISPLAY=192.168.1.200:0
export NLS_LANG=AMERICAN_AMERICA.UTF8
export NLS_DATE_FORMAT="yyyy-mm-dd hh24:mi:ss"
stty erase ^H

[[email protected] ~]$ source .bash_profile 

[[email protected] ~]$ cd $ORACLE_HOME/dbs
[[email protected] dbs]$ vi initambdb.ora 
*.audit_file_dest='/u01/app/oracle/admin/ambdb/adump'
*.audit_trail='db'
*.compatible='11.2.0.4.0'
*.control_files='/u01/app/oracle/oradata/ambdb/control01.ctl','/u01/app/oracle/fast_recovery_area/ambdb/control02.ctl'
*.db_block_size=8192
*.db_domain=''
*.db_name='ambdb'
*.db_recovery_file_dest='/u01/app/oracle/fast_recovery_area'
*.db_recovery_file_dest_size=107374182400
*.db_file_name_convert='+DATAFILE/ambdb/datafile','/u01/app/oracle/oradata/ambdb','+DATAFILE/ambdb/tempfile','/u01/app/oracle/
oradata/ambdb'
*.db_unique_name='ambsdb'
*.diagnostic_dest='/u01/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=ambdbXDB)'
*.fal_server='ambmdb'
*.log_archive_config='dg_config=(ambmdb,ambsdb)'
*.log_archive_dest_1='location=USE_DB_RECOVERY_FILE_DEST valid_for=(all_logfiles,all_roles) db_unique_name=ambsdb'
*.log_archive_dest_2='service=ambmdb lgwr async valid_for=(online_logfiles,primary_role) db_unique_name=ambmdb'
*.log_file_name_convert='+DATAFILE/ambdb/onlinelog','/u01/app/oracle/oradata/ambdb'
*.memory_max_target=1073741824
*.memory_target=1073741824
*.open_cursors=300
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.standby_file_management='auto'
*.undo_tablespace='UNDOTBS1'

[[email protected] dbs]$ sqlplus / as sysdba
SQL> create spfile from pfile;
File created.

[[email protected] dbs]$ orapwd file=/u01/app/oracle/product/11.2.0/db_1/dbs/orapwambdb password=oracle entries=5 force=y


[[email protected] ~]$ mkdir -p /u01/app/oracle/admin/ambdb/adump
[[email protected] ~]$ mkdir -p /u01/app/oracle/oradata/ambdb
[[email protected] ~]$ mkdir -p /u01/app/oracle/fast_recovery_area/ambdb


[[email protected] ~]$ sqlplus / as sysdba
SQL> startup nomount;ORACLE instance started.
Total System Global Area 1068937216 bytes
Fixed Size                  2260088 bytes
Variable Size             432014216 bytes
Database Buffers          629145600 bytes
Redo Buffers                5517312 bytes

[[email protected] ~]$ rman target sys/[email protected] auxiliary sys/[email protected] nocatalog
Recovery Manager: Release 11.2.0.4.0 - Production on Wed Nov 14 13:41:26 2018
Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.
connected to target database: AMBDB (DBID=4127342910)
using target database control file instead of recovery catalog
connected to auxiliary database: AMBDB (DBID=4127342910)

RMAN> duplicate target database for standby dorecover nofilenamecheck;


[[email protected] ~]$ sqlplus / as sysdba
SQL> alter database add standby logfile thread 1 '/u01/app/oracle/oradata/ambdb/standby01.log' size 50m;
SQL> alter database add standby logfile thread 1 '/u01/app/oracle/oradata/ambdb/standby02.log' size 50m;
SQL> alter database add standby logfile thread 1 '/u01/app/oracle/oradata/ambdb/standby03.log' size 50m;

SQL> alter database add standby logfile thread 2 '/u01/app/oracle/oradata/ambdb/standby04.log' size 50m;
SQL> alter database add standby logfile thread 2 '/u01/app/oracle/oradata/ambdb/standby05.log' size 50m;
SQL> alter database add standby logfile thread 2 '/u01/app/oracle/oradata/ambdb/standby06.log' size 50m;

SQL> alter database recover managed standby database disconnect from session using current logfile;


[[email protected] ~]$ sqlplus / as sysdba
SQL> alter system set log_archive_dest_state_2=enable scope=both;
SQL> alter system switch logfile;

[[email protected] ~]$ sqlplus / as sysdba
SQL> alter database recover managed standby database cancel;
SQL> alter database open;
SQL> alter database recover managed standby database disconnect from session using current logfile;


[[email protected] ~]$ sqlplus / as sysdba
SQL> set line 200
SQL> col database_mode for a30
SQL> col protection_mode for a30
SQL> col recovery_mode for a30
SQL> select dest_id , database_mode , recovery_mode , protection_mode from v$archive_dest_status where dest_id=2;
   DEST_ID DATABASE_MODE                  RECOVERY_MODE                  PROTECTION_MODE
---------- ------------------------------ ------------------------------ ------------------------------
         2 OPEN_READ-ONLY                 MANAGED REAL TIME APPLY        MAXIMUM PERFORMANCE
         
SQL> col dest_name for a20
SQL> col destination for a30
SQL> col error for a50 
SQL> select dest_id,dest_name,status, destination, error from v$archive_dest where dest_id<=2;
   DEST_ID DEST_NAME            STATUS                      DESTINATION                    ERROR
---------- -------------------- --------------------------- ------------------------------ --------------------------------------------------
         1 LOG_ARCHIVE_DEST_1   VALID                       USE_DB_RECOVERY_FILE_DEST
         2 LOG_ARCHIVE_DEST_2   VALID                       ambsdb
         
SQL> col type for a20
SQL> select dest_name,destination,status,type,archived_seq#,applied_seq# from v$archive_dest_status where dest_id<=2; 
DEST_NAME            DESTINATION                    STATUS                      TYPE                 ARCHIVED_SEQ# APPLIED_SEQ#
-------------------- ------------------------------ --------------------------- -------------------- ------------- ------------
LOG_ARCHIVE_DEST_1                                  VALID                       LOCAL                           30            0
LOG_ARCHIVE_DEST_2   ambsdb                         VALID                       PHYSICAL                        23           22

SQL> select thread# , sequence# , status from v$log;
   THREAD#  SEQUENCE# STATUS
---------- ---------- ------------------------------------------------
         1         31 CURRENT
         1         30 INACTIVE
         2         23 INACTIVE
         2         24 CURRENT


[[email protected] ~]$ sqlplus / as sysdba 
SQL> select thread# , sequence# , archived , status from v$standby_log;
   THREAD#  SEQUENCE# ARCHIVED   STATUS
---------- ---------- ---------- ------------------------------
         1         31 YES        ACTIVE
         1          0 NO         UNASSIGNED
         1          0 YES        UNASSIGNED
         2          0 NO         UNASSIGNED
         2         24 YES        ACTIVE
         2          0 YES        UNASSIGNED
         
SQL> select process , status , thread# , sequence# , block# , blocks  from v$managed_standby where process != 'ARCH';
PROCESS                     STATUS                                  THREAD#  SEQUENCE#     BLOCK#     BLOCKS
--------------------------- ------------------------------------ ---------- ---------- ---------- ----------
MRP0                        APPLYING_LOG                                  2         24      20942     102400
RFS                         IDLE                                          0          0          0          0
RFS                         IDLE                                          0          0          0          0
RFS                         IDLE                                          0          0          0          0
RFS                         IDLE                                          1         31      49129          1
RFS                         IDLE                                          0          0          0          0
RFS                         IDLE                                          0          0          0          0
RFS                         IDLE                                          0          0          0          0
RFS                         IDLE                                          2         24      20942          1


转载自://blog.51cto.com/13598811/2316741

招聘 不方便扫码就复制添加关注:程序员招聘谷,微信号:jobs1024



CentOS7.3上部署安装Oracle12c
在CentOS7上安装Oracle的方法,速速get起来
Oracle RAC SCN传播方式(Broadcast-On-Commit)
OracleRACSCN传播方式(Broadcast-On-Commit)
CentOS7 下 安装 Oracle12c
CentOS7下完整安装Oracle12cOracle介绍OracleDatabase,又名OracleRDBMS,或简称Oracle。是甲骨文公司的一款关系数据库管理系统。它是在数据库领域一直处于领先地位的产品??梢运礝racle数据库系统是目前世界上流行的关系数据库管理系统,系统可移植性好、使用方便、功能强,适用于各类大、中、小、微机环境。它是一种高效率、可靠性好的适应高吞吐量的数据库解决方案
Oracle Grid Infrastructure SCAN(单一客户访问名称)
OracleGridInfrastructureSCAN(单一客户访问名称)
Centos7中部署安装Oracle 12c
oracle数据库是在数据库领域一直处于领先地位的产品??梢运礝racle数据库系统是目前世界上流行的关系数据库管理系统,系统可移植性好、使用方便、功能强,适用于各类大、中、小、微机环境。它是一种高效率、可靠性好的适应高吞吐量的数据库解决方案。Oracle数据库12c引入了一个新的多承租方架构,使用该架构可轻松部署和管理数据库云。此外,一些创新特性可最大限度地提高资源使用率和灵活性,如Oracle
oracle sql monitor
sqlmonitor
Oracle 数据库实例与ASM实例的通信
Oracle数据库实例与ASM实例的通信
Oracle RAC 实例管理(Cluster Group Service)
OracleRAC实例管理(ClusterGroupService)