Install MongoDB 6.0 on CentOS

1. Installation dependencies

yum install libcurl openssl xz-libs

2. Download the installation package

The installation package download address https://www.mongodb.com/try/download/community Here I choose

The reason for choosing the RedHat/CentOS 7.0 platform is that my operating system uses CentOS 7.0, and I need to download the installation package that matches the operating system

3. Unzip and install

My compressed package is placed in the /opt directory

tar -zxvf mongodb-linux-x86_64-rhel70-6.0.6.tgz

There are two ways to add binary files to environment variables:

1. Copy the binary file to the /usr/local/bin directory

cp /opt/mongodb-linux-x86_64-rhel70-6.0.6/bin/* /usr/local/bin/

2. Create a soft link pointing to the binary file in the /usr/local/bin directory

ln -s  /opt/mongodb-linux-x86_64-rhel70-6.0.6/bin/* /usr/local/bin/

The effect of establishing a soft link is as follows:

4. Install MongoDB Shell

Installation package download address https://www.mongodb.com/try/download/shell

Here I choose

After the download is complete, unzip it:

tar -zxvf mongosh-1.8.2-linux-x64.tgz

There are two ways to add binary files to environment variables:

1. Copy the binary file to the /usr/local/bin directory

cp /opt/mongosh-1.8.2-linux-x64/bin/mongosh /usr/local/bin/
cp /opt/mongosh-1.8.2-linux-x64/bin/mongosh_crypt_v1.so /usr/local/lib/

2. Create a soft link pointing to the binary file in the /usr/local/bin directory

ln -s /opt/mongosh-1.8.2-linux-x64/bin/* /usr/local/bin/

5. Run MongoDB

1. Create the data storage path and log path of MongoDB

mkdir -p /var/lib/mongo
mkdir -p /var/log/mongodb

2. Start MongoDB

mongod --dbpath /var/lib/mongo --logpath /var/log/mongodb/mongod.log --fork

--dbpath specifies the data storage path

--logpath specifies the log file path

--fork refers to running the Mongo process in the background


3. Connect to MongoDB

mongosh

6. Reasons for installation failure

An error is reported at startup: Illegal instruction, there may be the following reasons:

1. The gcc version is too low, you need to upgrade the gcc version, you can refer to:

Linux upgrade gcc to the latest version gcc-11.2.0 https://blog.csdn.net/qq_41054313/article/details/119453611

2. MongoDB 5.0 and later versions need to use the AVX instruction set, you need to check whether the CPU supports the AVX instruction set

cat /proc/cpuinfo | grep avx

reference blog

Linux upgrade gcc to the latest version gcc-11.2.0

Guess you like

Origin blog.csdn.net/m1729339749/article/details/130704789