Centos 7 install and configure mongodb

1 Go to the /usr/local/ directory:
cd /usr/local

2 Create the tools directory in the current directory:
mkdir -p tools

3 Go to the tools directory:
cd tools

4 Download the mongodb-linux-x86_64- that matches the CentOS system rhel70-3.4.9.tgz file:
wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-3.4.9.tgz

5 Unzip mongodb-linux-x86_64-rhel70-3.4.9. tgz file:
tar -zxvf mongodb-linux-x86_64-rhel70-3.4.9.tgz After
the decompression is completed, the mongodb-linux-x86_64-rhel70-3.4.9 folder and its belonging files are obtained;

6 Rename mongodb-linux-x86_64 -rhel70-3.4.9 The file is mongodb3.4.9:
mv mongodb-linux-x86_64-rhel70-3.4.9 mongodb3.4.9

7 Go back to the previous directory and create the mongodb directory:
cd ../
mkdir -p mongodb

8 will The mongodb3.4.9 files are moved from the /usr/local/tools directory to the /usr/local/mongodb directory:
mv tools/mongodb3.4.9/ mongodb/

9 go to /usr/local/mongodb/mongodb3.4.9/bin directory:
cd mongodb/mongodb3.4.9/bin

10 in /usr/local/mongodb/mongodb3.4.9/bin/ Create a directory to store logs in the directory:
mkdir -p data/test/logs

11 Create a directory to store data files in the /usr/local/mongodb/mongodb3.4.9/bin/ directory:
mkdir -p data/test/db

12 Enter the bin directory:
cd bin/

13 Create the configuration file mongodb.conf:
vi mongodb.conf

Write the following in mongodb.conf:
# idae - MongoDB config start - 2016-05-02 # Set the storage directory dbpath

for data files
= /usr/local/mongodb/mongodb3.4.9/bin/data/test/db

# Set the storage directory of the log file and its log file name
logpath = /usr/local/mongodb/mongodb3.4.9/bin/data/test/ logs/mongodb.log

# Set the port number (the default port number is 27017)
port = 27017

# Set to run as a daemon process, that is, run in the background
fork = true

# nohttpinterface = true
nohttpinterface = true
# idae - MongoDB config end - 2016-05-02

Save and save as ":wq" in English Exit;


20 Add the mongodb service to the self-starting file:
vi /etc/rc.local
Append the following command at the end of the file:
/usr/local/mongodb/mongodb3.2.4/bin/mongod --config mongodb.conf
Save and exit :
:wq!

21 Common client commands:
db.version(); # View the version of mongodb
use test; # Enter the specified data, here is the test database

22 in /usr/local/mongodb/mongodb3.2.4/bin / directory, type the following command to open a mongodb client program, that is, open a mongodb shell client, this shell client is also a JavaScript editor, you can enter any JavaScript script by default:
./mongo
connects to Test database

23 Enter IP: 27017 in the browser, such as:
http://101.201.212.129:27017/
You can view the version information of MongoDB;

Beijing Java Job Search Group 145471323

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326085867&siteId=291194637