oracle 11g rac在rhel/centos 7+上ohasd无法启动,根本原因是systemd与init.d机制断层:root.sh硬编码调用/etc/init.d/init.ohasd,但systemd默认忽略该脚本;必须手动创建/usr/lib/systemd/system/ohas.service(非ohasd.service),execstart指向/etc/init.d/init.ohasd run且type=simple,并确保/etc/oracle/olr.loc存在、权限正确,ipc socket无残留,selinux不拦截,且服务须在root.sh执行完成后才启动。

为什么systemd不拉起ohasd,而init.d又失效
Oracle 11g RAC(特别是11.2.0.1–11.2.0.4)在RHEL/CentOS 7+上无法自启ohasd,根本不是配置漏了,而是启动机制断层:root.sh仍硬编码调用/etc/init.d/init.ohasd,但systemd默认忽略init.d脚本,也不自动注册它。结果就是crsctl start crs报CRS-0715: timed out waiting for init.ohasd,因为systemd压根没触发那个脚本。
必须用ohas.service,不能叫ohasd.service
手动创建systemd服务时,名字和路径是关键陷阱:
-
/usr/lib/systemd/system/ohas.service是唯一正确路径,文件名必须是ohas.service(不是ohasd.service),否则会和/etc/init.d/ohasd冲突,systemctl status ohasd.service会误读init.d状态而非真正控制进程 -
ExecStart必须指向/etc/init.d/init.ohasd run,不能直接跑/u01/app/11.2.0/grid/bin/ohasd——后者绕过初始化逻辑,必然失败 - 别设
Type=forking,ohasd进程不标准daemonize,用Type=simple更稳
/etc/oracle/olr.loc缺失或权限错会导致rootcrs.pl第443行abort
ohasd启动第一件事就是读/etc/oracle/olr.loc定位本地注册库(OLR)。这个文件一旦不存在、为空、路径指向未MOUNT的ASM磁盘组(如+OCR),或权限不是root:root且644以上,rootcrs.pl就在第443行直接abort,连systemd都还没介入。
检查命令:ls -l /etc/oracle/olr.loc;正常内容应类似olrconfig_loc=/u01/app/11.2.0/grid/cdata/rac1/olr.ocr。若损坏,不能手改,必须先运行rootcrs.pl -deconfig -force -verbose清理再重装。
IPC socket残留和SELinux拦截常被忽略
ohasd依赖Unix domain socket通信,典型路径是/var/tmp/.oracle/npohasd。若上次异常退出未清理,或SELinux处于enforcing模式,就会报Inappropriate ioctl for device——这不是权限不够,是socket创建被拒。
临时验证方法:setenforce 0后执行crsctl start ohasd;若成功,说明SELinux策略需调整。生产环境应避免永久禁用,而用semanage fcontext放行/var/tmp/.oracle/目录。清理残留命令:rm -f /var/tmp/.oracle/* /tmp/.oracle/*,但注意:删完要等root.sh重新生成,不能提前touch空文件。
最易被跳过的点:systemd服务必须在root.sh执行**完成之后**再systemctl start ohas.service——安装中途强行启动,会因OLR未写入、ASM未就绪而反复status=203/EXEC。等root.sh输出“Successfully configured Oracle Grid Infrastructure”后再操作,才真正可靠。











