1. Download the installation package
访问 http://www.redis.cn/ 中文官网进行下载。这里下载最新的5.0.5版本
2. Transfer files and decompress files
- 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
2. Move to the /usr/local/
next
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.5
directory and execute make
make MALLOC=libc
- To facilitate management, install and add
/usr/local/redis/src
files in the/usr/local/redis
directory to the directory
cd src && make install PREFIX=/usr/local/redis
- Effect after completion
The installation is complete!
Three, deployment start method
- 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
2. Configure redis to start in the background
vim /usr/local/redis/etc/redis.conf //将daemonize no 改成daemonize yes
3. Add redis to boot
vim /etc/rc.local //在里面添加内容
4. Start redis
/usr/local/redis/bin/redis-server /usr/local/redis/etc/redis.conf
Four, remote connection configuration
- We perform related configurations in the configuration file redis.conf
vim /usr/local/redis/etc/redis.conf
- Use the shortcut key "70gg" to quickly jump to line 70, and change the comment
- Change protected-mode yes to no in line 90
- Set the password. Uncomment line 507 and change the password
- Save and restart redis
#先查询进程,杀死进程,然后启动
ps -ef|grep redis
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
- 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.
- 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!