redis install

redis standard install

1
2
3
4
5
6
7
8
9
10
11
12

[root@localhost app]# echo "net.core.somaxconn = 65535" | tee -a /etc/sysctl.conf
[root@localhost app]# echo "vm.overcommit_memory = 1" | tee -a /etc/sysctl.conf
[root@localhost app]# sysctl -p

[root@localhost app]# echo never > /sys/kernel/mm/transparent_hugepage/enabled
[root@localhost app]# cat >> /etc/rc.local <<EOF
if test -f /sys/kernel/mm/transparent_hugepage/enabled;then
echo never > /sys/kernel/mm/transparent_hugepage/enabled
fi
EOF
[root@localhost app]# chmod +x /etc/rc.d/rc.local
1
2
3
[root@localhost app]# tar xzf redis-3.2.6.tar.gz
[root@localhost app]# cd redis-3.2.6/
[root@localhost redis-3.2.6]# make MALLOC=libc PREFIX=/mnt/app/redis install
1
2
3
4
[root@localhost redis-3.2.6]# echo 'export REDIS_HOME=/mnt/app/redis'|tee /etc/profile.d/redis.sh
[root@localhost redis-3.2.6]# echo 'export REDIS_BIN=$REDIS_HOME/bin'|tee -a /etc/profile.d/redis.sh
[root@localhost redis-3.2.6]# echo 'export PATH=$REDIS_BIN:$PATH'|tee -a /etc/profile.d/redis.sh
[root@localhost redis-3.2.6]# source /etc/profile
1
2
3
4
5
6
[root@localhost redis-3.2.6]# mkdir -p /mnt/app/redis/conf
[root@localhost redis-3.2.6]# mkdir -p /mnt/data/redis
[root@localhost redis-3.2.6]# mkdir -p /mnt/log/redis
[root@localhost redis-3.2.6]# cp redis.conf /mnt/app/redis/conf/redis.conf
[root@localhost redis-3.2.6]# chown -R wisdom.wisdom /mnt/app/redis
[root@localhost redis-3.2.6]# chown -R wisdom.wisdom /mnt/data/redis
1
2
3
[root@localhost redis-3.2.6]# su - wisdom
[wisdom@localhost ~]$ vim /mnt/app/redis/conf/redis.conf
[wisdom@localhost ~]$ /mnt/app/redis/bin/redis-server /mnt/app/redis/conf/redis.conf

redis master slave install

1
2
3
[root@localhost app]# tar xzf redis-3.2.8.tar.gz
[root@localhost app]# cd redis-3.2.8
[root@localhost redis-3.2.8]# make MALLOC=libc PREFIX=/mnt/app/redis install
1
2
3
4
[root@localhost redis-3.2.8]# echo 'export REDIS_HOME=/mnt/app/redis' | tee /etc/profile.d/redis.sh
[root@localhost redis-3.2.8]# echo 'export REDIS_BIN=$REDIS_HOME/bin' | tee -a /etc/profile.d/redis.sh
[root@localhost redis-3.2.8]# echo 'export PATH=$REDIS_BIN:$PATH' | tee -a /etc/profile.d/redis.sh
[root@localhost redis-3.2.8]# source /etc/profile
1
2
[root@localhost redis-3.2.8]# mkdir -p /mnt/app/redis/conf/6379
[root@localhost redis-3.2.8]# cp redis.conf /mnt/app/redis/conf/6379/
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
redis-master:
[root@localhost redis-3.2.8]# mkdir -p /mnt/{data,log}/redis/6379
[root@localhost redis-3.2.8]# chown -R wisdom.wisdom /mnt/{data,log}/redis/6379

[root@localhost redis-3.2.8]# vim /mnt/app/redis/conf/6379/redis.conf
bind 0.0.0.0
protected-mode yes
port 6379
tcp-backlog 2048
unixsocket /mnt/data/redis/6379/redis.sock
unixsocketperm 700
timeout 120
tcp-keepalive 60
daemonize yes
supervised no
pidfile /mnt/data/redis/6379/redis.pid
loglevel notice
logfile "/mnt/log/redis/6379/redis.log"
databases 16
save 900 1
save 300 10
save 60 10000
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
dbfilename 6379.rdb
dir /mnt/data/redis/6379
slave-serve-stale-data yes
slave-read-only yes
repl-diskless-sync no
repl-diskless-sync-delay 5
repl-ping-slave-period 10
repl-timeout 60
repl-disable-tcp-nodelay no
repl-backlog-size 200mb
repl-backlog-ttl 3600
slave-priority 100
maxclients 10000
appendonly yes
appendfilename "6379.aof"
appendfsync everysec
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 4096mb
aof-load-truncated yes
lua-time-limit 5000
slowlog-log-slower-than 10000
slowlog-max-len 1024
latency-monitor-threshold 0
notify-keyspace-events ""
hash-max-ziplist-entries 512
hash-max-ziplist-value 64
list-max-ziplist-size -2
set-max-intset-entries 512
zset-max-ziplist-entries 128
zset-max-ziplist-value 64
hll-sparse-max-bytes 3000
activerehashing yes
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit slave 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60
hz 10
aof-rewrite-incremental-fsync yes

[root@localhost redis-3.2.8]# chown -R wisdom.wisdom /mnt/app/redis/conf

[root@localhost redis-3.2.8]# su - wisdom
[wisdom@localhost ~]$ /mnt/app/redis/bin/redis-server /mnt/app/redis/conf/6379/redis.conf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
redis-slave:
[root@localhost redis-3.2.8]# mkdir -p /mnt/{data,log}/redis/6379
[root@localhost redis-3.2.8]# chown -R wisdom.wisdom /mnt/{data,log}/redis/6379

[root@localhost redis-3.2.8]# vim /mnt/app/redis/conf/6379/redis.conf
bind 0.0.0.0
protected-mode yes
port 6379
tcp-backlog 2048
unixsocket /mnt/data/redis/6379/redis.sock
unixsocketperm 700
timeout 120
tcp-keepalive 60
daemonize yes
supervised no
pidfile /mnt/data/redis/6379/redis.pid
loglevel notice
logfile "/mnt/log/redis/6379/redis.log"
databases 16
save 900 1
save 300 10
save 60 10000
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
dbfilename 6379.rdb
dir /mnt/data/redis/6379
slaveof 192.168.18.226 6379
slave-serve-stale-data yes
slave-read-only yes
repl-diskless-sync no
repl-diskless-sync-delay 5
repl-ping-slave-period 10
repl-timeout 60
repl-disable-tcp-nodelay no
repl-backlog-size 200mb
repl-backlog-ttl 3600
slave-priority 100
maxclients 10000
appendonly yes
appendfilename "6379.aof"
appendfsync everysec
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 4096mb
aof-load-truncated yes
lua-time-limit 5000
slowlog-log-slower-than 10000
slowlog-max-len 1024
latency-monitor-threshold 0
notify-keyspace-events ""
hash-max-ziplist-entries 512
hash-max-ziplist-value 64
list-max-ziplist-size -2
set-max-intset-entries 512
zset-max-ziplist-entries 128
zset-max-ziplist-value 64
hll-sparse-max-bytes 3000
activerehashing yes
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit slave 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60
hz 10
aof-rewrite-incremental-fsync yes

[root@localhost redis-3.2.8]# chown -R wisdom.wisdom /mnt/app/redis/conf

[root@localhost redis-3.2.8]# su - wisdom
[wisdom@localhost ~]$ /mnt/app/redis/bin/redis-server /mnt/app/redis/conf/6379/redis.conf

redis cluster install

1
2
3
[root@localhost app]# tar xzf redis-3.2.6.tar.gz
[root@localhost app]# cd redis-3.2.6/
[root@localhost redis-3.2.6]# make MALLOC=libc PREFIX=/mnt/app/redis install
1
2
3
4
[root@localhost redis-3.2.6]# echo 'export REDIS_HOME=/mnt/app/redis'|tee /etc/profile.d/redis.sh
[root@localhost redis-3.2.6]# echo 'export REDIS_BIN=$REDIS_HOME/bin'|tee -a /etc/profile.d/redis.sh
[root@localhost redis-3.2.6]# echo 'export PATH=$REDIS_BIN:$PATH'|tee -a /etc/profile.d/redis.sh
[root@localhost redis-3.2.6]# source /etc/profile
1
2
3
4
5
6
7
8
[root@localhost redis-3.2.6]# mkdir -p /mnt/app/redis/conf/{7001,7002,7003,7004,7005,7006}
[root@localhost redis-3.2.6]# mkdir -p /mnt/data/redis/{7001,7002,7003,7004,7005,7006}
[root@localhost redis-3.2.6]# mkdir -p /mnt/log/redis/{7001,7002,7003,7004,7005,7006}
[root@localhost redis-3.2.6]# cp redis.conf /mnt/app/redis/conf/{7001,7002,7003,7004,7005,7006}/redis.conf

[root@localhost redis-3.2.6]# chown -R wisdom.wisdom /mnt/app/redis/conf
[root@localhost redis-3.2.6]# chown -R wisdom.wisdom /mnt/data/redis
[root@localhost redis-3.2.6]# chown -R wisdom.wisdom /mnt/log/redis
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
[root@localhost redis-3.2.6]# vim /mnt/app/redis/conf/7001/redis.conf
port 7001
cluster-enabled yes
cluster-config-file /mnt/data/redis/7001/nodes.conf
cluster-node-timeout 5000
appendonly yes
dir /mnt/data/redis/7001
unixsocket /mnt/data/redis/7001/redis.sock
pidfile /mnt/data/redis/7001/redis.pid
logfile /mnt/log/redis/7001/redis.log

[root@localhost redis-3.2.6]# vim /mnt/app/redis/conf/7002/redis.conf
port 7002
cluster-enabled yes
cluster-config-file /mnt/data/redis/7002/nodes.conf
cluster-node-timeout 5000
appendonly yes
dir /mnt/data/redis/7002
unixsocket /mnt/data/redis/7002/redis.sock
pidfile /mnt/data/redis/7002/redis.pid
logfile /mnt/log/redis/7002/redis.log

[root@localhost redis-3.2.6]# vim /mnt/app/redis/conf/7003/redis.conf
port 7003
cluster-enabled yes
cluster-config-file /mnt/data/redis/7003/nodes.conf
cluster-node-timeout 5000
appendonly yes
dir /mnt/data/redis/7003
unixsocket /mnt/data/redis/7003/redis.sock
pidfile /mnt/data/redis/7003/redis.pid
logfile /mnt/log/redis/7003/redis.log

[root@localhost redis-3.2.6]# vim /mnt/app/redis/conf/7004/redis.conf
port 7004
cluster-enabled yes
cluster-config-file /mnt/data/redis/7004/nodes.conf
cluster-node-timeout 5000
appendonly yes
dir /mnt/data/redis/7004
unixsocket /mnt/data/redis/7004/redis.sock
pidfile /mnt/data/redis/7004/redis.pid
logfile /mnt/log/redis/7004/redis.log

[root@localhost redis-3.2.6]# vim /mnt/app/redis/conf/7005/redis.conf
port 7005
cluster-enabled yes
cluster-config-file /mnt/data/redis/7005/nodes.conf
cluster-node-timeout 5000
appendonly yes
dir /mnt/data/redis/7005
unixsocket /mnt/data/redis/7005/redis.sock
pidfile /mnt/data/redis/7005/redis.pid
logfile /mnt/log/redis/7005/redis.log

[root@localhost redis-3.2.6]# vim /mnt/app/redis/conf/7006/redis.conf
port 7006
cluster-enabled yes
cluster-config-file /mnt/data/redis/7006/nodes.conf
cluster-node-timeout 5000
appendonly yes
dir /mnt/data/redis/7006
unixsocket /mnt/data/redis/7006/redis.sock
pidfile /mnt/data/redis/7006/redis.pid
logfile /mnt/log/redis/7006/redis.log
1
2
[root@localhost redis-3.2.6]# su - wisdom
[wisdom@localhost ~]$ /mnt/app/redis/bin/redis-server /mnt/app/redis/conf/{7001,7002,7003,7004,7005,7006}/redis.conf &
1
2
3
4
5
6
7
[root@localhost app]# yum -y install ruby rubygem-redis
[root@localhost app]# tar xzf redis-3.2.6.tar.gz
[root@localhost app]# cd redis-3.2.6/src
[root@localhost src]# ./redis-trib.rb create --replicas 1 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 127.0.0.1:7006

[root@localhost src]# ./redis-trib.rb check 127.0.0.1:7001
[root@localhost src]# ./redis-trib.rb info 127.0.0.1:7001