查看数据库是否运行在归档模式:
SQL> archive log list;
Database log mode No Archive Mode
Automatic archival Disabled #未开启归档
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 117
Current log sequence 119
SQL>
备注:如果数据库已经开启归档,下面的操纵可以忽略。
如上所示未开启归档,可按下面方法开启数据库归档
SQL> shutdownimmediate #关闭数据库
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startupmount; #启动到mount状态
ORACLE instance started.
Total System Global Area 688959488 bytes
Fixed Size 2256432 bytes
Variable Size 566231504 bytes
Database Buffers 117440512 bytes
Redo Buffers 3031040 bytes
Database mounted.
SQL> alterdatabase archivelog; #开启归档
Database altered.
SQL> alterdatabase open; #open数据库
Database altered.
SQL> altersystem set log_archive_dest_1='location=/data/CEBPM/archivelog'; #设置归档路径
System altered.
SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /data/CEBPM/archivelog
Oldest online log sequence 119
Next log sequence to archive 121
Current log sequence 121
验证是否开启闪回
SQL> select flashback_on fromv$database;
FLASHBACK_ON
------------------
NO
备注:如果数据库已经开启flashback,那么下面步骤可忽略。
如上显示,该数据库未开启flashback,可按下面方法开启。
SQL> altersystem set db_recovery_file_dest='/data/CEBPM'; #设置闪回去路径
System altered.
SQL> altersystem set db_recovery_file_dest_size='5G'; #设置闪回区大小
System altered.
SQL> shutdownimmediate; #关闭数据库
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.
Total System Global Area 688959488 bytes
Fixed Size 2256432 bytes
Variable Size 566231504 bytes
Database Buffers 117440512 bytes
Redo Buffers 3031040 bytes
Database mounted.
SQL> alterdatabase flashback on; #开启闪回
Database altered.
SQL> alterdatabase open; #open数据库
Database altered.
SQL> selectflashback_on from v$database; #验证是否开启
FLASHBACK_ON
------------------
YES
验证是否开启focelogging
SQL>select force_logging from v$database;
FOR
---
NO
如果数据库已经开启force logging,那么下面步骤可忽略。
如上可以看出数据库未开启,则按下面步骤执行:
SQL>alter database force logging; #开启force logging
Databasealtered.
SQL>select force_logging fromv$database; #验证
FOR
---
YES
通过下面语句可以查询主库在线日志的大小和组数:
SQL> select group#,bytes/1024/1024 from v$log;
通过下面的语句可以查询备库 Standby 日志的大小和组数:
SQL> select group#,bytes/1024/1024 from v$standby_log;
创建 standby logfile
SQL> alter database add standby logfile group 11
'/u01/app/oracle/oradata/orcl/redo11_stb01.log' size 50M;
SQL> alter database add standby logfile group 12
'/u01/app/oracle/oradata/orcl/redo12_stb01.log'size 50M;
SQL> alter database add standby logfile group 13
'/u01/app/oracle/oradata/orcl/redo13_stb01.log'size 50M;
SQL> alter database add standby logfile group 14
'/u01/app/oracle/oradata/orcl/redo14_stb01.log'size 50M;
SQL> create pfile='/home/oracle/initorcl.ora' from spfile;
File created.
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup pfile='/home/oracle/initorcl.ora'
ORACLE instance started.
Total System Global Area 308981760 bytes
Fixed Size 2252784 bytes
Variable Size 167772176 bytes
Database Buffers 134217728 bytes
Redo Buffers 4739072 bytes
Database mounted.
Database opened.
SQL> create spfile from pfile;
[root@localhost dbs]# cp /home/oracle/initorcl.ora initorcl.ora
[root@localhost ~]# vim /home/oracle/initorcl.ora
orcl.__sga_target=310378496
orcl.__shared_io_pool_size=0
orcl.__shared_pool_size=130023424
orcl.__streams_pool_size=4194304
*.audit_file_dest='/u01/app/oracle/admin/orcl/adump'
*.audit_trail='db'
*.compatible='11.2.0.4.0'
*.control_files='/u01/app/oracle/oradata/orcl/control01.ctl','/u01/app/oracle/fast_recovery_area/orcl/control02.ctl'
*.db_block_size=8192
*.db_domain=''
*.db_name='orcl'
*.db_recovery_file_dest='/u01/app/oracle/fast_recovery_area'
*.db_recovery_file_dest_size=1073741824
*.diagnostic_dest='/u01/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=orclXDB)'
*.log_archive_format='%t_%s_%r.dbf'
*.open_cursors=300
*.pga_aggregate_target=102760448
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.sga_target=308281344
*.undo_tablespace='UNDOTBS1'
DB_UNIQUE_NAME=orcl
LOG_ARCHIVE_CONFIG='DG_CONFIG=(orcl,orcl)'
DB_FILE_NAME_CONVERT='/u01/app/oracle/oradata/orcl/','/u01/app/oracle/oradata/orcl/'
LOG_FILE_NAME_CONVERT='/u01/app/oracle/oradata/orcl/','/u01/app/oracle/oradata/orcl/'
LOG_ARCHIVE_DEST_2=
'SERVICE=orcl LGWR SYNC AFFIRM
VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE)
DB_UNIQUE_NAME=orcl'
LOG_ARCHIVE_DEST_STATE_1=ENABLE
LOG_ARCHIVE_DEST_STATE_2=ENABLE
REMOTE_LOGIN_PASSWORDFILE=EXCLUSIVE
STANDBY_FILE_MANAGEMENT=AUTO
FAL_SERVER=orcl
FAL_CLIENT=orcl
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/31464898/viewspace-2215284/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/31464898/viewspace-2215284/