Bootstrap

Oracle数据库巡检 - RAC巡检

RAC巡检

grid用户

sqlplus / as sysasm

crs_stat -t

ora.scan1.vip服务默认是在第一台主机上的,第一台主机挂掉之后,以秒计切换到第二台主机上
正常情况下:ora.gsd和ora.ons这两个服务是不开的
ora.ons   --数据库与中间件相连的,作为通讯用的
ora.gsd   --全局服务进程,兼容oracle9i
ora.cvu   --集群验证服务


#检查crs服务状态
crsctl check crs

#查看asm的命令
asmcmd
lsdg

#查看监听状态
lsnrctl status

#查看资源情况
crsctl status res -t

数据库状态

#查看数据库模式
select name,open_mode from v$database;
#查看实例状态:
select instance_name,status,DATABASE_TYPE from v$instance;

RAC的启动与停止

#启动
su - root
crsctl start crs
crsctl check crs
crsctl status res -t
crs_stat -t

su - oracle
sqlplus "/as sysdba"
startup
select name,open_mode from v$database;
select instance_name,status,DATABASE_TYPE from v$instance;



#停止
su - oracle
sqlplus "/as sysdba"
shutdown immediate

su - root
crsctl stop crs

RAC日常检查与操作

crsctl check crs
crsctl status res -t
crs_stat -t
asmcmd lsdg
ocrcheck

再检查grid,db日志,是否有异常



#检查数据库运行状态
srvctl status database -d testdb
#检查数据库实例的运行状态
srvctl status instance -d testdb -i testpdb1
#显示已配置的数据库信息
srvctl config database
#显示已配置的数据库的具体信息
srvctl config database -d testdb
#查看ASM状态
srvctl status asm
#停止数据库testdb的实例testpdb1
srvctl stop instance -d testdb -i testpdb1

RAC常用命令

crsctl add       - add a resource, type or other entity
crsctl check     - check a service, resource or other entity
crsctl config    - output autostart configuration
crsctl debug     - obtain or modify debug state
crsctl delete    - delete a resource, type or other entity
crsctl disable   - disable autostart
crsctl discover  - discover DHCP server
crsctl enable    - enable autostart
crsctl get       - get an entity value
crsctl getperm   - get entity permissions
crsctl lsmodules - list debug modules
crsctl modify    - modify a resource, type or other entity
crsctl query     - query service state
crsctl pin       - pin the nodes in the node list
crsctl relocate  - relocate a resource, server or other entity
crsctl replace   - replaces the location of voting files
crsctl release   - release a DHCP lease
crsctl request   - request a DHCP lease
crsctl setperm   - set entity permissions
crsctl set       - set an entity value
crsctl start     - start a resource, server or other entity
crsctl status    - get status of a resource or other entity
crsctl stop      - stop a resource, server or other entity
crsctl unpin     - unpin the nodes in the node list
crsctl unset     - unset an entity value, restoring its default


srvctl

Usage: srvctl <command> <object> [<options>]
    commands: enable|disable|start|stop|relocate|status|add|remove|modify|getenv|setenv|unsetenv|config|convert|upgrade
    objects: database|instance|service|nodeapps|vip|network|asm|diskgroup|listener|srvpool|server|scan|scan_listener|oc4j|home|filesystem|gns|cvu
For detailed help on each command and object and its options use:
  srvctl <command> -h or
  srvctl <command> <object> -h


crs_stat -t
crs_stop
crs_start

ocrconfig
ocrcheck

Oracle rac 与 单实例高可用crs管理命令的区别

单实例

#启动和停止has服务
crsctl stop has
crsctl start has
#检查高可用状态:
crsctl check has
#禁止/允许开机自启动:
crsctl disable has
crsctl enable has
#查看资源命令
crsctl stat res -t
#列出grid的常用服务
crs_stat -t
#详细列出grid服务
crs_stat -p

执行过程

[root@testos ~]# crsctl start has
CRS-4123: Oracle High Availability Services has been started.
[root@testos ~]# 
[root@testos ~]# crsctl check has
CRS-4638: Oracle High Availability Services is online
[root@testos ~]# crs_stat -t
Name           Type           Target    State     Host        
------------------------------------------------------------
ora....TA01.dg ora....up.type ONLINE    ONLINE    testdb   			#磁盘组
ora.DGGRID1.dg ora....up.type ONLINE    ONLINE    testdb   			#磁盘组
ora....VERY.dg ora....up.type ONLINE    ONLINE    testdb   			#磁盘组   
ora....STEM.dg ora....up.type ONLINE    ONLINE    testdb   			#磁盘组   
ora....ER.lsnr ora....er.type ONLINE    ONLINE    testdb			#监听   
ora.asm        ora.asm.type   ONLINE    ONLINE    testdb   			#ASM服务
ora.cssd       ora.cssd.type  ONLINE    ONLINE    testdb   			#cluster服务
ora.diskmon    ora....on.type OFFLINE   OFFLINE               		#针对一体机设计的监控服务
ora.evmd       ora.evm.type   ONLINE    ONLINE    testdb   			#事件进程
ora.testdb.db  ora....se.type OFFLINE   OFFLINE               		#数据库服务,offline表示数据库没有启动
ora.ons        ora.ons.type   OFFLINE   OFFLINE               		#数据库与中间件连接的通信服务
[root@testos ~]# 
[root@testos ~]# crs_stat -p
NAME=ora.DGDATA01.dg
TYPE=ora.diskgroup.type
ACTION_SCRIPT=
AUTO_START=always
CHECK_INTERVAL=300
DESCRIPTION=CRS resource type definition for ASM disk group resource
RESTART_ATTEMPTS=5
SCRIPT_TIMEOUT=60
START_TIMEOUT=900
STOP_TIMEOUT=180
UPTIME_THRESHOLD=1d

NAME=ora.DGGRID1.dg
TYPE=ora.diskgroup.type
ACTION_SCRIPT=
AUTO_START=always
CHECK_INTERVAL=300
DESCRIPTION=CRS resource type definition for ASM disk group resource
RESTART_ATTEMPTS=5
SCRIPT_TIMEOUT=60
START_TIMEOUT=900
STOP_TIMEOUT=180
UPTIME_THRESHOLD=1d

NAME=ora.DGRECOVERY.dg
TYPE=ora.diskgroup.type
ACTION_SCRIPT=
AUTO_START=always
CHECK_INTERVAL=300
DESCRIPTION=CRS resource type definition for ASM disk group resource
RESTART_ATTEMPTS=5
SCRIPT_TIMEOUT=60
START_TIMEOUT=900
STOP_TIMEOUT=180
UPTIME_THRESHOLD=1d

NAME=ora.DGSYSTEM.dg
TYPE=ora.diskgroup.type
ACTION_SCRIPT=
AUTO_START=always
CHECK_INTERVAL=300
DESCRIPTION=CRS resource type definition for ASM disk group resource
RESTART_ATTEMPTS=5
SCRIPT_TIMEOUT=60
START_TIMEOUT=900
STOP_TIMEOUT=180
UPTIME_THRESHOLD=1d

NAME=ora.LISTENER.lsnr
TYPE=ora.listener.type
ACTION_SCRIPT=
AUTO_START=restore
CHECK_INTERVAL=60
DESCRIPTION=CRS resource type for the Listener
RESTART_ATTEMPTS=5
SCRIPT_TIMEOUT=60
START_TIMEOUT=180
STOP_TIMEOUT=0
UPTIME_THRESHOLD=1d

NAME=ora.asm
TYPE=ora.asm.type
ACTION_SCRIPT=
AUTO_START=restore
CHECK_INTERVAL=1
DESCRIPTION=Oracle ASM resource
RESTART_ATTEMPTS=5
SCRIPT_TIMEOUT=60
START_TIMEOUT=900
STOP_TIMEOUT=600
UPTIME_THRESHOLD=1d

NAME=ora.cssd
TYPE=ora.cssd.type
ACTION_SCRIPT=
ACTIVE_PLACEMENT=0
AUTO_START=never
CHECK_INTERVAL=30
DESCRIPTION="Resource type for CSSD"
FAILOVER_DELAY=0
FAILURE_INTERVAL=3
FAILURE_THRESHOLD=5
HOSTING_MEMBERS=
PLACEMENT=balanced
RESTART_ATTEMPTS=5
SCRIPT_TIMEOUT=600
START_TIMEOUT=600
STOP_TIMEOUT=900
UPTIME_THRESHOLD=1m

NAME=ora.diskmon
TYPE=ora.diskmon.type
ACTION_SCRIPT=
ACTIVE_PLACEMENT=0
AUTO_START=never
CHECK_INTERVAL=3
DESCRIPTION="Resource type for Diskmon"
FAILOVER_DELAY=0
FAILURE_INTERVAL=3
FAILURE_THRESHOLD=5
HOSTING_MEMBERS=
PLACEMENT=balanced
RESTART_ATTEMPTS=10
SCRIPT_TIMEOUT=60
START_TIMEOUT=600
STOP_TIMEOUT=60
UPTIME_THRESHOLD=5s

NAME=ora.evmd
TYPE=ora.evm.type
ACTION_SCRIPT=
ACTIVE_PLACEMENT=0
AUTO_START=always
CHECK_INTERVAL=30
DESCRIPTION="Resource type for Evm Agent"
FAILOVER_DELAY=0
FAILURE_INTERVAL=3
FAILURE_THRESHOLD=5
HOSTING_MEMBERS=
PLACEMENT=balanced
RESTART_ATTEMPTS=10
SCRIPT_TIMEOUT=60
START_TIMEOUT=600
STOP_TIMEOUT=60
UPTIME_THRESHOLD=1m

NAME=ora.testdb.db
TYPE=ora.database.type
ACTION_SCRIPT=
ACTIVE_PLACEMENT=1
AUTO_START=restore
CHECK_INTERVAL=1
DESCRIPTION=Oracle Database resource
FAILOVER_DELAY=0
FAILURE_INTERVAL=60
FAILURE_THRESHOLD=1
HOSTING_MEMBERS=
PLACEMENT=balanced
RESTART_ATTEMPTS=2
SCRIPT_TIMEOUT=60
START_TIMEOUT=600
STOP_TIMEOUT=600
UPTIME_THRESHOLD=1h

NAME=ora.ons
TYPE=ora.ons.type
ACTION_SCRIPT=
AUTO_START=always
CHECK_INTERVAL=60
DESCRIPTION=Oracle ONS resource
RESTART_ATTEMPTS=3
SCRIPT_TIMEOUT=60
START_TIMEOUT=0
STOP_TIMEOUT=0
UPTIME_THRESHOLD=1d

[root@testos ~]# 
[root@testos ~]# crsctl stop has
CRS-2791: Starting shutdown of Oracle High Availability Services-managed resources on 'testdb'
CRS-2673: Attempting to stop 'ora.DGGRID1.dg' on 'testdb'
CRS-2673: Attempting to stop 'ora.DGRECOVERY.dg' on 'testdb'
CRS-2673: Attempting to stop 'ora.DGDATA01.dg' on 'testdb'
CRS-2673: Attempting to stop 'ora.DGSYSTEM.dg' on 'testdb'
CRS-2673: Attempting to stop 'ora.LISTENER.lsnr' on 'testdb'
CRS-2677: Stop of 'ora.DGSYSTEM.dg' on 'testdb' succeeded
CRS-2677: Stop of 'ora.DGRECOVERY.dg' on 'testdb' succeeded
CRS-2677: Stop of 'ora.DGDATA01.dg' on 'testdb' succeeded
CRS-2677: Stop of 'ora.LISTENER.lsnr' on 'testdb' succeeded
CRS-2677: Stop of 'ora.DGGRID1.dg' on 'testdb' succeeded
CRS-2679: Attempting to clean 'ora.DGGRID1.dg' on 'testdb'
CRS-2681: Clean of 'ora.DGGRID1.dg' on 'testdb' succeeded
CRS-2673: Attempting to stop 'ora.asm' on 'testdb'
CRS-2677: Stop of 'ora.asm' on 'testdb' succeeded
CRS-2673: Attempting to stop 'ora.cssd' on 'testdb'
CRS-2677: Stop of 'ora.cssd' on 'testdb' succeeded
CRS-2673: Attempting to stop 'ora.evmd' on 'testdb'
CRS-2677: Stop of 'ora.evmd' on 'testdb' succeeded
CRS-2793: Shutdown of Oracle High Availability Services-managed resources on 'testdb' has completed
CRS-4133: Oracle High Availability Services has been stopped.
[root@testos ~]# 

RAC集群

RAC常用维护操作

RAC基本维护命令
表决磁盘voting disk维护
OCR维护
集群组件状态查看
集群各组件资源配置查看
集群时钟验证
集群数据库和实例操作
RAC集群虚拟VIP地址漂移问题
RAC集群SCAN-IP地址漂移问题
ASM实例
ASM磁盘组
ASM磁盘组操作
向磁盘组中添加删除磁盘
磁盘组数据重新平衡
ASM文件目录结构
ASM目录和别名操作
ASM表空间及OMF操作
ASM日志组操作
RAC开启归档模式
asmcmd命令行工具使用
ASM参数文件spfile配置
RAC-SCAN-IP地址修改
RAC-VIP地址修改
RAC-PUBLIC-IP地址修改
RAC-心跳网络IP地址修改
RAC-HA高可用和LB负载均衡
Failover故障转移客户端TAF配置
Failover故障转移测试
添加删除Service服务
负载均衡配置及测试
https://edu.51cto.com/course/16558.html

oracle rac修改主机名

https://blog.csdn.net/xuliq/article/details/52863339

ocr操作

备份恢复OCR

问题记录

ocr的备份恢复 模拟OCR磁盘组损坏

https://blog.csdn.net/weixin_39133690/article/details/102878859

Oracle RAC 11.2.0.4 在OCR磁盘组损坏的情况下使用本地备份恢复

https://www.cnblogs.com/zzzqh/p/15501496.html

;