检查全局路径
echo $PATH
[root@yuanlnet /]# echo $PATH
/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/root/bin
#以上路径即为目前系统中配置的全局路径,如需添加新的路径,参见下面的操作
#创建目录
[root@yuanlnet /]# mkdir /data/redisCli/
#将新的目录加入到$PATH
[root@yuanlnet /]# echo "export PATH=/data/redisCli:$PATH" >> /etc/profile
#重置/etc/profile,是新的配置生效
[root@yuanlnet /]#source /etc/profile
复制redis-cli
#必要条件:系统中已经成功部署redis,本次操作使用目录(/usr/local/sbin/)
[root@yuanlnet ~]# sudo cp /opt/redis-5.0.10/bin/redis-cli /usr/local/sbin/
验证
#访问本机的redis
[root@yuanlnet ~]# redis-cli
127.0.0.1:6379> get test
(error) NOAUTH Authentication required.
127.0.0.1:6379> auth password_123456
OK
127.0.0.1:6379> set test "hello redis-cli"
OK
127.0.0.1:6379> get test
"hello redis-cli"
127.0.0.1:6379>
#通过ip访问其它机器上的redis
[root@yuanlnet ~]# redis-cli -h xxx.xxx.xxx.xxx -p 6379 -a password_123456
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
xxx.xxx.xxx.xxx:6379>