In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article will explain in detail about Mongodb parameter description and common error handling example analysis, Xiaobian thinks it is quite practical, so share it with you as a reference, I hope you can gain something after reading this article.
Examples:
Install MongoDB on CentOS 7
1 Connect to CentOS7 server via SecureCRT;
2 Go to/usr/local/directory:
cd /usr/local
3 Create the tools directory under the current directory:
mkdir -p tools
4 Enter the Tools directory:
cd tools
5 Download the mongodb-linux-x86_64-rhel70-3.2.4.tgz file for CentOS:
wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-3.2.4.tgz
Unzip mongodb-linux-x86_64-rhel70-3.2.4.tgz file:
tar -zxvf mongodb-linux-x86_64-rhel70-3.2.4.tgz
After decompression, the mongodb-linux-x86_64-rhel70 -3.2.4 folder and its files are obtained;
7 Rename mongodb-linux-x86_64-rhel70-3.2.4 file to mongodb3.2.4:
mv mongodb-linux-x86_64-rhel70-3.2.4 mongodb3.2.4
8 Go back one level up and create the mongodb directory:
cd ../ mkdir -p mongodb
9 Move the mongodb3.2.4 file from the/usr/local/tools directory to the/usr/local/mongodb directory:
mv tools/mongodb3.2.4/ mongodb/
10 Go to/usr/local/mongodb/mongodb3.2.4 directory:
cd mongodb/mongodb3.2.4
11 Create a log directory in/usr/local/mongodb/mongodb3.2.4/bin/:
mkdir -p data/test/logs
12 Create a directory for data files in/usr/local/mongodb/mongodb3.2.4/bin/directory:
mkdir -p data/test/db
13 Enter bin directory:
cd bin/
14 Create the configuration file mongodb.conf:
vi mongodb.conf
Write the following in mongodb.conf:
# idae - MongoDB config start - 2016-05-02#Set directory where data files are stored dbpath = /usr/local/mongodb/mongodb3.2.4/bin/data/test/db#Set directory where log files are stored and log file names logpath = /usr/local/mongodb/mongodb3.2.4/bin/data/test/logs/mongodb.log#Set port number port = 27017#Set to run as a daemon, i.e. in the background fork = true# nohttpinterface = truenohttpinterface = true#ids- MongoDB config end - 2016-05-02
press ":wq" in english to save and exit;
Parameter explanation:
--dbpath database path (data file)
--logpath Log file path
--master designated as master
--slave specified as slave machine
--source Specifies the IP address of the host
--pologSize specifies that the log file size does not exceed 64M. Because resync is very laborious and time-consuming, it is best to avoid resync by setting a sufficiently large oplog Size (the default oplog size is 5% of the free disk size).
--logappend Add at the end of the log file, i.e. write the log by appending
--journal Enable logging
--port Enable port number
--fork runs in the background
--only Specifies which database to copy only
--slavedelay refers to the time interval from replication detection
--auth Does authentication permission need to be logged in (username and password)
--syncdelay Time to write data to hard disk (seconds), 0 is no wait, write directly
--notablescan does not allow table scanning
--maxConns Maximum number of concurrent connections, default 2000
--pidfilepath specifies the process file, otherwise no process file is generated
--bind_ip Binds IP, after binding, only bound IP can access service
15 Start mongodb service:
15.1 Start with a custom mongodb profile:
./ mongod --config mongodb.conf
15.2 Start mongodb in repair mode:
./ mongod --repair -f mongodb.conf
15.3 Start parametrically:
./ mongod /usr/local/mongodb/mongodb3.2.4/bin/mongod --dbpath=/usr/local/mongodb/mongodb3.2.4/bin/data/test/db --logpath=/usr/local/mongodb/mongodb3.2.4/bin/data/test/logs/mongodb.log --fork
If the following error is reported:
ERROR: child process failed, exited with error number 1
It is likely that the path configured in mongodb.conf is inconsistent;
If the following error is reported:
ERROR: child process failed, exited with error number 100
It is likely that there is no normal shutdown, so you can delete the mongod.lock file.
15 View mongodb progress:
ps aux |grep mongodb
16 View the Mongodb service runtime log:
tail -200f /usr/local/mongodb/mongodb3.2.4/bin/data/test/logs/mongodb.log
17 Check whether the port is enabled:
netstat -lanp | grep 27017
18 Kill the mongodb process to shut down the mongodb service:
kill -15 PID
PID can be viewed via step 16
19 if the following occurs
warning: Failed to connect to 127.0.0.1:27017, reason: errno:111 Connection refused
This can be done in two ways:
19.1 If the database cannot be connected as above, it may be a problem with the mongod.lock file under the data directory, which can be repaired by using the following command:
./ bin/mongod --repair
19.2 Or simply delete mongod.lock
rm -f /usr/local/mongodb/data/db/mongod.lock
Then start the mongodb service:
./ mongod --config mongodb.conf
If the above two parts still cannot be solved, it is the path file. We can delete the/usr/local/mongodb/mongodb3.2.4/bin/data directory and its subdirectories, and use the absolute path method:
./ mongod /usr/local/mongodb/mongodb3.2.4/bin/mongod --dbpath=/usr/local/mongodb/mongodb3.2.4/bin/data/test/db --logpath=/usr/local/mongodb/mongodb3.2.4/bin/data/test/logs/mongodb.log --fork
20 Add mongodb services to the startup file:
vi /etc/rc.local
Add the following command to the end of the file:
/usr/local/mongodb/mongodb3.2.4/bin/mongod --config mongodb.conf
Save and Exit:
:wq!
21 Client Common Commands:
db.version(); #Check 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 type any JavaScript script:
./ mongo
Default connection to test database
23 Enter IP:27017 in your browser, for example:
http://101.201.212.129:27017/
You can view MongoDB version information;
About "Mongodb parameter description and common error handling example analysis" This article is shared here, I hope the above content can be of some help to everyone, so that you can learn more knowledge, if you think the article is good, please share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.