Redis的编译安装

Redis 官网:http://redis.io/

实验环境:

  • OS:centos6
  • 软件:redis2.4.4(截至2011-12的最新版本)

测试整个编译安装的基本过程如下:

[1].编译安装过程

ps: 该软件的编译安装不需要执行 ./configure 和make install 命令

如果看到有以下提示信息:

Hint: To run ‘make test’ is a good idea ;)

再执行命令: # make test

应该会看到如下信息:

\o/ All tests passed without errors!

Cleanup: may take some time… OK

上面的提示信息表示:测试没有错误都通过,编译成功

[2]. 配置:

这样以后就可以直接在shell窗口下调用这些命令了。

复制配置文件redis.conf

启动redis

控制台会看到如下信息:

[28335] 16 Dec 16:37:41 * Server started, Redis version 2.4.4
[28335] 16 Dec 16:37:41 # 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.
[28335] 16 Dec 16:37:41 * The server is now ready to accept connections on port 6379
[28335] 16 Dec 16:37:41 – 0 clients connected (0 slaves), 717480 bytes in use
[28335] 16 Dec 16:37:46 – 0 clients connected (0 slaves), 717480 bytes in use
[28335] 16 Dec 16:37:51 – 0 clients connected (0 slaves), 717480 bytes in use

ps:默认配置中redis程序启动不是以后台守护进程的模式启动的

[3]. 修改配置文件:/usr/local/etc/redis/redis.conf

具体的参数含义可以看conf文件中的注释,测试时只是简单修改了下面几个参数:

ps: 要确保你设置的目录已经存在

执行下面的测试命令:

可以看到数据库的数据文件:

可以看到redis的日志文件如下:

# cat /var/log/redis.log
[28468] 16 Dec 17:04:53 * Server started, Redis version 2.4.4
[28468] 16 Dec 17:04:53 # 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.
[28468] 16 Dec 17:04:53 * DB loaded from disk: 0 seconds
[28468] 16 Dec 17:04:53 * The server is now ready to accept connections on port 6379
[28468] 16 Dec 17:04:53 – 0 clients connected (0 slaves), 717512 bytes in use
[28468] 16 Dec 17:04:58 – 0 clients connected (0 slaves), 717512 bytes in use
[28468] 16 Dec 17:05:01 – Accepted 127.0.0.1:54313
[28468] 16 Dec 17:05:03 – 1 clients connected (0 slaves), 726040 bytes in use
[28468] 16 Dec 17:05:08 – 1 clients connected (0 slaves), 726040 bytes in use
[28468] 16 Dec 17:05:13 – DB 0: 1 keys (0 volatile) in 4 slots HT.
[28468] 16 Dec 17:05:13 – 1 clients connected (0 slaves), 726296 bytes in use
[28468] 16 Dec 17:05:18 – DB 0: 1 keys (0 volatile) in 4 slots HT.
[28468] 16 Dec 17:05:18 – 1 clients connected (0 slaves), 726280 bytes in use
[28468] 16 Dec 17:05:20 # User requested shutdown…
[28468] 16 Dec 17:05:20 * Saving the final RDB snapshot before exiting.
[28468] 16 Dec 17:05:21 * DB saved on disk
[28468] 16 Dec 17:05:21 * Removing the pid file.
[28468] 16 Dec 17:05:21 # Redis is now ready to exit, bye bye…

有关上面日志中的红色告警信息的说明:

这个告警信息是由于当内存分配策略设置为“0”时,启动会有警告提示,根据它的提示我们可以修改相应的配置文件/etc/sysctl.conf或者是通过sysctl命令设置,使之生效即可。

原创文章,转载请注明: 转载自micmiu – 软件开发+生活点滴[ http://www.micmiu.com/ ]

本文链接地址: http://www.micmiu.com/nosql/redis-install/

发表评论?

0 条评论。

发表评论


注意 - 你可以用以下 HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">