安装与配置
# 在/usr目录下创建redis目录[root@jianbao ~]# cd /usr[root@jianbao usr]# mkdir redis[root@jianbao usr]# cd redis# 将redis-linux包拖到redis目录下[root@jianbao redis]# lsredis-5.0.7.tar.gz# 解压redis-linux包[root@jianbao redis]# tar -zxvf redis-5.0.7.tar.gz[root@jianbao redis]# lsredis-5.0.7 redis-5.0.7.tar.gz# 进入redis-linux包目录,执行make命令[root@jianbao redis]# cd redis-5.0.7[root@jianbao redis-5.0.7]# make[root@jianbao redis-5.0.7]# make install# 在redis目录下新建config目录,将redis-5.0.7包中的配置文件redis.conf复制到config目录下。这样方便使用且可以保证安装包的完整性[root@jianbao redis-5.0.7]# cd ..[root@jianbao redis]# lsredis-5.0.7 redis-5.0.7.tar.gz[root@jianbao redis]# mkdir config[root@jianbao redis]# cd config[root@jianbao config]# cp /usr/redis/redis-5.0.7/redis.conf /usr/redis/config[root@jianbao config]# lsredis.conf
启动与关闭
通过配置文件首先启动 redis 服务端。
[root@jianbao redis]# redis-server config/redis.conf
随后启动 redis 客户端并用 ping 命令测试是否启动成功,如果返回 PONG 则说明启动成功。
[root@jianbao redis]# redis-cli -p 6379127.0.0.1:6379> pingPONG
通过查看进程查看 redis 进程是否存在。
[root@jianbao redis]# ps -ef|grep redisroot 5369 1565 0 18:13 pts/0 00:00:00 redis-server 127.0.0.1:6379root 11846 5467 0 18:15 pts/2 00:00:00 redis-cli -p 6379root 18420 16176 0 18:17 pts/4 00:00:00 grep --color=auto redis
通过 shutdown 和 exit 命令关闭 redis。
127.0.0.1:6379> shutdownnot connected> exit[root@jianbao redis]# ps -ef|grep redisroot 22840 16176 0 18:18 pts/4 00:00:00 grep --color=auto redis
