查看哪些是开机自启动服务
可以通过 chkconfig 命令查看
[root@linux30 ~]# chkconfig注:该输出结果只显示 SysV 服务,并不包含
原生 systemd 服务。SysV 配置数据
可能被原生 systemd 配置覆盖。要列出 systemd 服务,请执行 'systemctl list-unit-files'。查看在具体 target 启用的服务请执行'systemctl list-dependencies [target]'。netconsole 0:关 1:关 2:关 3:关 4:关 5:关 6:关
network 0:关 1:关 2:开 3:开 4:开 5:开 6:关
[root@linux30 ~]#
如果是原生 systemd 服务,则可以使用 systemctl list-unit-files命令查看
[root@linux30 tidb]# systemctl list-unit-files
UNIT FILE STATE
proc-sys-fs-binfmt_misc.automount static
dev-hugepages.mount static
dev-mqueue.mount static
proc-sys-fs-binfmt_misc.mount static
...省略...
tidb-4000.service enabled
tiflash-9000.service enabled
tikv-20160.service enabled
tikv-20161.service enabled
tikv-20162.service enabled
tuned.service enabled
vgauthd.service enabled
...省略...
关闭开机自启动服务
方法1:
[root@linux30 tidb]# systemctl disable NAME...
# 示例:
[root@linux30 tidb]# systemctl disable tidb-4000.service
Removed symlink /etc/systemd/system/multi-user.target.wants/tidb-4000.service.
[root@linux30 tidb]#
效果:
方法2:
针对具有集群管理工具的服务,可以使用其自带命令设置关闭
# 查看要禁用开机自启动的集群名称 :tidb-cluster
[root@linux30 tidb]# tiup cluster list
tiup is checking updates for component cluster ...
Starting component `cluster`: /root/.tiup/components/cluster/v1.9.3/tiup-cluster /root/.tiup/components/cluster/v1.9.3/tiup-cluster list
Name User Version Path PrivateKey
---- ---- ------- ---- ----------
tidb-cluster tidb v5.3.0 /root/.tiup/storage/cluster/clusters/tidb-cluster /root/.tiup/storage/cluster/clusters/tidb-cluster/ssh/id_rsa
关闭该 tidb-cluster集群的开机自启动服务
[root@linux30 tidb]# tiup cluster disable tidb-cluster
tiup is checking updates for component cluster ...
Starting component `cluster`: /root/.tiup/components/cluster/v1.9.3/tiup-cluster /root/.tiup/components/cluster/v1.9.3/tiup-cluster disable tidb-cluster
Disabling cluster tidb-cluster...
+ [ Serial ] - SSHKeySet: privateKey=/root/.tiup/storage/cluster/clusters/tidb-cluster/ssh/id_rsa, publicKey=/root/.tiup/storage/cluster/clusters/tidb-cluster/ssh/id_rsa.pub
+ [Parallel] - UserSSH: user=tidb, host=192.168.10.30
+ [Parallel] - UserSSH: user=tidb, host=192.168.10.30
+ [Parallel] - UserSSH: user=tidb, host=192.168.10.30
+ [Parallel] - UserSSH: user=tidb, host=192.168.10.30
+ [Parallel] - UserSSH: user=tidb, host=192.168.10.30
+ [Parallel] - UserSSH: user=tidb, host=192.168.10.30
+ [Parallel] - UserSSH: user=tidb, host=192.168.10.30
+ [Parallel] - UserSSH: user=tidb, host=192.168.10.30
+ [ Serial ] - DisableCluster
Disabling component pdDisabling instance 192.168.10.30:2379Disable instance 192.168.10.30:2379 success
Disabling component tikvDisabling instance 192.168.10.30:20162Disabling instance 192.168.10.30:20161Disabling instance 192.168.10.30:20160Disable instance 192.168.10.30:20161 successDisable instance 192.168.10.30:20162 successDisable instance 192.168.10.30:20160 success
Disabling component tidbDisabling instance 192.168.10.30:4000Disable instance 192.168.10.30:4000 success
Disabling component tiflashDisabling instance 192.168.10.30:9000Disable instance 192.168.10.30:9000 success
Disabling component prometheusDisabling instance 192.168.10.30:9090Disable instance 192.168.10.30:9090 success
Disabling component grafanaDisabling instance 192.168.10.30:3000Disable instance 192.168.10.30:3000 success
Disabling component node_exporterDisabling instance 192.168.10.30Disable 192.168.10.30 success
Disabling component blackbox_exporterDisabling instance 192.168.10.30Disable 192.168.10.30 success
Disabled cluster `tidb-cluster` successfully
[root@linux30 tidb]#
效果:
chkconfig命令帮助手册
[root@linux30 tidb]# chkconfig --help
chkconfig 版本 1.7.6 - 版权 (C) 1997-2000 Red Hat, Inc.
在 GNU 公共许可条款下,本软件可以免费重新发布。用法:chkconfig [--list] [--type <type>] [name]chkconfig --add <name>chkconfig --del <name>chkconfig --override <name>chkconfig [--level <levels>] [--type <type>] <name> <on|off|reset|resetpriorities>
[root@linux30 tidb]#