In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces you how to install MongoDB in Centos. The content is very detailed. Interested friends can refer to it for reference. I hope it can help you.
installation
A yum installation
installation steps
1. Configure yum
Create the file/etc/yum.repos.d/mongodb-org-4.0.repo for yum to install MongoDB
Document Details
[mongodb-org-4.0]name=MongoDB Repositorybaseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/4.0/x86_64/gpgcheck=1enabled=1gpgkey=https://www.mongodb.org/static/pgp/server-4.0.asc
2. Install MongoDB
Install the latest version of MongoDB using the command
sudo yum install -y mongodb-org
If you want to specify a version of MongoDB to install, you need to specify the version separately for each part after the package name, as shown in the following example
sudo yum install -y mongodb-org-4.0.9 mongodb-org-server-4.0.9 mongodb-org-shell-4.0.9 mongodb-org-mongos-4.0.9 mongodb-org-tools-4.0.9
2. Use compressed package to install
prerequisite
MongoDB.tar.gz archive must be installed to use dependencies
yum install libcurl openssl
step
1. Download the compressed package in MongoDB.tar.gz format
MongoDB Download Center.
2. Extract the downloaded compressed package file
tar -zxvf mongodb-linux-*-4.0.9.tgz
3. Add environment variables to ensure that executable files are listed in the directory
MongoDB executable files are in the bin/zip directory. You can follow these suggestions
Copy these executables into your environment variables directory, such as/usr/local/bin
Create links for these executable files from directories in your environment variables or modify your environment variables to include this directory
For example, you can add an initialization script (e.g. ~/.bashrc) to your shell
export PATH=/bin:$PATH
Replace with your actual MongoDB installation path
use
Many Uni-like operating systems restrict the use of system resources like sessions. These limitations may affect MongoDB operations. See more UNIX ulimit Settings
directory path
Common default path
Usually MongoDB uses these default directories via mongod user accounts and
/var/lib/mongo (data)/var/log/mongodb (log)
If you install through package
default directory will be created and the owner of this directory will be set to mongod
If you download it via zip
Default directories need to be created manually
Tip: Depending on your user privileges, you may need to use super privileges to perform these actions
mkdir -p /var/lib/mongomkdir -p /var/log/mongodb
By default MongoDB runs using the mongod user account. Once created, set the owner and organization of these directories to mongod
chown -R mongod:mongod
Instead of using the default directory, create the directory you want to use and modify the configuration file/etc/mongod.conf
storage.dbPath to specify a new data directory path (e.g. /some/data/directory)systemLog.path to specify a new log file path (e.g. /some/log/directory/mongod.log)
Confirm that running MongoDB has access to these directories
chown -R mongod:mongod
initiation step
1. Open MongoDB
Start MongoDB with the command
sudo service mongod start
Check if MongoDB has been successfully started
The requested URL/var/log/mongodb/mongod.log was not found on this server.
[initandlisten] waiting for connections on port
port Default configuration 27017, configuration location/etc/mongod.conf
You can confirm that MongoDB will track the reboot system by tracking commands
sudo chkconfig mongod on
Stop MongoDB
sudo service mongod stop
Restart MongoDB
sudo service mongod restart
Start using MongoDB
Open a mongo shell on the same host. You can run the mongo shell without any command-line options to connect to your local instance of mongod with default port 27017.
5. Uninstall MongoDB
Unloading will erase data. Please confirm before unloading.
1) Stop MongoDB
sudo service mongod stop
(2) Remove the package
sudo yum erase $(rpm -qa | grep mongodb-org)
(3) Remove the data directory
sudo rm -r /var/log/mongodbsudo rm -r /var/lib/mongo About how to install MongoDB in Centos is shared here. I hope the above content can be of some help to everyone and learn more. If you think the article is good, you can share it so that more people can see it.
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.