Linux system installation NoSQL (MongoDB and Redis) steps and problem solving of summary

  • 2020-05-12 06:38:58
  • OfStack

The following is the record of my work, which introduces the installation process, problems and solutions of NoSQL, MongoDB and Redis under the linux system:

If you need to install MongoDB and Redis, please follow the following steps :)!

1. MongoDB

1. Installation of MongoDB

(1) copy the installation package mongodb-linux-i686-3.0.2. tgz to the server to be installed

Here I use the rz command, if not supported, to install yum-y install lrzsz

(2) unzip installer tar xzvf mongodb-linux-i686-3.0.2. tgz

(3) enter directory: /usr/local/ create folder mkdir mongodb

(3) move files to /usr/local/mongodb directory:


<span style="font-family: "Microsoft YaHei"; font-size: 15px">mv mongodb-linux-i686-3.0.2/* /usr/local/mongodb

Enter /usr/local/mongodb to execute < /span >

(4) mkdir data

(5) touch logs

(6) launch into the bin directory


<span style="font-family: "Microsoft YaHei"; font-size: 15px"> ./mongod --dbpath=/usr/local/mongodb/data/ --fork --logpath=/usr/local/mongodb/logs

Description: --dbpath specifies the storage of mongodb library data

--fork background execution, or 1 direct foreground execution

--logpath specifies the log file for mongodb

Error: -bash:./mongod: /lib/ linux.so.2: bad ELF interpreter: No such file or directory

Solution: sudo yum install glibc.i686

Error reporting:./mongod: error loading shared libraries: libstdc++.so

Solution: yum provides libstdc++.so.6 see which contains so

libstdc++ -4.8.5-4.4.el7.i686, then perform the installation

yum install libstdc++-4.8.5-4. el7.i686

Error: Error: Protected: multilib versions: libstdc++-4.4.7-4.el6.i686! =

libstdc++-4.4.7-3.el6.x86_64

Solution: yum update libstdc++ -4.4.7-11.el6.x86_64 then follow step yum install libstdc++ -4.4.7-4.4.5en6.i686

In the execution started. After the success of the installation/mongod - dbpath = / usr/local/mongodb data / - fork logpath = / usr local/mongodb/logs < /span >

(7) view the mongodb process (either of the following)


<span style="font-family: "Microsoft YaHei"; font-size: 15px"> netstat -tlnup|grep mongod
netstat -tlnup|grep 27017</span>

2. MongoDB startup:

(1) enter /usr/bin

(2) execute the command to connect the client:./mongo

3. Check the startup status:


<span style="font-family: "Microsoft YaHei"; font-size: 15px">netstat -lntup|grep 27017
> show dbs;
db.stats()
use test ; </span>

So far, redis has been installed and tested successfully, so you can use it safely :)

2. Redis

Redis is divided into the server side and the client side. We first install the server side, which is actually compiled with C language. Successful compilation means successful installation, and then launch the client side to connect to the server side for testing.

1. Install the Redis server

(1) download the installation package

In the corresponding directory of the server (/opt), execute the wget command to download:


<span style="font-family: "Microsoft YaHei"; font-size: 15px">wget https://redis.googlecode.com/files/redis-2.6.13.tar.gz

Error: Permission denied

Reason: the current user ec2-user does not have w access to the opt folder

Solution: sudo-i chmod a+x /opt gives the current user access to opt files < /span >

(2) extract the installation package


<span style="font-family: "Microsoft YaHei"; font-size: 15px"> tar xzf redis-2.6.13.tar.gz</span>

(3) compilation


<span style="font-family: "Microsoft YaHei"; font-size: 15px">  Enter the redis-2.6.13 Directory to compile 

1)cd redis-2.6.13

2)make

Error: /bin/sh: cc: command not found

Reason: there is no C language compilation environment

Solution: yum install gcc

Continue with the compile installation

3)make install < /span >

(4) copy redis.conf to etc


<span style="font-family: "Microsoft YaHei"; font-size: 15px"> cp redis.conf /etc/</span>

2. Start Redis

(1) enter src of directory redis: cd /opt/ redis-3.0.0 /src

(2) start server (src directory) :./ redis-server &

Or src/ redis-server in the redis-3.0.0 directory

(3) open the client (src directory) :./ redis-cli &

Or src/ redis-cli in the redis-3.0.0 directory

3. Test the installation of Redis

There are two ways to test whether redis starts successfully, and you can choose either one

(1) detect whether port 6379 is listening


<span style="font-family: "Microsoft YaHei"; font-size: 15px">netstat -lntp | grep 6379</span>

(2) detect the existence of background process


<span style="font-family: "Microsoft YaHei"; font-size: 15px">ps -ef |grep redis</span>

4. Perform the Redis test


<span style="font-family: "Microsoft YaHei"; font-size: 15px"> ./mongod --dbpath=/usr/local/mongodb/data/ --fork --logpath=/usr/local/mongodb/logs
0

So far, Redis has been installed and tested successfully, so you can use it safely :)


Related articles: