Installation dependencies
# yum install-y gcc gcc-c++ wget
Download Redis Source Package
wget http://download.redis.io/releases/redis-4.0.0.tar.gz
# TAR-ZXVF Redis-4.0.0.tar.gz
# Make Prefix=/usr/local/redis Install #安装到指定目录中
See a bin directory that includes the following files:
Redis-benchmark redis-check-rdb redis-sentinel redis-check-aof redis-cli redis-server
Copy Service script to system directory
# CP Redis-4.0.0/utils/redis_init_script/etc/rc.d/init.d/redis
# Vim/etc/rc.d/init.d/redis
In the second row,
#!/bin/sh
, add the following line
#chkconfig: 2345 80 90
Registering Redis as a service
# chkconfig--add Redis
Copying a configuration file
Create a new Conf folder under the Redis directory
# CP *.conf/usr/local/redis/conf/
cd /usr/local/redis/bin/cp redis-benchmark redis-cli redis-server /usr/bin/
vim /usr/local/redis/conf/redis.conf# 修改一下配置# redis以守护进程的方式运行# no表示不以守护进程的方式运行(会占用一个终端) daemonize yes# 客户端闲置多长时间后断开连接,默认为0关闭此功能 timeout 300# 设置redis日志级别,默认级别:notice loglevel verbose# 设置日志文件的输出方式,如果以守护进程的方式运行redis 默认:"" # 并且日志输出设置为stdout,那么日志信息就输出到/dev/null里面去了 logfile stdout
Because we are a custom path installation, we want to modify the relevant path configuration in the script
Exec=/usr/local/redis/bin/redis-server
Cliexec=/usrlocal/redis/bin/redis-cli
conf= "/usr/local/redis/conf/redis-${redisport}.conf"
Configure the Redis configuration file
Daemonize Yes
Bind 127.0.0.1 10.10.1.3
LogFile "/data/logs/redis/redis.log"
dir/data/data/redis/
Timeout 0
These configurations are simply modified,
Start Redis
Input command:/usr/local/redis/bin/redis-server/usr/local/redis/conf/redis.conf
See if Redis starts normally
Using the command: Ps-aux|grep Redis
Using Redis clients to connect to Redis
Cd/usr/local/redis/bin \ \ Enter the installation directory
./redis-cli \ \ Connect Redis
Set Key to test
Start Redis
# systemctl Restart Redis.service
Redis compiled installation