oracle怎么切换模式,oracle用户切换
Oracle怎么从非归档模式变成归档模式,详细步骤
操作步骤:
创新互联公司是专业的睢宁县网站建设公司,睢宁县接单;提供网站建设、网站制作,网页设计,网站设计,建网站,PHP网站建设等专业做网站服务;采用PHP框架,可快速的进行睢宁县网站开发网页制作和功能扩展;专业做搜索引擎喜爱的网站,专业的做网站团队,希望更多企业前来合作!
1 登录数据库查看数据库的归档状态
SQL archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 2923
Next log sequence to archive 2925
Current log sequence 2925
2 关闭数据库
SQLshutdown immediate;
3 启动数据库到mount状态
SQLstartup mount;
4 启动归档模式
SQLalter database noarchivelog; (非归档模式为:alter database noarchivelog)
如果报错:
SQL alter database noarchivelog;
alter database noarchivelog
*
ERROR at line 1:
ORA-38774: cannot disable media recovery - flashback database is enabled
先关闭flashback
SQL alter database flashback off;
Database altered.
再更改为非归档模式
SQL alter database noarchivelog;
Database altered.
5 打开数据库
SQLalter database open;更改数据库的非归档模式需要重新启动数据库,在mount模式下修改,简要步骤
1 以shutdown immediate方式关闭数据库
2 启动实例到mount状态
3 更改运行非模式并打开数据库
ORACLE如何切换到用户需要的数据库?
1、使用组合键“Win + R”打开运行对话框,在输入框中输入 regedit 并回车打开“注册表编辑器”。
2、在“注册表编辑器”对话框,依次展开 HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE\KEY_OraDb10g_home1名称为 ORACLE_SID 的数据 orcl 即 Oracle数据库的SID。
3、在远程连接工具 XShell使用 root 用户或者 oracle 用户连接 Linux/Unix Oracle数据库服务器。
4、输入命令 su - oracle 切换到 oracle 用户即可。
oracle数据库切换问题
你这个属于主、备机切换
1. 察看主库状态
select switchover_status from v$database;
收集主库上的临时表空间的情况,原因是备库激活后临时文件可能丢失,需要手工建上去:
col file_name format a40
select file_name,tablespace_name,bytes/1024/1024 from dba_temp_files;
FILE_NAME TABLESPACE_NAME BYTES/1024/1024
---------------------------------------- -------------------- ---------------
/data/oradata/alihr/temp01.dbf TEMP 2048
2.切换主库到standby
alter database commit to switchover to physical standby;
或:
ALTER DATABASE COMMIT TO SWITCHOVER TO PHYSICAL STANDBY WITH SESSION SHUTDOWN;
shutdown immediate;
startup nomount;
alter database mount standby database;
3.验证要被切换的standby是否接收到switch to 通知
SELECT SWITCHOVER_STATUS FROM V$DATABASE;
以前的状态就是SESSIONS ACTIVE,现在就变为TO PRIMARY
4.切换物理standby到主用模式,检查redo log是否创建好
ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY;
shutdown immediate;
startup;
5. standby数据库切换成主库后,检查是否需要、对临时表空间增加临时文件:
先检查临时文件是否丢失:
col file_name format a60
select file_name,tablespace_name from dba_temp_files;
把结果前面原主库上的临时文件进行对比,如有丢失则使用如下命令增加:
alter tablespace temp add tempfile '/data/oradata/alihr/temp02.dbf' size 2048M reuse;
正常情况下,如果db_file_name_convert参数设置正确的话,11g会自动建立temp file
6.在新的standby机器上
alter system set log_archive_dest_state_2='defer';
alter database recover managed standby database disconnect from session;
7.检查主备库中fal参数
fal_server服务名是在standby机器的tnsnames中,指向主库,fal_client是在主库上的tnsnames中,指向standby。
fal参数只在standby机器上生效,所以在standby机器上fal_server指向主库,fal_client机器指向备库.
而主库上的fal参数虽然不生效,但为了避免主库切换成standby时,我们还要修改fal参数,所以现在就设置好,
让fal_server指向现在的standby数据库,fal_client指向自己。
8.在新的主库
alter system set log_archive_dest_state_2='enable';
alter system archive log current;
然后到备库上检查备库机器上日志是否正常的传过来了。
9.检查和调整主备库两台机器中的crontab中的数据库备份脚本和删除归档脚本。
=================oracle11g的最大保护和最大可用模式下的切换==================
如果主库是意外宕机的,则直接把备库切换成主库:
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE FINISH;
shutdown immediate;
connect / as sysdba;
startup mount;
ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY;
shutdown immediate;
connect / as sysdba;
startup mount;
ALTER DATABASE SET STANDBY DATABASE TO MAXIMIZE AVAILABILITY;
alter database open;
注意:上面操作中是手工的把数据库重新置成MAXIMIZE AVAILABILITY,否则数据库起来后是最大性能模式。
检查数据库的角色:
select database_role from v$database;
原有主库启动后,如果不是硬盘坏,主库上的数据还存在,则把主库转换成standby就可以了:
主库上:
startup mount;
recover automatic database;
ALTER DATABASE CONVERT TO PHYSICAL STANDBY;
shutdown immediate;
注意千万不要把主库打开了,否则会导致主库的SCN发生变化,无法转换成standby数据库了。
在把原先的主库转化为standby时,有时可能报如下错误:
SQL alter database recover managed standby database finish;
alter database recover managed standby database finish
*
ERROR at line 1:
ORA-00283: recovery session canceled due to errors
ORA-19909: datafile 1 belongs to an orphan incarnation
ORA-01110: data file 1: '/opt/oracle/oradata/oratest/system01.dbf'
这里把到rman中:
list incarnation of database;
reset database to incarnation 1;
recover database;
reset database to incarnation 2;
=========================================================
failover在物理standby的切换
1.检查standby看是否使用了standby log
2.有standby log,执行下面的命令
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE FINISH;
2.1 没有standby log则不执行上面的
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE FINISH SKIP STANDBY LOGFILE;
3. 切换
ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY;
3.1 如果上面3步骤失败,则
ALTER DATABASE ACTIVATE STANDBY DATABASE;
4. 重启db
shutdown immediate
startup
switchover的方法:
主库和物理standby的切换
1.察看主库状态
SELECT SWITCHOVER_STATUS FROM V$DATABASE;
2.切换
ALTER DATABASE COMMIT TO SWITCHOVER TO PHYSICAL STANDBY;
3.原主库
shutdown immediate;
startup nomount
alter database mount standby database;
4.验证要被切换的standby是否接收到switch to 通知
SELECT SWITCHOVER_STATUS FROM V$DATABASE;
增加online redo日志
5.切换物理standby到主
ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY;
shutdown immediate;
startup;
6.在新的standby机器(也就是老的主库)
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION;
7.在新的主库
alter system archive log current;
========active standby database===========
当:
alter database activate standby database;
原来的主库只能通过闪回转化成standby database,但要求数据库的flashback打开。
在新主库上:
select to_char(standby_became_primary_scn) from v$database;
在旧主库上:
SHUTDOWN IMMEDIATE;
STARTUP MOUNT;
FLASHBACK DATABASE TO SCN standby_became_primary_scn;
ALTER DATABASE CONVERT TO PHYSICAL STANDBY;
select max(sequence#) from v$log_history where RESETLOGS_TIME=(select max(RESETLOGS_TIME) from v$log_history);
实例恢复:
recover managed standby database disconnect using current logfile;
=================lgwr设置====================================
alter system set log_archive_dest_3 = 'location=/disk3/arch/bopscha reopen=2 MAX_FAILURE=3';
alter system set log_archive_dest_state_3 = alternate;
alter system set log_archive_dest_1 = 'location=/disk2/arch/bopscha alternate=log_archive_dest_3 reopen=60 MAX_FAILURE=5' ;
*.log_archive_dest_2='SERVICE=DTMRT LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=DTMRT';
alter database add standby logfile group 4 ('/oracle/u02/ORA10GDG/STANDBYRD01.LOG') size 200M;
select group#,thread#,sequence#,archived,status from v$standby_log;
alter database set standby database to maximize {availability | performance | protection};
select protection_mode from v$database;
ORA-19527:
LOG_FILE_NAME_CONVERT='/u02/oracle/oradata/oract/','/u02/oracle/oradata/oract/'
alter system set log_archive_dest_2='SERVICE=bopsteststb lgwr sync affirm';
select frequency, duration from v$redo_dest_resp_histogram where dest_id=2 and frequency1;
SQL ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;
SQL ALTER DATABASE OPEN;
SQL ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT;
alter database convert to snapshot standby;
alter database convert to physical standby;
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT;
alter database commit to switchover to physical standby;
alter database activate standby database finish apply;
alter database recover managed standby database finish;
旧主库转换成standby的步骤:
在新主库上:
select to_char(standby_became_primary_scn) from v$database;
在旧主库上:
SHUTDOWN IMMEDIATE;
STARTUP MOUNT;
FLASHBACK DATABASE TO SCN standby_became_primary_scn;
ALTER DATABASE CONVERT TO PHYSICAL STANDBY;
ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY WITH SESSION SHUTDOWN;
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE FINISH FORCE;
oracle终端如何切换到insert模式
A中有3例,B表中你只能获得2列,可以用常量占位解决
insert into tableA (列1,列2,列3) select 列1,列2,常量 from tableB
例:如下
insert into tableA (列1,列2,列3) select 列1,列2,'123' from tableB 【字符串常量】
insert into tableA (列1,列2,列3) select 列1,列2,123 from tableB 【数值常量】
3ORACLE数据库日志有哪几种模式,如何在不同模式中切换?
有两种模式:
一:日志模式,日志模式的设置分为Archive
Mode和No
Archive
Mode。
二:自动归档模式:自动归档模式的设置分为:Enabled和Disabled
可用可用archive
log
list命令来查看数据库的现行日志和自动归档模式的设置。
希望对你有帮助。
oracle数据库如何切换模式
oracle dg 三大模式切换
1、最大性能模式MAXIMUM PERFORMANCE --默认模式,最大性能模式特点。
192.168.1.181
SQL select database_role,protection_mode,protection_level from v$database;
DATABASE_ROLE PROTECTION_MODE PROTECTION_LEVEL
---------------- -------------------- --------------------
PRIMARY MAXIMUM PERFORMANCE MAXIMUM PERFORMANCE
SQL col dest_name for a25
SQL select dest_name,status from v$archive_dest_status;
DEST_NAME STATUS
------------------------- ---------
LOG_ARCHIVE_DEST_1 VALID
LOG_ARCHIVE_DEST_2 VALID
SQL show parameter log_archive
NAME TYPE VALUE
------------------------------------ ----------- ---------------------------
log_archive_config string dg_config=(orcl,db01)
log_archive_dest_1 string location=/home/oracle/arch_orc
l valid_for=(all_logfiles,all_
roles) db_unique_name=orcl
log_archive_dest_2 string service=db_db01 LGWR ASYNC val
id_for=(online_logfiles,primar
y_roles) db_unique_name=db01
SQL archive log list
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /home/oracle/arch_orcl
Oldest online log sequence 31
Next log sequence to archive 33
Current log sequence 33
192.168.1.183
SQL select database_role,protection_mode,protection_level from v$database;
DATABASE_ROLE PROTECTION_MODE PROTECTION_LEVEL
---------------- -------------------- --------------------
PHYSICAL STANDBY MAXIMUM PERFORMANCE MAXIMUM PERFORMANCE
SQL col dest_name for a25
SQL select dest_name,status from v$archive_dest_status;
DEST_NAME STATUS
------------------------- ---------
LOG_ARCHIVE_DEST_1 VALID
LOG_ARCHIVE_DEST_2 VALID
SQL show parameter log_archive
NAME TYPE VALUE
------------------------------------ ----------- ---------------------------
log_archive_config string dg_config=(db01,orcl)
log_archive_dest_1 string location=/home/oracle/arch_db0
1 valid_for=(all_logfiles,all_
roles) db_unique_name=db01
log_archive_dest_2 string service=db_orcl LGWR ASYNC val
id_for=(online_logfiles,primar
y_roles) db_unique_name=orcl
SQL archive log list
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /home/oracle/arch_orcl
Oldest online log sequence 31
Next log sequence to archive 33
Current log sequence 33
192.168.1.181
SQL alter system switch logfile;
SQL archive log list
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /home/oracle/arch_orcl
Oldest online log sequence 32
Next log sequence to archive 34
Current log sequence 34
192.168.1.183
SQL archive log list
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /home/oracle/arch_db01
Oldest online log sequence 32
Next log sequence to archive 0
Current log sequence 34
2 、最大性能模式--切换到--最大高可用 (默认是最大性能模式---MAXIMUM PERFORMANCE)。
192.168.1.181
SQL select DATABASE_ROLE,PROTECTION_MODE,PROTECTION_LEVEL from v$database;
DATABASE_ROLE PROTECTION_MODE PROTECTION_LEVEL
---------------- -------------------- --------------------
PRIMARY MAXIMUM PERFORMANCE MAXIMUM PERFORMANCE
SQL show parameter log_archive_dest_2
NAME TYPE VALUE
------------------------------------ ----------- ---------------------------
log_archive_dest_2 string service=db_db01 LGWR ASYNC val
id_for=(online_logfiles,primar
y_roles) db_unique_name=db01
192.168.1.181
SQL shutdown immediate
192.168.1.183
SQL alter database recover managed standby database cancel;
SQL shutdown immediate
192.168.1.181
SQL startup mount;
SQL alter database set standby database to maximize availability;
SQL alter system set log_archive_dest_2='service=db_db01 LGWR SYNC valid_for=(online_logfiles,primary_roles) db_unique_name=db01' scope=spfile;
192.168.1.183
SQL startup nomount
SQL alter database mount standby database;
SQL alter system set log_archive_dest_2='service=db_orcl LGWR SYNC valid_for=(online_logfiles,primary_roles) db_unique_name=orcl' scope=spfile;
SQL shutdown immediate
SQL startup nomount
SQL alter database mount standby database;
192.168.1.181
SQL startup
SQL col dest_name for a25
SQL select dest_name,status from v$archive_dest_status;
DEST_NAME STATUS
------------------------- ---------
LOG_ARCHIVE_DEST_1 VALID
LOG_ARCHIVE_DEST_2 VALID
SQL show parameter log_archive_dest_2
NAME TYPE VALUE
------------------------------------ ----------- ---------------------------
log_archive_dest_2 string service=db_db01 LGWR SYNC vali
d_for=(online_logfiles,primary
_roles) db_unique_name=db01
SQL select database_role,protection_level,protection_mode from v$database;
DATABASE_ROLE PROTECTION_LEVEL PROTECTION_MODE
---------------- -------------------- --------------------
PRIMARY MAXIMUM AVAILABILITY MAXIMUM AVAILABILITY
SQL archive log list
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /home/oracle/arch_orcl
Oldest online log sequence 34
Next log sequence to archive 36
Current log sequence 36
192.168.1.183
SQL col dest_name for a25
SQL select dest_name,status from v$archive_dest_status;
DEST_NAME STATUS
------------------------- ---------
LOG_ARCHIVE_DEST_1 VALID
LOG_ARCHIVE_DEST_2 VALID
SQL show parameter log_archive_dest_2
NAME TYPE VALUE
------------------------------------ ----------- ---------------------------
log_archive_dest_2 string service=db_orcl LGWR SYNC vali
d_for=(online_logfiles,primary
_roles) db_unique_name=orcl
SQL select database_role,protection_level,protection_mode from v$database;
DATABASE_ROLE PROTECTION_LEVEL PROTECTION_MODE
---------------- -------------------- --------------------
PHYSICAL STANDBY MAXIMUM AVAILABILITY MAXIMUM AVAILABILITY
SQL archive log list
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /home/oracle/arch_db01
Oldest online log sequence 35
Next log sequence to archive 0
Current log sequence 36
192.168.1.181
SQL alter system switch logfile;
SQL archive log list
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /home/oracle/arch_orcl
Oldest online log sequence 35
Next log sequence to archive 37
Current log sequence 37
192.168.1.183
SQL archive log list
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /home/oracle/arch_db01
Oldest online log sequence 36
Next log sequence to archive 0
Current log sequence 37
3、最大高可用--切换到--最保护能模式,DG最大保护模式Maximum protection。
192.168.1.181
SQL shutdown immediate
192.168.1.183
SQL shutdown immediate
192.168.1.181
SQL alter database set standby database to maximize protection;
SQL shutdown immediate
192.168.1.183
SQL startup nomount
SQL alter database mount standby database;
192.168.1.181
SQL startup
SQL col dest_name for a25
SQL select dest_name,status from v$archive_dest_status;
DEST_NAME STATUS
------------------------- ---------
LOG_ARCHIVE_DEST_1 VALID
LOG_ARCHIVE_DEST_2 VALID
SQL show parameter log_archive_dest_2
NAME TYPE VALUE
------------------------------------ ----------- ---------------------------
log_archive_dest_2 string service=db_db01 LGWR SYNC vali
d_for=(online_logfiles,primary
_roles) db_unique_name=db01
SQL select database_role,protection_level,protection_mode from v$database;
DATABASE_ROLE PROTECTION_LEVEL PROTECTION_MODE
---------------- -------------------- --------------------
PRIMARY MAXIMUM PROTECTION MAXIMUM PROTECTION
SQL archive log list
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /home/oracle/arch_orcl
Oldest online log sequence 37
Next log sequence to archive 39
Current log sequence 39
192.168.1.183
SQL col dest_name for a25
SQL select dest_name,status from v$archive_dest_status;
DEST_NAME STATUS
------------------------- ---------
LOG_ARCHIVE_DEST_1 VALID
LOG_ARCHIVE_DEST_2 VALID
SQL show parameter log_archive_dest_2
NAME TYPE VALUE
------------------------------------ ----------- ---------------------------
log_archive_dest_2 string service=db_db01 LGWR SYNC vali
d_for=(online_logfiles,primary
_roles) db_unique_name=db01
SQL select database_role,protection_level,protection_mode from v$database;
DATABASE_ROLE PROTECTION_LEVEL PROTECTION_MODE
---------------- -------------------- --------------------
PRIMARY MAXIMUM PROTECTION MAXIMUM PROTECTION
SQL archive log list
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /home/oracle/arch_db01
Oldest online log sequence 37
Next log sequence to archive 0
Current log sequence 39
192.168.1.181
SQL alter system switch logfile;
SQL archive log list
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /home/oracle/arch_orcl
Oldest online log sequence 38
Next log sequence to archive 40
Current log sequence 40
192.168.1.183
SQL archive log list
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /home/oracle/arch_db01
Oldest online log sequence 37
Next log sequence to archive 0
Current log sequence 40
网页标题:oracle怎么切换模式,oracle用户切换
网站地址:http://cdiso.cn/article/hcojji.html