Linux system Installation MongoDB

Source: Internet
Author: User
Tags chmod mkdir mongodb

1. On the official website https://www.mongodb.org/dl/linux/x86_64 download the corresponding installation compression package, I use 3.2.5, we recommend this version, the higher the version, there may be other unknown problems, such as the need to glibc high version, through

Ll/lib64/libc.so.6 can view the native version of/lib64/libc.so.6-libc-2.17.so, installed once.

2. Put the compressed package in the/usr/download directory, enter the download directory, unzip, TAR-ZXVF mongodb-linux-x86_64-3.2.5.tgz.

3. Copy the folder to the/usr/local/mongodb directory, Cp-r Mongodb-linux-x86_64-3.2.5/usr/local/mongodb.

4. Edit the environment variable information, sudo vi/etc/profile, add the following content, and then Source/etc/profile.

Export Mongodb_home=/usr/local/mongodb/mongodb-linux-x86_64-3.2.5export path= $PATH: $MONGODB _home/bin

5. Enter/usr/local/mongodb/mongodb-linux-x86_64-3.2.5 and execute the following commands sequentially.

sudo mkdir-p data/dbsudo chmod-r 777 Data/dbsudo mkdir LOGSCD Logstouch mongodb.log

6. Enter/usr/local/mongodb/mongodb-linux-x86_64-3.2.5/bin, execute sudo vi mongodb.conf, add the following content.

DBPath =/usr/local/mongodb/mongodb-linux-x86_64-3.2.5/data/db #数据文件存放目录logpath =/usr/local/mongodb/ Mongodb-linux-x86_64-3.2.5/logs/mongodb.log #日志文件存放目录port = 27017  #端口fork = True  #以守护程序的方式启用, That is, running in the background Nohttpinterface = True

7. Execute the./mongod-f mongodb.conf in the bin directory to start the MongoDB database service as a configuration file.

8. Execute./mongo, you can connect to the MongoDB database.

MongoDB Shell version:3.2.5connecting to:testwelcome to the MongoDB shell. For interactive help, type ' help '. For more comprehensive documentation, see http://docs.mongodb.org/Questions? Try the support group Http://groups.google.com/group/mongodb-userServer have startup warnings:2018-08-21t15:16:33.561+ 0800 I control [Initandlisten] 2018-08-21t15:16:33.561+0800 i control [initandlisten] * * warning:insecure configuration , access control is not enabled and no--bind_ip have been specified.2018-08-21t15:16:33.561+0800 I control [Initandlisten ] * * Read and Write access to data and configuration are unrestricted, 2018-08-21t15:16:33.561+0800 I CONTROL [in   Itandlisten] * * and the server listens on all available network interfaces.2018-08-21t15:16:33.561+0800 I CONTROL [Initandlisten] * * Warning:you was running this process as the root user, which was not recommended.2018-08-21t15:16:33. 561+0800 I control [Initandlisten] 2018-08-21t15:16:33.562+0800 i control [inItandlisten] 2018-08-21t15:16:33.562+0800 I CONTROL [initandlisten] * * WARNING:/sys/kernel/mm/transparent_hugepage/ Enabled is ' Always '. 2018-08-21t15:16:33.562+0800 I CONTROL [initandlisten] * * We suggest setting it to ' never ' 2018 -08-21t15:16:33.562+0800 I control [Initandlisten] 2018-08-21t15:16:33.562+0800 i control [initandlisten] * * WARNING:/s Ys/kernel/mm/transparent_hugepage/defrag is ' always '. 2018-08-21t15:16:33.562+0800 I CONTROL [initandlisten] * * We Suggest setting it to ' Never ' 2018-08-21t15:16:33.562+0800 I CONTROL [Initandlisten] >

9. Set the Mongodb.service to start the service, set the boot start, sequentially execute the following command.

Cd/lib/systemd/systemsudo VI Mongodb.service

Add the following content to the content, and then save it.

[Unit] Description=mongodbafter=network.target Remote-fs.target nss-lookup.target[service]type=forkingexecstart=/usr/ Local/mongodb/mongodb-linux-x86_64-3.2.5/bin/mongod--config/usr/local/mongodb/mongodb-linux-x86_64-3.2.5/bin/ Mongodb.confexecreload=/bin/kill-s HUP $MAINPIDExecStop =/usr/local/mongodb/mongodb-linux-x86_64-3.2.5/bin/mongod --shutdown--config/usr/local/mongodb/mongodb-linux-x86_64-3.2.5/bin/mongodb.confprivatetmp=true[install] Wantedby=multi-user.target

10. Authorized chmod 754 Mongodb.service.

11. The Operation commands of the system Mongodb.service are as follows.

#启动服务  systemctl start mongodb.service  #关闭服务  systemctl stop mongodb.service  #开机启动  systemctl Enable Mongodb.service

12. You will find that executing systemctl start Mongodb.service will have the following content, no matter, no impact, no better.

Job for Mongodb.service failed because the control process exited with error code. See "Systemctl Status Mongodb.service" and "Journalctl-xe" for details.

13. Execute cd/usr/local/mongodb/mongodb-linux-x86_64-3.2.5/bin/to the bin directory, execute./mongo, the following screen shows that the MongoDB database started successfully, you can go to connect to do any operation.

MongoDB Shell version:3.2.5connecting To:testserver has startup warnings:2018-08-21t15:16:33.561+0800 I CONTROL [Inita Ndlisten] 2018-08-21t15:16:33.561+0800 I CONTROL [initandlisten] * * warning:insecure configuration, Access CONTROL is no  T-enabled and no--bind_ip has been specified.2018-08-21t15:16:33.561+0800 I CONTROL [initandlisten] * * Read and          Write access to data and configuration is unrestricted, 2018-08-21t15:16:33.561+0800 I CONTROL [Initandlisten] * * And the server listens on all available network interfaces.2018-08-21t15:16:33.561+0800 I CONTROL [initandlisten] * * W Arning:you was running this process as the root user, which was not recommended.2018-08-21t15:16:33.561+0800 i CONTROL [i Nitandlisten] 2018-08-21t15:16:33.562+0800 i control [Initandlisten] 2018-08-21t15:16:33.562+0800 i control [ Initandlisten] * * WARNING:/sys/kernel/mm/transparent_hugepage/enabled is ' always '. 2018-08-21t15:16:33.562+0800 I CONTROL [Initandlisten] * * We SuggeSt setting it to ' Never ' 2018-08-21t15:16:33.562+0800 I control [Initandlisten] 2018-08-21t15:16:33.562+0800 I control [I Nitandlisten] * * WARNING:/sys/kernel/mm/transparent_hugepage/defrag is ' always '. 2018-08-21t15:16:33.562+0800 I  control [Initandlisten] * * We suggest setting it to ' Never ' 2018-08-21t15:16:33.562+0800 I CONTROL [Initandlisten] >

14. Download the NoSQL Manager for MongoDB, enter the IP and port (default is 27017), you can connect to do any of your previous operations in Oracle or MySQL, but the syntax is different.

Linux system Installation MongoDB

Related Article

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.