Redis安装ForCentOS6.4_64

来源:互联网 发布:qt creator是什么软件 编辑:程序博客网 时间:2024/05/20 23:02

Redis安装ForCentOS6.4_64

分类: linux服务篇 2013-10-21 16:23 291人阅读 评论(0) 收藏 举报目录(?)[+]下载获取Redis源码http://code.google.com/p/redis/downloads/list[html] view plaincopycd /usr/src/  wget http://redis.googlecode.com/files/redis-2.6.14.tar.gz  解压[html] view plaincopytar -zxvf redis-2.6.14.tar.gz  cd redis-2.6.14  测试[html] view plaincopy[root@dev redis-2.6.14]# ls  00-RELEASENOTES  CONTRIBUTING  deps     Makefile   README      runtest        src    utils  BUGS             COPYING       INSTALL  MANIFESTO  redis.conf  sentinel.conf  tests  [root@dev redis-2.6.14]# ./runtest  //测试运行  You need tcl 8.5 or newer in order to run the Redis test    //缺包tcl 8.5的支持  [root@dev redis-2.6.14]# yum list|grep tcl  db4-tcl.x86_64                            4.7.25-17.el6               CentOS6.4   graphviz-tcl.x86_64                       2.26.0-10.el6               CentOS6.4   libpurple-tcl.x86_64                      2.7.9-5.el6.2               CentOS6.4   postgresql-pltcl.x86_64                   8.4.13-1.el6_3              CentOS6.4   rrdtool-tcl.x86_64                        1.3.8-6.el6                 CentOS6.4   ruby-tcltk.x86_64                         1.8.7.352-7.el6_2           CentOS6.4   setools-libs-tcl.x86_64                   3.3.7-4.el6                 CentOS6.4   sqlite-tcl.x86_64                         3.6.20-1.el6                CentOS6.4   tcl.i686                                  1:8.5.7-6.el6               CentOS6.4   tcl.x86_64                                1:8.5.7-6.el6               CentOS6.4 //yum中有tcl包此处直接yum安装之  tcl-brlapi.x86_64                         0.5.4-7.el6                 CentOS6.4   tcl-devel.i686                            1:8.5.7-6.el6               CentOS6.4   tcl-devel.x86_64                          1:8.5.7-6.el6               CentOS6.4   tcl-pgtcl.x86_64                          1.6.2-3.el6                 CentOS6.4   tclx.i686                                 8.4.0-15.el6                CentOS6.4   tclx.x86_64                               8.4.0-15.el6                CentOS6.4   tclx-devel.i686                           8.4.0-15.el6                CentOS6.4   tclx-devel.x86_64                         8.4.0-15.el6                CentOS6.4   xchat-tcl.x86_64                          1:2.8.8-1.el6               CentOS6.4  <pre name="code" class="html">[root@dev redis-2.6.14]# yum -y install ctl.x86_64</pre>  如果没有yum源的话可以去此处download安装[html] view plaincopy# make  ...//此处略去N个字  # make test  ...  \o/ All tests passed without errors!    Cleanup: may take some time... OK  make[1]: Leaving directory `/usr/src/redis-2.6.14/src'   //install OK    # cd /usr/src/  # mv /usr/src/redis-2.6.14 /usr/local/redis  # cd /usr/local/redis/  [root@dev redis]# src/redis-server   [28586] 21 Oct 15:50:14.705 # Warning: no config file specified, using the default config. In order to specify a config file use src/redis-server /path/to/redis.conf  [28586] 21 Oct 15:50:14.707 * Max number of open files set to 10032     //可以指定配置文件 src/redis-server /path/to/redis.conf              _._                                                               _.-``__ ''-._                                                //文件的最大打开数是10032         _.-``    `.  `_.  ''-._           Redis 2.6.14 (00000000/0) 64 bit    .-`` .-```.  ```\/    _.,_ ''-._                                      (    '      ,       .-`  | `,    )     Running in stand alone mode   |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379   |    `-._   `._    /     _.-'    |     PID: 28586    `-._    `-._  `-./  _.-'    _.-'                                      |`-._`-._    `-.__.-'    _.-'_.-'|                                     |    `-._`-._        _.-'_.-'    |           http://redis.io            `-._    `-._`-.__.-'_.-'    _.-'                                      |`-._`-._    `-.__.-'    _.-'_.-'|                                     |    `-._`-._        _.-'_.-'    |                                      `-._    `-._`-.__.-'_.-'    _.-'                                           `-._    `-.__.-'    _.-'                                                   `-._        _.-'                                                           `-.__.-'                                                   [28586] 21 Oct 15:50:14.709 # Server started, Redis version 2.6.14  [28581] 21 Oct 15:47:05.658 # 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.  [28586] 21 Oct 15:50:14.709 * The server is now ready to accept connections on port 6379  //[28581]内核参数vm.overcommit_memory这个目前是0 应该设置成1    # echo "vm.overcommit_memory = 1" >> /etc/sysctl.conf && sysctl -p            //解决28581的问题  # vi /etc/security/limits.conf        //解决28586 在此文件中加入如下内容  * soft nofile 387300    #此处的内容只要大于它所警告的10032就可以  * hard nofile 387300    # ulimit -n 387300     //让参数立即生效  # ulimit -n  387300  # src/redis-server /usr/local/redis/redis.conf  //启动服务 所有的警告都消失  配置[html] view plaincopy# pwd  /usr/local/redis  # cat redis.conf   daemonize yes         //后台运行  pidfile /var/run/redis.pid  port 6379  timeout 0  tcp-keepalive 0  loglevel notice  logfile stdout  databases 16  save 900 1  save 300 10  save 60 10000  stop-writes-on-bgsave-error yes  rdbcompression yes  rdbchecksum yes  dbfilename dump.rdb  dir ./  slave-serve-stale-data yes  slave-read-only yes  repl-disable-tcp-nodelay no  slave-priority 100  appendonly no  appendfsync everysec  no-appendfsync-on-rewrite no  auto-aof-rewrite-percentage 100  auto-aof-rewrite-min-size 64mb  lua-time-limit 5000  slowlog-log-slower-than 10000  slowlog-max-len 128  hash-max-ziplist-entries 512  hash-max-ziplist-value 64  list-max-ziplist-entries 512  list-max-ziplist-value 64  set-max-intset-entries 512  zset-max-ziplist-entries 128  zset-max-ziplist-value 64  activerehashing yes  client-output-buffer-limit normal 0 0 0  client-output-buffer-limit slave 256mb 64mb 60  client-output-buffer-limit pubsub 32mb 8mb 60  hz 10  aof-rewrite-incremental-fsync yes    # src/redis-server /usr/local/redis/redis.conf  ///usr/local/redis/redis.conf配置文件启动服务  测试[html] view plaincopy# netstat -nlp|grep 6379  tcp        0      0 0.0.0.0:6379                0.0.0.0:*                   LISTEN      28612/src/redis-ser   # ps -ef|grep redis |grep -v grep  root     28612     1  0 16:11 ?        00:00:00 src/redis-server /usr/local/redis/redis.conf  # src/redis-cli   redis 127.0.0.1:6379> ping  PONG  redis 127.0.0.1:6379> set foo br       //存入一个keyfoo = valnebr的的值  OK                                     //存入成功  redis 127.0.0.1:6379> get foo          //获取keyfoovalue  "br"  redis 127.0.0.1:6379> incr cai           (integer) 1  redis 127.0.0.1:6379> incr cai  (integer) 2  redis 127.0.0.1:6379> help              //帮助 帮助方法  redis-cli 2.6.14  Type: "help @<group>" to get a list of commands in <group>        "help <command>" for help on <command>        "help <tab>" to get a list of possible help topics        "quit" to exit    redis 127.0.0.1:6379> help set   //例如      SET key value [EX seconds] [PX milliseconds] [NX|XX]    summary: Set the string value of a key    since: 1.0.0    group: string    redis 127.0.0.1:6379> help incr      INCR key    summary: Increment the integer value of a key by one    since: 1.0.0    group: string    redis 127.0.0.1:6379> quit          //退出  附加[html] view plaincopyredis-benchmark -h localhost -p 6379 -c 100 -n 100000   100个并发连接,100000个请求,检测hostlocalhost 端口为6379redis服务性能测试    redis-cli -h localhost -p 6379 monitor   Dump all the received requests in real time;   监控hostlocalhost,端口为6379redis的连接及读写操作     redis-cli -h localhost -p 6380 info   提供hostlocalhost,端口为6379redis服务的统计信息   登录示例:redis-cli -h 192.168.1.11 --raw看数据库大小:dbsize其他命令上面基本上都讲到了。
0 0
原创粉丝点击