linux下Redis的安装

 redis是当前比较热门的NOSQL系统之一,它是一个key-value存储系统。和Memcached类似,但很大程度补偿了memcached的不足,它支持存储的value类型相对更多,包括string、list、set、zset和hash。这些数据类型都支持push/pop、add/remove及取交集并集和差集及更丰富的操作。在此基础上,redis支持各种不同方式的排序。Redis数据都是缓存在计算机内存中,并且会周期性的把更新的数据写入磁盘或者把修改操作写入追加的记录文件。

     redis官网地址:http://www.redis.io/

     最新版本:2.8.3

     在Linux下安装Redis非常简单,具体步骤如下(官网有说明):

     1、下载源码,解压缩后编译源码。

$ wget http://download.redis.io/releases/redis-2.8.3.tar.gz
$ tar xzf redis-2.8.3.tar.gz
$ cd redis-2.8.3
$ make

     2、编译完成后,在Src目录下,配置文件对应redis.conf,更改该配置文件,修改启动方式为后台进程,如有需要可修改对应端口号,默认是6732;

# By default Redis does not run as a daemon. Use 'yes' if you need it.
# Note that Redis will write a pid file in /var/run/redis.pid when daemonized.
daemonize yes

# When running daemonized, Redis writes a pid file in /var/run/redis.pid by
# default. You can specify a custom pid file location here.
pidfile /var/run/redis.pid

# Accept connections on the specified port, default is 6379.
# If port 0 is specified Redis will not listen on a TCP socket.
port 9999

     3、启动Redis服务。

$ ./src/redis-server   redis.conf

     4、然后用客户端测试一下是否启动成功。

$ ./src/redis-cli -h host -p port
redis> set foo bar
OK
redis> get foo
"bar"


设置密码的步骤如下:

<!--[endif]-->修改redis.conf文件配置

root@ubuntu:/usr/local/redis-2.4.14# vim redis.conf

# requirepass foobared去掉注释,foobared改为自己的密码,我在这里改为123456

requirepass 123456

原文地址:https://www.cnblogs.com/shine_cn/p/3985636.html