• 瀚高数据库开机自启动失败


    问题描述:使用瀚高数据库企业版,开机自启动没有正常运行。
    使用命令

    [root@hgdb ~]$ systemctl start hgdb-see-4.5.8.service
    
    • 1

    现象:

    ==== 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.
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8

    一般出现access denied是参数设置错误造成的,所以有以下解决思路,也顺利解决了问题。
    解决办法:

    [root@localhost system]# cd /usr/lib/systemd/system/
    [root@localhost system]# vim hgdb-see-4.5.8.service 
    
    • 1
    • 2

    文件内容如下:

    [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
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    [root@localhost system]# vim /opt/highgo/hgdb-see-4.5.8/bin/service.sh
    
    • 1
    #/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
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53

    修改

    $BIN/pg_ctl start 为 $BIN/pg_ctl start -D /data/highgo/data/
    
    • 1

    -D /data/highgo/data/是data路径

  • 相关阅读:
    kafka学习1 - 线程、进程消息通信方式、JMS模型、Kafka原理图
    闲人闲谈PS之二十九——关于精确统计工程合同产值问题
    读阿里P8大佬15W字的Spring文档,面试犹如开了挂,成了Offer收割机
    Unity关于无法新建项目的可能解决办法
    量子化学新突破:提前预测分子基态中的化学键断裂时间
    Vue.js+SpringBoot开发计算机机房作业管理系统
    字符函数和字符串函数(下)
    双向链表C语言版本
    算法学习:LeetCode-6. Z 字形变换
    python每日一练(9)
  • 原文地址:https://blog.csdn.net/lijuncheng963375877/article/details/134004213