# # Build the most detailed database on Ali cloud MongoDB server and remote access

A server-side installation and start Mongodb

1.1 download Mongodb

Jump to save the installation package location, the following code is executed

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

1.2 unzip

tar zxvf mongodb-linux-x86_64-3.2.9.tgz

1.3 Create a file

Go to the installation directory files needed to create Mongodb database (database folder, log files, configuration files)

cd /usr/local
mkdir -p  /usr/local/mongodb/data  
touch /usr/local/mongodb/mongod.log
touch /usr/local/mongodb/mongodb.conf

1.4 All Mongodb file is extracted moved to the installation directory

mv /home/tempfile/mongodb-linux-x86_64-3.2.9/* /usr/local/mongodb/ 

1.5 Configuring the system environment variables

vi /etc/profile

Keyboard Press "i" to enter edit mode. In the final document, plus:

#mongodb
export PATH=$PATH:/root/mongodb/bin

Finally, press the "Esc", enter ": wq" to save and exit vi editing mode, execute the following command for the changes to take effect.

source /etc/profile

1.6 start Mongodb (There are two ways)

  1. Modify the configuration file starts
    at Mongodb directory of Mongodb.conf file add the following

dbpath=/usr/local/mongodb/data
logpath=/usr/local/mongodb/mongod.log
logappend = true
port = 27017
fork = true
auth = true

parameter description
dbpath Database path
logpath Log save path
logappend Whether to keep history log
port The port number
fork Whether the log written to the log file without displaying the command line
auth Whether to adopt the authentication (when false or deleted, do not need external access user name and password)

Enter Mongodb / bin directory, execute the following command to start Mongodb

./mongod --config /usr/local/mongodb/mongodb.conf
  1. Start up (by mongodb client tools can be accessed directly)
    into the Mongodb / bin directory, execute the following command to start Mongodb
./mongod --dbpath=/usr/local/mongodb/data --logpath=/usr/local/mongodb/mongod.log --logappend  --port=27017 --fork 

mongodb If there is illegal when closed

about to fork child process, waiting until server is ready for connections 

So you need to perform

rm /data/mongodb/mongo.lock 命令    ###权限不足的话加上sudo

Then perform

./mongod  --repair (命令修复)  ###权限不足的话加上sudo
###如果执行以上命令出现权限问题则修改权限:
sudo chmod 777 mongodb.conf

stop

./mongod -shutdown -dbpath=/usr/local/mongodb/data

If left path parameters with the following error

There doesn't seem to be a server running with dbpath: /data/db 

2 remote management database

2.1 Opening cloud server port 27017

Here Insert Picture Description

2.2 download MongoDB Compass visualization tools

According to their own system installation package in the official website to download and install MongoDB Compass
MongoDB Compass Official Download

2.2 to establish a connection

  1. 点击 Fill in connection fields individually
    Here Insert Picture Description
  2. In the Hostname in the Hostname fill in your public IP address and then click on CONNECT
    Here Insert Picture Description
  3. The following page appears, says the connection is successful
    Here Insert Picture Description
Published 59 original articles · won praise 2 · Views 4632

Guess you like

Origin blog.csdn.net/lch551218/article/details/104067710