• Centos-6.8 x64安装redis-3.2.8


    Redis源码安装 安装环境Centos-6.8 x64 redis-3.2.8.tar.gz(放置在download下)
    1.解压文件
    [root@LS-Min download]# tar -zxvf redis-3.2.8.tar.gz 
    ...
    [root@LS-Min download]# cd redis-3.2.8
    2.编译文件
    [root@LS-Min redis-3.2.8]# make
    ...
    [root@LS-Min redis-3.2.8]# cd src
    3.测试是否编译成功
    [root@LS-Min src]# ./redis-server 
    4590:C 03 Mar 14:07:31.106 # Warning: no config file specified, using the default config. In order to specify a config file use ./redis-server /path/to/redis.conf
    4590:M 03 Mar 14:07:31.106 * Increased maximum number of open files to 10032 (it was originally set to 1024).
                    _._                                                  
               _.-``__ ''-._                                             
          _.-``    `.  `_.  ''-._           Redis 3.2.8 (00000000/0) 64 bit
      .-`` .-```.  ```/    _.,_ ''-._                                   
     (    '      ,       .-`  | `,    )     Running in standalone mode
     |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
     |    `-._   `._    /     _.-'    |     PID: 4590
      `-._    `-._  `-./  _.-'    _.-'                                   
     |`-._`-._    `-.__.-'    _.-'_.-'|                                  
     |    `-._`-._        _.-'_.-'    |           http://redis.io        
      `-._    `-._`-.__.-'_.-'    _.-'                                   
     |`-._`-._    `-.__.-'    _.-'_.-'|                                  
     |    `-._`-._        _.-'_.-'    |                                  
      `-._    `-._`-.__.-'_.-'    _.-'                                   
          `-._    `-.__.-'    _.-'                                       
              `-._        _.-'                                           
                  `-.__.-'                                               
    
    4./usr/local下建立redis文件夹
    [root@LS-Min src]# mkdir -p /usr/local/redis-3.2.8/conf
    [root@LS-Min src]# mkdir -p /usr/local/redis-3.2.8/bin
    5.将redis-3.2.8/src目录下可执行文件复制
    [root@LS-Min src]# cp redis-server redis-cli redis-benchmark redis-check-aof redis-check-rdb redis-sentinel /usr/local/redis-3.2.8/bin
    [root@LS-Min src]# cd ../
    [root@LS-Min redis-3.2.8]# cp redis.conf /usr/local/redis-3.2.8/conf
    6.作为系统服务
    [root@LS-Min redis-3.2.8]# cp utils/redis_init_script /etc/init.d/redis
    
    7.编辑redis.conf
    [root@LS-Min redis-3.2.8]# vim /usr/local/redis-3.2.8/conf/redis.conf
     (1)bind 127.0.0.1 后追加 本机ip 
        bind 127.0.0.1 10.21.36.120
     (2)daemonize no --> daemonize yes 守护进程运行
     (3)pidfile /var/run/redis_6379.pid -->pidfile /var/run/redis.pid
     (4)logfile "" --> logfile "/usr/local/redis-3.2.8/logs/redis.log"
     (5)#requirepass foobared --> requirepass abcd1234 启用密码
    [root@LS-Min redis-3.2.8]#wq 
    8.编辑init.d/redis
    [root@LS-Min redis-3.2.8]# vim /etc/init.d/redis
     (1)增加
      # chkconfig: 2345 90 10 
      # description: Redis is a persistent key-value database
     (2)EXEC=/usr/local/redis-3.2.8/bin/redis-server
     (3)CLIEXEC=/usr/local/redis-3.2.8/bin/redis-cli
     (4)PIDFILE=/var/run/redis.pid
     (5)CONF="/usr/local/redis-3.2.8/conf/redis.conf"
     (6)$CLIEXEC -p $REDISPORT shutdown -->$CLIEXEC -a "abcd1234" -p $REDISPORT shutdown  #-a 指定密码
    [root@LS-Min redis-3.2.8]#wq
    9.开机自启动
     [root@LS-Min redis-3.2.8]# chkconfig redis on
    
    10. 开放防火墙6379端口
    [root@LS-Min ~]# vim /etc/sysconfig/iptables
     -A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT 下增加
     -A INPUT -m state --state NEW -m tcp -p tcp --dport 6379  -j ACCEPT
    [root@LS-Min ~]# service iptables restart
    iptables: Setting chains to policy ACCEPT: filter          [  OK  ]
    iptables: Flushing firewall rules:                         [  OK  ]
    iptables: Unloading modules:                               [  OK  ]
    iptables: Applying firewall rules:                         [  OK  ]
    
     常见问题:
    (1)bind 127.0.0.1 10.21.36.120 绑定10.21.36.120后,让其他机器访问,不能去掉127.0.0.1否则本机服务stop会失败
     [root@LS-Min ~]# service redis stop
       Stopping ...
       Could not connect to Redis at 127.0.0.1:6379: Connection refused
       Waiting for Redis to shutdown ...
       Waiting for Redis to shutdown ...
    (2)启用密码后,/etc/init.d/redis 要做修改$CLIEXEC -p $REDISPORT shutdown -->$CLIEXEC -a "abcd1234" -p $REDISPORT shutdown
       否则本机服务stop会失败
       [root@LS-Min ~]# service redis stop
       Stopping ...
       OK
       (error) NOAUTH Authentication required.
       Waiting for Redis to shutdown ...
       Waiting for Redis to shutdown ..
    
    (3))service redis stop失败时 停止redis服务
       [root@LS-Min ~]# ps -ef|grep redis
       root      4518     1  0 13:47 ?        00:00:00 /usr/local/redis-3.2.8/bin/redis-server 127.0.0.1:6379                        
       [root@LS-Min ~]# kill -9 4518
       [root@LS-Min ~]# rm -rf /var/run/redis.pid 
    
    
       

     

  • 相关阅读:
    textarea宽度、高度自动适应处理方法
    Table嵌套去掉子table的外边框
    发现原来自己挺能给自己找理由开脱的
    Life is not the amount of breath you take.
    在遍历ResultSet的循环中再执行SQL会发生什么(前提:同一个Statement)
    按月查询数据
    Oracle SQL 判断某表是否存在
    在Python程序中执行linux命令
    在Oracle中十分钟内创建一张千万级别的表
    Redis Sentinel结构 及相关文档
  • 原文地址:https://www.cnblogs.com/ahjx1628/p/6496529.html
Copyright © 2020-2023  润新知