设为首页收藏本站

追梦Linux

 找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 781|回复: 1

centos7配置zookeeper开机启动

[复制链接]

30

主题

39

帖子

2万

积分

CEO

Rank: 9Rank: 9Rank: 9

积分
25284

最佳新人活跃会员热心会员推广达人宣传达人灌水之王突出贡献优秀版主荣誉管理论坛元老

QQ
发表于 2017-8-8 17:08:53 | 显示全部楼层 |阅读模式
centos7启动服务改变了centos6的/etc/init.d的繁琐,sysctemctl直接调用服务的启动命令,总的来说省事很多,但是坑也多,总是缺少东西,报错,下面是配置zookeeper成为开机服务.
```
[root@soa-prod-zookeeper-010177210093 /etc/systemd/system] 03:56:01 0
# pwd
/etc/systemd/system
```
```
[root@soa-prod-zookeeper-010177210093 /etc/systemd/system] 04:00:39 1
# cat zookeeper-2181.service
[Unit]
Description=Zookeeper-2181
After=network.target

[Service]
Type=forking
User=user_00
Group=users
ExecStart=/usr/local/services/zookeeper-2181/bin/zkServer.sh  start
ExecStop=/usr/local/services/zookeeper-2181/bin/zkServer.sh stop
PIDFile=/data/zookeeper-2181/data/zookeeper_server.pid
[Install]
WantedBy=multi-user.target
```
然后启动服务:
```
[root@soa-prod-zookeeper-010177210093 ~] 03:45:01 1
# systemctl status zookeeper-2183.service
● zookeeper-2183.service - Zookeeper-2183
   Loaded: loaded (/etc/systemd/system/zookeeper-2183.service; enabled; vendor preset: disabled)
   Active: failed (Result: resources) since Tue 2017-08-08 03:45:01 CDT; 5s ago
  Process: 18732 ExecStart=/usr/local/services/zookeeper-2183/bin/zkServer.sh start (code=exited, status=0/SUCCESS)

Aug 08 03:45:00 soa-prod-zookeeper-010177210093.sl systemd[1]: Starting Zookeeper-2183...
Aug 08 03:45:00 soa-prod-zookeeper-010177210093.sl zkServer.sh[18732]: ZooKeeper JMX enabled by default
Aug 08 03:45:00 soa-prod-zookeeper-010177210093.sl zkServer.sh[18732]: Using config: /usr/local/services/zookeeper-2183/bin/../conf/zoo.cfg
Aug 08 03:45:00 soa-prod-zookeeper-010177210093.sl zkServer.sh[18732]: Starting zookeeper ... /usr/local/services/zookeeper-2183/bin/zkServer.sh: line 140: ./zookeeper.out: Permission denied
Aug 08 03:45:01 soa-prod-zookeeper-010177210093.sl systemd[1]: PID 18755 read from file /data/zookeeper-2183/data/zookeeper_server.pid does not exist or is a zombie.
Aug 08 03:45:01 soa-prod-zookeeper-010177210093.sl systemd[1]: Failed to start Zookeeper-2183.
Aug 08 03:45:01 soa-prod-zookeeper-010177210093.sl systemd[1]: Unit zookeeper-2183.service entered failed state.
Aug 08 03:45:01 soa-prod-zookeeper-010177210093.sl systemd[1]: zookeeper-2183.service failed.
```
发现报错了。
这里因为我指定了用户启动,所以一直起不来,zookeeper.out显示没有权限以及pid文件,因此额吧用户和用户组注释掉,然后通过root启动,然后找到zookeeper.out文件 ,并更改用户主,用户组,然后更改完成后执行:
```
systemctl daemon-reload
systemctl start Zookeeper-2181
```

5

主题

9

帖子

1700

积分

CEO

Rank: 9Rank: 9Rank: 9

积分
1700
发表于 2017-8-10 17:39:43 | 显示全部楼层
起飞
回复

使用道具 举报

QQ|小黑屋|手机版|Archiver|追梦Linux ( 粤ICP备14096197号  点击这里给我发消息

GMT+8, 2018-10-21 14:06 , Processed in 0.334309 second(s), 32 queries .

Powered by 追梦Linux! X3.3 Licensed

© 2015-2017 追梦Linux!.

快速回复 返回顶部 返回列表