Centos7.5 installation and configuration MongoDB4.0.4

**After reviewing this year’s interviews with Ali, Toutiao and Meituan, I have an important discovery.......>>> **

Centos7.5 installation and configuration MongoDB4.0.4

2018- 11- 22 10:25:39

CollectionI want to contribute

MongoDB is a database based on distributed file storage. Written in C++ language. Designed to provide scalable high-performance data storage solutions for WEB applications. MongoDB is a product between relational and non-relational databases. It is the most versatile and most like relational database among non-relational databases.

1、 Download and unzip mongodb

cd /data/

curl -O https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-4.0.4.tgz

tar zxvf mongodb-linux-x86_64-4.0.4.tgz

2、 Create mongodb related directories

mv mongodb-linux-x86_64-4.0.4 mongodb

mkdir -p mongodb/{data/db,log}

mkdir -p /etc/mongodb

3、 Create mongodb configuration file

vim /etc/mongodb/mgdb.conf

dbpath=/data/mongodb/data/db #Data file storage directory

logpath=/data/mongodb/log/mongodb.log #Log file storage directory

port=37485 #Port, default 27017, can be customized

logappend=true #Open log and add log

fork=true #Enable as a daemon, that is, run in the background

bind_ip=0.0.0.0 #Local listening IP, 0.0.0.0 means all local IP

auth=true #Do you need authentication permission to log in (user name and password)

4、 Add environment variables

vim /etc/profile

export MONGODB_HOME=/data/mongodb

export PATH=PATH:MONGODB_HOME/bin

Make environment variables take effect immediately

source /etc/profile

5、 Create mongodb startup configuration file

vim /usr/lib/systemd/system/mongodb.service

[ Unit]

Description=mongodb

After=network.target remote-fs.target nss-lookup.target

[ Service]

Type=forking

RuntimeDirectory=mongodb

PIDFile=/data/mongodb/data/db/mongod.lock

ExecStart=/data/mongodb/bin/mongod --config /etc/mongodb/mgdb.conf

ExecStop=/data/mongodb/bin/mongod --shutdown --config /etc/mongodb/mgdb.conf

PrivateTmp=true

[ Install]

WantedBy=multi-user.target

6、 Start mongodb and add it to boot

systemctl daemon-reload

systemctl start mongodb

systemctl enable mongodb

7、 Configure firewalld firewall policy

firewall-cmd --permanent --add-port=37485/tcp

firewall-cmd --reload

8、 test

(1) Create an administrative user

mongo --port 37485

use admin

db.createUser({user:"admin",pwd:"xuad830818",roles:[{role:"userAdminAnyDatabase",db: "admin"}]})

db.auth('admin','xuad830818')

(2) Create a test user

use test

db.createUser({user:"xuad",pwd:"123456",roles:[{role:"readWrite",db:"securitydata"}]})

db.auth('xuad','123456')

exit

Centos 7.5 install and configure MongoDB 4.0.4

(3) Login with test user

mongo --port 37485 -u xuad -p 123456

Centos 7.5 install and configure MongoDB 4.0.4

Recommended Posts

Centos7.5 installation and configuration MongoDB4.0.4
Centos mysql installation and configuration
Centos7 installation and configuration prometheus
CentOS installation and configuration cmake
CentOS 7 installation and configuration PPTP
Centos7 installation and configuration of Jenkins
Centos7 hadoop cluster installation and configuration
Java-JDK installation and configuration under CentOS
CentOS 7 Tomcat service installation and configuration
CentOS NTP server installation and configuration
Centos7 mysql database installation and configuration
Tomcat installation and configuration under CentOS 7 (Tomcat startup)
MySQL 8.0 installation, deployment and configuration under CentOS 6/7
Installation and configuration of redis under centos7
Mysql8.0.15 installation configuration (centos7)
Centos7 hive stand-alone mode installation and configuration
Installation and configuration of JDK in CentOS 7 system
CentOS 6.5 system installation and configuration graphic tutorial (detailed graphic)
CentOS 7 installation and configuration graphic tutorials under VMware10
Installation and configuration of rsync server under CentOS 6.5
Installation and configuration of CentOS 7 in VMware Workstation
MySQL 8.0 installation, deployment and configuration tutorial on CentOS 8
Ubuntu16.04 installation and simple configuration
Centos6.5 install and configure mongodb
centos7 kvm installation and use
CentOS7 postgresql installation and use
Ubuntu PostgreSQL installation and configuration
Centos7 elk7.1.1 installation and use
2019-07-09 CentOS7 installation
centos7_1708 installation
CentOS 8 install Git and basic configuration
Centos6.5 installation and deployment of KVM
CentOS7 installation and maintenance of Gitlab
CentOS7.2 and Nginx configuration virtual host
CentOS 7.X system installation and optimization
Centos 7 RAID 5 detailed explanation and configuration
Ubuntu 19.1 installation and configuration Chinese environment
Configuration and beautification after Ubuntu installation (1)
Nginx installation and configuration load (ubuntu12.04)
CentOs7 installation and deployment Zabbix3.4 original
Erlang 20.2 installation and deployment under CentOS 7
Ubuntu configuration source and installation software
Detailed explanation of Spark installation and configuration tutorial under centOS7
CentOS7.0 network configuration
Installation and use of Mysql under CentOS
CentOS 7.0 network configuration
Centos7.5 configuration java environment installation tomcat explanation
Centos-6.5 installation and deployment of LNMP environment
Python - centos6 installation
Centos7.6 operating system installation and optimization record
Centos7 installation and deployment of gitlab server
Docker installation (CentOS7 installation)
Centos python3 compile installation and compile gcc upgrade
Zabbix installation and deployment and localization under CentOS
CentOS7 installation zabbix 4.0 tutorial (graphics and text)
Jenkins installation and deployment tutorial under CentOS 7
CentOS7 docker installation
KVM installation and preliminary use under CentOS 7.2
Centos MySQL8 configuration
DLNA/UPnP Server installation and configuration under Ubuntu 12.04
Centos7 installation and deployment of Airflow detailed