由于重生,init.d 终止了我的 mongod 进程

由于重生,init.d 终止了我的 mongod 进程

我正在使用 Ansible 在 Centos 6.8 VM 上启动 mongod 服务。任务非常简单:

- name: Start mongod service
  service: 
    state: started
    name: mongod

但是服务无法启动,/var/log/messages我看到

Jun 26 15:40:18 server1 ansible-service: Invoked with name=mongod pattern=None enabled=None state=started sleep=None arguments= runlevel=default
Jun 26 15:40:18 server1 init: mongod main process (4133) terminated with status 1
Jun 26 15:40:18 server1 init: mongod main process ended, respawning
Jun 26 15:40:18 server1 init: mongod main process (4143) terminated with status 1
Jun 26 15:40:18 server1 init: mongod main process ended, respawning
Jun 26 15:40:18 server1 init: mongod main process (4145) terminated with status 1
Jun 26 15:40:18 server1 init: mongod main process ended, respawning
Jun 26 15:40:18 server1 init: mongod main process (4147) terminated with status 1
Jun 26 15:40:18 server1 init: mongod main process ended, respawning
Jun 26 15:40:18 server1 init: mongod main process (4149) terminated with status 1
Jun 26 15:40:18 server1 init: mongod main process ended, respawning
Jun 26 15:40:18 server1 init: mongod main process (4151) terminated with status 1
Jun 26 15:40:18 server1 init: mongod main process ended, respawning
Jun 26 15:40:18 server1 init: mongod main process (4153) terminated with status 1
Jun 26 15:40:18 server1 init: mongod main process ended, respawning
Jun 26 15:40:18 server1 init: mongod main process (4155) terminated with status 1
Jun 26 15:40:18 server1 init: mongod main process ended, respawning
Jun 26 15:40:18 server1 init: mongod main process (4157) terminated with status 1
Jun 26 15:40:18 server1 init: mongod main process ended, respawning
Jun 26 15:40:18 server1 init: mongod main process (4159) terminated with status 1
Jun 26 15:40:18 server1 init: mongod main process ended, respawning
Jun 26 15:40:18 server1 init: mongod main process (4161) terminated with status 1
Jun 26 15:40:18 server1 init: mongod respawning too fast, stopped

/var/log/mongodb/mongod.log看到该进程收到了 SIGTERM

2020-06-25T18:57:21.842+0000 I NETWORK  [conn1] end connection 127.0.0.1:49576 (0 connections now open)
2020-06-25T18:57:41.815+0000 I CONTROL  [signalProcessingThread] got signal 15 (Terminated), will terminate after current cmd ends

但我不知道是什么将它发送给了进程,大概是 init 吧?

现在真正奇怪的是,当我手动登录到虚拟机并使用启动 mongod 服务时service mongod start,它非常顺利并正常启动。

有什么想法可以让我追踪这个问题,并找出为什么我的进程在通过 Ansible 启动时被终止?

答案1

除非你已经以 Ansible 用户身份登录,否则root你可能需要添加become: yes任务中用于提升权限的选项。

- name: Start mongod service
  service: 
    state: started
    name: mongod
  become: yes

相关内容