Redis笔记

本文详细记录了在Ubuntu 14.04上安装Redis 2.8.9的步骤,包括下载安装包、解压、编译、安装和测试Redis服务的正确运行。测试过程中需注意可能出现的连接拒绝问题,可能由于服务未启动或端口未正确绑定导致。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

系统环境和版本说明
Linux操作系统选用Ubuntu 14.04,Redis的版本选取目前的最新稳定版本2.8.9。

1.下载Redis的安装包
wget http://download.redis.io/releases/redis-2.8.9.tar.gz
2.解压
tar -zxvf redis-2.8.9.tar.gz
3.编译
sudo make
4.安装
sudo make install
5.在安装成功之后,可以运行测试,确认Redis的功能是否正常
sudo make test

  1 seconds - unit/quit
  1 seconds - unit/scan
  1 seconds - unit/auth
  2 seconds - unit/multi
  3 seconds - unit/protocol
  11 seconds - unit/expire
  13 seconds - unit/type/list-2
  4 seconds - integration/aof
  3 seconds - integration/rdb
  16 seconds - unit/type/list
  1 seconds - unit/pubsub
  2 seconds - integration/convert-zipmap-hash-on-load
  2 seconds - unit/slowlog
  0 seconds - unit/introspection
  19 seconds - unit/type/hash
  2 seconds - unit/limits
  21 seconds - unit/other
  22 seconds - unit/aofrw
  6 seconds - unit/scripting
  27 seconds - unit/type/set
  9 seconds - unit/dump
  30 seconds - unit/type/zset
  31 seconds - unit/sort
  16 seconds - unit/maxmemory
  13 seconds - unit/bitops
  34 seconds - integration/replication-2
  37 seconds - unit/basic
  42 seconds - unit/type/list-3
  40 seconds - integration/replication-psync
  43 seconds - integration/replication
  26 seconds - unit/hyperloglog
  50 seconds - integration/replication-3
  52 seconds - integration/replication-4
  54 seconds - unit/obuf-limits
  313 seconds - unit/memefficiency

\o/ All tests passed without errors!

Cleanup: may take some time... OK

测试最后一步等待时间有点长~~~我还以为卡了

如果出现进入Redis连接拒绝,请先确定服务是否启动了

gulugu@Dell:~$ redis-cli
Could not connect to Redis at 127.0.0.1:6379: Connection refused
not connected> 

作为后台进程启动服务 redis-server &

redis-server &
[1] 14496
wangxiong@Dell:~/Soft/redis-2.8.9$ [14496] 02 Aug 16:46:52.436 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
[14496] 02 Aug 16:46:52.437 # You requested maxclients of 10000 requiring at least 10032 max file descriptors.
[14496] 02 Aug 16:46:52.437 # Redis can't set maximum open files to 10032 because of OS error: Operation not permitted.
[14496] 02 Aug 16:46:52.437 # Current maximum open files is 1024. maxclients has been reduced to 4064 to compensate for low ulimit. If you need higher maxclients increase 'ulimit -n'.
                _._                                                  
           _.-``__ ''-._                                             
      _.-``    `.  `_.  ''-._           Redis 2.8.9 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._                                   
 (    '      ,       .-`  | `,    )     Running in stand alone mode
 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
 |    `-._   `._    /     _.-'    |     PID: 14496
  `-._    `-._  `-./  _.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |           http://redis.io        
  `-._    `-._`-.__.-'_.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |                                  
  `-._    `-._`-.__.-'_.-'    _.-'                                   
      `-._    `-.__.-'    _.-'                                       
          `-._        _.-'                                           
              `-.__.-'                                               

[14496] 02 Aug 16:46:52.438 # Server started, Redis version 2.8.9
[14496] 02 Aug 16:46:52.438 # 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.
[14496] 02 Aug 16:46:52.438 * The server is now ready to accept connections on port 6379

正常访问:

gulugulu@Dell:~$ redis-cli
127.0.0.1:6379> 

因为没有添加开机启动,所以开机的时候我执行启动服务,发现端口并不是6379,所以还是会报连接拒绝,我尝试这样去绑定端口6379

gg@Dell:~$ redis-server --port 6379 --daemonize yes
gg@Dell:~$ redis-cli -p 6379
127.0.0.1:6379> exit
gg@Dell:~$ ps -aux|grep redis
root      3913  0.0  0.0  85864  4304 pts/4    T    17:19   0:00 sudo redis-server
root      3973  0.0  0.0  85864  4488 pts/4    T    17:21   0:00 sudo redis-server
wangxio+  4071  0.0  0.0  15100  6040 pts/0    S+   17:25   0:00 redis-cli
wangxio+  4105  0.0  0.1  42260  8692 ?        Ssl  17:26   0:00 redis-server *:6379                     
wangxio+  4119  0.0  0.0  15956  2216 pts/10   S+   17:27   0:00 grep --color=auto redis
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值