redis安装

官网

http://redis.io/download

安装依赖

yum -y install gcc
yum -y install gcc-c++

安装

wget http://download.redis.io/releases/redis-3.0.7.tar.gz
tar xzf redis-3.0.3.tar.gz
cd redis-3.0.3
make  # redis5以后版本使用make MALLOC=libc

make install
mkdir /etc/redis
cp /data/download/redis-3.0.7/redis.conf /etc/redis/

前台启动

$ src/redis-server

后台启动

#加上`&`号使redis以后台程序方式运行
./redis-server &
启动
cd /etc/redis
redis-server 6379.conf
redis-server 10000.conf

检测

#检测后台进程是否存在
ps -ef |grep redis

#检测6379端口是否在监听
netstat -lntp | grep 6379

#使用`redis-cli`客户端检测连接是否正常
./redis-cli
127.0.0.1:6379> keys *
(empty list or set)
127.0.0.1:6379> set key "hello world"
OK
127.0.0.1:6379> get key
"hello world"

停止

#使用客户端
redis-cli shutdown
#因为Redis可以妥善处理SIGTERM信号,所以直接kill -9也是可以的
kill -9 PID

-------------

redis-cli -a 123456 -h 127.0.0.1 -p 6379 shutdown
关闭redis服务器,关闭时一定要指定好药关闭的redis服务器的ip和port.

使用文档

http://redisdoc.com/

进入redis

主库
 redis-cli -a 1224 -p 6379
从库
 redis-cli -a 1234 -p 10000

查看版本

redis-server -v
redis-cli -v
原文地址:https://www.cnblogs.com/linn/p/4692686.html