问题描述:使用瀚高数据库企业版,开机自启动没有正常运行。
使用命令
[root@hgdb ~]$ systemctl start hgdb-see-4.5.8.service
现象:
==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ===
Authentication is required to manage system services or units.
Authenticating as: root (tbs)
Password:
polkit-agent-helper-1: pam_authenticate failed: Authentication failure
==== AUTHENTICATION FAILED ===
Failed to start hgdb-see-4.5.8.service: Access denied
See system logs and 'systemctl status hgdb-see-4.5.8.service' for details.
一般出现access denied是参数设置错误造成的,所以有以下解决思路,也顺利解决了问题。
解决办法:
[root@localhost system]# cd /usr/lib/systemd/system/
[root@localhost system]# vim hgdb-see-4.5.8.service
文件内容如下:
[Unit]
Description=hgdb
Requires=network.target local-fs.target
After=network.target local-fs.target
[Service]
Type=forking
User=root
ExecStart=/bin/bash -c "/opt/highgo/hgdb-see-4.5.8/bin/service.sh start"
ExecStop=/bin/bash -c "/opt/highgo/hgdb-see-4.5.8/bin/service.sh stop"
TimeoutSec=60
[Install]
WantedBy=multi-user.target graphical.target
[root@localhost system]# vim /opt/highgo/hgdb-see-4.5.8/bin/service.sh
#/bin/bash -e
PROGNAME=$(basename $0)
BIN=$(dirname "$0")
PKGTYPE=$([ `which dpkg 2> /dev/null` ] && echo deb || echo rpm)
if [[ $# != 1 ]]; then
echo "Usage: $PROGNAME {start|stop|restart|status}" >&2
exit 1
fi
if [[ $PKGTYPE == 'rpm' ]]; then
source /etc/profile
[[ -f ~/.bashrc ]] && source ~/.bashrc
[[ -f ~/.bash_profile ]] && source ~/.bash_profile
else
eval "`cat /etc/profile`"
[[ -f ~/.bashrc ]] && eval "`cat ~/.bashrc`"
[[ -f ~/.bash_profile ]] && eval "`cat ~/.bash_profile`"
fi
if [[ $PGDATA == '' ]]; then
pgconf=`find $BIN/.. -name postgresql.conf | head -n 1`
if [[ $pgconf ]]; then
export PGDATA=`dirname $pgconf`
else
echo "Cannot find datadir"
exit 1
fi
fi
case $1 in
start)
$BIN/pg_ctl start -D /data/highgo/data/
exit
;;
stop)
$BIN/pg_ctl stop
exit
;;
restart)
$BIN/pg_ctl restart
exit
;;
status)
$BIN/pg_ctl status
exit
;;
*)
echo "Invalid argument" >&2
exit 1
;;
esac
修改
$BIN/pg_ctl start 为 $BIN/pg_ctl start -D /data/highgo/data/
-D /data/highgo/data/
是data路径