在RHEL7/CENTOS7/SUSE12及最新的Ubuntu等linux发行版本中, 均使用systemd进行服务控制管理(Service Control Manager)。
使用systemd, 不再需要编写shell脚本程序来控制启动、关闭。
以下是通过systemd方式实现GBase 8s数据库的自启动与关闭。
适用于操作系统: RHEL7/CENTOS7, 以及基于RHEL7内核的系统
###systemd需要的两个配置文件目录为
1,service 文件所在位置
/usr/lib/systemd/system/
2,service 的环境配置文件位置
/etc/sysconfig/
1, 在/usr/lib/systemd/system/目录下创建 gbasedbtd.service文件
[Unit]
Description=GBase 8s Database Server v8.7 2.0.1a2_2
Documentation=file:/opt/gbase/release/en_us/0333
Wants=network-online.target
After=network.target network-online.target
[Service]
Type=oneshot
User=gbasedbt
Group=gbasedbt
RemainAfterExit=yes
EnvironmentFile=/etc/sysconfig/gbasedbtd_service
ExecStart=/opt/gbase/bin/oninit
ExecStop=/opt/gbase/bin/onmode -ky
#Restart=on-abort
[Install]
WantedBy=multi-user.target
说明:
[Unit] 区块:启动顺序与依赖关系
[Service] 区块:启动行为
[Install] 区块:定义如何安装这个配置文件,即怎么做到开机启动。
2, 在/etc/sysconfig目录下创建 gbasedbtd_service
# gbasedbtd.service environmental variables
GBASEDBTDIR=/opt/gbase
GBASEDBTSERVER=gbase01
ONCONFIG=onconfig.gbase01
GBASEDBTSQLHOSTS=/opt/gbase/etc/sqlhosts
3, 管理gbasedbtd服务
启动gbasedbtd服务(数据库应未启动)
# systemctl start gbasedbtd
检查gbasedbtd状态
# systemctl status gbasedbtd
关闭gbasedbtd服务
# systemctl stop gbasedbtd
设置gbasedbtd服务随系统启动
# systemctl enable gbasedbtd
关闭gbasedbtd服务的自启动
# systemctl disable gbasedbtd
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。




