(2)或在profile.d目录下新建一个,专门放redis的情况变量文件
进入/etc/profile.d/路径下新建redis.sh
vim /etc/profile.d/redis.sh
在redis.sh文件中新增以下内容
export PATH=$PATH:/usr/local/redis/src
5.革新情况变量
source /etc/profile
复制代码
6.重启redis
systemctl restart redis
复制代码
说明:如果后续各人还重新修改了/etc/systemd/system/redis.service文件,启动redis时出现提示:Warning: The unit file, source configuration file or drop-ins of redis.service changed on disk. Run 'systemctl daemon-reload' to reload units
重新实行命令:systemctl daemon-reload
这个警告提示您的 redis.service 单位文件、源设置文件或附加设置文件在磁盘上发生了变化。为了加载这些变化,您必要运行 systemctl daemon-reload 命令来重新加载单位。
五、验证
1.查看redis的运行状态
2.查看redis进程
3.利用命令毗连客户端
redis-cli
进入之后,必要你输入暗码才能获取到redis输出的信息(info)
auth 暗码
或者 之前在毗连的时候输入暗码:
redis-cli -a <password>