DevOps让系统管理更轻松。
分类: Oracle
2009-11-15 16:17:52
1).启动和停止某节点上实例
停止某节点上的应用
2.emctl stop dbconsole (使用oracle用户,如果启动了em,则停止)
3.srvctl stop instance -d pna -i pna1 (停实例pna1)
4.srvctl stop asm -n udb1 (停udb1上的asm实例)
5.srvctl stop nodeapps -n udb1 (停udb1上的应用,包括虚拟 IP、GSD、TNS 监听器和 ONS)
启动某节点上的应用(跟停止步骤相反)
2.srvctl start nodeapps -n udb1 (起应用,包括虚拟 IP、GSD、TNS 监听器和 ONS)
3.srvctl start asm -n udb1 (启动asm实例)
4.srvctl start instance -d pna -i pna1 (启动pna1实例)
5.emctl start dbconsole (如果配置了em,需要使用pnae进行启动)
启动/停止所有实例
srvctl start database -d pna
srvctl stop database -d pna
2).状态监控
所有实例和服务的状态
$ srvctl status database -d pna
Instance pna1 is running on node udb1
Instance pna2 is running on node udb2
单个实例的状态
$ srvctl status instance -d pna -i pna2
Instance pna2 is running on node udb2
在数据库全局命名服务的状态
$ srvctl status service -d pna -s pnatest
Service pnatest is running on instance(s) pna2, pna1
特定节点上节点应用程序的状态
$ srvctl status nodeapps -n udb1
VIP is running on node:udb1
GSD is running on node:udb1
Listener is running on node:udb1
ONS daemon is running on node:udb1
ASM 实例的状态
$ srvctl status asm -n udb1
ASM instance +ASM1 is running on node udb1.
列出配置的所有数据库
$ srvctl config database
pna
显示 RAC 数据库的配置
$ srvctl config database -d pna
udb1 pna1 /data/oracle/product/10.1.0/db_1
udb2 pna2 /data/oracle/product/10.1.0/db_1
显示指定集群数据库的所有服务
$ srvctl config service -d pna
显示节点应用程序的配置 -(VIP、GSD、ONS、监听器)
$ srvctl config nodeapps -n udb1 -a -g -s -l
显示 ASM 实例的配置
$ srvctl config asm -n udb1
集群中所有正在运行的实例
SELECT
inst_id
, instance_number inst_no
, instance_name inst_name
, parallel
, status
, database_status db_status
, active_state state
, host_name host
FROM gv$instance
ORDER BY inst_id;
INST_ID INST_NO INST_NAME PAR STATUS DB_STATUS STATE HOST
-------- -------- ---------- --- ------- ------------ --------- -------
1 1 pna1 YES OPEN ACTIVE NORMAL udb1
2 2 pna2 YES OPEN ACTIVE NORMAL udb2
位于磁盘组中的所有数据文件
select name from v$datafile
union
select member from v$logfile
union
select name from v$controlfile
union
select name from v$tempfile;
显示磁盘组的所有 ASM 磁盘
SELECT path
FROM v$asm_disk;
3).相关服务
[root@dev101-88 init.d]# ll /etc/init.d/init*
-r-xr-xr-x 1 root root 1951 Nov 4 08:57 /etc/init.d/init.crs
-r-xr-xr-x 1 root root 4714 Nov 4 08:57 /etc/init.d/init.crsd
-r-xr-xr-x 1 root root 35394 Nov 4 08:57 /etc/init.d/init.cssd
-r-xr-xr-x 1 root root 3190 Nov 4 08:57 /etc/init.d/init.evmd
[root@dev101-88 init.d]#
[root@dev101-88 init.d]# ll /etc/rc3.d/S96*
lrwxrwxrwx 1 root root 20 Nov 4 08:57 /etc/rc3.d/S96init.crs -> /etc/init.d/init.crs
在inittab文件中增加的配置项:
cat /etc/inittab
...
# Run xdm in runlevel 5
x:5:respawn:/etc/X11/prefdm -nodaemon
h1:35:respawn:/etc/init.d/init.evmd run >/dev/null 2>&1 h2:35:respawn:/etc/init.d/init.cssd fatal >/dev/null 2>&1 h3:35:respawn:/etc/init.d/init.crsd run >/dev/null 2>&1 ...
看以看到,启动的时候通过启动/etc/init.d/init.crs服务来启动所有的资源和数据库
查看所有的资源情况
crs_stat -t
[root@dev101-88 bin]# crs_stat -t
Name Type Target State Host
------------------------------------------------------------
ora....L1.inst application ONLINE ONLINE dev101-87
ora....L2.inst application ONLINE ONLINE dev101-88
ora.ORCL.db application ONLINE ONLINE dev101-88
ora....SM1.asm application ONLINE ONLINE dev101-87
ora....87.lsnr application ONLINE ONLINE dev101-87
ora....-87.gsd application ONLINE ONLINE dev101-87
ora....-87.ons application ONLINE ONLINE dev101-87
ora....-87.vip application ONLINE ONLINE dev101-87
ora....SM2.asm application ONLINE ONLINE dev101-88
ora....88.lsnr application ONLINE ONLINE dev101-88
ora....-88.gsd application ONLINE ONLINE dev101-88
ora....-88.ons application ONLINE ONLINE dev101-88
ora....-88.vip application ONLINE ONLINE dev101-88
通过crs_stat 来查看启动的资源情况
程序crs_stop可以用来停止某一资源
程序crs_start则用来启动对应某一资源
4) asmcmd实用程序
用来管理asm文件系统,操作类似linux
[root@dev101-88 init.d]# su - oracle
[oracle@dev101-88 ~]$ export ORACLE_SID=+ASM2
[oracle@dev101-88 ~]$ asmcmd
ASMCMD> help
asmcmd [-p] [command]
The environment variables ORACLE_HOME and ORACLE_SID determine the
instance to which the program connects, and ASMCMD establishes a
bequeath connection to it, in the same manner as a SQLPLUS / AS
SYSDBA. The user must be a member of the SYSDBA group.
Specifying the -p option allows the current directory to be displayed
in the command prompt, like so:
ASMCMD [+DATAFILE/ORCL/CONTROLFILE] >
[command] specifies one of the following commands, along with its
parameters.
Type "help [command]" to get help on a specific ASMCMD command.
commands:
--------
cd
du
find
help
ls
lsct
lsdg
mkalias
mkdir
pwd
rm
rmalias
ASMCMD> ls
VOL_ARC/
VOL_DATA/
ASMCMD> cd VOL_DATA
ASMCMD> ls
ORCL/
ASMCMD> cd ORCL
ASMCMD> ls
CONTROLFILE/
DATAFILE/
ONLINELOG/
PARAMETERFILE/
TEMPFILE/
spfileORCL.ora
查看数据文件
ASMCMD> cd DATAFILE
ASMCMD> ls
SYSAUX.262.702037609
SYSTEM.260.702037599
UNDOTBS1.261.702037607
UNDOTBS2.264.702037613
USERS.265.702037617
回到在线重做日志目录
ASMCMD> cd ../ONLINELOG
ASMCMD> ls
group_1.257.702037589
group_2.258.702037591
group_3.266.702038487
group_4.267.702038489
group_5.259.702037595
group_6.268.702038493
查看归档日志
ASMCMD> cd ../../../
ASMCMD> ls
VOL_ARC/
VOL_DATA/
ASMCMD> cd VOL_ARC
ASMCMD> ls
ORCL/
ASMCMD> cd ORCL
ASMCMD> ls
1_11_702037583.dbf
1_12_702037583.dbf
1_13_702037583.dbf
2_1_702037583.dbf
2_2_702037583.dbf
2_3_702037583.dbf
ARCHIVELOG/
CONTROLFILE/
ONLINELOG/
ASMCMD> exit
[oracle@dev101-88 ~]$