linux 下安装 redis

下载 redis

进入 /usr/local/src 目录 , 下载 redis , 解压安装.

1
2
3
4
5
6
wget http://download.redis.io/releases/redis-4.0.0.tar.gz
tar zxvf redis-4.0.0.tar.gz
cd redis-4.0.0
make
cd src
make install

创建 redis 管理目录

1
2
3
4
5
mkdir -p /usr/local/redis/bin 
mkdir -p /usr/local/redis/etc
mv /usr/local/src/redis-4.0.0/redis.conf /usr/local/redis/etc
cd /usr/local/src/redis-4.0.0/src
cp mkreleasehdr.sh redis-benchmark redis-check-aof redis-check-dump redis-cli redis-server /usr/local/redis/bin

修改 redis.conf , 让 redis 后台运行

找到 daemonize , 将值设置为 yes

启动与连接

1
2
/usr/local/redis/bin/redis-server /usr/local/redis/etc/redis.conf
/usr/local/redis/bin/redis-cli

常用

查看是否启动

1
ps -ef | grep redis

端口占用

1
netstat -tunpl | grep 6379

停止 redis

1
/usr/local/redis/bin/redis-cli shutdown