标签:ica prot 可用性 stand gap abi 序列号 启动 over
DataGuard的关启状态
启用备库:
SQL>STARTUP NOMOUNT;
SQL>alter database mount standby database;
SQL>alter database recover managed standby database disconnect from session;(同步但不实时应用日志)
关闭备库:
SQL>alter database recover managed standby database cancel;
SQL>shutdown immediate;
从关闭状态打开:
SQL>startup nomount;
SQL>alter database mount standby database;
SQL>alter database open read only;
从恢复状态只读打开:
SQL>
SQL>
SQL>alter database recover managed standby database using current logfile disconnect from session;(同步并实时应用日志)
------------------------------------------------------------------------
主备库的切换:
主库:
SQL>alter database commit to switchover to physical standby;
SQL>shutdown immediate;
SQL>startup nomount;
SQL>alter database mount standby database;
SQL>alter database recover managed standby database disconnect from session;
备库:
SQL>alter database commit to switchover to primary;
SQL>shutdown immediate;
SQL>startup;
------------------------------------------------------------------
非正常切换:(主库当机的时候)启动fallover
备库:
SQL>alter database recover managed standby database finish;
SQL>alter database commit to switchover to primary;
SQL>shutdown immediate;
SQL>startup;
-----------------------------------------------------------------
日常维护命令:
查询数据库状态:
SQL>select instance_name,status from v$instance;
查询主备库:
SQL> select database_role from v$database;
检查数据库的可切换状态:
SQL>
select switchover_status from v$database;
归档一份日志:
alter system switch logfile;
查询归档日志是否被应用:
SQL> select sequence#,dest_id,first_time,next_time,archived,applied from v$archived_log;
查看备库是否和主库同步:
SQL> select archived_thread#,archived_seq#,applied_thread#,applied_seq# from v$archive_dest_status;
查询日志传送情况:
SQL> select * from v$archive_gap;
查询当前主机运行状态:
SQL> select switchover_status,database_role,protection_mode from v$database;
查看当前备库的一些进程情况和进程ID
SQL> select process,status,thread#,sequence#,block#,blocks from v$managed_standby;
查看同步错误情况:
SQL> select error from v$archive_dest;
验证传过来的归档文件:
SQL> select sequence#,first_time,next_time,applied,completion_time from v$archived_log order by sequence#;
查询主备库的归档文件最大序列号是否相同;
SQL> select distinct thread#,max(sequence#) over(partition by thread#) a from v$archived_log;
------------------------------------------------------------------
主备库的切换详解:
主库端:
检查数据库的可切换状态:
SQL>
select switchover_status from v$database;
如果是TO STANDBY则可以正常切换,
alter database commit to switchover to physical standby;
如果是SESSIONS ACTIVE,表示当前有会话处于ACTIVE状态。
alter database commit to switchover to physical standby with session shutdown;
运行完成后主库被修改为备库
备库端:
重启主库
shutdown immediate;
startup mount;
查询备库的可切换状态:
select switchover_status from v$database;
如果是TO PRIMARY则可以正常切换,
alter database commit to switchover to primary;
如果是SESSIONS ACTIVE 则:
alter database commit to switchover to primary with session shutdown ;
运行完成后备库变成主库:
----------------------------------------------------------------------
主库开启日志:
SQL>
show parameter log_archive_dest_state_;
alter system set log_archive_dest_state_2=enable scope=both;
-------------------------------------------------------------------
开启备库
SQL>
alter database recover managed standby database using current logfile disconnect from session;
alter database recover managed standby database cancel;
alter database open;
alter database recover managed standby database using current logfile disconnect from session;
--------------------------------------------------------------------------
查看数据库的保护模式:
select DATABASE_ROLE,PROTECTION_MODE,PROTECTION_LEVEL from v$database;
最大保护:在主库写入的同时保证在备库也写入,(MAXIMUM PROTECTION)
最高可用性:在不影响主库的情况下,提供最大保护数据,(MAXIMUM AVAILABILITY)
最高性能:不是同步写入,在网络环境良好的情况下,几乎是同步的(MAXIMUM PERFORMANCE)
修改保护模式:
alter system set log_archive_dest_2="SERVICE=DG2 ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=DG2";
1、查询oracle的连接数
select count(*) from v$session;
2、查询oracle的并发连接数
select count(*) from v$session where status=‘ACTIVE‘;
3、查看不同用户的连接数
select username,count(username) from v$session where username is not null group by username;
4、查看所有用户:
select * from all_users;
5、查看用户或角色系统权限(直接赋值给用户或角色的系统权限):
select * from dba_sys_privs;
select * from user_sys_privs;
6、查看角色(只能查看登陆用户拥有的角色)所包含的权限
select * from role_sys_privs;
7、查看用户对象权限:
select * from dba_tab_privs;
select * from all_tab_privs;
select * from user_tab_privs;
8、查看所有角色:
select * from dba_roles;
9、查看用户或角色所拥有的角色:
select * from dba_role_privs;
select * from user_role_privs;
10、查看哪些用户有sysdba或sysoper系统权限(查询时需要相应权限)
select * from V$PWFILE_USERS;
oracle data guard的管理
标签:ica prot 可用性 stand gap abi 序列号 启动 over
原文地址:https://www.cnblogs.com/caibaofei/p/8927084.html