一聚教程网:一个值得你收藏的教程网站

热门教程

oracle etc目录下的init.ohasd和ohasd文件丢失后如何启动GI

时间:2022-06-29 09:43:49 编辑:袖梨 来源:一聚教程网

我们已经知道11.2和12c RAC中的/etc/init.d/init.ohasd是启动RAC所有其他进程的守护进程。
那么如果有人误删除了这个文件或者错误修改了,怎么办呢?
这个解决不难,因为在Standalone环境中,/etc/init.d/init.ohasd来自于$GRID_HOME/crs/init/init.ohasd,而/etc/init.d/ohasd来自于$GRID_HOME/crs/init/ohasd。
[root@lunarlib etc]# env|grep ORA
ORACLE_SID=+ASM
GRID_HOME=/u01/app/11.2.0.4/grid
[root@lunarlib rootwork]# ls -lrt $GRID_HOME/crs/init
total 28
-rw-r--r-- 1 root root 6721 Oct 11 01:30 ohasd
-rw-r--r-- 1 root root 8794 Oct 11 01:30 init.ohasd
-rw-r--r-- 1 root root 7038 Oct 11 01:30 ohasd.sles
[root@lunarlib rootwork]#
我们对比一下$GRID_HOME/crs/init/和/etc/init.d/下的ohasd和init.ohasd,看看文件内容是否一致:
[/shell]
[root@lunarlib rootwork]# ls -lrt $GRID_HOME/crs/init/ohasd
-rw-r--r-- 1 root root 6721 Oct 11 01:30 /u01/app/11.2.0.4/grid/crs/init/ohasd
[root@lunarlib rootwork]# ls -lrt /etc/init.d/ohasd
-rwxr-x--- 1 root root 6721 Oct 11 01:30 /etc/init.d/ohasd
[root@lunarlib rootwork]# ls -lrt $GRID_HOME/crs/init/init.ohasd
-rw-r--r-- 1 root root 8794 Oct 11 01:30 /u01/app/11.2.0.4/grid/crs/init/init.ohasd
[root@lunarlib rootwork]# ls -lrt /etc/init.d/init.ohasd
-rwxr-x--- 1 root root 8794 Jan 11 11:56 /etc/init.d/init.ohasd
[root@lunarlib rootwork]#
[root@lunarlib rootwork]# diff $GRID_HOME/crs/init/ohasd /etc/init.d/ohasd
[root@lunarlib rootwork]# diff $GRID_HOME/crs/init/init.ohasd /etc/init.d/init.ohasd
[root@lunarlib rootwork]#
可以看到,$GRID_HOME/crs/init/和/etc/init.d/目录下的文件内容是一致的,只是权限不同。/etc/init.d/目录下的文件权限是750,$GRID_HOME/crs/init下的权限是644。
好了,解决方法有了,如果/etc/init.d/init.ohasd或者/etc/init.d/ohasd丢失了,手工创建/etc/init.d/init.ohasd 就可以了:
cp $GRID_HOME/crs/init/init.ohasd /etc/init.d/init.ohasd
chmod 750 /etc/init.d/init.ohasd
如果再细心一点,我们会发现$GRID_HOME/crs/init目录下除了这两个文件外,还有一个名称为ohasd.sles的文件。
熟悉SLES Linux的朋友可能猜到了,是的,这个是在SLES Linux上使用的ohasd版本。
检查当前版本是否为SLES:
[root@lunarlib rootwork]# rpm -q sles-release
package sles-release is not installed
[root@lunarlib rootwork]#
现在,我们删除/etc/init.d/init.ohasd文件来模拟init.ohasd文件丢失或者损坏:
[root@lunarlib rootwork]# rm -f /etc/init.d/init.ohasd
[root@lunarlib rootwork]#
然后我们使用$GRID_HOME/crs/init/下面的文件复制过来,手工启动试试看:
下面的显示删除/etc/init.d/init.ohasd后reboot系统的结果(也可以使用kill进程的方式,不重启主机):
[root@lunarlib rootwork]# ps -ef | grep -v grep|grep ohasd
[root@lunarlib rootwork]# ps -ef | grep -v grep|grep -E 'init|d.bin|ocls|evmlogger|UID'
UID        PID  PPID  C STIME TTY          TIME CMD
root         1     0  0 09:37 ?        00:00:00 /sbin/init
[root@lunarlib rootwork]#
可以看到,当前没有任何RAC的进程被启动。
我们尝试恢复这个丢失的ohasd守护进程配置文件:
[root@lunarlib rootwork]# cp $GRID_HOME/crs/init/init.ohasd /etc/init.d/init.ohasd
cp: overwrite `/etc/init.d/init.ohasd'? y
[root@lunarlib rootwork]#
然后reboot系统后,该进程已经启动了:
[root@lunarlib rootwork]# ps -ef | grep -v grep|grep ohasd
root      2882     1  0 10:33 ?        00:00:00 /bin/sh /etc/init.d/init.ohasd run
[root@lunarlib rootwork]# ps -ef | grep -v grep|grep -E 'init|d.bin|ocls|evmlogger|UID'
UID        PID  PPID  C STIME TTY          TIME CMD
root         1     0  0 10:32 ?        00:00:00 /sbin/init
root      2882     1  0 10:33 ?        00:00:00 /bin/sh /etc/init.d/init.ohasd run
[root@lunarlib rootwork]#
[root@lunarlib rootwork]# /sbin/initctl list |grep oracle-ohasd
oracle-ohasd start/running, process 2882
[root@lunarlib rootwork]#

热门栏目