GBase 8s 通过systemd实现自启动与关闭

在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文
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
[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
1
2
3
4
5
# gbasedbtd.service environmental variables
GBASEDBTDIR=/opt/gbase
GBASEDBTSERVER=gbase01
ONCONFIG=onconfig.gbase01
GBASEDBTSQLHOSTS=/opt/gbase/etc/sqlhosts
3, 管理gbasedbtd服务
启动gbasedbtd服务(数据库应未启动)
1
# systemctl start gbasedbtd
检查gbasedbtd状态
1
# systemctl status gbasedbtd
关闭gbasedbtd服务
1
# systemctl stop gbasedbtd
设置gbasedbtd服务随系统启动
1
# systemctl enable gbasedbtd
关闭gbasedbtd服务的自启动
1
# systemctl disable gbasedbtd
posted @ 2024-06-24 11:03  一只竹节虫  阅读(4)  评论(0编辑  收藏  举报