Redis之环境搭建

安装redis

[root@TA30-53 redis]# tar zxvf redis-3.0.7.tar.gz 
[root@TA30-53 redis]# cd redis-3.0.7
[root@TA30-53 redis-3.0.7]# ll
总用量 152
-rw-rw-r--  1 root root 36761 1月  25 2016 00-RELEASENOTES
-rw-rw-r--  1 root root    53 1月  25 2016 BUGS
-rw-rw-r--  1 root root  1805 1月  25 2016 CONTRIBUTING
-rw-rw-r--  1 root root  1487 1月  25 2016 COPYING
drwxrwxr-x  6 root root  4096 1月  25 2016 deps
-rw-rw-r--  1 root root    11 1月  25 2016 INSTALL
-rw-rw-r--  1 root root   151 1月  25 2016 Makefile
-rw-rw-r--  1 root root  4223 1月  25 2016 MANIFESTO
-rw-rw-r--  1 root root  5201 1月  25 2016 README
-rw-rw-r--  1 root root 41560 1月  25 2016 redis.conf
-rwxrwxr-x  1 root root   271 1月  25 2016 runtest
-rwxrwxr-x  1 root root   280 1月  25 2016 runtest-cluster
-rwxrwxr-x  1 root root   281 1月  25 2016 runtest-sentinel
-rw-rw-r--  1 root root  7109 1月  25 2016 sentinel.conf
drwxrwxr-x  2 root root  4096 1月  25 2016 src
drwxrwxr-x 10 root root  4096 1月  25 2016 tests
drwxrwxr-x  5 root root  4096 1月  25 2016 utils
执行make 对Redis解压后文件进行编译,
编译完成之后,可以看到解压文件redis-3.0.7 中会有对应的src、conf等文件夹
编译成功后,进入src文件夹,执行make install进行Redis安装
make[1]: Leaving directory `/usr/local/redis/redis-3.0.7/src'
[root@TA30-53 redis-3.0.7]# ll
总用量 152
-rw-rw-r--  1 root root 36761 1月  25 2016 00-RELEASENOTES
-rw-rw-r--  1 root root    53 1月  25 2016 BUGS
-rw-rw-r--  1 root root  1805 1月  25 2016 CONTRIBUTING
-rw-rw-r--  1 root root  1487 1月  25 2016 COPYING
drwxrwxr-x  6 root root  4096 3月  10 16:17 deps
-rw-rw-r--  1 root root    11 1月  25 2016 INSTALL
-rw-rw-r--  1 root root   151 1月  25 2016 Makefile
-rw-rw-r--  1 root root  4223 1月  25 2016 MANIFESTO
-rw-rw-r--  1 root root  5201 1月  25 2016 README
-rw-rw-r--  1 root root 41560 1月  25 2016 redis.conf
-rwxrwxr-x  1 root root   271 1月  25 2016 runtest
-rwxrwxr-x  1 root root   280 1月  25 2016 runtest-cluster
-rwxrwxr-x  1 root root   281 1月  25 2016 runtest-sentinel
-rw-rw-r--  1 root root  7109 1月  25 2016 sentinel.conf
drwxrwxr-x  2 root root  4096 3月  10 16:18 src
drwxrwxr-x 10 root root  4096 1月  25 2016 tests
drwxrwxr-x  5 root root  4096 1月  25 2016 utils
[root@TA30-53 redis-3.0.7]# cd src/
[root@TA30-53 src]# make install

Hint: It's a good idea to run 'make test' ;)

    INSTALL install
    INSTALL install
    INSTALL install
    INSTALL install
    INSTALL install

部署redis

首先为了方便管理,将Redis文件中的conf配置文件和常用命令移动到统一文件中
[root@TA30-53 redis-3.0.7]# mkdir bin
[root@TA30-53 redis-3.0.7]# mkdir etc
[root@TA30-53 redis-3.0.7]# mv redis.conf etc/         
[root@TA30-53 redis-3.0.7]# cd src/
[root@TA30-53 src]# mv mkreleasehdr.sh redis-benchmark redis-check-aof redis-check-dump redis-cli redis-server ../bin/

启动Redis 服务

[root@TA30-53 redis-3.0.7]# cd bin
[root@TA30-53 bin]# ll
总用量 15472
-rwxrwxr-x 1 root root     566 1月  25 2016 mkreleasehdr.sh
-rwxr-xr-x 1 root root 4589195 3月  10 16:18 redis-benchmark
-rwxr-xr-x 1 root root   22233 3月  10 16:18 redis-check-aof
-rwxr-xr-x 1 root root   45451 3月  10 16:18 redis-check-dump
-rwxr-xr-x 1 root root 4698410 3月  10 16:18 redis-cli
-rwxr-xr-x 1 root root 6471367 3月  10 16:18 redis-server
[root@TA30-53 bin]# ./redis-server 
3873:C 10 Mar 17:49:58.850 # Warning: no config file specified, using the default config. In order to specify a config file use ./redis-server /path/to/redis.conf
3873:M 10 Mar 17:49:58.851 * Increased maximum number of open files to 10032 (it was originally set to 1024).
                _._                                                  
           _.-``__ ''-._                                             
      _.-``    `.  `_.  ''-._           Redis 3.0.7 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._                                   
 (    '      ,       .-`  | `,    )     Running in standalone mode
 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
 |    `-._   `._    /     _.-'    |     PID: 3873
  `-._    `-._  `-./  _.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |           http://redis.io        
  `-._    `-._`-.__.-'_.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |                                  
  `-._    `-._`-.__.-'_.-'    _.-'                                   
      `-._    `-.__.-'    _.-'                                       
          `-._        _.-'                                           
              `-.__.-'                                               

3873:M 10 Mar 17:49:58.853 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
3873:M 10 Mar 17:49:58.853 # Server started, Redis version 3.0.7
3873:M 10 Mar 17:49:58.853 # 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.
3873:M 10 Mar 17:49:58.853 # 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.
3873:M 10 Mar 17:49:58.854 * The server is now ready to accept connections on port 6379
注意:这里直接执行./redis-server 启动的Redis服务,是在前台直接运行的,执行完该命令后,如果Lunix关闭当前会话,则Redis服务也随即关闭。正常情况下,启动Redis服务需要从后台启动,并且指定启动配置文件。

后台启动redis服务

首先编辑conf文件,将daemonize属性改为yes(表明需要在后台运行)
cd etc/
Vi redis.conf

再次启动redis服务,并指定启动服务配置文件
[root@TA30-53 bin]# ./redis-server ../etc/redis.conf 

服务端启动成功后,执行redis-cli启动Redis 客户端,查看端口号
[root@TA30-53 bin]# ./redis-cli 
127.0.0.1:6379> 
[root@TA30-53 ~]# netstat -tunpl|grep 6379
tcp        0      0 0.0.0.0:6379                0.0.0.0:*                   LISTEN      4037/./redis-server 
[root@TA30-53 ~]# 
[root@TA30-53 bin]# ./redis-cli shutdown
[root@TA30-53 bin]# netstat -tunpl|grep 6379

                
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值