1、由于 redis 是用 C 语言开发,安装之前必先确认是否安装 gcc 环境(gcc -v)
yum install -y gcc
2、下载并解压
wget http://download.redis.io/releases/redis-5.0.3.tar.gz
tar -zxvf redis-5.0.3.tar.gz
3、切换目录 执行编译
cd redis-5.0.3
make
4、安装并指定安装目录
make install PREFIX=/home/worksoft/redis53/
5、前台启动
cd /home/worksoft/redis/bin
./redis-server
6、后台启动
cp /home/worksoft/redis5/redis.conf /home/worksoft/redis/bin
vi redis.conf
设置密码:requirepass 123456
注释掉: bind 127.0.0.1
daemonize no 改为daemonize yes
./redis-server redis.conf
7、设置开机启动
vi /etc/systemd/system/redis.service
[Unit]
Description=redis-server
After=network.target
[Service]
Type=forking
ExecStart= /home/worksoft/redis/bin/redis-server
/home/worksoft/redis/bin/redis.conf
PrivateTmp=true
[Install]
WantedBy=multi-user.target
systemctl daemon-reload
systemctl start redis.service
systemctl enable redis.service
systemctl start redis.service #启动redis服务
systemctl stop redis.service #停止redis服务
systemctl restart redis.service #重新启动服务
systemctl status redis.service #查看服务当前状态
systemctl enable redis.service #设置开机自启动
systemctl disable redis.service #停止开机自启动
ps -ef | grep redis 查看是否启动