下载redis3.2.4
wget http://download.redis.io/releases/redis-3.2.4.tar.gz
解压
tar -zxf redis-3.2.4.tar.gz
编译需要gcc环境,如果没有gcc环境
yum install gcc
编译
cd redis-3.2.4
make
安装
make install
开启aof持久化、以守护进程启动、远程访问
先把配置文件拷贝一份到/etc/redis/下面,目录随意
cp redis-3.2.4/redis.conf /etc/redis/
vim /etc/redis/redis.conf
修改四个配置:
daemonize yes #守护进程
appendonly yes #开启aof持久化
appendfsync everysec
bind 0.0.0.0 #开启远程访问
将redis安装为服务,设置开机启动
vim /lib/systemd/system/redis.service
加入以下内容:
[Unit]
Description=redis service
Wants=network.target
[Service]
Type=forking
ExecStart=/usr/local/bin/redis-server /etc/redis/redis.conf
[Install]
WantedBy=multi-user.target
重新载入
systemctl daemon-reload
设置开机启动
systemctl enable redis
启动redis
systemctl start redis
开启防火墙的3306端口
firewall-cmd –add-port=3306/tcp –permanent
firewall-cmd –reload