A complete tutorial on Linux system installation and deployment of Redis (detailed explanation with pictures and texts)

Foreword: Recently, I need to install and deploy Redis on a Linux server. I refer to many articles on the Internet, which are relatively fragmented, so I wrote a complete Redis installation and deployment document myself. Before deploying Redis, I reinstalled my Huawei server. Everyone explained my operation process step by step. Every line of code has been strictly tested, and the explanation with pictures and texts is more easy to understand!

Blogger's other deployment tutorials:

1. Jenkins deploys front-end and back-end separation projects: The most complete graphic tutorial for Jenkins deployment front-end and back-end separation projects (hands-on teaching)

2. Docker deploys front-end and back-end separation projects: deploy front-end and back-end separation projects through Docker (pro-test available)

3. Linux system deployment Tomcat: Linux system deployment Tomcat detailed tutorial (graphic explanation)

4. Deploy Nginx in Linux system: Detailed tutorial on deploying Nginx in Linux system (graphic explanation)

5. Linux system configuration Maven: Linux system configuration Maven environment detailed tutorial (graphic explanation)

6. Linux system configuration Node.js: Linux system configuration Node.js environment detailed tutorial (graphic explanation)

7. Linux system installation and deployment of MySQL: A complete tutorial on Linux system installation and deployment of MySQL (detailed explanation with pictures and texts)

8. Linux system installation and deployment of MongoDB: A complete tutorial on Linux system installation and deployment of MongoDB (detailed explanation with pictures and texts)

9. Linux system installation and deployment of Jenkins: Linux system installation and deployment of Jenkins detailed tutorial (graphic explanation)

10. Pagoda panel deployment front-end separation project: Hands-on teaching using the pagoda panel deployment front-end separation project (full details)

Table of contents

1. Prepare the Redis installation package

Two, install tcl

3. Install Redis

Fourth, configure Redis

5. Start Redis

Sixth, set the boot to start automatically

7. Release port number

8. Use Navicat to connect to Redis

Nine. Summary


1. Prepare the Redis installation package

Official website address: Download | Redis

Click Download directly to download

Two, install tcl

When testing Redis, the following error was reported. The error message is that you need tcl8.5 or higher to run Redis. I stepped on the pit here, so you need to install tcl first.

make[1]: Entering directory `/usr/local/redis/src'
    CC Makefile.dep
make[1]: Leaving directory `/usr/local/redis/src'
make[1]: Entering directory `/usr/local/redis/src'
You need tcl 8.5 or newer in order to run the Redis test
make[1]: *** [test] Error 1
make[1]: Leaving directory `/usr/local/redis/src'
make: *** [test] Error 

1. Enter the /root directory

/root

2. Use the wget command to download the compressed package

wget http://downloads.sourceforge.net/tcl/tcl8.6.12-src.tar.gz

This download is very slow, the blogger has already downloaded it for everyone, just get it directly

Link: https://pan.baidu.com/s/1LWQHvKOYC3GSUpkiTCPnMg?pwd=2syo

3. Unzip the source code package tcl8.6.12-src.tar.gz to the /usr/local directory

sudo tar xzvf tcl8.6.12-src.tar.gz  -C /usr/local/  

4. Go to the specified unix directory

cd  /usr/local/tcl8.6.12/unix/

5. Run the configure script in the current directory

sudo ./configure

6. Compile the source code

sudo make

7. Installation

sudo make install

3. Install Redis

After the above tcl installation is complete, I deleted the tcl compressed package, so it looks cleaner.

1. Upload the downloaded .tar.gz file to the server (Xftp), and I put the file under /root

2. Unzip

tar -zvxf redis-7.0.12.tar.gz

  

3. Move the redis installation directory named redis-7.0.12 to a more standard directory /usr/local, and rename the directory name to simple redis

mv /root/redis-7.0.12 /usr/local/redis

4. Enter the redis directory

cd /usr/local/redis

5. Enter the command make to execute the compilation command

make

7, make test test

make test

The process will be relatively long, and the final result is as follows

everything is normal! 

6. Specify the PREFIX installation directory as /usr/local/redis, if you do not add this keyword, Linux will store the executable file in the /usr/local/bin directory

make PREFIX=/usr/local/redis install

Fourth, configure Redis

1. Set soft connection

ln -s /usr/local/redis/redis.conf /etc/redis.conf

2. Editing

vi /etc/redis.conf

3. Press / on the keyboard to enter the search mode, search for the keyword daemonize no , press the i key to enter the edit mode, change no to yes, and set it to start redis in the background

4. Find the keyword protected-mode and change yes to no

5. Look up bind 127.0.0.1 , change from bind 127.0.0.1 to bind 0.0.0.0

6. Press Esc to exit the editing mode, press :wq to save and exit the vim editor

7. Steps 5 and 6 are mainly for connecting with Navicat 16 for Redis software below

5. Start Redis

1. Go to the bin directory of Redis

cd /usr/local/redis/bin

2. Start the Redis service

./redis-server /etc/redis.conf

3. Check whether Redis starts successfully

lsof -i:6379

4. Connect to the local Redis

./redis-cli -h 127.0.0.1 -p 6379

everything is normal!

5. Close the Redis service

./redis-cli shutdown

Sixth, set the boot to start automatically

1. Enter the etc directory

cd /etc

2. Create a new redis directory

mkdir redis

3. Copy the redis configuration file and name it 6379.conf

cp /usr/local/redis/redis.conf /etc/redis/6379.conf

4. Copy the redis startup script and put it in the /etc/init.d directory

cp /usr/local/redis/utils/redis_init_script /etc/init.d/redis

5. Edit the copied redis file

vi /etc/init.d/redis

Change it to your own installation directory, otherwise the startup will fail!

6. Enter the directory where Linux stores self-starting scripts

cd /etc/init.d

7. Set executable permissions

chmod 777 /etc/init.d/redis

8. Set to boot automatically

chkconfig redis on

9. View service list

chkconfig --list

Level 2-5 is displayed as on, which means that it will start automatically after booting  

10. Start the Redis service

service redis start

11. Stop the Redis service

service redis stop

7. Release port number

I purchased a HUAWEI CLOUD server, port number 6379 must be allowed in the security group, otherwise the external connection will not be possible

8. Use Navicat to connect to Redis

Enter the host ip and port number to connect

You're done!

Nine. Summary

The above is a complete tutorial on how to install and deploy Redis using Linux. If you have any questions, welcome to discuss in the comment area! 

Guess you like

Origin blog.csdn.net/HJW_233/article/details/131866231