免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2743 | 回复: 2

[桌面系统] CentOS7.2 使用sysv init script,对服务进行reload 失败 [复制链接]

论坛徽章:
0
发表于 2016-06-05 22:41 |显示全部楼层
因为CentOS7版的haproxy reload时,失败时无法显示错误,所以需要使用centos6的sysv init script。
在CentOS7.1时,是没有问题的。但是在CentOS7.2(1511)上,进行reload,就失败了。。reload脚本执行是成功的,但是不知道为什么会被kill掉。

[root@localhost x86_64]# service haproxy restart
Restarting haproxy (via systemctl):                        [  OK  ]
[root@localhost x86_64]#
[root@localhost x86_64]#
[root@localhost x86_64]#
[root@localhost x86_64]# service haproxy status
● haproxy.service - SYSV: HAProxy is a free, very fast and reliable solution offering high availability, load balancing, and proxying for TCP and  HTTP-based applications
   Loaded: loaded (/etc/rc.d/init.d/haproxy)
   Active: active (running) since Sun 2016-06-05 10:38:20 EDT; 2s ago
     Docs: man:systemd-sysv-generator(
  Process: 3550 ExecStop=/etc/rc.d/init.d/haproxy stop (code=exited, status=0/SUCCESS)
  Process: 3544 ExecReload=/etc/rc.d/init.d/haproxy reload (code=exited, status=0/SUCCESS)
  Process: 3617 ExecStart=/etc/rc.d/init.d/haproxy start (code=exited, status=0/SUCCESS)
Main PID: 3622 (haproxy)
   CGroup: /system.slice/haproxy.service
           └─3622 /usr/sbin/haproxy -D -f /etc/haproxy/haproxy.cfg -p /var/run/haproxy.pid

Jun 05 10:38:20 localhost.localdomain systemd[1]: Starting SYSV: HAProxy is a free, very fast and reliable solution offering high availability, load balanci...ations...
Jun 05 10:38:20 localhost.localdomain haproxy[3617]: Starting haproxy: [  OK  ]
Jun 05 10:38:20 localhost.localdomain systemd[1]: Started SYSV: HAProxy is a free, very fast and reliable solution offering high availability, load balancin...ications.
Hint: Some lines were ellipsized, use -l to show in full.
[root@localhost x86_64]#
[root@localhost x86_64]#
[root@localhost x86_64]# service haproxy reload
Reloading haproxy configuration (via systemctl):           [  OK  ]
[root@localhost x86_64]#
[root@localhost x86_64]#
[root@localhost x86_64]# service haproxy status
● haproxy.service - SYSV: HAProxy is a free, very fast and reliable solution offering high availability, load balancing, and proxying for TCP and  HTTP-based applications
   Loaded: loaded (/etc/rc.d/init.d/haproxy)
   Active: failed (Result: signal) since Sun 2016-06-05 10:38:24 EDT; 2s ago
     Docs: man:systemd-sysv-generator(
  Process: 3671 ExecStop=/etc/rc.d/init.d/haproxy stop (code=exited, status=0/SUCCESS)
  Process: 3665 ExecReload=/etc/rc.d/init.d/haproxy reload (code=exited, status=0/SUCCESS)
  Process: 3617 ExecStart=/etc/rc.d/init.d/haproxy start (code=exited, status=0/SUCCESS)
Main PID: 3670 (code=killed, signal=KILL)

Jun 05 10:38:20 localhost.localdomain systemd[1]: Starting SYSV: HAProxy is a free, very fast and reliable solution offering high availability, load balanci...ations...
Jun 05 10:38:20 localhost.localdomain haproxy[3617]: Starting haproxy: [  OK  ]
Jun 05 10:38:20 localhost.localdomain systemd[1]: Started SYSV: HAProxy is a free, very fast and reliable solution offering high availability, load balancin...ications.
Jun 05 10:38:24 localhost.localdomain haproxy[3665]: Reloading haproxy:
Jun 05 10:38:24 localhost.localdomain systemd[1]: Reloaded SYSV: HAProxy is a free, very fast and reliable solution offering high availability, load balanci...ications.
Jun 05 10:38:24 localhost.localdomain systemd[1]: haproxy.service: main process exited, code=killed, status=9/KILL
Jun 05 10:38:24 localhost.localdomain haproxy[3671]: Stopping haproxy: [FAILED]
Jun 05 10:38:24 localhost.localdomain systemd[1]: Unit haproxy.service entered failed state.
Jun 05 10:38:24 localhost.localdomain systemd[1]: haproxy.service failed.
Hint: Some lines were ellipsized, use -l to show in full.
[root@localhost x86_64]#

论坛徽章:
17
巨蟹座
日期:2014-11-20 23:04:5215-16赛季CBA联赛之北控
日期:2018-08-01 16:08:4015-16赛季CBA联赛之浙江
日期:2017-12-08 11:25:2415-16赛季CBA联赛之四川
日期:2016-11-21 00:16:50操作系统版块每日发帖之星
日期:2016-07-28 06:20:0015-16赛季CBA联赛之吉林
日期:2016-05-25 15:36:04操作系统版块每日发帖之星
日期:2016-02-12 06:20:002015亚冠之西悉尼流浪者
日期:2015-08-28 14:48:322015亚冠之平阳省
日期:2015-08-19 14:54:162015亚冠之武里南联
日期:2015-07-07 10:49:112015亚冠之城南
日期:2015-06-22 10:15:002015亚冠之山东鲁能
日期:2015-06-18 18:03:44
发表于 2016-06-06 09:20 |显示全部楼层
centos7已经在使用systemd的服务管理,请使用新款管理工具sysctrl

论坛徽章:
0
发表于 2016-06-08 10:09 |显示全部楼层
回复 2# yyu0378

即使用systemctl也是一样的结果~~
重点我是不明白。到底什么地方会导致进程被kill掉。

[root@unknown ~]# service haproxy status
● haproxy.service - LSB: HAProxy
   Loaded: loaded (/etc/rc.d/init.d/haproxy)
   Active: active (running) since Tue 2016-06-07 11:33:22 UTC; 1h 14min ago
     Docs: man:systemd-sysv-generator(
  Process: 16636 ExecStart=/etc/rc.d/init.d/haproxy start (code=exited, status=0/SUCCESS)
Main PID: 16641 (haproxy)
   CGroup: /system.slice/haproxy.service
           mq16641 /usr/sbin/haproxy -D -f /etc/haproxy/haproxy.cfg -p /var/run/haproxy.pid

Jun 07 11:33:22 unknown systemd[1]: Starting LSB: HAProxy...
Jun 07 11:33:22 unknown haproxy[16636]: Starting haproxy: [  OK  ]
Jun 07 11:33:22 unknown systemd[1]: Started LSB: HAProxy.
[root@unknown ~]#
[root@unknown ~]# service haproxy reload
Reloading haproxy configuration (via systemctl):           [  OK  ]
[root@unknown ~]# echo $?
0                                                     -> 显示reload是成功的
[root@unknown ~]#
[root@unknown ~]# service haproxy status
● haproxy.service - LSB: HAProxy
   Loaded: loaded (/etc/rc.d/init.d/haproxy)
   Active: failed (Result: signal) since Tue 2016-06-07 12:48:01 UTC; 1s ago
     Docs: man:systemd-sysv-generator(
  Process: 16869 ExecStop=/etc/rc.d/init.d/haproxy stop (code=exited, status=0/SUCCESS)
  Process: 16863 ExecReload=/etc/rc.d/init.d/haproxy reload (code=exited, status=0/SUCCESS)
  Process: 16636 ExecStart=/etc/rc.d/init.d/haproxy start (code=exited, status=0/SUCCESS)
Main PID: 16868 (code=killed, signal=KILL)

Jun 07 11:33:22 unknown systemd[1]: Starting LSB: HAProxy...
Jun 07 11:33:22 unknown haproxy[16636]: Starting haproxy: [  OK  ]
Jun 07 11:33:22 unknown systemd[1]: Started LSB: HAProxy.
Jun 07 12:48:00 unknown systemd[1]: Reloaded LSB: HAProxy.
Jun 07 12:48:00 unknown systemd[1]: haproxy.service: main process exited, code=killed, status=9/KILL  -> 但是之后被kill掉了,关键是什么kill掉的呢,cgroup么?
Jun 07 12:48:01 unknown haproxy[16869]: [FAILED]
Jun 07 12:48:01 unknown systemd[1]: Unit haproxy.service entered failed state.
Jun 07 12:48:01 unknown systemd[1]: haproxy.service failed.
[root@unknown ~]#


查看日志。具体过程如下:

Jun 07 13:02:59 elb systemd[1]: Starting LSB: HAProxy...
Jun 07 13:02:59 elb systemd[7010]: Executing: /etc/rc.d/init.d/haproxy start
Jun 07 13:02:59 elb haproxy[7010]: Starting haproxy: [  OK  ]
Jun 07 13:02:59 elb systemd[1]: Child 7010 belongs to haproxy.service
Jun 07 13:02:59 elb systemd[1]: haproxy.service: control process exited, code=exited status=0
Jun 07 13:02:59 elb systemd[1]: haproxy.service got final SIGCHLD for state start
Jun 07 13:02:59 elb systemd[1]: Main PID loaded: 7015
Jun 07 13:02:59 elb systemd[1]: haproxy.service changed start -> running
Jun 07 13:02:59 elb systemd[1]: Job haproxy.service/start finished, result=done
Jun 07 13:02:59 elb systemd[1]: Started LSB: HAProxy.          -> start 成功


Jun 07 13:03:27 elb systemd[1]: Trying to enqueue job haproxy.service/reload/replace
Jun 07 13:03:27 elb systemd[1]: Installed new job haproxy.service/reload as 9504
Jun 07 13:03:27 elb systemd[1]: Enqueued job haproxy.service/reload as 9504


Jun 07 13:03:27 elb systemd[1]: About to execute: /etc/rc.d/init.d/haproxy reload
Jun 07 13:03:27 elb systemd[1]: Forked /etc/rc.d/init.d/haproxy as 7060
Jun 07 13:03:27 elb systemd[1]: haproxy.service changed running -> reload
Jun 07 13:03:27 elb systemd[7060]: Executing: /etc/rc.d/init.d/haproxy reload
Jun 07 13:03:27 elb systemd[1]: Child 7015 belongs to haproxy.service
Jun 07 13:03:27 elb systemd[1]: Main PID changing: 7015 -> 7065
Jun 07 13:03:27 elb systemd[1]: Child 7060 belongs to haproxy.service
Jun 07 13:03:27 elb systemd[1]: haproxy.service: control process exited, code=exited status=0
Jun 07 13:03:27 elb systemd[1]: haproxy.service got final SIGCHLD for state reload
Jun 07 13:03:27 elb systemd[1]: haproxy.service changed reload -> running
Jun 07 13:03:27 elb systemd[1]: Job haproxy.service/reload finished, result=done
Jun 07 13:03:27 elb systemd[1]: Reloaded LSB: HAProxy.                                    -> reload成功

Jun 07 13:03:27 elb systemd[1]: Child 7065 belongs to haproxy.service
Jun 07 13:03:27 elb systemd[1]: haproxy.service: main process exited, code=killed, status=9/KILL -> 7065 进程被kill掉。这里不知道是不是cgroup 发现了7065是7060的子进程。就一起kill掉了。
Jun 07 13:03:27 elb systemd[1]: haproxy.service changed running -> failed
Jun 07 13:03:27 elb systemd[1]: Unit haproxy.service entered failed state.
Jun 07 13:03:27 elb systemd[1]: haproxy.service failed.
Jun 07 13:03:27 elb systemd[1]: haproxy.service: cgroup is empty
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP