Install the latest version of redis-6.2.6

System: CentOS Linux release 7.9.2009 (Core)

1. Installation of GCC

Since redis is developed in C language, you must first confirm whether to install gcc environment (gcc -v) before installation. If not, execute the following command to install

  course: https://www.cnblogs.com/huangshuqiang/p/15477407.html

2. Download and unzip the installation package

[root@mesnosql ~]# wget http://download.redis.io/releases/redis-6.2.6.tar.gz

[root@mesnosql ~]# tar -zxvf redis-6.2.6.tar.gz

3. Switch CD to redis decompression directory and execute compilation

[root@mesnosql ~]# cd redis-6.2.6

[root@mesnosql redis-6.2.6]# make

4. Install and specify the installation directory

[root@mesnosql  redis-6.2.6]# make install PREFIX=/usr/local/redis

5. Start service - background start

[root@mesnosql redis-6.2.6]# cd /usr/local/redis/bin/

Copy redis.conf from the redis source directory to the redis installation directory. PS: push to ~ directory.

[root@mesnosql ~]# cp redis-6.2.6/redis.conf /usr/local/redis/bin/

6. Modify the redis.conf configuration file. PS: re enter bin

[root@mesnosql bin]# vim redis.conf

  There are three main modifications:

  1).  Add # comments before bind   ; Unlimited ip access. By default, it can only be accessed locally

  2). 

          The default is yes and changed to no. Turn off the protected mode mode, and the external network can access it directly

  3).    

            Daemon is used to specify whether redis should be started as a daemon thread. The default is no

7. Start redis  

[root@mesnosql bin]# ./redis-server redis.conf

8. Set startup

root@mesnosql bin]# vi /etc/systemd/system/redis.service 

Copy and paste the following:

[Unit]
Description=redis-server
After=network.target

[Service]
Type=forking
ExecStart=/usr/local/redis/bin/redis-server /usr/local/redis/bin/redis.conf
PrivateTmp=true

[Install]
WantedBy=multi-user.target

Note: ExecStart is configured as its own path  

9. Set startup

[root@mesnosql bin]# systemctl daemon-reload

[root@mesnosql bin]# systemctl start redis.service

[root@mesnosql bin]# systemctl enable redis.service

10. Create redis command soft link

[root@mesnosql ~]# ln -s /usr/local/redis/bin/redis-cli /usr/bin/redis

Test redis

 

 

 

  At this point, redis installation is complete.

Service operation command

systemctl start redis.service    # Start redis service

systemctl stop redis.service    # Stop redis service

systemctl restart redis.service    # Restart the service

systemctl status redis.service    # View the current status of the service

systemctl enable redis.service    # Set startup and self startup

systemctl disable redis.service    # Stop startup and self startup.

Supplement 1: redis make reports an error after upgrading GCC to the latest version. Solution:

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

solve:

1. Go back to the root directory (~)

sudo yum -y install gcc gcc-c++ libstdc++-devel              
2. When returning to the redis make directory, execute:

    make MALLOC=libc

Supplement 2: when the firewall is turned on, the external network cannot be accessed

View open ports

firewall-cmd --list-ports

View firewall status

firewall-cmd --state

Turn on the firewall

systemctl start firewalld

Open port

firewall-cmd --zone=public --add-port=6379/tcp --permanent

service iptables restart

firewall-cmd --reload

After opening the port, you must restart the firewall, otherwise opening the port will not work.

 

Conclusion: I have never been in contact with linux before. When installing redis, I encountered many problems. It took several days to install it successfully. Most of the installation tutorials on the Internet are not good.

          Finally, at each installation step, although there are sometimes a large series of commands, you must pay attention to whether there is an error in it, otherwise in the end, redis will be confused if it can't be used.

reference resources:

https://www.cnblogs.com/heqiuyong/p/10463334.html

https://redis.io/download   Official course

https://www.cnblogs.com/Crazy-Liu/p/14313017.html

https://blog.csdn.net/liyanhui1001/article/details/106589682

https://www.cnblogs.com/xuliangxing/p/7151685.html



 

Keywords: Redis

Added by mburkwit on Thu, 28 Oct 2021 15:21:06 +0300