LoginSignup
1
0

More than 5 years have passed since last update.

MongoDBをsupervisorでプロセス監視する手順メモ

Last updated at Posted at 2018-02-08

環境

ubuntu16.04LTS
MongoDB version v3.4.11
supervisor 3.2.0

手順

/etc/supervisor/conf.d/mongod.confを作成

/etc/supervisor/conf.d/mongod.conf
[program:mongod] ;
directory=/var/lib/mongodb ; 
command=/usr/bin/mongod -f /etc/mongod.conf ;
numprocs=1 ; 
autostart=true ; 
autorestart=true ; 
user=mongodb ; 
redirect_stderr=true ; 
stdout_logfile=/var/log/supervisor/mongod.log ;

/etc/mongod.confはデフォルトだけど一応掲載

/etc/mongod.conf
# mongod.conf

# for documentation of all options, see:
#   http://docs.mongodb.org/manual/reference/configuration-options/

# Where and how to store data.
storage:
  dbPath: /var/lib/mongodb
  journal:
    enabled: true
#  engine:
#  mmapv1:
#  wiredTiger:

# where to write logging data.
systemLog:
  destination: file
  logAppend: true
  path: /var/log/mongodb/mongod.log

# network interfaces
net:
  port: 27017
  bindIp: 127.0.0.1


#processManagement:

#security:

#operationProfiling:

#replication:

#sharding:

## Enterprise-Only Options:

#auditLog:

#snmp:

dbpathの/var/lib/mongodb 以下が全てmongodbユーザでアクセスできるか確認
なってなければ次のコマンドで所有権変更しとけばok

$ cd /var/lib
$ sudo chown -R mongodb mongodb
$ sudo chgrp -R mongodb mongodb

あとはsupervisorを起動してファイル読ませてmongod起動、起動確認

$ sudo service supervisor start
$ sudo supervisorctl reread
$ sudo supervisorctl start mongod
$ sudo supervisorctl status
mongod                           RUNNING   pid 5652, uptime 0:00:10

上手くいかなければsupervisorを再起動

$ sudo service supervisor restart
$ sudo supervisorctl status
mongod                           RUNNING   pid 5652, uptime 0:00:10

一応、

$ mongo

でmongodbに接続できるか確認

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0