-
download
Choose the appropriate installation package for your system version. This article installs CentOS 7
MongoDB's official website is https://www.mongodb.com/ , you can download the MongoDB program on the official website. The reason why it's a program is that the relevant programs of MongoDB in the downloaded installation package have been compiled. What I use is mongodb-linux-x86_64-3.6.4.tgz , you can select download from this page https://www.mongodb.com/download-center?jmp=nav#community.
[root@bigdata1 software]# cd /data/software/ [root@bigdata1 software]# wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-3.6.4.tgz
-
install and configure
Wait for the download to complete, unzip, and change the folder name to mongodb (optional)
[root@bigdata1 software]# tar -zxf mongodb-linux-x86_64-3.6.4.tgz [root@bigdata1 software]# mv mongodb-linux-x86_64-3.6.4.tgz mongodb
Create database directory db, log directory logs and configuration file directory conf in mongodb directory
[root@bigdata1 software]# cd mongodb [root@bigdata1 mongodb]# mkdir db [root@bigdata1 mongodb]# mkdir logs [root@bigdata1 mongodb]# mkdir conf [root@bigdata1 mongodb]# ll total 120 drwxr-xr-x. 2 root root 248 May 5 10:25 bin drwxr-xr-x. 2 root root 26 May 5 10:48 conf drwxr-xr-x. 4 root root 4096 May 5 10:55 db -rw-r--r--. 1 root root 34520 Apr 13 23:37 GNU-AGPL-3.0 drwsr-xr-x. 2 root root 25 May 5 10:40 logs -rw-r--r--. 1 root root 16726 Apr 13 23:37 MPL-2 -rw-r--r--. 1 root root 2195 Apr 13 23:37 README -rw-r--r--. 1 root root 57190 Apr 13 23:37 THIRD-PARTY-NOTICES
Create a new configuration file mogodb.conf under conf, and configure the following
[root@bigdata1 mongodb]# cd conf/ [root@bigdata1 conf]# touch mongodb.conf [root@bigdata1 conf]# vi mongodb.conf
Configuration content. If you are prompted that the nohttpinterface does not exist, comment it
#Port number, use default port port = 27017 #Database directory dbpath = /data/software/mongodb/db #Log directory logpath = /data/software/mongodb/logs/mongodb.log logappend = true #Whether to run as Daemons fork = true #Close http management interface or not #nohttpinterface=true
-
Startup validation
start-up
To start mongodb, you need to use mongod in bin directory. If you specify the configuration file through - f or – config =, you need to
[root@bigdata1 conf]# cd /data/software/mongodb [root@bigdata1 mongodb]# ./bin/mongod -f conf/mongodb.conf about to fork child process, waiting until server is ready for connections. forked process: 6770 child process started successfully, parent exiting [root@bigdata1 mongodb]# ps -ef | grep mongodb root 6770 1 50 11:24 ? 00:00:51 ./bin/mongod -f conf/mongodb.conf root 6800 1124 3 11:26 pts/0 00:00:00 grep --color=auto mongodb
Connect
To connect mongodb, you need to use mongo in bin directory
[root@bigdata1 mongodb]# ./bin/mongo MongoDB shell version v3.6.4 connecting to: mongodb://127.0.0.1:27017 MongoDB server version: 3.6.4 Server has startup warnings: 2018-05-05T11:25:44.045+0800 I CONTROL [initandlisten] 2018-05-05T11:25:44.045+0800 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database. 2018-05-05T11:25:44.045+0800 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted. 2018-05-05T11:25:44.045+0800 I CONTROL [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended. 2018-05-05T11:25:44.045+0800 I CONTROL [initandlisten] 2018-05-05T11:25:44.045+0800 I CONTROL [initandlisten] ** WARNING: This server is bound to localhost. 2018-05-05T11:25:44.045+0800 I CONTROL [initandlisten] ** Remote systems will be unable to connect to this server. 2018-05-05T11:25:44.045+0800 I CONTROL [initandlisten] ** Start the server with --bind_ip <address> to specify which IP 2018-05-05T11:25:44.045+0800 I CONTROL [initandlisten] ** addresses it should serve responses from, or with --bind_ip_all to 2018-05-05T11:25:44.045+0800 I CONTROL [initandlisten] ** bind to all interfaces. If this behavior is desired, start the 2018-05-05T11:25:44.045+0800 I CONTROL [initandlisten] ** server with --bind_ip 127.0.0.1 to disable this warning. 2018-05-05T11:25:44.045+0800 I CONTROL [initandlisten] 2018-05-05T11:25:44.050+0800 I CONTROL [initandlisten] 2018-05-05T11:25:44.050+0800 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'. 2018-05-05T11:25:44.050+0800 I CONTROL [initandlisten] ** We suggest setting it to 'never' 2018-05-05T11:25:44.050+0800 I CONTROL [initandlisten] 2018-05-05T11:25:44.050+0800 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'. 2018-05-05T11:25:44.050+0800 I CONTROL [initandlisten] ** We suggest setting it to 'never' 2018-05-05T11:25:44.050+0800 I CONTROL [initandlisten] > show dbs admin 0.000GB config 0.000GB local 0.000GB > db.runoob.insert({"name":"Rookie tutorial"}) WriteResult({ "nInserted" : 1 }) > show dbs admin 0.000GB config 0.000GB local 0.000GB test 0.000GB > db.runoob.find().pretty() { "_id" : ObjectId("5aed259516b74971a27b2528"), "name" : "Rookie tutorial" } >
CentOS 7 installation of MongoDB standalone
Posted by CousinCocaine on Fri, 20 Mar 2020 08:58:30 -0700