yum install -y gcc-c++
yum install -y wget
wget http://download.redis.io/releases/redis-5.0.5.tar.gz
tar -zxf redis-5.0.5.tar.gz
cd redis-5.0.5/src
make
mkdir /usr/redis -p
make install PREFIX=/usr/redis
./redis-server
vim redis.conf
# 将`daemonize`由`no`改为`yes`
daemonize yes
# 默认绑定的是回环地址,默认不能被其他机器访问
# bind 127.0.0.1
# 是否开启保护模式,由yes该为no protected-mode no
./redis-server redis.conf
./redis-cli shutdown
* redis-server :启动 redis 服务
* redis-cli :进入 redis 命令客户端
* redis-benchmark : 性能测试的工具
* redis-check-aof : aof 文件进行检查的工具
* redis-check-dump : rdb 文件进行检查的工具
* redis-sentinel : 启动哨兵监控服务
./redis-cli -h 127.0.0.1 -p 6379
-h:redis服务器的ip地址
-p:redis实例的端口号
如果不指定主机和端口也可以
./redis0-cli
192.168.56.103:6381 主(Master)
192.168.56.103:6382 主(Master)
192.168.56.103:6383 主(Master)
192.168.56.103:6384 从(Slave)
192.168.56.103:6385 从(Slave)
192.168.56.103:6386 从(Slave)
192.168.56.103:6387 主(Master)后加
192.168.56.103:6388 从(Slave)后加
bind 0.0.0.0
port 6381
daemonize yes
appendonly yes
cluster-enabled yes
cluster-config-file nodes-6381.conf
./redis6381/redis-server ./redis6381/redis.conf
./redis6382/redis-server ./redis6382/redis.conf
./redis6383/redis-server ./redis6383/redis.conf
./redis6384/redis-server ./redis6384/redis.conf
./redis6385/redis-server ./redis6385/redis.conf
./redis6386/redis-server ./redis6386/redis.conf
./redis6387/redis-server ./redis6387/redis.conf
./redis6388/redis-server ./redis6388/redis.conf
./redis6381/redis-cli --cluster create 192.168.56.103:6381 192.168.56.103:6382 192.168.56.103:6383 192.168.56.103:6384 192.168.56.103:6385 192.168.56.103:6386 --cluster-replicas 1
./redis6381/redis-cli --cluster add-node 192.168.56.103:6387 192.168.56.103:6382
./redis6381/redis-cli --cluster add-node 192.168.56.103:6388 192.168.56.103:6382 --cluster-slave --cluster-master-id 6c256900dba703c23bb2a0e4ecdf1df456cb9593