设为首页 收藏本站
查看: 692|回复: 0

[经验分享] Redis的编译安装

[复制链接]

尚未签到

发表于 2016-12-18 08:38:56 | 显示全部楼层 |阅读模式
  blog迁移至:http://www.micmiu.com
  Redis 官网:http://redis.io/
  实验环境:

  • OS:centos6
  • 软件:redis2.4.4(截至本文的最新版本)
  测试整个编译安装的基本过程如下:
  [1].编译安装过程
  # wget http://redis.googlecode.com/files/redis-2.4.4.tar.gz
  # tar -zxvf redis-2.4.4.tar.gz
  # mv redis-2.4.4 /usr/local/
  # cd /usr/local/redis-2.4.4
  ps: 该软件的编译安装不需要执行 ./configure 和make install 命令
  # make
  如果看到有以下提示信息:
Hint: To run 'make test' is a good idea ;)
  再执行命令# make test
   应该会看到如下信息:
\o/ All tests passed without errors!

Cleanup: may take some time... OK
  上面的提示信息表示:测试没有错误都通过,编译成功
  [2]. 配置:
  # cp src/redis-server /usr/local/bin
  # cp src/redis-benchmark /usr/local/bin
  # cp src/redis-cli /usr/local/bin
  # cp src/redis-check-dump /usr/local/bin
  # cp src/redis-check-aof /usr/local/bin
  这样以后就可以直接在shell窗口下调用这些命令了。
  复制配置文件redis.conf:
  # mkdir /usr/local/etc/redis
  # cp redis.conf /usr/local/etc/redis
  启动redis:
  # redis-server /usr/local/etc/redis/redis.conf
  控制台会看到如下信息:
[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文件中的注释,测试时只是简单修改了下面几个参数:
daemonize no => yes   是否后天守护进程
logfile stdout => /var/log/redis.log   日志文件
dir ./ => /var/db/redis    目录设置
  ps: 要确保你设置的目录已经存在 
  执行下面的测试命令:
# redis-server /usr/local/etc/redis/redis.conf
# redis-cli
redis 127.0.0.1:6379> set myblog "sjsky.iyunv.com"
OK
redis 127.0.0.1:6379> get myblog
"sjsky.iyunv.com"
redis 127.0.0.1:6379> shutdown
redis 127.0.0.1:6379> exit

   可以看到数据库的数据文件:
# ls -lh /var/db/redis/
总用量 4.0K
-rw-r--r--. 1 root root 36 12月 16 17:05 dump.rdb

   可以看到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...

  有关上面日志中的告警信息的说明:
# 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.
  这个告警信息是由于当内存分配策略设置为“0”时,启动会有警告提示,根据它的提示我们可以修改相应的配置文件/etc/sysctl.conf或者是通过sysctl命令设置,使之生效即可。
  本文连接:http://sjsky.iyunv.com/blog/1313886
  转载请注明来自:Michael's blog @ http://sjsky.iyunv.com
  

----------------------------- 分 ------------------------------ 隔 ------------------------------ 线 ------------------------------

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-315769-1-1.html 上篇帖子: java使用jedis操作redis 下篇帖子: Redis 基本命令
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表