CentOS 中 redis 安装

前端之家收集整理的这篇文章主要介绍了CentOS 中 redis 安装前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

第一步:下载redis安装包

wget http://download.redis.io/releases/redis-4.0.6.tar.gz

 

第二步:解压压缩包

tar -zxvf redis-4.0.6.tar.gz

第三步:yum安装gcc依赖

yum install gcc

第四步:跳转到redis解压目录下

cd redis-4.0.11

第五步:编译安装

make MALLOC=libc  

 

[[email protected] redis-4.0.6]# cd src && make install
    CC Makefile.dep

Hint: Its a good idea to run make test ;)

    INSTALL install
    INSTALL install
    INSTALL install
    INSTALL install
    INSTALL install

 

 

第六步 : 启动redis

        先切换到redis src目录下

  1、直接启动redis

          ./redis-server

[[email protected] src]# ./redis-server
18685:C 13 Dec 12:56:12.507 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
18685:C 13 Dec 12:56:12.507 # Redis version=4.0.6,bits=64,commit=00000000,modified=0,pid=18685,just started
18685:C 13 Dec 12:56:12.507 # Warning: no config file specified,using the default config. In order to specify a config file use ./redis-server /path/to/redis.conf
                _._                                                  
           _.-``__ ‘‘-._                                             
      _.-``    `.  `_.  ‘‘-._           Redis 4.0.6 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ‘‘-._                                   
 (    ,.-`  | `,)     Running in standalone mode
 |`-._`-...-` __...-.``-._|` _.-|     Port: 6379
 |    `-._   `._    /     _.-    |     PID: 18685
  `-._    `-._  `-./  _.-    _.-                                   
 |`-._`-._    `-.__.-    _.-_.-|                                  
 |    `-._`-._        _.-_.-    |           http://redis.io        
  `-._    `-._`-.__.-_.-    _.-                                   
 |`-._`-._    `-.__.-    _.-_.-|                                  
 |    `-._`-._        _.-_.-    |                                  
  `-._    `-._`-.__.-_.-    _.-                                   
      `-._    `-.__.-    _.-                                       
          `-._        _.-                                           
              `-.__.-                                               

18685:M 13 Dec 12:56:12.508 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
18685:M 13 Dec 12:56:12.508 # Server initialized
18685:M 13 Dec 12:56:12.508 # 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.
18685:M 13 Dec 12:56:12.508 # 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.
18685:M 13 Dec 12:56:12.508 * Ready to accept connections

 

2、设置redis开机自启动

  1、在/etc目录下新建redis目录

       mkdir redis

      2、将/usr/local/redis-4.0.6/redis.conf 文件复制一份到/etc/redis目录下,并命名为6379.conf

   3、将redis的启动脚本复制一份放到/etc/init.d目录下

    

   4、设置redis开机自启动

      先切换到/etc/init.d目录下

      然后执行自启命令

 

[[email protected] init.d]# chkconfig redisd on

  5、现在可以直接已服务的形式启动和关闭redis了

      启动:

     service redisd start 

  

[[email protected] 桌面]# service redisd start
Starting Redis server...
4456:C 26 Dec 20:10:40.367 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
4456:C 26 Dec 20:10:40.367 # Redis version=4.0.11,pid=4456,just started
4456:C 26 Dec 20:10:40.367 # Configuration loaded
4456:M 26 Dec 20:10:40.368 * Increased maximum number of open files to 10032 (it was originally set to 1024).
                _._                                                  
           _.-``__ ‘‘-._                                             
      _.-``    `.  `_.  ‘‘-._           Redis 4.0.11 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,)     Running in standalone mode
 |`-._`-...-` __...-.``-._|` _.-|     Port: 6379
 |    `-._   `._    /     _.-    |     PID: 4456
  `-._    `-._  `-./  _.-    _.-                                   
 |`-._`-._    `-.__.-    _.-_.-|                                  
 |    `-._`-._        _.-_.-    |           http://redis.io        
  `-._    `-._`-.__.-_.-    _.-                                   
 |`-._`-._    `-.__.-    _.-_.-|                                  
 |    `-._`-._        _.-_.-    |                                  
  `-._    `-._`-.__.-_.-    _.-                                   
      `-._    `-.__.-    _.-                                       
          `-._        _.-                                           
              `-.__.-                                               

4456:M 26 Dec 20:10:40.369 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
4456:M 26 Dec 20:10:40.369 # Server initialized
4456:M 26 Dec 20:10:40.369 # 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.
4456:M 26 Dec 20:10:40.369 # 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.
4456:M 26 Dec 20:10:40.370 * DB loaded from disk: 0.000 seconds
4456:M 26 Dec 20:10:40.370 * Ready to accept connections

 

 

   关闭

    service redisd stop

  

[email protected] 桌面]#     service redisd stop
Stopping ...
Redis stopped
[[email protected] 桌面]# 

 

     此时大功告成!!!!!!!!

猜你在找的CentOS相关文章