安装3.x
[root@node1 ~]# yum install wget gcc-c++ make [root@node1 ~]# wget http://download.redis.io/releases/redis-3.2.8.tar.gz [root@node1 ~]# tar -zxvf redis-3.2.8.tar.gz [root@node1 ~]# mv redis-3.2.8 /usr/local/redis [root@node1 ~]# cd /usr/local/redis/ [root@node1 redis]# make [root@node1 redis]# make install
出错截图:
安装4.0.x
[root@node4 redis]# yum install wget gcc-c++ make [root@node4 ~]# wget http://download.redis.io/releases/redis-4.0.0.tar.gz [root@node4 ~]# tar zxvf redis-4.0.0.tar.gz [root@node4 ~]# mv redis-4.0.0 /usr/local/redis [root@node4 ~]# cd /usr/local/redis/
[root@node4 redis]# yum install epel-release [root@node4 redis]# yum install jemalloc-devel
[root@node4 redis]# ls deps/ hiredis jemalloc linenoise lua Makefile README.md update-jemalloc.sh [root@node4 redis]# cd deps/ [root@node4 deps]# make hiredis lua jemalloc linenoise [root@node4 deps]# cd .. [root@node4 redis]# make [root@node4 redis]# make install
出错截图:
服务器启动
redis-server
客户端启动
# redis-cli 127.0.0.1:6379> ping PONG
开机启动
在源码包的utils目录下存在 install_server.sh 脚本,执行即可
假设安装目录为: /usr/local/redis/
[root@node1 ~]# cd /usr/local/redis/utils/ # 安装开机启动服务 [root@node1 utils]# ./install_server.sh # 查看状态 [root@node1 utils]# systemctl status redis_6379 [root@node1 utils]# systemctl start redis_6379 # 查看是否开机自启动 [root@node1 utils]# systemctl is-enabled redis_6379
个人觉得redis_6379看着不舒服,于是对原配置文件稍作修改。
除了端口号后 安装效果如下:
[root@node4 utils]# ./install_server.sh Welcome to the redis service installer This script will help you easily set up a running redis server Please select the redis port for this instance: [6379] Selecting default: 6379 Please select the redis config file name [/etc/redis/redis.conf] Selected default - /etc/redis/redis.conf Please select the redis log file name [/var/log/redis.log] Selected default - /var/log/redis.log Please select the data directory for this instance [/var/lib/redis/] Selected default - /var/lib/redis/ Please select the redis executable path [/usr/local/bin/redis-server] Selected config: Port : 6379 Config file : /etc/redis/redis.conf Log file : /var/log/redis.log Data dir : /var/lib/redis/ Executable : /usr/local/bin/redis-server Cli Executable : /usr/local/bin/redis-cli Is this ok? Then press ENTER to go on or Ctrl-C to abort. Copied /tmp/6379.conf => /etc/init.d/redis Installing service... Successfully added to chkconfig! Successfully added to runlevels 345! Starting Redis server... Installation successful!