当前位置:   article > 正文

如何在Linux 7中配置开机自动启动_zookeeper unregistered authentication agent for

zookeeper unregistered authentication agent for

传统rc.local方式

第一种方法可以使用传统的rc.local方式。
过程如下:

# chmod +x /etc/rc.d/rc.local
# touch /usr/local/bin/startZookeeper.sh
# chown oracle:oracle /usr/local/bin/startZookeeper.sh
# chmod u+x /usr/local/bin/startZookeeper.sh
# cat /usr/local/bin/startZookeeper.sh
#!/bin/bash
cd /grid/membership/zookeeper-3.4.10
bin/zkServer.sh start
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8

重启后,验证Zookeeper服务已启动:

$ netstat -an|grep 2181
tcp6       0      0 :::2181                 :::*                    LISTEN   
  • 1
  • 2

Linux 7 systemd方式

在Linux 7版本下使用systemd是推荐的方式。
仍然使用之前的脚本,即/usr/local/bin/startZookeeper.sh
编辑文件/etc/systemd/system/zookeeper.service,内容如下:

touch /etc/systemd/system/zookeeper.service
chmod 664 /etc/systemd/system/zookeeper.service
vim /etc/systemd/system/zookeeper.service
  • 1
  • 2
  • 3
# cat /etc/systemd/system/zookeeper.service
[Unit]
Description=zookeeper
After=network.target,local-fs.target

[Service]
ExecStart=/usr/local/bin/startZookeeper.sh
User=oracle
Type=forking

[Install]
WantedBy=default.target
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12

其中的User=oracle相当于su - oracle。另外其中的Type=forking和/usr/local/bin/startZookeeper.sh脚本中的第一行#!/bin/bash是必不可少的。
然后启用和启动服务:

systemctl enable zookeeper
systemctl start zookeeper
  • 1
  • 2

虽然没有定义停止脚本,但systemctl stop仍可以停止服务,估计是保存了PID,然后kill的。
比较重要的是错误诊断的过程,如果启动出错,可以使用以下的方法:

# journalctl -xe
-- 
-- Unit zookeeper.service has begun starting up.
Oct 22 18:41:02 localhost.localdomain systemd[4271]: Failed at step EXEC spawning /usr/local/bin/startZookeeper.sh: Exec format error
-- Subject: Process /usr/local/bin/startZookeeper.sh could not be executed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- The process /usr/local/bin/startZookeeper.sh could not be executed and failed.
-- 
-- The error number returned by this process is 8.
Oct 22 18:41:02 localhost.localdomain systemd[1]: zookeeper.service: main process exited, code=exited, status=203/EXEC
Oct 22 18:41:02 localhost.localdomain systemd[1]: Unit zookeeper.service entered failed state.
Oct 22 18:41:02 localhost.localdomain systemd[1]: zookeeper.service failed.
Oct 22 18:41:02 localhost.localdomain polkitd[712]: Unregistered Authentication Agent for unix-process:4264:202535 (system bus name :1.137, object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale en_
Oct 22 18:44:14 localhost.localdomain chronyd[669]: Source 178.63.9.212 replaced with 2001:638:504:2000::36
Oct 22 18:48:21 localhost.localdomain polkitd[712]: Registered Authentication Agent for unix-process:4346:246494 (system bus name :1.138 [/usr/bin/pkttyagent --notify-fd 5 --fallback], object path /org/freedeskt
Oct 22 18:48:21 localhost.localdomain systemd[1]: Reloading.
Oct 22 18:48:22 localhost.localdomain polkitd[712]: Unregistered Authentication Agent for unix-process:4346:246494 (system bus name :1.138, object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale en_
Oct 22 18:48:25 localhost.localdomain polkitd[712]: Registered Authentication Agent for unix-process:4375:246858 (system bus name :1.139 [/usr/bin/pkttyagent --notify-fd 5 --fallback], object path /org/freedeskt
Oct 22 18:48:25 localhost.localdomain systemd[1]: Starting zookeeper...
-- Subject: Unit zookeeper.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit zookeeper.service has begun starting up.
Oct 22 18:48:25 localhost.localdomain systemd[4382]: Failed at step EXEC spawning /usr/local/bin/startZookeeper.sh: Exec format error
-- Subject: Process /usr/local/bin/startZookeeper.sh could not be executed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- The process /usr/local/bin/startZookeeper.sh could not be executed and failed.
-- 
-- The error number returned by this process is 8.
Oct 22 18:48:25 localhost.localdomain systemd[1]: zookeeper.service: control process exited, code=exited status=203
Oct 22 18:48:25 localhost.localdomain systemd[1]: Failed to start zookeeper.
-- Subject: Unit zookeeper.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit zookeeper.service has failed.
-- 
-- The result is failed.
Oct 22 18:48:25 localhost.localdomain systemd[1]: Unit zookeeper.service entered failed state.
Oct 22 18:48:25 localhost.localdomain systemd[1]: zookeeper.service failed.
Oct 22 18:48:25 localhost.localdomain polkitd[712]: Unregistered Authentication Agent for unix-process:4375:246858 (system bus name :1.139, object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale en_
  • 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

如果在systemctl status命令中可以显示PID,如4382,还可以用以下的命令:

# journalctl _PID=4382
-- Logs begin at Mon 2018-10-22 18:07:17 CST, end at Mon 2018-10-22 18:48:25 CST. --
Oct 22 18:48:25 localhost.localdomain systemd[4382]: Failed at step EXEC spawning /usr/local/bin/startZookeeper.sh: Exec format error
  • 1
  • 2
  • 3
声明:本文内容由网友自发贡献,转载请注明出处:【wpsshop】
推荐阅读
相关标签
  

闽ICP备14008679号