Redis

http://redisdoc.com/

redis在key-value存储上性能比memcached更好.

安装:

1
2
# redis-cli, redis-sentinel, redis-server
$ sudo apt-get install redis-server

只安装redis-cli:

1
$ sudo apt-get install redis-tools

redis-server监听端口6379.

redis-sentinel端口26379.

redis gui:

https://github.com/uglide/RedisDesktopManager


redis的命令

server:

1
redis-server

client:

1
redis-client

test:

1
redis-benchmark

sentinel:

1
redis-sentinel

CLI

redis-cli 进入命令行模式

1
2
3
4
5
> command    # 查看所有可用命令

> info    # 查看redis服务器信息

> monitor

数据类型

string

1
2
> set <key> <value>
> get <key>

list

1
2
3
4
5
6
> lset <key> <index> <value>
> lindex <key> <index>
> rpop
> lpop <key>
> rpush
> lpush

hash

1
2
> hset <key> <field> <value>
> hget <key> <field>

set

1
2
3
> sadd <key> <member>
> spop <key>
> srem <key> <memeber>

sorted set

1
2
> zadd <key> <score> <member>
> zrem <key> <member>

Monitoring

通过redis-cli> info查看

1
2
3
4
5
6
7
8
其它指标参考grafana dashboard.

Redis_mode: cluster/standalone

>>> replication (master/slave)
Connected_slaves:    连接的slave实例个数

>>> persistence  (rdb和aof的持久化信息)