大橙子网站建设,新征程启航
为企业提供网站建设、域名注册、服务器等服务
查看oracle数据库是否为归档模式
创新互联-专业网站定制、快速模板网站建设、高性价比东兰网站开发、企业建站全套包干低至880元,成熟完善的模板库,直接使用。一站式东兰网站制作公司更省心,省钱,快速模板网站建设找我们,业务覆盖东兰地区。费用合理售后完善,10多年实体公司更值得信赖。
SQL select name,log_mode from V$database;
NAME LOG_MODE
------------------ ------------------------
TEST NOARCHIVELOG
SQL archive log list
Database log mode No Archive Mode
Automatic archival Disabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 80157
Current log sequence 80163
编辑本段配置数据库的.归档模式
1.改变非归档模式到归档模式:
1)SQL conn / as sysdba (以DBA身份连接数据库)
2)SQL shutdown immediate;(立即关闭数据库)
3)SQL startup mount (启动实例并加载数据库,但不打开)
4)SQL alter database archivelog; (更改数据库为归档模式)
5)SQL alter database open; (打开数据库)
6)SQL alter system archive log start; (启用自动归档)
7)SQL exit (退出)
做一次完全备份,因为非归档日志模式下产生的备份日志对于归档模式已经不可用了.这一步非非常重要!
2.改变归档模式到非归档模式:
1)SQLSHUTDOWN NORMAL/IMMEDIATE;
2)SQLSTARTUP MOUNT;
3)SQLALTER DATABASE NOARCHIVELOG;
4)SQLALTER DATABASE OPEN;
3.归档相关命令
archive log stop;
archive log start;
archive log list;
show parameters;
show parameters log_archive_start;
show parameters log_archive_max_process; #归档进程数
alter system set log_archive_max_process=5; #将归档进程数改为5
select * from v$bgprocess; #检察后台进程
oracle RAC——归档日志的开启方法
==================================
g R 要修改cluster_database参数 G R 和以后的版本就不需要了
例子( g R 或之前) srvctl stop database d RAC节点 sqlstartup mount SQL alter system set log_archive_dest_ = location=/racdb _arch scope=spfile sid= RAC SQL alter system set log_archive_dest_ = location=/racdb _arch scope=spfile sid= RAC SQL alter system set log_archive_dest_ = service=rac scope=spfile sid= RAC SQL alter system set log_archive_dest_ = service=rac scope=spfile sid= RAC SQL alter system set standby_archive_dest= /racdb _arch scope=spfile sid= RAC SQL alter system set standby_archive_dest= /racdb _arch scope=spfile sid= RAC sqlalter system set cluster_database=false scope=spfile sqlshutdown immediate sqlstartup mount sqlalter database archivelog sqlalter database open sqlalter system set cluster_database=true scope=spfile sqlshutdown immediate srvctl start database d RAC
例子( g R 或之后) 节点 SQLstartup mount SQL alter system set log_archive_dest_ = location=/racdb _arch scope=spfile sid= RAC SQL alter system set log_archive_dest_ = location=/racdb _arch scope=spfile sid= RAC SQL alter system set log_archive_dest_ = service=rac scope=spfile sid= RAC SQL alter system set log_archive_dest_ = service=rac scope=spfile sid= RAC SQL alter system set standby_archive_dest= /racdb _arch scope=spfile sid= RAC SQL alter system set standby_archive_dest= /racdb _arch scope=spfile sid= RAC srvctl stop database d RAC节点 SQL startup mount SQL alter database archivelog srvctl start database d RAC
测试归档日志的切换
节点一 二上分别执行切换日志操作如下 SQL alter system switch logfile 操作执行这条语句 次
节点一查询 SQL !ls l /racdb* /racdb _arch total rw r—— oracle oinstall Oct _ _ dbf rw r—— oracle oinstall Oct _ _ dbf rw r—— oracle oinstall Oct _ _ dbf rw r—— oracle oinstall Oct _ _ dbf rw r—— oracle oinstall Oct _ _ dbf /racdb _arch total rw rw—— oracle oinstall Oct _ _ dbf rw rw—— oracle oinstall Oct _ _ dbf rw rw—— oracle oinstall Oct _ _ dbf rw rw—— oracle oinstall Oct _ _ dbf rw rw—— oracle oinstall Oct _ _ dbf
节点二查询
SQL !ls l /racdb* /racdb _arch total rw rw—— oracle oinstall Oct _ _ dbf rw rw—— oracle oinstall Oct _ _ dbf rw rw—— oracle oinstall Oct _ _ dbf rw rw—— oracle oinstall Oct _ _ dbf rw rw—— oracle oinstall Oct _ _ dbf /racdb _arch total rw r—— oracle oinstall Oct _ _ dbf rw r—— oracle oinstall Oct _ _ dbf rw r—— oracle oinstall Oct _ _ dbf rw r—— oracle oinstall Oct _ _ dbf rw r—— oracle oinstall Oct _ _ dbf
节点一 SQL show parameter archive_dest NAME TYPE VALUE
log_archive_dest string log_archive_dest_ string location=/racdb _arch log_archive_dest_ string log_archive_dest_ string service=rac log_archive_dest_ string log_archive_dest_ string log_archive_dest_ string log_archive_dest_ string log_archive_dest_ string log_archive_dest_ string log_archive_dest_ string log_archive_dest_state_ string enable log_archive_dest_state_ string enable log_archive_dest_state_ string enable log_archive_dest_state_ string enable log_archive_dest_state_ string enable log_archive_dest_state_ string enable log_archive_dest_state_ string enable log_archive_dest_state_ string enable log_archive_dest_state_ string enable log_archive_dest_state_ string enable standby_archive_dest string /racdb _arch
节点二
SQL show parameter archive_dest NAME TYPE VALUE
log_archive_dest string log_archive_dest_ string location=/racdb _arch log_archive_dest_ string log_archive_dest_ string service=rac log_archive_dest_ string log_archive_dest_ string log_archive_dest_ string log_archive_dest_ string log_archive_dest_ string log_archive_dest_ string log_archive_dest_ string log_archive_dest_state_ string enable log_archive_dest_state_ string enable log_archive_dest_state_ string enable log_archive_dest_state_ string enable log_archive_dest_state_ string enable log_archive_dest_state_ string enable log_archive_dest_state_ string enable log_archive_dest_state_ string enable log_archive_dest_state_ string enable log_archive_dest_state_ string enable standby_archive_dest string /racdb _arch
lishixinzhi/Article/program/Oracle/201311/18379
1、打开oracle sql developer工具,没有此工具的可以去oracle官网下载安装即可,刚刚安装完成的是没有记录的,只有使用工具执行过后才会留下记录可以查询。打开之后不需要连接数据库就可以查询到sql记录了。
2、在二级菜单中,选择SQL历史记录选项,或者按快捷键F8打开窗口。
3、默认打开是会显示在最下方的小窗口,在标题栏双击鼠标左键,即可最大化窗口,再次双击左键还原窗口。
4、最大化窗口之后,便于更好的查询记录结果,如图所示,以往执行的sql记录都显示出来了,可以在每个栏目标题上单击,进行排序操作,一般可以点击时间戳字段,按时间来排序查询记录。第二次点击,可以切换顺序和逆序。
5、最后一个字段是持续时间,点击排序之后可以查询出哪些sql语句最快,哪些sql语句执行比较慢,需要优先等。
6、对于一些不需要的sql记录可以删除的,因为记录多了不便于查询,没有用的sql最好及时清除了。只需要选择您需要删除的记录,然后点击如图所示的清除按钮,在二次确认弹框中选择是,即可删除。
7、在删除按钮后面就是一个搜索输入框,在此处输入搜索关键字可以模糊匹配到记录,对于记不清的记录,采用模糊搜索的方式查询,效率非常高。工具会自动根据我们输入的关键字进行筛选过滤的。
启动监听日志的步骤如下:
1.首先查看当前监听的状态
[oracle@oel ~]$ lsnrctl status
LSNRCTL for Linux: Version 11.2.0.3.0 – Production on 01-JUL-2012 13:29:58
Copyright (c) 1991, 2011, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=oel)(PORT=1521)))
STATUS of the LISTENER
————————
Alias listener
Version TNSLSNR for Linux: Version 11.2.0.3.0 – Production
Start Date 01-JUL-2012 13:12:51
Uptime 0 days 0 hr. 17 min. 7 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
Listening Endpoints Summary…
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=oel)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Services Summary…
Service “orcl” has 1 instance(s).
Instance “orcl”, status READY, has 1 handler(s) for this service…
Service “orclXDB” has 1 instance(s).
Instance “orcl”, status READY, has 1 handler(s) for this service…
The command completed successfully
从上面显示信息来看,我们监听正常。并且没有看到Listener Log File的信息。
2.进入监听配置,查看监听详细信息
[oracle@oel ~]$ lsnrctl –进入监听配置
LSNRCTL for Linux: Version 11.2.0.3.0 – Production on 01-JUL-2012 13:35:00
Copyright (c) 1991, 2011, Oracle. All rights reserved.
Welcome to LSNRCTL, type “help” for information.
LSNRCTL show –查看监听参数信息
The following operations are available after show
An asterisk (*) denotes a modifier or extended command:
rawmode displaymode
rules trc_file
trc_directory trc_level
log_file log_directory
log_status current_listener
inbound_connect_timeout startup_waittime
snmp_visible save_config_on_stop
dynamic_registration enable_global_dynamic_endpoint
oracle_home pid
connection_rate_limit
LSNRCTL show log_status –查看监听日志状态
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=oel)(PORT=1521)))
LISTENER parameter “log_status” set to OFF
The command completed successfully
上面信息显示Listener parameter “log_status” set to OFF说明监听日志是关闭的。这是时候我们需要启动监听日志。
3.设置当前监听,如果有多个监听,在修改监听配置的时候需要指定某个具体的监听,我这里只有一个默认的Listener,所以不需要设置。我这里还是演示一下。
LSNRCTL show current_listener
Current Listener is LISTENER
LSNRCTL set current_listener Listener
Current Listener is Listener
LSNRCTL show current_listener
Current Listener is Listener
4.启动监听日志,并且保存配置信息
LSNRCTL set log_status on –设置监听日志状态为on
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=oel)(PORT=1521)))
LISTENER parameter “log_status” set to ON
The command completed successfully
LSNRCTL save_config –保存监听配置
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=oel)(PORT=1521)))
Saved listener configuration parameters.
Listener Parameter File /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
Old Parameter File /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.bak
The command completed successfully
5.在查看监听状态
[oracle@oel ~]$ lsnrctl status
LSNRCTL for Linux: Version 11.2.0.3.0 – Production on 01-JUL-2012 13:44:32
Copyright (c) 1991, 2011, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=oel)(PORT=1521)))
STATUS of the LISTENER
————————
Alias listener
Version TNSLSNR for Linux: Version 11.2.0.3.0 – Production
Start Date 01-JUL-2012 13:12:51
Uptime 0 days 0 hr. 31 min. 41 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
Listener Log File /u01/app/oracle/diag/tnslsnr/oel/listener/alert/log.xml
Listening Endpoints Summary…
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=oel)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Services Summary…
Service “orcl” has 1 instance(s).
Instance “orcl”, status READY, has 1 handler(s) for this service…
Service “orclXDB” has 1 instance(s).
Instance “orcl”, status READY, has 1 handler(s) for this service…
The command completed successfully
通过上述配置之后,看到了Listener Log File /u01/app/oracle/diag/tnslsnr/oel/listener/alert/log.xml
最后我们可以通过监听日志来查询里面的详细信息
[oracle@oel ~]$ grep ‘2012-07-01T13:45:40′ /u01/app/oracle/diag/tnslsnr/oel/listener/alert/log.xml|more
msg time=’2012-07-01T13:45:40.302+08:00′ org_id=’oracle’ comp_id=’tnslsnr’
一 设置为归档方式
Sql代码
sql archive log list; #查看是不是归档方式sql alter system set log_archive_start=true scope=spfile; #启用主动归档sql alter system set log_archive_dest=''location=/oracle/ora9/oradata/arch'' scope=spfile;#设置归档路径sql alter system set log_archive_dest_1=''location=/oracle/ora9/oradata/arch1'' scope=spfile;sql alter system set log_archive_dest_2=''location=/oracle/ora9/oradata/arch2'' scope=spfile;#如果归档到两个位置,则可以通过上边方法实现sql alter system set log_archive_format=''arch_%d_%t_%r_%s.log'' #设置归档日记款式sql shutdown immediate;
sql startup mount; #打开控制文件,不打开数据文件sql alter database archivelog; #将数据库切换为归档模式sql alter database open; #将数据文件打开sql archive log list; #查看此时是否处于归档模式查询以确定数据库位于archivelog模式中且归档过程正在运行sql select log_mode from v$database;
sql select archiver from v$instance;
Sql代码
日志切换
sql alter system switch logfile;
这次日志切换将归档写到两个目标地,
即上边的/oracle/ora9/oradata/arch1和/oracle/ora9/oradata/arch1,要是要对目录确认
在oracle情况中运行如下查询:
sql select name from v$archived_log;
而后在操作系统中确认查询所列出的文件
二 设置非归档方式
Sql代码
sql archive log list; #查看是否是归档方式sql alter system set log_archive_start=false scope=spfile;#禁用自动归档
sql shutdown immediate;
sql startup mount; #打开控制文件,不打开数据文件sql alter database noarchivelog; #将数据库切换为非归档模式sql alter database open; #将数据文件打开sql archive log list; #查看此时便处于非归档模式三 归档相关命令
Sql代码
archive log stop;
archive log start;
archive log list;
show parameters;
show parameters log_archive_start;
show parameters log_archive_max_process; #归档进程数alter system set log_archive_max_process=5; #将归档进程数改为5select * from v$bgprocess; #检察后台进程