Linux system installation NoSQL (mongodb and redis) steps and Solutions

Time:2020-12-5

The original text is from listening to cloud technology blog:http://blog.tingyun.com/web/a…

The problems encountered in the installation of noredis and mongodb are as follows:

You can install mongodb and redis quickly according to the following steps. I hope you can help:)!

1、 Mongodb

1. Mongodb installation

(1) Copy the installation package mongodb-linux-i686-3.0.2.tgz to the server you want to install

Here I use the RZ command. If it does not support it, you need to install Yum – y install lrzsz

(2) Unzip the installation program tar xzvf mongodb-linux-i686-3.0.2.tgz

(3) Enter the directory / usr / local / create the folder MKDIR mongodb

(3) Move the file to the / usr / local / mongodb Directory:

MV mongodb-linux-i686-3.0.2 / * / usr / local / mongodb entry / usr / local / mongodb execution

(4)mkdir data

(5)touch logs

(6) Enter bin directory to execute startup

./mongod --dbpath=/usr/local/mongodb/data/ --fork --logpath=/usr/local/mongodb/logs
   Description: - dbpath specifies to store mongodb database data
        --Fork is executed in the background, otherwise it is always executed in the foreground
--Logpath specifies the logging file for mongodb
    Error: - bash:. / mongod: / lib / LD- linux.so .2: bad ELF interpreter: No such file or directory
Solution: sudo Yum install glibc.i686
Error:. / mongod: error while loading shared libraries: libstdc + +. So. 6: cannot open shared object file: no such file or directory
Solution: Yum provides libstdc + +. So. 6 to see which contains so. 6
Libstdc + + - 4.8.5-4.el7.i686, and then perform the installation
    Yum install libstdc + + - 4.8.5-4.el7.i686 to perform the installation
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_ Then execute step Yum install libstdc + + - 4.4.7-4.el6.i686
    After the installation is successful, execute startup. / mongod -- dbpath = / usr / local / mongodb / data / -- fork -- logpath = / usr / local / mongodb / logs

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

 netstat -tlnup|grep mongod
netstat -tlnup|grep 27017

2. Mongodb start:

(1) Enter / usr / bin

(2) Execute command to connect client:. / Mongo

3. To view the startup status:

netstat -lntup|grep 27017
> show dbs;
db.stats()
use test;

So far, redis has been installed and tested successfully. You can use it with confidence:)

2、 Redis

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

1. Install redis server

(1) Download installation package

Execute the WGet command in the corresponding directory of the server (/ opt) to download:

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 permission on opt
Solution: sudo - I Chmod a + X / opt enables the current user to execute the opt file

(2) Unzip the installation package

 tar xzf redis-2.6.13.tar.gz

(3) Compiling

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 compiling environment
Solution: Yum install GCC
Continue with build install
3)make install

(4) Copy redis.conf Go to the etc folder

  cp redis.conf /etc/

2. Start redis

(1) Enter the Src in the directory redis: CD / opt / redis-3.0.0/src

(2) Start the server (SRC directory):. / redis server&

Or run Src / redis server in the redis-3.0.0 directory

(3) Open the client (SRC directory):. / redis cli&

Or execute Src / redis cli in the redis-3.0.0 directory

3. Test redis installation

There are two ways to test whether redis is started successfully. Choose either method

(1) Check whether port 6379 is listening

netstat -lntp | grep 6379

(2) Detect whether the background process exists

ps -ef |grep redis

4. Execute redis test

127.0.0.1:6379> set name yhb
OK
127.0.0.1:6379> get name
"yhb"
127.0.0.1:6379>

So far, redis has been installed and tested successfully. You can use it with confidence:)

Recommended Today

PHP 12th week function learning record

sha1() effect sha1()Function to evaluate the value of a stringSHA-1Hash. usage sha1(string,raw) case <?php $str = “Hello”; echo sha1($str); ?> result f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0 sha1_file() effect sha1_file()Function calculation fileSHA-1Hash. usage sha1_file(file,raw) case <?php $filename = “test.txt”; $sha1file = sha1_file($filename); echo $sha1file; ?> result aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d similar_text() effect similar_text()Function to calculate the similarity between two strings. usage similar_text(string1,string2,percent) case […]