oracle 11.2和12c RAC的ohasd守护进程对比

前面我们已经讲解过11.2 RAC的启动过程,可以注意到,RAC的根守护进程是/etc/init.d/init.ohasd,那么不同版本的Linux中/etc/init.d/init.ohasd是如何启动的呢?
注意:12.1的非Flex Cluster启动过程跟11.2 RAC一致。但是从12.2beta版 RAC的测试结果来看,从12.2开始OUI安装很可能只有Flex Cluster了,没有了11.2的那种普通RAC了。
.
Linux4和Linux5中,在完成核内引导(内核被载入内存并运行,初始化所有的设备驱动程序和数据结构等)之后,就通过启动一个用户级程序/sbin/init的方式来启动其他用户级的进程或服务。
所以,init始终是第一个进程,其PID始终为1(ps -aux | less),它是系统所有进程的父进程.
[root@lunarnew1 grid]# ps -ef|grep init|grep -v grep
root         1     0  0 Jan14 ?        00:00:00 init [5]                                                                
root      2987     1  0 Jan14 ?        00:00:00 /bin/sh /etc/init.d/init.ohasd run
[root@lunarnew1 grid]#
[root@lunarnew1 grid]# which init
/sbin/init
[root@lunarnew1 grid]#
接下来/sbin/init会读取/etc/inittab的内容,/etc/inittab中包含了很多启动其他用户进程和服务的指令:
其格式如下:
 identifier :  run_level  :  action  :  process
因此,开机自动启动/etc/init.d/init.ohasd的脚本也配置在/etc/inittab中。
我的环境是Linux5.10,看一下ohasd的启动脚本的具体信息:
[root@lunarnew1 grid]# cat /etc/issue
Oracle Linux Server release 5.10
Kernel \r on an \m
 
[root@lunarnew1 grid]#
[root@lunarnew1 grid]# ll /etc/inittab.orig
ls: /etc/inittab.orig: No such file or directory
[root@lunarnew1 grid]# ll /etc/inittab*
-rw-r--r-- 1 root root 1671 Mar 21  2015 /etc/inittab.no_crs
-rw-r--r-- 1 root root 1740 Mar 21  2015 /etc/inittab.crs
-rw-r--r-- 1 root root 1740 Mar 21  2015 /etc/inittab
[root@lunarnew1 grid]#
我们看一下这三个文件哪里不同:
[root@lunarnew1 grid]# diff /etc/inittab.crs /etc/inittab
[root@lunarnew1 grid]# diff /etc/inittab.no_crs /etc/inittab
58a59,60
>
> h1:35:respawn:/etc/init.d/init.ohasd run >/dev/null 2>&1 </dev/null
[root@lunarnew1 grid]#
可以看出,/etc/inittab.no_crs的内容就是在没安装GI以前的/etc/inittab备份文件,而/etc/inittab.crs的内容就是安装GI以后/etc/inittab 备份文件
也就是说,在Linux 5中,安装完RAC(10.2或者11.2)后,该脚本就会增加上面一行启动ohasd守护进程的脚本,如果要在系统启动时启动crs,那么就需要让/etc/inittab中包含下面的一行启动命令:
h1:35:respawn:/etc/init.d/init.ohasd run >/dev/null 2>&1 如果要让系统启动时不启动crs,那么就不能包含上述行。当然这个方法是Oracle不支持的,Oracle建议使用crsctl disable has来禁止开机启动HAS。
(注意,如果rac环境,使用crsctl disable crs命令)
/etc/inittab的全部内容如下(注意,只有Linux 5 和Linux5以下的版本是这样的):
[root@lunarnew1 grid]# cat  /etc/inittab
#
# inittab       This file describes how the INIT process should set up
#               the system in a certain run-level.
#
# Author:       Miquel van Smoorenburg, <miquels@drinkel.nl.mugnet.org>
#               Modified for RHS Linux by Marc Ewing and Donnie Barnes
#
 
# Default runlevel. The runlevels used by RHS are:
#   0 – halt (Do NOT set initdefault to this)
#   1 – Single user mode
#   2 – Multiuser, without NFS (The same as 3, if you do not have networking)
#   3 – Full multiuser mode
#   4 – unused
#   5 – X11
#   6 – reboot (Do NOT set initdefault to this)
#
id:5:initdefault:
 
# System initialization.
si::sysinit:/etc/rc.d/rc.sysinit
 
l0:0:wait:/etc/rc.d/rc 0
l1:1:wait:/etc/rc.d/rc 1
l2:2:wait:/etc/rc.d/rc 2
l3:3:wait:/etc/rc.d/rc 3
l4:4:wait:/etc/rc.d/rc 4
l5:5:wait:/etc/rc.d/rc 5
l6:6:wait:/etc/rc.d/rc 6
 
# Trap CTRL-ALT-DELETE
ca::ctrlaltdel:/sbin/shutdown -t3 -r now
 
# When our UPS tells us power has failed, assume we have a few minutes
# of power left.  Schedule a shutdown for 2 minutes from now.
# This does, of course, assume you have powerd installed and your
# UPS connected and working correctly. 
pf::powerfail:/sbin/shutdown -f -h +2 "Power Failure; System Shutting Down"
 
# If power was restored before the shutdown kicked in, cancel it.
pr:12345:powerokwait:/sbin/shutdown -c "Power Restored; Shutdown Cancelled"
 
 
# Run gettys in standard runlevels
1:2345:respawn:/sbin/mingetty tty1
2:2345:respawn:/sbin/mingetty tty2
3:2345:respawn:/sbin/mingetty tty3
4:2345:respawn:/sbin/mingetty tty4
5:2345:respawn:/sbin/mingetty tty5
6:2345:respawn:/sbin/mingetty tty6
 
# Run xdm in runlevel 5
x:3:respawn:/etc/X11/prefdm -nodaemon
 
 
h1:35:respawn:/etc/init.d/init.ohasd run >/dev/null 2>&1 </dev/null
[root@lunarnew1 grid]#
到了Linux 6中,init只负责读取配置文件,处理各种服务和应用程序的依赖关系,根据事件来启动这些功能和服务,并动态的进行管理。
而事件在Linux 6中是由“Upstart 事件管理器”来管理的,并且这些事件使用initctl工具来控制,initctl的作用类似于Linux5中的chkconfig工具。
我这里的一套在Linux 6.6环境安装的11.2.0.4 单机ASM环境(Standalone),可以看到其中并没有Linux 5中那样/etc/inittab.orig文件:
[root@lunarlib rootwork]# ll /etc/inittab.orig
ls: cannot access /etc/inittab.orig: No such file or directory
[root@lunarlib rootwork]#
也就是说,到了Linux 6版本,Oracle不再将/etc/init.d/init.ohasd的启动不再写入/etc/inittab文件(不由/sbin/init进程根据inittab来启动ohasd的脚本):
[root@lunarlib rootwork]# ll /etc/inittab*
-rw-r-----. 1 root root 884 Apr  6  2015 /etc/inittab
[root@lunarlib rootwork]#
[root@lunarlib rootwork]# tail /etc/inittab
# Default runlevel. The runlevels used are:
#   0 - halt (Do NOT set initdefault to this)
#   1 - Single user mode
#   2 - Multiuser, without NFS (The same as 3, if you do not have networking)
#   3 - Full multiuser mode
#   4 - unused
#   5 - X11
#   6 - reboot (Do NOT set initdefault to this)
#
id:3:initdefault:
[root@lunarlib rootwork]#
那么在Linux 6中Oracle RAC的这个守护进程如何启动的呢?
因为从Linux 6开始系统采用upstart事件引导机制(好像是Linux 6特有的),根据/etc/init/目录下的事件管理配置文件来决定系统在启动时运行哪些服务:
[root@lunarlib init.d]# cat /etc/init/oracle-ohasd.conf
# Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
#
# Oracle OHASD startup
 
start on runlevel [35]
stop  on runlevel [!35]
respawn
exec /etc/init.d/init.ohasd run >/dev/null 2>&1 </dev/null
[root@lunarlib init.d]#
因此,Oracle也采用了这种方式。安装GI时,oracle会为/etc/init.d/init.ohasd引导进程配置一个相应的配置文件,也就是/etc/init/oracle-ohasd.conf配置文件。
也就是说,在Linux 6中使用/etc/init目录下的oracle-ohasd.conf配置文件的启动方式,取代了Linux5中的配置使用/etc/inittab启动的方式。
这个就是Oracle顺应Linux的发展,根据系统启动时的引导和启动服务的机制在Linux中不同版本的变化而变化。
[root@lunarlib rootwork]# ll /etc/init
total 72
-rw-r--r--. 1 root root  412 Jul 22  2014 control-alt-delete.conf
-rw-r--r--. 1 root root  130 Mar 12  2014 init-system-dbus.conf
-rw-r--r--. 1 root root  463 Jul 22  2014 kexec-disable.conf
-rw-r--r--  1 root root  220 Oct 11 01:30 oracle-ohasd.conf
-rw-r--r--. 1 root root  560 Jul 22  2014 plymouth-shutdown.conf
-rw-r--r--. 1 root root  357 Jul 22  2014 prefdm.conf
-rw-r--r--. 1 root root  505 Jul 22  2014 quit-plymouth.conf
-rw-r--r--. 1 root root  417 Jul 22  2014 rc.conf
-rw-r--r--. 1 root root 1046 Jul 22  2014 rcS.conf
-rw-r--r--. 1 root root  430 Jul 22  2014 rcS-emergency.conf
-rw-r--r--. 1 root root  725 Jul 22  2014 rcS-sulogin.conf
-rw-r--r--. 1 root root 2915 Nov 21  2013 readahead-collector.conf
-rw-r--r--. 1 root root 1559 Nov 21  2013 readahead.conf
-rw-r--r--. 1 root root  726 Nov 21  2013 readahead-disable-services.conf
-rw-r--r--. 1 root root 1302 Jul 22  2014 serial.conf
-rw-r--r--. 1 root root  791 Jul 22  2014 splash-manager.conf
-rw-r--r--. 1 root root  473 Jul 22  2014 start-ttys.conf
-rw-r--r--. 1 root root  335 Jul 22  2014 tty.conf
[root@lunarlib rootwork]#
[root@lunarlib rootwork]# ls -l /etc/init/oracle-ohasd.conf
-rw-r--r-- 1 root root 220 Oct 11 01:30 /etc/init/oracle-ohasd.conf
[root@lunarlib rootwork]#
在Linux 6中,可以使用/sbin/initctl工具(类似于Linux5的chkconfig工具)来管理/etc/init.d/init.ohasd的启动。
(注意,Linux5中不能使用chkconfig管理/etc/init.d/init.ohasd进程)
[root@lunarlib rootwork]# initctl list
rc stop/waiting
tty (/dev/tty3) start/running, process 4353
tty (/dev/tty2) start/running, process 4349
tty (/dev/tty1) start/running, process 4347
tty (/dev/tty6) start/running, process 4365
tty (/dev/tty5) start/running, process 4361
tty (/dev/tty4) start/running, process 4359
plymouth-shutdown stop/waiting
control-alt-delete stop/waiting
rcS-emergency stop/waiting
readahead-collector stop/waiting
kexec-disable stop/waiting
quit-plymouth stop/waiting
rcS stop/waiting
prefdm stop/waiting
init-system-dbus stop/waiting
readahead stop/waiting
splash-manager stop/waiting
start-ttys stop/waiting
readahead-disable-services stop/waiting
rcS-sulogin stop/waiting
serial stop/waiting
oracle-ohasd start/running, process 12661
[root@lunarlib rootwork]#
查看oracle-ohasd服务的信息:
[root@lunarlib rootwork]# /sbin/initctl list |grep oracle-ohasd
oracle-ohasd start/running, process 2897
[root@lunarlib rootwork]#
[root@lunarlib rootwork]# ps -ef|grep ohasd
root      2897     1  0 06:05 ?        00:00:01 /bin/sh /etc/init.d/init.ohasd run
root      6651  6336  0 07:52 pts/0    00:00:00 grep ohasd
[root@lunarlib rootwork]#
到了Linux 7,由于系统的引导方式又变化了,系统采用systemd机制,使用 socket 和 D-Bus 来并行启动服务的模式,提供基于守护进程的按需启动策略,已经没有运行级别的概念(但是完全兼容sysvinit)。
哪些需要启动的服务的配置文件放在 /lib/systemd/system/ 目录下,以 *.service命名,类似如下:
在Linux7中,系统启动加载Oracle RAC使用的ohasd单元需要如下配置(安装时,执行root.sh就会配置ohasd服务单元,如果没有配置好,自己手工配置就可以了):
[root@lunar system]# ll /etc/systemd/system/|grep ohasd
-rw-r--r--  1 root root  361 Oct  9 12:29 oracle-ohasd.service
[root@lunar system]#
[root@lunar system]# systemctl list-units -t service|grep ohasd
ohasd.service                      loaded active exited  ohasd.service
oracle-ohasd.service               loaded active running Oracle High Availability Services
[root@lunar system]#
事实上,在Linux 7(当前的版本只有Linux 7.1和7.2)上安装,Oracle 11.2.0.4(在11.2的版本中,只有11.2.0.4支持Linux 7,其余11.2支持Linux 7以下的版本)和12c(当前的是12.1和12.2beta版本)RAC时,有bug,该文件是不能被root.sh创建的,需要自己手工创建。
具体看下服务定义文件的格式:
[root@lunar system]# cat /etc/systemd/system/oracle-ohasd.service
# Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
#
# Oracle OHASD startup
 
[Unit]
Description=Oracle High Availability Services
After=syslog.target network.target remote-fs.target
 
[Service]
ExecStart=/etc/init.d/init.ohasd run >/dev/null 2>&1 </dev/null
Type=simple
Restart=always
 
[Install]
WantedBy=multi-user.target graphical.target
[root@lunar system]#
systemd的单元定义中,如果指定了“After=”,那么就表示这个服务依赖于After指定的服务。如果没有After,就表示这个服务可以跟其他的并行启动。
这里定义了oracle-ohasd.service在syslog.target network.target remote-fs.target这三个单元启动后开始启动
执行命令为:/etc/init.d/init.ohasd run >/dev/null 2>&1 启动类型为:simple
最后,我们查看系统当前加载的所有单元:
[root@lunar system]# ll /etc/systemd/system/
total 16
drwxr-xr-x. 2 root root   30 Oct  8 07:17 basic.target.wants
drwxr-xr-x. 2 root root   30 Oct  7 23:08 bluetooth.target.wants
lrwxrwxrwx. 1 root root   41 Oct  7 23:08 dbus-org.bluez.service -> /usr/lib/systemd/system/bluetooth.service
lrwxrwxrwx. 1 root root   44 Oct  7 23:10 dbus-org.freedesktop.ModemManager1.service -> /usr/lib/systemd/system/ModemManager.service
lrwxrwxrwx. 1 root root   46 Oct  7 23:04 dbus-org.freedesktop.NetworkManager.service -> /usr/lib/systemd/system/NetworkManager.service
lrwxrwxrwx. 1 root root   57 Oct  7 23:04 dbus-org.freedesktop.nm-dispatcher.service -> /usr/lib/systemd/system/NetworkManager-dispatcher.service
lrwxrwxrwx  1 root root   41 Oct  8 16:51 default.target -> /usr/lib/systemd/system/multi-user.target
drwxr-xr-x. 2 root root   85 Oct  7 23:02 default.target.wants
lrwxrwxrwx. 1 root root   35 Oct  7 23:08 display-manager.service -> /usr/lib/systemd/system/gdm.service
drwxr-xr-x. 2 root root   31 Oct  7 23:02 getty.target.wants
drwxr-xr-x. 2 root root   90 Oct  9 12:29 graphical.target.wants
drwxr-xr-x. 2 root root 4096 Oct  9 12:29 multi-user.target.wants
lrwxrwxrwx. 1 root root   38 Oct  7 23:04 mysql.service -> /usr/lib/systemd/system/mysqld.service
-rw-r--r--  1 root root  361 Oct  9 12:29 oracle-ohasd.service
drwxr-xr-x. 2 root root   25 Oct  7 23:05 printer.target.wants
drwxr-xr-x. 2 root root 4096 Oct  8 07:32 sockets.target.wants
drwxr-xr-x. 2 root root   35 Oct  7 23:10 spice-vdagentd.target.wants
drwxr-xr-x. 2 root root 4096 Oct  8 22:19 sysinit.target.wants
drwxr-xr-x. 2 root root   83 Oct  7 23:05 system-update.target.wants
[root@lunar system]#
[root@lunar system]# ps -ef|grep ohasd
root      1132     1  0 04:26 ?        00:00:00 /bin/sh /etc/init.d/init.ohasd run >/dev/null 2>&1 </dev/null
grid      4017     1  0 04:27 ?        00:00:59 /u01/app/12.1.0.2/grid/bin/ohasd.bin reboot
root     11362  8874  0 09:50 pts/1    00:00:00 grep --color=auto ohasd
[root@lunar system]#

时间: 2024-08-08 03:05:23

oracle 11.2和12c RAC的ohasd守护进程对比的相关文章

Oracle 11.2.0.4 RAC Database for Windows 2012安装DB时收到[INS-35423]错误

    这是同事遇到的问题,在这里做个标记,希望对大家有所帮助. 一.问题描述. 操作系统:Microsoft Windows x64 (64-bit) 2012数据库版本:Oracle11g 11.2.0.4 经查询,11.2.0.4在windows2012上通过了验证.Grid安装成功,crs_stat -t 查看相关资源都是online,状态正常安装DB软件时,第4步,选择安装集群数据库时出现报错: [INS-35423] 安装程序检测到 Oracle Clusterware 未在本地节点

oracle 11.2.0.4 RAC CRS diskgroup auto dismount问题

这几天出差到甘肃,某客户的集群有点小问题.其中节点的crs检测发现有点异常,不过怪异的是业务却没有受到任何影响.如下是我检测的结果: [grid@tysy1 bin]$ ocrcheck PROT-602: Failed to retrieve data from the cluster registry PROC-26: Error while accessing the physical storage   [grid@tysy1 bin]$ crsctl query css votedis

oracle 11.2.0.4 rac for rhel 6.8 installation

                                                                                      >               >>            >>       >>                                                                >><<  >><<        

oracle中11.2中手工kill所有的CRS进程而不导致主机重启方法

我们都知道,在RAC环境中,如果kill ocssd.bin进程,会引起主机重启. 但是有时候系统已经异常了了,且CRS不能正常关闭,而主机可能是几年没重启的老系统,没人敢重启,现在怎么办? 我们只能尝试手工kill进程的方式,然后手工修复CRS(注意,在10.2 RAC中,只有3个d.bin进程). 测试环境:操作系统是OEL 6.6 [root@lunar1 ~]# cat /etc/oracle-release Oracle Linux Server release 6.6 [root@l

oracle 12c rac安装acfs文件系统教程

这篇文章介绍了如何在一个已经安装12c rac的虚拟机上,如何建立acfs文件系统,并且利用acfs snapshot刷一个COW(Copy-On-Write)库出来做测试库. Highlight Step: 一.给虚拟机增加asm盘,以便建立acfs文件系统 二.创建acfs文件系统 三.在节点1创建数据库在acfs文件系统上.(12c支持数据文件,控制文件,日志文件等数据库的文件放在acfs上.参考Doc ID 1369107.1中ACFS Advanced Features Platfor

ORACLE 12C RAC修改ocr/votedisk/asm spfile所在磁盘组名称

今天看着我这个单节点的12C rac,突然觉得ocr所在的磁盘组叫做+DG_SYS有点不舒服,想改成+SYS_DG.处理方法是先把ocr/votedisk/asm spfile迁移到已经存在的asm中,然后修改磁盘组名称,最后迁移到新名称磁盘组中(本次处理流程+DG_SYS->+DATA->+SYS_DG) 当前运行情况 [grid@xifenfei ~]$ crsctl status res -t -----------------------------------------------

SUSE 11.1 安装ORACLE 11.2.0.3 ASM非RAC双机过程纪要

SUSE 11.1 安装ORACLE 11.2.0.3 ASM非RAC双机过程纪要 增加用户和组: /usr/sbin/groupadd -g 501 oinstall /usr/sbin/groupadd -g 502 dba /usr/sbin/groupadd -g 503 oper /usr/sbin/groupadd -g 504 asmadmin /usr/sbin/groupadd -g 505 asmoper /usr/sbin/groupadd -g 506 asmdba us

ORACLE 12C RAC中使用in memory特性请注意parallel_degree_policy和parallel_force_local参数

在12C RAC的in memory测试中由于未正确启用并行,导致测试结果flush buffer cache后,总是出现大量并行,通过ORACLE 各方努力最终确定是由于parallel_degree_policy=AUTO和parallel_force_local=false开始未设置正确导致.在rac中需要imdb的朋友请注意这两个参数. 设置表存放中inmemory SQL> alter table CHF.XIFENFEI_888 inmemory; Table altered. SQ

ORACLE 11.2 RAC修改数据库静态参数

操作系统:HP UNIX 11.31 数据库:oracle 11.2 rac 今天对一套ORACLE 11.2 RAC数据库进行参数调整,修改db_files为3000,系统默认为200.顺便修改了操作系统的内核参数:fs_async,服务器也需要重启. 操作计划: 1.参数在两个节点都修改完毕,不重启机器和数据. 2.先重启节点1,节点2先不动,等节点1起来之后,再重启节点2. 故障: 可是在节点1启动之后,实例怎么都起不来,然后手工用srvctl启动实例报错: racdb1:/home/gr