Difference between revisions of "MongoDB"
Line 98: | Line 98: | ||
systemctl {start|stop|restart} mongodb | systemctl {start|stop|restart} mongodb | ||
+ | |||
+ | |||
+ | === USing keys=== | ||
+ | |||
+ | config setprop mongod service status enabled | ||
+ | |||
+ | Minimal config I use for Rocket.Chat | ||
+ | |||
+ | grep '^[[:blank:]]*[^[:blank:]#;]' /etc/mongod.conf | ||
+ | |||
+ | systemLog: | ||
+ | verbosity: 0 | ||
+ | destination: file | ||
+ | logAppend: true | ||
+ | path: /var/log/mongodb/mongod.log | ||
+ | storage: | ||
+ | dbPath: /var/lib/mongo | ||
+ | journal: | ||
+ | enabled: true | ||
+ | processManagement: | ||
+ | fork: true # fork and run in background | ||
+ | pidFilePath: /var/run/mongodb/mongod.pid # location of pidfile | ||
+ | timeZoneInfo: /usr/share/zoneinfo | ||
+ | net: | ||
+ | port: 27017 | ||
+ | bindIp: 127.0.0.1 # Enter 0.0.0.0,:: to bind to all IPv4 and IPv6 addresses or, alternatively, use the net.bindIpAll setting. | ||
+ | replication: | ||
+ | replSetName: rs0 | ||
===Vaporise or reinitialise the database=== | ===Vaporise or reinitialise the database=== |
Revision as of 15:09, 27 October 2021
How to install MongoDB 4.0
Install Official Repository
This should work for every version of Koozali SME
You may need to change the mongodb version as required
db yum_repositories set mongodb repository \ BaseURL https://repo.mongodb.org/yum/redhat/\$releasever/mongodb-org/4.0/$basearch/ \ EnableGroups no \ GPGCheck yes \ Name "MongoDB" \ GPGKkey https://www.mongodb.org/static/pgp/server-4.0.asc \ Visible no \ status disabled
signal-event yum-modify
yum install mongodb-org --enablerepo=mongodb
If refuses to install because of no GPG Key you can change GPGCheck above from Yes to No and try yum install... again or
rpm --import https://www.mongodb.org/static/pgp/server-4.0.asc
Or
yum install mongodb-org --enablerepo=mongodb --nogpgcheck
Start Mongo
/etc/init.d/mongod start
Add the symlinks to start automatically:
ln -s /etc/init.d/mongod /etc/rc.d/rc6.d/K03mongodb ln -s /etc/init.d/mongod /etc/rc.d/rc7.d/S57mongodb
Optional: create symlink to use mongo or mongodb as service name
ln /etc/init.d/mongod /etc/init.d/mongodb
To ensure everything is all right:
signal-event post-upgrade signal-event reboot
Additional Notes
Note - I need to test this again This is my initial observation.
As far as I can see, the link above to mongodb is not necessary.
It may need this to set on and off correctly in other service levels:
chkconfig mongod on
Create a service link in in rc7.d:
ln -s /etc/init.d/mongod /etc/rc.d/rc7.d/S57mongod
To use e-smith-service it will need a key:
config set mongod service status enabled
You should now be able to do:
service mongod start|stop|restart etc
Mongo should come up on boot.
Koozali SME v10
Install
Use the above method to add the repo and then:
yum --enablerepo=mongodb install mongodb-org
Mongo will automatically create a symlink so currently there is no way to enable/disable it apart from manually. Once Koozali SME has some more systemd tools we can use DB keys etc.
Created symlink from /etc/systemd/system/multi-user.target.wants/mongod.service to /usr/lib/systemd/system/mongod.service
To enable/disable this just use:
systemctl {en|dis}able mongodb
And to start stop
systemctl {start|stop|restart} mongodb
USing keys
config setprop mongod service status enabled
Minimal config I use for Rocket.Chat
grep '^blank:*[^[:blank:]#;]' /etc/mongod.conf
systemLog: verbosity: 0 destination: file logAppend: true path: /var/log/mongodb/mongod.log storage: dbPath: /var/lib/mongo journal: enabled: true processManagement: fork: true # fork and run in background pidFilePath: /var/run/mongodb/mongod.pid # location of pidfile timeZoneInfo: /usr/share/zoneinfo net: port: 27017 bindIp: 127.0.0.1 # Enter 0.0.0.0,:: to bind to all IPv4 and IPv6 addresses or, alternatively, use the net.bindIpAll setting. replication: replSetName: rs0
Vaporise or reinitialise the database
Remove the directory contents:
rm -rf /var/lib/mongo/*
Or remove the entire directory and recreate it with the correct ownership:
rm -rf /var/lib/mongo mkdir -p /var/lib/mongo chown -R mongod:mongod /var/lib/mongo
If you have a replicaset set in /etc/mongod.conf make sure you initiate it:
mongo --eval "printjson(rs.initiate())"