centos 安装redis5.0.9
下载包
wget http://download.redis.io/releases/redis-5.0.9.tar.gz
解压并移动
tar -zvxf redis-5.0.9.tar.gz
mv /root/redis-5.0.9 /usr/local/redis
编译
cd /usr/local/redis
make
安装
make PREFIX=/usr/local/redis install
修改配置文件
#远程访问
#bind 127.0.0.1
protected-mode no
port 6360 #随意
requirepass yourpassword
daemonize yes #可以后台进程运行
启动
./bin/redis-server ./redis.conf
开发端口
firewall-cmd --zone=public --add-port=6360/tcp --permanent
firewall-cmd --reload
设置开机启动
创建服务
vim /lib/systemd/system/redis.service
[Unit]
Description=Redis
After=network.target
[Service]
Type=forking
PIDFile=/var/run/redis_6379.pid
ExecStart=/usr/local/redis/bin/redis-server /usr/local/redis/redis.conf
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target
刷新配置
systemctl daemon-reload
启动、重启、停止
systemctl start redis
systemctl restart redis
systemctl stop redis
开机自启动
redis服务加入开机启动
systemctl enable redis
禁止开机启动
systemctl disable redis