GBase8a 开机自启动

1、/etc/rc.local 方式

shell 复制代码
echo 'su - gbase -c "gcware_services all restart;gcluster_services all restart"' >> /etc/rc.local
chmod +x /etc/rc.local

2、/etc/init.d 启动服务(测试于centos7)【对于953,可以拆分成两个服务GCluster、GCware】

注意文件加上可执行权限,比如chmod a+x GBase8aBoot

shell 复制代码
[root@node1 init.d]# cat /etc/init.d/GBase8aBoot
#!/bin/sh
#
### BEGIN INIT INFO
# Provides:                    GBase
# Required-Start:       $network
# Should-Start:         $syslog
# Required-Stop:        $network
# Default-Start:                2 3 4 5
# Default-Stop:                 0 1 6
# Short-Description:    GBase 8a Cluster MPP.
# Description:          Provide MPP Database service
### END INIT INFO
#

LOG_PATH=/var/log/GBase8aBoot.log

function is_OK()
{
  if [ $RETVAL -eq 0 ] ;then
    echo "OK"
  else
    echo "FAIL"
  fi
}

RETVAL=0

# See how we were called.
case "$1" in
  start)
          date >> $LOG_PATH
          echo -n "Starting gbase: "
          su - gbase -c"gcware_services all start;gcluster_services all start" >> $LOG_PATH
          RETVAL=$?
          echo `is_OK`
          ;;
  stop)
          date  >> $LOG_PATH
          echo -n "Stopping gbase: "
          su - gbase -c"gcware_services all stop;gcluster_services all stop"  >> $LOG_PATH
          RETVAL=$?
          echo `is_OK`
          ;;
  restart)
        date  >> $LOG_PATH
        echo -n "Restarting gbase: "
        su - gbase -c"gcware_services all restart;gcluster_services all restart"  >> $LOG_PATH
        RETVAL=$?
        echo `is_OK`
        ;;
  status)
        su - gbase -c"gcware_services all info;gcluster_services all info"
        RETVAL=$?
        ;;
  *)
        echo "Usage: $0 {start|stop|restart|status}"
        exit 1
esac

exit $RETVAL

检查命令是否正常

shell 复制代码
[root@node1 init.d]# service GBase8aBoot status
/opt/192.168.140.68/gcware/sbin/gcware is stopped
/opt/192.168.140.68/gcluster/server/bin/gclusterd is stopped
/opt/192.168.140.68/gcluster/server/bin/gcrecover is stopped
/opt/192.168.140.68/gnode/server/bin/gbased is stopped
/opt/192.168.140.68/gnode/server/bin/gc_sync_server is stopped

添加到开机自启动

chkconfig 开机的时候传递一个start的值,作为$1

chkconfig 关机的时候传递一个stop的值,作为$1

shell 复制代码
[root@node1 init.d]# chkconfig --add GBase8aBoot
[root@node1 init.d]# chkconfig --list|grep GBase8aBoot

注:该输出结果只显示 SysV 服务,并不包含
原生 systemd 服务。SysV 配置数据
可能被原生 systemd 配置覆盖。

      要列出 systemd 服务,请执行 'systemctl list-unit-files'。
      查看在具体 target 启用的服务请执行
      'systemctl list-dependencies [target]'。

GBase8aBoot     0:关    1:关    2:开    3:开    4:开    5:开    6:关
相关推荐
qwer555882 分钟前
linux-----------------库制作与原理(下)
linux·运维·服务器
m0_519523106 分钟前
Linux——UDP/TCP协议理论
linux·tcp/ip·udp
vortex519 分钟前
Bash fork 炸弹 —— :(){ :|:& };:
运维·服务器·开发语言·网络安全·bash
xmweisi0230 分钟前
【Linux】ssh命令 – 安全的远程连接服务
linux·安全·ssh
Blossom.11836 分钟前
基于区块链技术的供应链溯源系统:重塑信任与透明度
服务器·网络·人工智能·目标检测·机器学习·计算机视觉·区块链
Pacify_The_North36 分钟前
【进程控制二】进程替换和bash解释器
linux·c语言·开发语言·算法·ubuntu·centos·bash
ephemerals__1 小时前
【Linux】简易版Shell实现(附源码)
linux·运维·chrome
JeffersonZU1 小时前
【shell】shell和shell脚本简介
linux·ubuntu·bash
烦躁的大鼻嘎2 小时前
【Linux】ELF与动静态库的“暗黑兵法”:程序是如何跑起来的?
linux·运维·服务器·c++·vscode·ubuntu
API_technology2 小时前
阿里巴巴 1688 数据接口开发指南:构建自动化商品详情采集系统
大数据·运维·数据挖掘·自动化