Graylog2 / graylog-ansible-role

Ansible role which installs and configures Graylog
Apache License 2.0
212 stars 126 forks source link

Fixing mongodb error after restarting at Red Hat #114

Closed guilhermewolf closed 4 years ago

guilhermewolf commented 5 years ago

With this template for the /etc/mongod.conf file, the service starts but does not recognize the pid file and then fails in the Red Hat environment. The fix allows mongodb to parse this pid file

CLAassistant commented 5 years ago

CLA assistant check
All committers have signed the CLA.

malcyon commented 4 years ago

This makes MongoDB fail to start on Debian Stretch and Buster. See the Travis CI job below.

malcyon commented 4 years ago

Based on reading through https://github.com/Graylog2/graylog-ansible-role/pull/87 and https://github.com/Graylog2/graylog-ansible-role/pull/86, it sounds like forking mongodb makes it fail under systemd.

So maybe it should just never be forked.

malcyon commented 4 years ago

I'm confused, because when I test it against a local VM, I can restart the service just fine:

(venv) donald@laptop:~/src/graylog-ansible-role$ molecule login
Last login: Thu Jul 30 16:35:01 2020 from 192.168.121.1
[vagrant@instance ~]$ sudo su -
[root@instance ~]# systemctl status mongod
● mongod.service - High-performance, schema-free document-oriented database
   Loaded: loaded (/usr/lib/systemd/system/mongod.service; enabled; vendor preset: disabled)
   Active: active (running) since Thu 2020-07-30 16:33:22 UTC; 2min 26s ago
     Docs: https://docs.mongodb.org/manual
 Main PID: 6566 (mongod)
   CGroup: /system.slice/mongod.service
           └─6566 /usr/bin/mongod -f /etc/mongod.conf

Jul 30 16:33:22 instance systemd[1]: Starting High-performance, schema-free document-oriented database...
Jul 30 16:33:22 instance systemd[1]: Started High-performance, schema-free document-oriented database.
[root@instance ~]# systemctl restart mongod
[root@instance ~]# systemctl status mongod 
● mongod.service - High-performance, schema-free document-oriented database
   Loaded: loaded (/usr/lib/systemd/system/mongod.service; enabled; vendor preset: disabled)
   Active: active (running) since Thu 2020-07-30 16:35:58 UTC; 3s ago
     Docs: https://docs.mongodb.org/manual
  Process: 7835 ExecStartPre=/usr/bin/chmod 0755 /var/run/mongodb (code=exited, status=0/SUCCESS)
  Process: 7832 ExecStartPre=/usr/bin/chown mongod:mongod /var/run/mongodb (code=exited, status=0/SUCCESS)
  Process: 7831 ExecStartPre=/usr/bin/mkdir -p /var/run/mongodb (code=exited, status=0/SUCCESS)
 Main PID: 7837 (mongod)
   CGroup: /system.slice/mongod.service
           └─7837 /usr/bin/mongod -f /etc/mongod.conf

Jul 30 16:35:58 instance systemd[1]: Stopped High-performance, schema-free document-oriented database.
Jul 30 16:35:58 instance systemd[1]: Starting High-performance, schema-free document-oriented database...
Jul 30 16:35:58 instance systemd[1]: Started High-performance, schema-free document-oriented database.
[root@instance ~]# getenforce
Enforcing
[root@instance ~]# cat /etc/os-release
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"

CENTOS_MANTISBT_PROJECT="CentOS-7"
CENTOS_MANTISBT_PROJECT_VERSION="7"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="7"

Centos should be very similar to Redhat, from what I understand.

@mariussturm Any input here? I know it's been a couple years since you touched this.

malcyon commented 4 years ago

Closing this for lack of response. Doesn't look like forking mongodb is a good idea, and it fails most of the tests.