Linux environment install redis5.0.5 detailed tutorial complete steps

1. Download the installation package

访问 http://www.redis.cn/ 中文官网进行下载。这里下载最新的5.0.5版本

Insert picture description here

2. Transfer files and decompress files

  1. Use the remote management tool to copy the compressed package to the Linux server and perform the decompression operation
tar -zxvf redis-5.0.5.tar.gz

Insert picture description here
2. Move to the /usr/local/next
Insert picture description here
4. Install GCC dependencies

yum -y install gcc automake autoconf libtool make

If the redis version is high, remember to update the gcc version and use the high version of gcc
5. Enter the redis-5.0.5directory and execute make

make MALLOC=libc
  1. To facilitate management, install and add /usr/local/redis/srcfiles in the /usr/local/redisdirectory to the directory
cd src && make install PREFIX=/usr/local/redis

Insert picture description here

  • Effect after completionInsert picture description here
The installation is complete!

Three, deployment start method

  1. Create a new etc folder in the redis folder and move the configuration file to the etc folder
mkdir etc
mv /usr/local/redis-5.0.5/redis.conf /usr/local/redis/etc

Insert picture description here
2. Configure redis to start in the background

vim /usr/local/redis/etc/redis.conf      //将daemonize no 改成daemonize yes

Insert picture description here
Insert picture description here
3. Add redis to boot

vim /etc/rc.local        //在里面添加内容

Insert picture description here
Insert picture description here
4. Start redis

/usr/local/redis/bin/redis-server /usr/local/redis/etc/redis.conf

Insert picture description here
Insert picture description here

Four, remote connection configuration

  1. We perform related configurations in the configuration file redis.conf
vim /usr/local/redis/etc/redis.conf
  1. Use the shortcut key "70gg" to quickly jump to line 70, and change the comment
    Insert picture description here
  2. Change protected-mode yes to no in line 90
    Insert picture description here
  3. Set the password. Uncomment line 507 and change the password
    Insert picture description here
  4. Save and restart redis
#先查询进程,杀死进程,然后启动
ps -ef|grep redis

Insert picture description here
Insert picture description here

Configuration is complete!!!

Common problems and solutions

  Redis is started in the background of the server. After a period of time, the remote connection cannot be successful, and redis needs to be restarted to start

  1. The connection may report an error
    MISCONF Redis is configured to save RDB snapshots, but is currently not able to persist on disk. Commands that may modify the data set are disabled. Please check Redis logs for details about the error.
    
  2. The cause of the problem: The
    server used to forcibly shut down redis, which caused it to fail to persist, so the connection could not be made.

solution

Log in to the server, open it redis-cli, and enter the following command to force it to close and report an error:

config set stop-writes-on-bgsave-error no

After the input is completed, in the remote connection, you will find that you can successfully connect!

Guess you like

Origin blog.csdn.net/qq_41435602/article/details/104890631