redis安装配置

来源:互联网 发布:淘宝十元商品有哪些 编辑:程序博客网 时间:2024/06/09 22:58

环境为ubuntu14.04

1:下载redis 压缩包  redis-4.0.0.2.tar.gz   https://redis.io/

2:解压缩:tar xzf  redis-4.0.0.2.tar.gz

3:cd redis-4.0.0.2

4 make  //编译

5:src/redis-cli  遇到错误,因为redis 服务没打开需要先运行redis-server redis.conf

liyafei@liyafei-OEM:~/myfile/software/redis/redis-4.0.2/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


6:redis-server redis.conf    提示错误
liyafei@liyafei-OEM:~/myfile/software/redis/redis-4.0.2$ redis-server redis.conf10257:C 31 Oct 15:29:27.526 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
10257:C 31 Oct 15:29:27.526 # Redis version=4.0.2, bits=64, commit=00000000, modified=0, pid=10257, just started
10257:C 31 Oct 15:29:27.526 # Configuration loaded
10257:M 31 Oct 15:29:27.528 # You requested maxclients of 10000 requiring at least 10032 max file descriptors.
10257:M 31 Oct 15:29:27.528 # Server can't set maximum open files to 10032 because of OS error: Operation not permitted.
10257:M 31 Oct 15:29:27.528 # Current maximum open files is 4096. maxclients has been reduced to 4064 to compensate for low ulimit. If you need higher maxclients increase 'ulimit -n'.
                _._                                                  
           _.-``__ ''-._                                             
      _.-``    `.  `_.  ''-._           Redis 4.0.2 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._                                   
 (    '      ,       .-`  | `,    )     Running in standalone mode
 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
 |    `-._   `._    /     _.-'    |     PID: 10257
  `-._    `-._  `-./  _.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |           http://redis.io        
  `-._    `-._`-.__.-'_.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |                                  
  `-._    `-._`-.__.-'_.-'    _.-'                                   
      `-._    `-.__.-'    _.-'                                       
          `-._        _.-'                                           
              `-.__.-'                                               

10257:M 31 Oct 15:29:27.530 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
10257:M 31 Oct 15:29:27.530 # Server initialized
10257:M 31 Oct 15:29:27.530 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
10257:M 31 Oct 15:29:27.530 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
10257:M 31 Oct 15:29:27.531 * Ready to accept connections
^C10257:signal-handler (1509435068) Received SIGINT scheduling shutdown...
10257:M 31 Oct 15:31:08.317 # User requested shutdown...
10257:M 31 Oct 15:31:08.317 * Saving the final RDB snapshot before exiting.
10257:M 31 Oct 15:31:08.380 * DB saved on disk
10257:M 31 Oct 15:31:08.380 * Removing the pid file.
10257:M 31 Oct 15:31:08.380 # Redis is now ready to exit, bye bye...

7:修改redis.conf

 daemonize no修改 为 daemonize yes

   8:可以打开redis服务和客户端了

 liyafei@liyafei-OEM:/etc$ sudo vi redis.conf
liyafei@liyafei-OEM:/etc$ redis-server redis.conf
10279:C 31 Oct 15:35:00.402 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
10279:C 31 Oct 15:35:00.402 # Redis version=4.0.2, bits=64, commit=00000000, modified=0, pid=10279, just started
10279:C 31 Oct 15:35:00.402 # Configuration loaded
liyafei@liyafei-OEM:/etc$ redis-cli
127.0.0.1:6379> exit
liyafei@liyafei-OEM:/etc$ ^C


9;为了便于处理可以将redis.conf copy到etcc目录下。liyafei@liyafei-OEM:~/myfile/software/redis/redis-4.0.2$ sudo cp redis.conf /et

liyafei@liyafei-OEM:/etc$ redis-server redis.conf

参考:http://www.cnblogs.com/zjfjava/p/6881375.html

原创粉丝点击