介绍redis
Redis 是一个开源(BSD许可)的,内存中的数据结构存储系统,它可以用作数据库、缓存和消息中间件。 它支持多种类型的数据结构,如 字符串(strings), 散列
(hashes), 列表(lists), 集合(sets), 有序集合(sorted sets) 与范围查询, bitmaps, hyperloglogs 和 地理空间(geospatial) 索引半径查询。 Redis 内置了
复制(replication),LUA脚本(Lua scripting), LRU驱动事件(LRU eviction),事务(transactions) 和不同级别的 磁盘持久化(persistence), 并通过 Redis哨兵
(Sentinel)和自动 分区(Cluster)提供高可用性(high availability)。(http://www.redis.cn)
安装
1.下载redis(redis官网给出)
2.解压下载文件$ wget http://download.redis.io/releases/redis-3.2.9.tar.gz
3.进入redis的文件夹,并编译$ tar xzf redis-3.2.9.tar.gz
4.启动redis服务$ cd redis-3.2.9 $ make
$ src/redis-server & (&表示后台运行该命令)
5.使用redis内置客户端
$ src/redis-cli
redis> set foo bar
OK
redis> get foo
"bar"
6.redis默认只能本机才能连接,在配置文件中bind 127.0.0.1,修改为bind ×
配置
进入client之后,输入cofig get *,表示获得所有配置
输入config set CONFIG_NAME NEW_CONFIG_VALUE 设置redis具体配置
redis.conf 配置项说明如下:
1. Redis默认不是以守护进程的方式运行,可以通过该配置项修改,使用yes启用守护进程
daemonize no
2. 当Redis以守护进程方式运行时,Redis默认会把pid写入/var/run/redis.pid文件,可以通过pidfile指定
pidfile /var/run/redis.pid
3.