In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Go to the Mongodb official website to download the installation package
Mongodb download address: https://www.mongodb.com/download-center
You can download the latest version to install and learn or click All Version Binaries to download the historical version to install. The installation and subsequent quick start of this article uses the 3.4.10 version. I use mongodb-linux-x86_64-rhel70-3.4.10.tgz on this machine, but I can't find the effect of using rehl62 in the historical version. If there are problems in the installation process of using rehl62, please leave a message and exchange messages.
Upload the downloaded mongodb-linux-x86_64-rhel62-3.4.10.tgz to the Linux machine using xsftp or other tools. Mine is uploaded directly to the / root directory of Linux.
Use the command to extract the installation package that has just been uploaded to the Linux machine. The parameter after-C is the pressurized storage path.
Tar-zxvf mongodb-linux-x86_64-rhel70-3.4.10.tgz-C / usr/local/
Cd to the specified path after decompression cd / usr/local
Cd to Mongodb installation root directory / usr/local/mongodb-linux-x86_64-rhel70-3.4.10, this is my installation root directory. I personally enter the installation root directory according to my own installation directory.
Create the Mongodb data storage directory and log storage directory, which will be used in later configuration files
Command: mkdir data logs
Cd to the logs directory you just created cd logs/ to create a log file vim mongodb.log
I use the mongodb.log log file created by the root user, which only has read and write access to the creator. I hope that other users can read and write to the file, and the file needs to be re-authorized.
Command: chmod 777 mongodb.log
Create a mongodb.conf file from cd to the bin directory
Command: vim mongodb.conf
The mongodb.conf configuration file is based on yml format. About yml, please use Baidu to add the following configuration to the configuration file.
Storage:
DbPath: "/ usr/local/apache/mongoDB/mongodb-linux-x86_64-rhel70-3.4.10/data"
SystemLog:
Destination: file
Path: "/ usr/local/apache//mongoDB/mongodb-linux-x86_64-rhel70-3.4.10/logs/mongodb.log"
Net:
Port: 27022
Http:
RESTInterfaceEnabled: true
ProcessManagement:
Fork: false
Using the command vim mongodb.conf, the structure of the file after adding the configuration is as follows. Remember that it is in yml format: there should be a space between and the value.
Cd to cd bin under the bin directory of the root directory
Note that starting mongodb with. / mongod will not start with the configuration file we just created, so use the command. / mongod-f mongodb.conf will use our configuration file to start similar to redis startup. You need to specify a configuration file at startup.
It is troublesome to start each time using the specified configuration file, so create a shell script in bin to start
Vim start-mongodb.sh adds the following to the shell script: nohup. / mongod-f mongodb.conf & you can use the command to weight the shell script to chmod 777 vim start-mongodb.sh
Start mongodb. / start-mongodb.sh using the shell script
Use the command to check whether the process starts ps-ef | grep mongodb. The following shows that mongodb has started normally.
Use the command line client to verify that mongodb starts properly. / mongo localhost:27022 specifies IP and port connection mongodb
Basic commands:
View the database: show dbs
View the collection: show collections
Mongodb does not need to create libraries and tables to automatically switch to the db_ name library using use db_name, but db_name libraries are not created at this time, libraries and collections (tables) are created the first time the data is inserted
Mongodb automatically creates collections and libraries by specifying the name of the collection (table) when inserting data
Command: use db_name db.user.insert ({"name": "zhangsan", "addr": "guangdong"})
After performing the data insertion operation, it will be found that the library and collection have been created.
Data query: db.table_name.find ()
Command line verifies that mongodb is complete and that restAPI is available
First of all, you need to turn off the firewall related commands of Linux.
Centos7:
Systemctl status firewalld.service// View Firewall status
Systemctl stop firewalld.service//, turn off the firewall
Disable the boot self-startup firewall in systemctl disable firewalld.service//
The following versions of centos7: can be set by referring to this website
Web site: https://www.cnblogs.com/eaglezb/p/6073739.html
Enter ip: port on the browser side to access it. Note that the port of restAPI is the service port + 1000 configured in the configuration file. The service port of mongodb in my profile is 27022.
I have little talent and learning, and there are many flaws and mistakes in the documents. I hope that Haihan will be criticized and corrected.
Empty without thinking is labor lost; thinking without learning is perilous.
The industry is good at diligence but wasted in play, and the action is done in thought and destroyed in following.
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.