http://download.redis.io/releases/redis-4.0.14.tar.gz
[root@bobo01 opt]# tar -zxvf redis-4.0.14.tar.gz
yum install -y wget gcc make tcl
make MALLOC=libc
make install
./src/redis-server
./src/redis-cli
[root@bobo01 redis]# vim redis.conf
[root@bobo01 redis]# ./src/redis-server redis.conf
2248:C 24 Feb 14:32:48.796 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
2248:C 24 Feb 14:32:48.796 # Redis version=4.0.14, bits=64, commit=00000000,modified=0, pid=2248, just started
2248:C 24 Feb 14:32:48.796 # Configuration loaded
[root@bobo01 redis]# ./src/redis-cli
127.0.0.1:6379> ping
PONG
127.0.0.1:6379>
[root@bobo01 redis]# ./src/redis-cli
127.0.0.1:6379> ping
PONG
127.0.0.1:6379> exit
[root@bobo01 redis]# ./src/redis-cli
127.0.0.1:6379> SHUTDOWN
not connected> exit
[root@bobo01 redis]# ./src/redis-cli
Could not connect to Redis at 127.0.0.1:6379: Connection refused
Could not connect to Redis at 127.0.0.1:6379: Connection refused
not connected> exit
[root@bobo01 redis]#
127.0.0.1:6379> set name dpb
OK
12
127.0.0.1:6380> set name zhangsan
OK
127.0.0.1:6380> select 4
OK
127.0.0.1:6380[4]> get name
(nil)
127.0.0.1:6380[4]> select 0
OK
127.0.0.1:6380> get name
"zhangsan"
12345678910
127.0.0.1:6379> del name
(integer) 1
127.0.0.1:6379> del name
(integer) 0
1234
127.0.0.1:6379> dump name
"\x00\x03dpb\t\x00\xe5\xa2\xc4\xd1\xfc\xb2\xd9\xcb"
127.0.0.1:6379> dump name1
(nil)
1234
127.0.0.1:6379> exists name
(integer) 1
127.0.0.1:6379> exists name1
(integer) 0
1234
127.0.0.1:6379> ttl name
(integer) -1
127.0.0.1:6379> ttl name1
(integer) -2
1234
127.0.0.1:6379> expire name 120
(integer) 1
127.0.0.1:6379> ttl name
(integer) 112
127.0.0.1:6379> ttl name
(integer) 10
127.0.0.1:6379> ttl name
(integer) 7
127.0.0.1:6379> ttl name
(integer) -2
12345678910
127.0.0.1:6379> pexpire name 100
(integer) 1
127.0.0.1:6379> ttl name
(integer) -2
1234
127.0.0.1:6379> pexpire name 100000
(integer) 1
127.0.0.1:6379> ttl name
(integer) 91
127.0.0.1:6379> pttl name
(integer) 84601
123456
127.0.0.1:6379> set age 18
OK
127.0.0.1:6379> set sex 男
OK
127.0.0.1:6379> set address 深圳
OK
127.0.0.1:6379> keys *
1) "age"
2) "address"
3) "sex"
12345678910
127.0.0.1:6379> randomkey
"address"
127.0.0.1:6379> randomkey
"age"
127.0.0.1:6379> randomkey
"sex"
127.0.0.1:6379> randomkey
"age"
12345678
127.0.0.1:6379> type name
none
127.0.0.1:6379> type age
string
127.0.0.1:6379> type sex
string
123456
127.0.0.1:6379> rename age age1
OK
127.0.0.1:6379> exists age
(integer) 0
127.0.0.1:6379> exists age1
(integer) 1
123456
127.0.0.1:6380> keys *
1) "name"
127.0.0.1:6380> flushdb
OK
127.0.0.1:6380> keys *
(empty list or set)
127.0.0.1:6380>
1234567
127.0.0.1:6379> set name abc
OK
12
127.0.0.1:6379> get name
"abc"
127.0.0.1:6379> get aaa
(nil)
1234
127.0.0.1:6379> strlen name
(integer) 10
12
127.0.0.1:6379> append name 123
(integer) 6
127.0.0.1:6379> get name
"abc123"
127.0.0.1:6379> append aaa
(error) ERR wrong number of arguments for 'append' command
123456
127.0.0.1:6379> set age 18
OK
127.0.0.1:6379> get age
"18"
127.0.0.1:6379> incr age
(integer) 19 #正常数字增1
127.0.0.1:6379> incr aaa
(integer) 1 # 不存在 初始为0增1
127.0.0.1:6379> incr name # 类型不匹配报错
(error) ERR value is not an integer or out of range
12345678910
127.0.0.1:6379> incrby age 5
(integer) 24
127.0.0.1:6379> incrby age 5
(integer) 29
1234
127.0.0.1:6379> incrbyfloat age 2.3
"31.3"
127.0.0.1:6379> incrbyfloat age 2.3
"33.6"
1234
127.0.0.1:6379> get age
"18"
127.0.0.1:6379> decr age
(integer) 17
1234
27.0.0.1:6379> decrby age 8
(integer) 9
127.0.0.1:6379> decrby age 8
(integer) 1
1234
127.0.0.1:6379> getrange name 2 5
"c123"
127.0.0.1:6379> getrange name 4 6
"23"
127.0.0.1:6379> getrange name 2 6
"c123"
123456
127.0.0.1:6379> set name helloworld
OK
127.0.0.1:6379> get name
"helloworld"
127.0.0.1:6379> setrange name 5 redis
(integer) 10
127.0.0.1:6379> get name
"helloredis"
12345678
127.0.0.1:6379> getset name 波波烤鸭
"abc123"
127.0.0.1:6379> get name
"\xe6\xb3\xa2\xe6\xb3\xa2\xe7\x83\xa4\xe9\xb8\xad"
1234
127.0.0.1:6379> mget name age address
1) "abc"
2) "1"
3) "sz"
1234
127.0.0.1:6379> mset a1 a1 a2 a2 a3 a3 a4 a4
OK
127.0.0.1:6379> mget a1 a2 a3 a4
1) "a1"
2) "a2"
3) "a3"
4) "a4"
1234567
127.0.0.1:6379> setex name1 20 test
OK
127.0.0.1:6379> ttl name1
(integer) 16
127.0.0.1:6379> ttl name1
(integer) 6
127.0.0.1:6379> ttl name1
(integer) -2
12345678
127.0.0.1:6379> psetex name2 20000 aaa
OK
127.0.0.1:6379> ttl name2
(integer) 17
127.0.0.1:6379> pttl name2
(integer) 4020
127.0.0.1:6379> pttl name2
(integer) 381
12345678
127.0.0.1:6379> setnx name aaa
(integer) 0
127.0.0.1:6379> get name
"abc"
127.0.0.1:6379> setnx name3 aaa
(integer) 1
127.0.0.1:6379> get name3
"aaa"
12345678
127.0.0.1:6379> msetnx b1 bb1 b2 bb2 b3 bb3
(integer) 1
127.0.0.1:6379> mget b1 b2 b3
1) "bb1"
2) "bb2"
3) "bb3"
127.0.0.1:6379> msetnx a1 aaa b5 bbb b6 bbb
(integer) 0
127.0.0.1:6379> mget a1 b5 b6
1) "a1"
2) (nil)
3) (nil)
127.0.0.1:6379> set k1 a
OK
12
127.0.0.1:6379> set k1 a
OK
127.0.0.1:6379> getbit k1 0
(integer) 0
127.0.0.1:6379> getbit k1 1
(integer) 1
127.0.0.1:6379> getbit k1 2
(integer) 1
127.0.0.1:6379> getbit k1 3
(integer) 0
127.0.0.1:6379> getbit k1 4
(integer) 0
127.0.0.1:6379> getbit k1 5
(integer) 0
127.0.0.1:6379> getbit k1 6
(integer) 0
127.0.0.1:6379> getbit k1 7
(integer) 1
123456789101112131415161718
127.0.0.1:6379> set k2 c
OK
127.0.0.1:6379> get k1
"a"
127.0.0.1:6379> get k2
"c"
127.0.0.1:6379> setbit k1 6 1
(integer) 0
127.0.0.1:6379> get k1
"c"
12345678910
127.0.0.1:6379> get k1
"a"
127.0.0.1:6379> get k2
"c"
127.0.0.1:6379> bitcount k1
(integer) 3
127.0.0.1:6379> bitcount k2
(integer) 4
12345678
127.0.0.1:6379> get k1
"a"
127.0.0.1:6379> get k2
"c"
127.0.0.1:6379> bitop and k3 k1 k2
(integer) 1
127.0.0.1:6379> get k3
"a"
127.0.0.1:6379> bitop or k4 k1 k2
(integer) 1
127.0.0.1:6379> get k4
"c"
127.0.0.1:6379> bitop xor k5 k1 k2
(integer) 1
127.0.0.1:6379> get k5
"\x02"
12345678910111213141516
127.0.0.1:6379> bitop not k6 k1
(integer) 1
127.0.0.1:6379> get k6
"\x9e"
1234
127.0.0.1:6379> bitpos k1 1
(integer) 1
127.0.0.1:6379> bitpos k1 0
(integer) 0
127.0.0.1:6379> hset user1 name zhangsan
(integer) 1
12
127.0.0.1:6379> hget user1 name
"zhangsan"
12
127.0.0.1:6379> hmset user2 name zhangsan age 18 sex nan address sz
OK
12
127.0.0.1:6379> hmget user2 name age sex address
1) "zhangsan"
2) "18"
3) "nan"
4) "sz"
12345
127.0.0.1:6379> hdel user2 address a1
(integer) 1 # 移除成功
127.0.0.1:6379> hmget user2 name age sex address
1) "zhangsan"
2) "18"
3) "nan"
4) (nil) # 不存在了
1234567
127.0.0.1:6379> hsetnx user2 name lisi
(integer) 0 # name字段存在,不起作用
127.0.0.1:6379> hsetnx user2 id 1001
(integer) 1 # id不存在,设置成功
127.0.0.1:6379> hmget user2 name age id
1) "zhangsan"
2) "18"
3) "1001"
12345678
127.0.0.1:6379> hvals user2
1) "zhangsan"
2) "18"
3) "nan"
4) "1001"
12345
127.0.0.1:6379> hkeys user2
1) "name"
2) "age"
3) "sex"
4) "id"
12345
127.0.0.1:6379> hgetall user2
1) "name"
2) "zhangsan"
3) "age"
4) "18"
5) "sex"
6) "nan"
7) "id"
8) "1001"
123456789
127.0.0.1:6379> hexists user2 name
(integer) 1
127.0.0.1:6379> hexists user2 ids
(integer) 0
1234
127.0.0.1:6379> hget user2 age
"18"
127.0.0.1:6379> hincrby user2 age 2
(integer) 20 # 增加2 并返回增加后的结果
127.0.0.1:6379> hincrby user2 age1 10
(integer) 10 # 关联字段 初始0 再加10
127.0.0.1:6379> hincrby user2 name 10
(error) ERR hash value is not an integer # 类型不匹配,报错
12345678
127.0.0.1:6379> hlen user2
(integer) 5
12
127.0.0.1:6379> hstrlen user2 name
(integer) 8
127.0.0.1:6379> hstrlen user2 address
(integer) 0 #不存在返回0
127.0.0.1:6379> hstrlen user2 sex
(integer) 3
127.0.0.1:6379> lpush games lol dnf cs cf
(integer) 4
127.0.0.1:6379> lpush user2 a b c
(error) WRONGTYPE Operation against a key holding the wrong kind of value
1234
127.0.0.1:6379> lrange games 0 -1
1) "cf"
2) "cs"
3) "dnf"
4) "lol"
127.0.0.1:6379> lrange games 0 3
1) "cf"
2) "cs"
3) "dnf"
4) "lol"
127.0.0.1:6379> lrange games 0 1
1) "cf"
2) "cs"
12345678910111213
127.0.0.1:6379> lpush games a1 a2
(integer) 6
127.0.0.1:6379> rpush games b1 b2
(integer) 8
127.0.0.1:6379> lrange games 0 -1
1) "a2"
2) "a1"
3) "cf"
4) "cs"
5) "dnf"
6) "lol"
7) "b1"
8) "b2"
12345678910111213
127.0.0.1:6379> llen games
(integer) 3
12
127.0.0.1:6379> lset games 1 aaa
OK
127.0.0.1:6379> lrange games 0 -1
1) "a1"
2) "aaa"
3) "a3"
123456
127.0.0.1:6379> rpop games
"b2" # 获取到了最后一个
127.0.0.1:6379> lrange games 0 -1
1) "a2"
2) "a1"
3) "cf"
4) "cs"
5) "dnf"
6) "lol"
7) "b1" # b2被移除了
12345678910
127.0.0.1:6379> lpop games
"a2" # 移除了头部是a2并返回了
127.0.0.1:6379> lrange games 0 -1
1) "a1" # a2被移除了
2) "cf"
3) "cs"
4) "dnf"
5) "lol"
6) "b1"
123456789
127.0.0.1:6379> lindex games 0
"a1" #第一个
127.0.0.1:6379> lindex games -1
"b1" # 最后一个
127.0.0.1:6379> lindex games 3
"dnf" # 第四个
123456
127.0.0.1:6379> lrange games 0 -1
1) "a1"
2) "cf"
3) "cs"
4) "dnf"
5) "lol"
6) "b1"
127.0.0.1:6379> ltrim games 0 3
OK
127.0.0.1:6379> lrange games 0 -1
1) "a1"
2) "cf"
3) "cs"
4) "dnf"
1234567891011121314
127.0.0.1:6379> blpop games 20
1) "games"
2) "cf"
127.0.0.1:6379> blpop games 20
1) "games"
2) "cs"
127.0.0.1:6379> blpop games 20
1) "games"
2) "dnf"
127.0.0.1:6379> blpop games 20
(nil) # 列表为空了,所以阻塞了20秒
(20.01s)
127.0.0.1:6379>
12345678910111213
127.0.0.1:6379> lrange games 0 -1
1) "cs"
2) "dnf"
3) "lol"
127.0.0.1:6379> brpop games 5
1) "games"
2) "lol"
127.0.0.1:6379> brpop games 5
1) "games"
2) "dnf"
127.0.0.1:6379> brpop games 5
1) "games"
2) "cs"
127.0.0.1:6379> brpop games 5
(nil)
(5.04s)
12345678910111213141516
127.0.0.1:6379> rpush games a1 a2 a3
(integer) 3
127.0.0.1:6379> lrange games 0 -1
1) "a1"
2) "a2"
3) "a3"
127.0.0.1:6379> rpoplpush games mygame
"a3"
127.0.0.1:6379> lrange games 0 -1
1) "a1"
2) "a2"
127.0.0.1:6379> lrange mygame 0 -1
1) "a3"
127.0.0.1:6379> rpoplpush games mygame
"a2"
127.0.0.1:6379> rpoplpush games mygame
"a1"
127.0.0.1:6379> rpoplpush games mygame
(nil)
127.0.0.1:6379> lrange games 0 -1
(empty list or set)
127.0.0.1:6379> lrange mygame 0 -1
1) "a1"
2) "a2"
3) "a3"
12345678910111213141516171819202122232425
127.0.0.1:6379> brpoplpush mygame games 5
"a3"
127.0.0.1:6379> brpoplpush mygame games 5
"a2"
127.0.0.1:6379> brpoplpush mygame games 5
"a1"
127.0.0.1:6379> brpoplpush mygame games 5
(nil) #阻塞到了timeout
(5.03s)
127.0.0.1:6379> sadd stu zhangsan lisi wangwu lisi zhangsan
(integer) 3
12
127.0.0.1:6379> scard stu
(integer) 3
12
127.0.0.1:6379> sismember stu zhangsan
(integer) 1 # 含有zhangsan
127.0.0.1:6379> sismember stu zhangsan1
(integer) 0 # 不含有zhangsan1
1234
127.0.0.1:6379> smembers stu
1) "lisi"
2) "zhangsan"
3) "wangwu"
1234
127.0.0.1:6379> srem stu lisi
(integer) 1
127.0.0.1:6379> srem stu aa
(integer) 0 # 集合中不含有 aa 返回0
127.0.0.1:6379> smembers stu
1) "zhangsan"
2) "wangwu"
1234567
127.0.0.1:6379> srandmember stu
"zhangsan" # 取一个随机值
127.0.0.1:6379> srandmember stu
"bobo"
127.0.0.1:6379> srandmember stu
"dpb"
127.0.0.1:6379> srandmember stu 3
1) "bobo" #取三个随机值
2) "dpb"
3) "wangwu"
127.0.0.1:6379> srandmember stu 3
1) "bobo"
2) "dpb"
3) "lisi"
127.0.0.1:6379> srandmember stu 100
1) "lisi" # 大于总的个数,去所有值
2) "dpb"
3) "bobo"
4) "zhangsan"
5) "wangwu"
127.0.0.1:6379> srandmember stu -2
1) "dpb" # 负数取绝对值 两个
2) "zhangsan"
127.0.0.1:6379> srandmember stu -2
1) "lisi"
2) "dpb"
1234567891011121314151617181920212223242526
127.0.0.1:6379> smembers stu
1) "bobo"
2) "zhangsan"
3) "dpb"
4) "lisi"
5) "wangwu"
127.0.0.1:6379> spop stu 2
1) "zhangsan" # 随机获取两个元素并移除
2) "dpb"
127.0.0.1:6379> smembers stu
1) "bobo"
2) "lisi"
3) "wangwu"
12345678910111213
127.0.0.1:6379> smembers stu
1) "bobo"
2) "lisi"
3) "wangwu"
127.0.0.1:6379>
127.0.0.1:6379> smove stu stu1 bobo
(integer) 1
127.0.0.1:6379> smembers stu
1) "lisi"
2) "wangwu"
127.0.0.1:6379> smembers stu1
1) "bobo"
123456789101112
127.0.0.1:6379> smembers stu
1) "lisi"
2) "wangwu"
127.0.0.1:6379> smembers stu1
1) "bobo"
127.0.0.1:6379> sdiff stu stu1
1) "lisi"
2) "wangwu"
127.0.0.1:6379> sdiff stu1 stu
1) "bobo"
12345678910
127.0.0.1:6379> sdiffstore stu2 stu1 stu
(integer) 1
127.0.0.1:6379> smembers stu2
1) "bobo"
1234
127.0.0.1:6379> smembers stu
1) "lisi"
2) "wangwu"
127.0.0.1:6379> smembers stu2
1) "lisi"
2) "bobo"
127.0.0.1:6379> sinter stu stu2
1) "lisi" #两个集合中都有lisi
12345678
127.0.0.1:6379> sinterstore stu3 stu stu2
(integer) 1
127.0.0.1:6379> smembers stu3
1) "lisi"
1234
127.0.0.1:6379> sunion stu stu2
1) "bobo"
2) "lisi"
3) "wangwu"
1234
127.0.0.1:6379> sunionstore stu3 stu stu2
(integer) 3
127.0.0.1:6379> smembers stu3
1) "bobo"
2) "lisi"
3) "wangwu"
127.0.0.1:6379> zadd student 60 a1 70 a2 80 a3 90 a4
(integer) 4
12
127.0.0.1:6379> zscore student a1
"60"
127.0.0.1:6379> zscore student a4
"90"
1234
127.0.0.1:6379> zrange student 0 -1
1) "a1"
2) "a2"
3) "a3"
4) "a4"
127.0.0.1:6379> zrange student 0 -1 withscores
1) "a1"
2) "60"
3) "a2"
4) "70"
5) "a3"
6) "80"
7) "a4"
8) "90"
1234567891011121314
127.0.0.1:6379> zrevrange student 0 3
1) "a4"
2) "a3"
3) "a2"
4) "a1"
127.0.0.1:6379> zrevrange student 0 3 withscores
1) "a4"
2) "90"
3) "a3"
4) "80"
5) "a2"
6) "70"
7) "a1"
8) "60"
1234567891011121314
127.0.0.1:6379> zcard student
(integer) 4
12
127.0.0.1:6379> zcount student 60 90
(integer) 4
127.0.0.1:6379> zcount student 60 (90
(integer) 3
127.0.0.1:6379> zcount student (60 90
(integer) 3
127.0.0.1:6379> zcount student (60 (90
(integer) 2
12345678
127.0.0.1:6379> zrangebyscore student 60 90
1) "a1"
2) "a2"
3) "a3"
4) "a4"
127.0.0.1:6379> zrangebyscore student 60 90 withscores
1) "a1"
2) "60"
3) "a2"
4) "70"
5) "a3"
6) "80"
7) "a4"
8) "90"
127.0.0.1:6379> zrangebyscore student (60 (90 withscores
1) "a2"
2) "70"
3) "a3"
4) "80"
12345678910111213141516171819
127.0.0.1:6379> zrank student a3
(integer) 2
127.0.0.1:6379> zrank student a66
(nil)
127.0.0.1:6379> zrank student a1
(integer) 0
123456
127.0.0.1:6379> zrevrank student a3
(integer) 1
127.0.0.1:6379> zrevrank student a1
(integer) 3
1234
127.0.0.1:6379> zrange student 0 -1 withscores
1) "a1"
2) "60"
3) "a2"
4) "70"
5) "a3"
6) "80"
7) "a4"
8) "90"
127.0.0.1:6379> zincrby student 5 a1
"65"
127.0.0.1:6379> zrange student 0 -1 withscores
1) "a1"
2) "65"
3) "a2"
4) "70"
5) "a3"
6) "80"
7) "a4"
8) "90"
127.0.0.1:6379> zincrby student 5 aa
"5"
127.0.0.1:6379> zrange student 0 -1 withscores
1) "aa"
2) "5"
3) "a1"
4) "65"
5) "a2"
6) "70"
7) "a3"
8) "80"
9) "a4"
10) "90"
127.0.0.1:6379> SUBSCRIBE c1 c2 c3
Reading messages... (press Ctrl-C to quit)
1) "subscribe"
2) "c1"
3) (integer) 1
1) "subscribe"
2) "c2"
3) (integer) 2
1) "subscribe"
2) "c3"
3) (integer) 3
127.0.0.1:6379> PUBLISH c1 hello
(integer) 1
127.0.0.1:6379>
127.0.0.1:6379> PSUBSCRIBE c*
Reading messages... (press Ctrl-C to quit)
1) "psubscribe"
2) "c*"
3) (integer) 1
1) "pmessage"
2) "c*"
3) "cc"
4) "okokok"
127.0.0.1:6379> MULTI
OK
127.0.0.1:6379> set k1 v1
QUEUED
127.0.0.1:6379> set k2 v2
QUEUED
127.0.0.1:6379> set k3 v3
QUEUED
127.0.0.1:6379> sets k4 v4
(error) ERR unknown command `sets`, with args beginning with: `k4`, `v4`,127.0.0.1:6379> set k5 v5 s5
QUEUED
127.0.0.1:6379> EXEC
(error) EXECABORT Transaction discarded because of previous errors.
127.0.0.1:6379> MULTI
OK
127.0.0.1:6379> set k1 v1
QUEUED
127.0.0.1:6379> set k2 v2
QUEUED
127.0.0.1:6379> set k3 v3
QUEUED
127.0.0.1:6379> set k4 v4 s4
QUEUED
127.0.0.1:6379> EXEC
1) OK
2) OK
3) OK
4) (error) ERR syntax error
127.0.0.1:6379> get k1
"v1"
127.0.0.1:6379> get k2
"v2"
127.0.0.1:6379> get k3
"v3"
127.0.0.1:6379> get k4
(nil)
因为不需要对回滚进行支持,所以 Redis 的内部可以保持简单且快速。
127.0.0.1:6379> set k1 v1
OK
127.0.0.1:6379> WATCH k1
OK
127.0.0.1:6379> MULTI
OK
127.0.0.1:6379> set k1 kkkk
QUEUED
127.0.0.1:6379> set k2 v2
QUEUED
127.0.0.1:6379> set k3 v3
QUEUED
127.0.0.1:6379> exec
1) OK
2) OK
3) OK
127.0.0.1:6379> get k1
"kkkk"
127.0.0.1:6379> WATCH k1
OK
127.0.0.1:6379> set k1 okokok
OK
127.0.0.1:6379> MULTI
OK
127.0.0.1:6379> set k1 bbbb
QUEUED
127.0.0.1:6379> set user zhang
QUEUED
127.0.0.1:6379> EXEC
################################ SNAPSHOTTING ################################
#
# Save the DB on disk:
#
# save
#
# Will save the DB if both the given number of seconds and the given
# number of write operations against the DB occurred.
#
# In the example below the behaviour will be to save:
# after 900 sec (15 min) if at least 1 key changed
# after 300 sec (5 min) if at least 10 keys changed
# after 60 sec if at least 10000 keys changed
#
# Note: you can disable saving completely by commenting out all "save" lines.
#
# It is also possible to remove all the previously configured save
# points by adding a save directive with a single empty string argument
# like in the following example:
#
# save ""
save 900 1 # 900秒之后至少有一个key被改变就执行一次快照
save 300 10 # 300秒之后至少有10个1key被改变就执行一次快照
save 60 10000 # 60秒之后至少有10000个1key被改变就执行一次快照
192.168.100.120:6379
192.168.100.120:6380
192.168.100.120:6381
port 6379
pidfile /var/run/redis6379.pid
logfile "6379.rdb"
dbfilename dump6379.rdb
appendfilename "appendonly6379.aof"
[root@bobo01 redis]# ./src/redis-server redis6379.conf
[root@bobo01 redis]# ./src/redis-server redis6380.conf
[root@bobo01 redis]# ./src/redis-server redis6381.conf
127.0.0.1:6380> SLAVEOF 127.0.0.1 6379
OK
127.0.0.1:6380>
127.0.0.1:6381> SLAVEOF 127.0.0.1 6379
OK
127.0.0.1:6381>
127.0.0.1:6381> SLAVEOF 127.0.0.1 6380
OK
127.0.0.1:6381>