zoukankan      html  css  js  c++  java
  • Centos7 linux下通过源码安装redis以及使用

    下载redis安装包

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

    解压压缩包

    tar -zxvf redis-5.0.3.tar.gz

    yum安装gcc依赖

    [root@iZwz991stxdwj560bfmadtZ local]# yum -y install gcc

    跳转到redis解压目录下

    cd redis-5.0.3

    编译

    [root@iZwz991stxdwj560bfmadtZ redis-5.0.3]# make MALLOC=libc

    安装

    [root@iZwz991stxdwj560bfmadtZ redis-4.0.6]# cd src && make install
        CC Makefile.dep
    
    Hint: It's a good idea to run 'make test' ;)
    
        INSTALL install
        INSTALL install
        INSTALL install
        INSTALL install
        INSTALL install

    测试是否能够启动redis

    [root@iZwz991stxdwj560bfmadtZ 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

    移动目录

    sudo mv redis-5.0.3 /usr/local/redis

    修改配置文件(后台运行)

    sudo vi /usr/local/redis/redis.conf 

    daemonize no

    修改为

    daemonize yes

    使用配置文件启动

    redis-server /usr/local/redis/redis.conf

    关闭redis

    首先使用ps -aux | grep redis查看redis进程

    [root@iZwz991stxdwj560bfmadtZ src]# ps -aux | grep redis
    root     18714  0.0  0.1 141752  2008 ?        Ssl  13:07   0:00 ./redis-server 127.0.0.1:6379
    root     18719  0.0  0.0 112644   968 pts/0    R+   13:09   0:00 grep --color=auto redis

    使用kill命令杀死进程

    [root@iZwz991stxdwj560bfmadtZ src]# kill -9 18714

    客户端连接

    [root@localhost bin]# redis-cli
    127.0.0.1:6379> 

    参考:

    https://www.cnblogs.com/zuidongfeng/p/8032505.html

  • 相关阅读:
    [leetcode]49. Group Anagrams变位词归类
    [leetcode]40. Combination Sum II组合之和(每元素限用一次)
    [leetcode]39. Combination Sum组合之和
    [leetcode]35. Search Insert Position寻找插入位置
    [leetcode]28. Implement strStr()实现strStr()
    [leetcode]25. Reverse Nodes in k-Group每k个节点反转一下
    [leetcode]24. Swap Nodes in Pairs交换节点对
    SVG基础知识 Adobe Illustrator绘制SVG
    Java静态方法和实例方法 java中的数组作为形参传入
    SVG可伸缩的矢量图形
  • 原文地址:https://www.cnblogs.com/sea-stream/p/10390711.html
Copyright © 2011-2022 走看看