## Initial system environment, reference document: Server system environment initialization, Centos7 system
#mongodbDownload and Install
mkdir -p / server / src / server / logs
groupadd mongod
useradd -s / sbin / nologin -g mongod mongod
cat / etc / passwdgrep mongo
cd / server / src
## Install mongodb version 3.0.7. If other versions are required, download it from the official website https://fastdl.mongodb.org/linux/
wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-3.0.7.tgz
tar zxvf mongodb-linux-x86_64-rhel70-3.0.7.tgz
mv mongodb-linux-x86_64-rhel70-3.0.7 / usr / local / mongodb
mkdir -p / data / mongodb / db
mkdir / data / mongodb / log
touch /data/mongodb/log/mongo.log
chmod 644! $
chown -R mongod.mongod / data / mongodb
yum -y install tree
tree / data
vim /lib/systemd/system/mongod.service
[Unit]
Description = mongodb
After = network.target remote-fs.target nss-lookup.target
[Service]
Type = forking
PIDFile = / data / mongodb / db / mongod.lock
ExecStart = / usr / local / mongodb / bin / mongod --dbpath = / data / mongodb / db --logpath = / data / mongodb / log / mongo.log --fork --port 27017 --logappend --auth
ExecReload = / bin / kill -s HUP $ MAINPID
ExecStop = / bin / kill -s QUIT $ MAINPID
PrivateTmp = true
[Install]
WantedBy = multi-user.target
systemctl enable mongod.service
systemctl start mongod.service
ps aux | grep mongo | grep -v ‘grep’
systemctl status mongod.service
## mongo start process analysis
ps aux | grep mongo | grep -vE "cp2 | grep"
root 75815 0.1 0.1 658320 72384? Sl 17:50 0:08 / usr / local / mongodb / bin / mongod --dbpath = / data / mongodb / db --logpath = / data / mongodb / log / mongo.log- fork --port 27017 --logappend --auth
## parse
#mongod is to start the mongodb service
# -portmongodb port used at startup
#-dbpath Specify a directory for the mongodb database storage path
#-logpath Log file storage path
#-logappend Log files are automatically accumulated instead of overwritten
#-fork start Mongdb service in the background
#-directoryperdb put each database in a separate directory
#Add mongo program to environment variables
mongo ## The default login method, using the default port 27017 to start the mongo service, directly enter
mongo --port = 27027 ## Specify the port 27027 to start the mongo service, you need to add the port number to start
mongo 103.56.195.5:27017 ## Log in to the mongo service of the specified remote host. This can be used to test whether the peer firewall is open.
#Create an administrator account
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.