1. Download the MongoDB installation package
wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-3.2.4.tgz
2. Unzip
TAR-ZXVF mongodb-linux-x86_64-rhel70-3.2.4.tgz
3. Copy the extracted MongoDB folder to the/usr/local/mongodb installation directory as a whole
MV mongodb-linux-x86_64-rhel70-3.2.4 MongoDB
MV mongodb/usr/local/
4. Create a logs directory in the MongoDB directory to store the logs
Cd/usr/local/mongodb
mkdir Logs
5. Create db directory in MongoDB directory for data storage
mkdir DB
6. Create the/usr/local/mongodb/mongodb.conf file and write the following:
# idae-mongodb config start-2017-11-10
# Set the data file's storage directory
DBPath =/usr/local/mongodb/db
# Set the log file's storage directory and its log filename C3/>logpath =/usr/local/mongodb/logs/mongodb.log
# Set the port number (the default port number is 27017)
port = 27017
# set to run as daemon, That is, running fork in the background
= True
# Nohttpinterface = True
Nohttpinterface = True
# idae-mongodb config end-2017-11- 10
Parameter explanation:
--dbpath database path (data file)
--logpath log file path
--master specified
as slave machine--source for master machine--slave
Specifies the host machine's IP address
--pologsize Specifies that the log file size does not exceed 64M. Because the resync is very large and time-consuming, it is best to avoid resync by setting a large enough oplogsize (the default The Oplog size is 5% of the free disk size).
add at the end of the--logappend log file, that is, write the log using append
--journal enable log
--port enable port number
--fork run in the background
--only Specifies which database is replicated only
--slavedelay refers to the time interval that is detected from replication
--auth Whether you need to verify permissions to log on (user name and password)
--syncdelay the time that data is written to the hard disk (in seconds), 0 is not waiting, write directly
--notablescan does not allow the table to scan
--maxconns maximum number of concurrent connections, the default is
--pidfilepath Specify the process file, do not specify the process file does not produce
--bind_ip Bind IP, bind only IP Access service after binding
8. Start MongoDB Service
$./bin/mongod--config mongodb.conf about
to fork child process, waiting until server was ready for connections.
Forked process:29627 Child
process started successfully, parent exiting
9. See if Port 27017 is started
$ NETSTAT-LANP | grep 27017
TCP 0 0 0.0.0.0:27017 0.0.0.0:* LISTEN 12804/./bin/mongod
Unix 2 [ACC] STREAM LISTENING 645556 12804/./bin/mongod /tmp/mongodb-27017.sock
10. Add the MongoDB service to the self-boot file
Vi/etc/rc.local
/usr/local/mongodb/bin/mongod--config/usr/local/mongodb/mongodb.conf
11. Test the connection
Download or start studio 3T Create connection
Bash
Server xxx.xx.28.xxx
Port 27017
Authentication Keep Default None
# may not be connected here, still Alibaba Cloud is not open 27017 port, please open your own
Continue the connection test (port open to connect successfully)