安装

1
2
3
4
5
yum -y install gcc-c++
wget http://download.redis.io/releases/redis-5.0.9.tar.gz
tar xzf redis-5.0.9.tar.gz
cd redis-5.0.9
make

配置

1
2
3
4
5
6
7
8
9
#修改配置文件
vi ./redis.conf

#daemonize设置为yes
daemonize yes
#密码
requirepass 123
#注释
#bind 127.0.0.1
  1. 启动 src/redis-server ./redis.conf

命令

1
2
#登录
redis-cli -h 127.0.0.1 -p 6379 -a password -c

集群配置

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
port 7000
bind 10.26.90.5
pidfile /usr/local/redis/redis_cluster/redis_7000.pid
cluster-config-file /usr/local/redis/redis_cluster/nodes_7000.conf
# 通用
daemonize yes
cluster-enabled yes
cluster-node-timeout 10100
appendonly yes
logfile "/usr/local/redis/log/redis-7000.log"
# 密码
masterauth 123
requirepass 123

集群命令

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
# 防火墙
firewall-cmd --permanent --add-port=17000-17005/tcp
firewall-cmd --permanent --add-port=7000-7005/tcp

# 启动所有节点
./redis-server ../redis_cluster/7000/redis.conf
./redis-server ../redis_cluster/7001/redis.conf
./redis-server ../redis_cluster/7002/redis.conf
./redis-server ../redis_cluster/7003/redis.conf
./redis-server ../redis_cluster/7004/redis.conf
./redis-server ../redis_cluster/7005/redis.conf

# 创建集群
./redis-cli --cluster create 127.0.0.1:7000 127.0.0.1:7001 127.0.0.1:7002 127.0.0.1:7003 127.0.0.1:7004 127.0.0.1:7005 --cluster-replicas 1 -a password