www. On IT Road .com
解决方案
对 oracle 所有者进程执行 su 的 dbora 脚本存在问题,而 systemd 无法跟踪该进程。
这是示例 dbora 脚本
ORA_HOME=/u01/app/oracle/product/12.1.0.2/dbhome_1 ORA_OWNER=oracle case "" in 'start') # Start the Oracle databases: # The following command assumes that the oracle login # will not prompt the user for any values # Remove "&" if you don't want startup as a background process. su - $ORA_OWNER -c "$ORA_HOME/bin/dbstart $ORA_HOME" touch /var/lock/subsys/dbora ;; 'stop') # Stop the Oracle databases: # The following command assumes that the oracle login # will not prompt the user for any values su - $ORA_OWNER -c "$ORA_HOME/bin/dbshut $ORA_HOME" rm -f /var/lock/subsys/dbora ;; esac
通过这种安排,systemd 失去了对服务的控制,并且没有及时停止它。
更好的选择是直接在带有用户和所有者详细信息的指令下使用 dbstart 和 dbstop 脚本:
[Unit] Description=The Oracle Database Service After=network.target [Service] Type=forking RemainAfterExit=yes KillMode=none TimeoutStopSec=5min User=oracle << Replace Oracle software owner details here Group=oinstall ExecStart=$ORACLE_HOME/bin/dbstart $ORACLE_HOME & ===> Please use absolute path here instead of the $ORACLE_HOME variable ExecStop=$ORACLE_HOME/bin/dbshut $ORACLE_HOME ===> Please use absolute path here instead of the $ORACLE_HOME variable Restart=no [Install] # Puts wants directive for the other units in the relationship WantedBy=default.target
然后 systemd 可以控制服务
# systemctl status dbora.service ● dbora.service - The Oracle Database Service Loaded: loaded (/usr/lib/systemd/system/dbora.service; enabled; vendor preset: disabled) Active: active (running) since Wed 2017-02-01 12:19:53 GMT; 22s ago Process: 3905 ExecStop=/u01/app/oracle/product/12.1.0.2/dbhome_1/bin/dbshut /u01/app/oracle/product/12.1.0.2/dbhome_1 (code=exited, status=0/SUCCESS) Process: 4043 ExecStart=/u01/app/oracle/product/12.1.0.2/dbhome_1/bin/dbstart /u01/app/oracle/product/12.1.0.2/dbhome_1 & (code=exited, status=0/SUCCESS) CGroup: /system.slice/dbora.service ├─4051 /u01/app/oracle/product/12.1.0.2/dbhome_1/bin/tnslsnr LISTENER -inherit ├─4143 ora_pmon_XXXXX └─4477 ora_q003_XXXX
问题
在使用 Oracle 数据库 12.1.0.2 版本的 CentOS/RHEL 7 上,在服务器关闭期间尝试停止数据库时,自动关闭脚本出现以下错误:
# cat /u01/app/oracle/product/12.1.0.2/dbhome_1/shutdown.log Processing Database instance "XXXX1": log file /u01/app/oracle/product/12.1.0.2/dbhome_1/shutdown.log Info: Database instance "XXXX" already down (PMON process not there).
这表明在调用脚本之前 PMON 被强行关闭。
这是使用的配置
# cat dbora.service [Unit] Description=The Oracle Database Service After=network.target [Service] Type=forking # Type=oneshot RemainAfterExit=yes KillMode=none # Set this to something larger if it has an impact TimeoutStopSec=0 ExecStart=/u01/app/oracle/product/12.1.0.2/dbhome_1/bin/dbora start ExecStop=/u01/app/oracle/product/12.1.0.2/dbhome_1/bin/dbora stop [Install] # Puts wants directive for the other units in the relationship WantedBy=default.target
systemctl enable dbora.service systemctl daemon-reload systemctl start dbora.service
日期:2020-09-17 00:11:29 来源:oir作者:oir