官网
环境准备
- 如果是新机子有必要先更新下yum
命令:
# sudo yum install epel-release
# sudo yum update
- 使用make 或 make install 提示command not found
安装make命令:
# yum -y install gcc automake autoconf libtool make
-
安装gcc (g++),缺少可能会出现以下错误
gcc-error
命令:
# yum install gcc gcc-c++
安装过程
- 获取安装包
命令:

- 解压
命令:
# tar -zxvf redis-5.0.5.tar.gz
- 安装
命令:
# cd redis-5.0.5
# make
解压后
-
安装成功
安装成功
- 启动
在redis 安装目录下,使用如下启动命令:
# src/redis-server

- 使用内置客户端与Redis进行交互测试
ps: 因为上面的启动方式是非后台启动,所以要新开窗口使用内置客户端与Redis进行交互测试
命令:
# cd /home/redisSoftware/redis-5.0.0
# src/redis-cli

- 至此,redis已经启动成功
- (ps,非后台启动,结束按Ctrl + C或者关闭窗口,就可以结束)
创建usr下的redis目录
创建存储redis文件目录,复制redis-server、redis-cli、redis.conf到新建立的文件夹
逐条执行命令:
# cp /home/redisSoftware/redis-5.0.5/src/redis-server /usr/local/redis/
# cp /home/redisSoftware/redis-5.0.5/src/redis-cli /usr/local/redis/
\ # cp /home/redisSoftware/redis-5.0.5/redis.conf /usr/local/redis/

配置redis.config,设置密码
命令:
# cd /usr/local/redis
# vim redis.conf

-
注释 127.0.0.1
注释127.0.0.1
-
设置密码
密码密码
- 保存退出:wq! 或 shift + (按两次)z
配置后台运行,且跟系统运行
-
修改配置文件,允许后台运行
在redis.config中配置 daemonize yes
允许后台运行
- 配置开机启动
在/etc/systemd/system目录创建redis.service
命令one:
# touch /etc/systemd/system/redis.service
- 编辑redis.service
加入以下内容
[Unit]
Description=redis-server
After=network.target
[Service]
Type=forking
ExecStart=/usr/local/redis/redis-server /usr/local/redis/redis.conf
PrivateTmp=true
[Install]
WantedBy=multi-user.target

- 保存退出则好!
- 后台启动
逐条执行以下命令:
# systemctl daemon-reload
# systemctl start redis.service
# systemctl enable redis.service

至此,redis已经完成安装且可以随系统启动
补充命令
systemctl status redis.service #查看服务当前状态
systemctl start redis.service #启动redis服务
systemctl stop redis.service #停止redis服务
systemctl restart redis.service #重启动服务
systemctl enable redis.service #设置开机自启动
systemctl disable redis.service #停止开机自启动
原创声明:转载请写明出处
网友评论