In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
1. Download the installation package
Download the installation file for mongoDB
Address: https://www.mongodb.org/downloads#production
Select the Linux 64-bit legacy version and download it to the target server.
Extract the file
Tar-zxvf mongodb-linux-x86_64-3.0.2.tgz
Mv mongodb-linux-x86_64-3.0.2 / workspace/app/mongodb
Enter the extracted directory and set all the files in the bin folder to executable permissions
Chmod-R 755 bin
2, create the data file path
Here, I want to put the data files and log files in the data directory and create the data directory anywhere
Mkdir data
Go to data and create a data file directory
Mkdir db
Assign writeable permissions to the data directory
Chmod-R 755 data
3, write the configuration file
To make it easier for us to start mongoDB, write a configuration file first
I put the configuration file directly into the bin directory here.
Vi mongodb.conf
The contents are as follows:
Port=27017
Dbpath=/workspace/data/mongodb/db
Logappend=true
Fork=true
Logpath=/workspace/log/mongodb/logs
Note that when you turn on the daemon mode fork, be sure to set the log log
When setting up log logs, it is important to note that the path to logpath must be a file path, not a folder path.
4, test start
Enter the bin directory and enter the command
. / mongod-f. / mongodb.conf
At this time, it will show that the database started successfully.
Test it locally on the server and use the command
. / mongo 127.0.0.1
MongoDB shell version: 2.6.4
Connecting to: 127.0.0.1/test
This indicates that the database started successfully
Use tool connections to test other machines in the local area network.
Some partners may find that they cannot connect, usually because the port of the firewall is not open.
Use the command to open the port
Open the port
Firewall-cmd-zone=public-add-port=27017/tcp-permanent
View Port
Firewall-cmd-permanent-query-port=27017/tcp
Restart the firewall
Firewall-cmd-reload
Note:
A, add-- permanent to ensure that it can be opened after reboot.
B, it's better to restart the firewall here. Sometimes opening the port doesn't take effect immediately. I don't know why.
Well, now other machines in the local area network can also connect to the database.
5, register to boot the system
The startup of centos 7 is very different from previous versions of centos. Now replace the previous chkconfig and service commands with the systemctl command
The method to register to boot is as follows:
Create a new startup service for mongodb under the system service directory, and give 754 permissions
Cd / lib/systemd/system
Vi mongodb.service
Chmod 754 mongodb.service
The contents are as follows
[Unit]
Description=mongodb
After=network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
ExecStart=/workspace/app/mongodb/bin/mongod-f / workspace/app/mongodb/bin/mongodb.conf
ExecReload=/bin/kill-s HUP $MAINPID
ExecStop=/workspace/app/mongodb/bin/mongod-- shutdown-f / workspace/app/mongodb/bin/mongodb.conf
PrivateTmp=true
[Install]
WantedBy=multi-user.target
The path must write the absolute path.
Start
Systemctl start mongodb.service
Close
Systemctl stop mongodb.service
Register to boot
Systemctl enable mongodb.service
6. Restart the machine to verify
Reboot
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.