zoukankan      html  css  js  c++  java
  • linux 6安装 redis2.6

    linux 6安装 redis2.6

    安装

    1、下载源文件

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

    2、安装所需依赖

    # yum install -y tcl gcc gcc-c++

    3、解压编译安装

    # tar -zxvf redis-2.6.17.tar.gz 

    make

    # cd redis-2.6.17
    # make
    ...
        LINK redis-server
        INSTALL redis-sentinel
        CC redis-cli.o
        LINK redis-cli
        CC redis-benchmark.o
        LINK redis-benchmark
        CC redis-check-dump.o
        LINK redis-check-dump
        CC redis-check-aof.o
        LINK redis-check-aof
    
    Hint: To run 'make test' is a good idea ;)
    
    make[1]: Leaving directory `/root/download/redis-2.6.17/src'
    #

    make test

    # make test
    ...
      41 seconds - unit/type/list-3
      36 seconds - unit/obuf-limits
    
    o/ All tests passed without errors!
    
    Cleanup: may take some time... OK
    make[1]: Leaving directory `/root/download/redis-2.6.17/src'
    #

    make install

    # make install
    cd src && make install
    make[1]: Entering directory `/root/download/redis-2.6.17/src'
    
    Hint: To run 'make test' is a good idea ;)
    
    mkdir -p /usr/local/bin
        INSTALL install
        INSTALL install
        INSTALL install
        INSTALL install
        INSTALL install
    make[1]: Leaving directory `/root/download/redis-2.6.17/src'
    # 
    # cd deps/
    [root@centos6 deps]# ls
    hiredis  jemalloc  linenoise  lua  Makefile
    # 
    ]# 
    # make hiredis  jemalloc  linenoise  lua
    ...
    MAKE linenoise
    cd linenoise && make
    make[1]: Entering directory `/root/download/redis-2.6.17/deps/linenoise'
    make[1]: `linenoise.o' is up to date.
    make[1]: Leaving directory `/root/download/redis-2.6.17/deps/linenoise'
    MAKE lua
    cd lua/src && make all CFLAGS="-O2 -Wall -DLUA_ANSI " MYLDFLAGS=""
    make[1]: Entering directory `/root/download/redis-2.6.17/deps/lua/src'
    make[1]: Nothing to be done for `all'.
    make[1]: Leaving directory `/root/download/redis-2.6.17/deps/lua/src'
    # echo $?
    0
    #

    4、开启服务

    执行./install_server你可能需要root权限,这个脚本可能会问你几个问题,然后为系统重新启动,Redis作为后台守护进程运行所需要的所有配置设置好。你可以使用/etc/init.d/redis_<portnumber>,例如/etc/init.d/redis_6379中的脚本来启动和停止Redis。

    # cd src/
    # ./redis-server 
    [5857] 13 Dec 10:40:46.080 # Warning: no config file specified, using the default config. In order to specify a config file use ./redis-server /path/to/redis.conf
    [5857] 13 Dec 10:40:46.081 * Max number of open files set to 10032
                    _._                                                  
               _.-``__ ''-._                                             
          _.-``    `.  `_.  ''-._           Redis 2.6.17 (00000000/0) 64 bit
      .-`` .-```.  ```/    _.,_ ''-._                                   
     (    '      ,       .-`  | `,    )     Running in stand alone mode
     |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
     |    `-._   `._    /     _.-'    |     PID: 5857
      `-._    `-._  `-./  _.-'    _.-'                                   
     |`-._`-._    `-.__.-'    _.-'_.-'|                                  
     |    `-._`-._        _.-'_.-'    |           http://redis.io        
      `-._    `-._`-.__.-'_.-'    _.-'                                   
     |`-._`-._    `-.__.-'    _.-'_.-'|                                  
     |    `-._`-._        _.-'_.-'    |                                  
      `-._    `-._`-.__.-'_.-'    _.-'                                   
          `-._    `-.__.-'    _.-'                                       
              `-._        _.-'                                           
                  `-.__.-'                                               
    
    [5857] 13 Dec 10:40:46.091 # Server started, Redis version 2.6.17
    [5857] 13 Dec 10:40:46.091 # 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.
    [5857] 13 Dec 10:40:46.091 * The server is now ready to accept connections on port 6379

    5、验证进程

    # netstat -lnp | grep redis
    tcp        0      0 0.0.0.0:6379                0.0.0.0:*                   LISTEN      5857/./redis-server 
    # 
    # ps -ef | grep redis
    root      5857  1761  0 10:40 pts/0    00:00:00 ./redis-server
    root      5883  5864  0 10:44 pts/1    00:00:00 grep redis

    6、配置文件

    redis命令目录

    # ll /usr/local/bin/
    total 13656
    -rwxr-xr-x. 1 root root 4165748 Dec 13 10:22 redis-benchmark
    -rwxr-xr-x. 1 root root   22185 Dec 13 10:22 redis-check-aof
    -rwxr-xr-x. 1 root root   45427 Dec 13 10:22 redis-check-dump
    -rwxr-xr-x. 1 root root 4232272 Dec 13 10:22 redis-cli
    -rwxr-xr-x. 1 root root 5504090 Dec 13 10:22 redis-server

    基础配置

    创建配置文件目录

    # whereis redis          
    redis: /etc/redis
    # ll /etc/redis/
    total 28
    -rw-r--r--. 1 root root 25750 Dec 13 10:32 6379.conf
    #
    #
    # mkdir /usr/local/redis/etc -p
    # cp /etc/redis/6379.conf /usr/local/redis/etc/
    # ln -s /usr/local/redis/etc/6379.conf   /etc/redis.conf
    #
    # touch /var/log/redis.log

    配置redis.conf文件

    # cat /etc/redis.conf |grep -v '#' |grep -v '^$'
    daemonize yes
    pidfile /var/run/redis_6379.pid
    port 6379
    timeout 0
    tcp-keepalive 0
    loglevel notice
    logfile /var/log/redis_6379.log
    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 /var/lib/redis/6379
    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
    #

    手动启动redis-server

    # redis-server /etc/redis.conf 
    [root@centos6 ~]# 
    # ps -ef | grep redis          
    root      5946     1  0 11:01 ?        00:00:00 redis-server /etc/redis.conf
    root      5950  5864  0 11:01 pts/1    00:00:00 grep redis

    7、redis关闭

    # redis-cli
    redis 127.0.0.1:6379> 
    redis 127.0.0.1:6379> shutdown save
    redis 127.0.0.1:6379> quit
    # 
    # ps -ef | grep redis          
    root      5954  5864  0 11:02 pts/1    00:00:00 grep redis
    # 
  • 相关阅读:
    系统编程-进程-fork深度理解、vfork简介
    九鼎S5PV210开发板的SD卡启动、uboot tftp升级内核镜像
    jiffies相关时间比较函数time_after、time_before详解
    Java基础第六章(循环结构二)
    Java基础第五章(循环结构一)
    Java基础第四章(选择结构二)
    Java基础第三章(选择结构一)
    Java基础第二章(变量、数据类型和运算符)
    Java基础第一章
    HTML iframe的使用
  • 原文地址:https://www.cnblogs.com/zwj-linux/p/12036884.html
Copyright © 2011-2022 走看看