Summary of Mongodb parameter specification and common error handling
- 2020-06-23 02:12:47
- OfStack
This article is mainly about the Mongodb parameter description and common error handling related content, Shared for your reference and learning, the following is a detailed introduction:
1. Install MongoDB on CentOS7
1 Connect to CentOS7 server via SecureCRT;
2 Enter /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 es29EN-ES30en-x86_64-rhel70-3.2.4.tgz file matching CentOS system:
wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-3.2.4.tgz
6 unzip mongodb-ES39en-x86_64-rhel70-3.2.4.tgz file:
tar -zxvf mongodb-linux-x86_64-rhel70-3.2.4.tgz
After decompression, mongodb-ES48en-x86_64-rhel70-3.2.4 folder and its files;
7. Rename mongodb-ES54en-x86_64-rhel70-3.2.4 to mongodb3.2.4:
mv mongodb-linux-x86_64-rhel70-3.2.4 mongodb3.2.4
8 Returns to the previous level 1 directory and creates the mongodb directory:
cd ../
mkdir -p mongodb
9. Move the mongodb3.2.4 file from /usr/local/tools to /usr/local/mongodb:
mv tools/mongodb3.2.4/ mongodb/
10 to enter/usr local mongodb/mongodb3. 2.4 directory:
cd mongodb/mongodb3.2.4
11 in/usr local/mongodb/mongodb3. 2.4 / bin deposit/directory to create a log directory:
mkdir -p data/test/logs
12 in/usr/local/mongodb/mongodb3. 2.4 / bin/directory to create a directory where the data files:
mkdir -p tools
0
13 Enter the bin directory:
cd bin/
14. Create configuration file ES109en. conf:
vi mongodb.conf
In ES115en.conf, write the following:
mkdir -p tools
3
Press "wq" in English state to save and exit;
Parameter interpretation:
15 Start mongodb Service:
15.1 Start as a custom mongodb profile:
mkdir -p tools
4
15.2 Start mongodb in repair mode:
mkdir -p tools
5
15.3 Start with parameter:
mkdir -p tools
6
If the following error is reported:
ERROR: child process failed, exited with error number 1
It is likely that the path configured in ES176en. conf is not 1.
If the following error is reported:
ERROR: child process failed, exited with error number 100
It is likely that there was no normal closure, so you can delete the ES185en.lock file
15 View the mongodb process:
mkdir -p tools
9
16 View the running log of mongodb service:
tail -200f /usr/local/mongodb/mongodb3.2.4/bin/data/test/logs/mongodb.log
17 Check whether the port has been started:
netstat -lanp | grep 27017
18 Kill the mongodb process to close the mongodb service:
kill -15 PID
PID can be viewed in Step 16
19 If the following occurs
warning: Failed to connect to 127.0.0.1:27017, reason: errno:111 Connection refused
It can be solved in the following two ways:
19.1 If the database cannot be connected as mentioned above, it may be the file problem of ES220en. lock in data directory, you can use the following command to fix it:
./bin/mongod --repair
19.2 Or 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 still not solve, is the path to the file, we can delete/usr/local mongodb/mongodb3. 2.4 / bin data directory and its subdirectories, together with the method of absolute path:
./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 the mongodb service to the bootstrap file:
vi /etc/rc.local
Append 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 Common commands of the client:
db.version(); # To view mongodb The version of the
use test; # Go into the specified data, here is test The database
22 in/usr local/mongodb/mongodb3. 2.4 / bin/directory, type the following command, open a mongodb client program, or open a mongodb shell client, this shell client is also a JavaScript editor, you can enter any JavaScript scripts:
./mongo
The default connection is to the test database
23 Enter IP:27017 in the browser, for example:
http://101.201.212.129:27017/
You can view the version information of MongoDB.
conclusion