install redis

来源:互联网 发布:中国工业企业数据库 编辑:程序博客网 时间:2024/06/07 02:45
1.Office Download redis.tar.gz  from website --- redis.io

2.uncompact file

$ tar zxvf redis-3.2.9.tar.gz && mv redis-3.2.9  /opt/redis

3.compile redis:

$ cd /opt/redis && make && make install

4.configure redis

$ sudo mkdir /etc/redis

$ sudo cp redis.conf  /etc/redis/redis.conf

5.launch redis,specialize configuration file

$ /opt/redis/src/redis-server /etc/redis/redis.conf

6.lauch redis passing arguments via the command line

$ ./redis-server --port 6380 --slaveof 127.0.0.1 6379

7. use redis-cli

redis-Command Line Interface

(1)

$ ./redis-cli  # Pass authentication Using "auth" directives

127.0.0.1:6379> auth foobared
OK

(2)

$ ./redis-cli -n 1 -a foobared incr mycounter

8. get value

$ ./src/redis-cli -a foobared get k1

 9. enable authentication

(1) uncomment the line including 'requirepass'

$ sudo sed -r '/^#\s?requirepass/ s/^#\s?//g' -i /etc/redis/redis.conf

$ cat /etc/redis/redis.conf | grep -P \s?requirepass