• centos6下安装redis单机版


    1.下载redis,在根目录创建software文件夹,使用winScp工具上传文件到centos服务器的/software/目录下

    跳转至根目录: cd /
    创建software文件夹: mkdir software
    下载文件地址:链接:https://pan.baidu.com/s/1-H_vR42SHegeMkPwmjCpOQ 密码:ywsq

    2.,再解压文件

    tar -zxvf redis-4.0.6.tar.gz 

    3.yum安装gcc依赖 , 遇到提示一直按y然后Enter确认

    yum install gcc

    4.进入redis的Home路径下编译安装

    make MALLOC=libc

     5.将/software/redis-4.0.6/src目录下的文件加到/usr/local/bin目录

    cd src && make install

     6.测试是否安装成功 

     ./redis-server
    2310:C 26 Jul 22:50:20.805 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
    2310:C 26 Jul 22:50:20.805 # Redis version=4.0.6, bits=64, commit=00000000, modified=0, pid=2310, just started
    2310:C 26 Jul 22:50:20.805 # Warning: no config file specified, using the default config. In order to specify a config file use ./redis-server /path/to/redis.conf
    2310:M 26 Jul 22:50:20.806 * Increased maximum number of open files to 10032 (it was originally set to 1024).
                    _._                                                  
               _.-``__ ''-._                                             
          _.-``    `.  `_.  ''-._           Redis 4.0.6 (00000000/0) 64 bit
      .-`` .-```.  ```/    _.,_ ''-._                                   
     (    '      ,       .-`  | `,    )     Running in standalone mode
     |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
     |    `-._   `._    /     _.-'    |     PID: 2310
      `-._    `-._  `-./  _.-'    _.-'                                   
     |`-._`-._    `-.__.-'    _.-'_.-'|                                  
     |    `-._`-._        _.-'_.-'    |           http://redis.io        
      `-._    `-._`-.__.-'_.-'    _.-'                                   
     |`-._`-._    `-.__.-'    _.-'_.-'|                                  
     |    `-._`-._        _.-'_.-'    |                                  
      `-._    `-._`-.__.-'_.-'    _.-'                                   
          `-._    `-.__.-'    _.-'                                       
              `-._        _.-'                                           
                  `-.__.-'                                               
    
    2310:M 26 Jul 22:50:20.818 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
    2310:M 26 Jul 22:50:20.818 # Server initialized

    出现如上图,说明redis安装成功.

    7.以后台进程方式启动redis

      1)修改redis.conf文件

    将文件中内容  daemonize no   
    修改为
             daemonize yes 

      2)指定redis.conf文件启动

    切换至redis的目录下:
    
    ./redis-server /software/redis-4.0.6/redis.conf

    2336:C 26 Jul 22:59:27.916 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
    2336:C 26 Jul 22:59:27.916 # Redis version=4.0.6, bits=64, commit=00000000, modified=0, pid=2336, just started
    2336:C 26 Jul 22:59:27.916 # Configuration loaded

      3)关闭redis进程

    查找redis进程   ps -ef | grep redis

    root 2337 1 0 22:59 ? 00:00:00 ./redis-server 127.0.0.1:6379
    root 2356 1429 0 23:01 pts/0 00:00:00 grep redis

      杀死进程  kill -9 2337

    8.设置redis开机自启动 

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

    mkdir /etc/redis

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

    cp /software/redis-4.0.6/redis.conf /etc/redis/6379.conf

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

    cp /software/redis-4.0.6/utils/redis_init_script /etc/init.d/redisd

      4)设置redis开机自启动

    先切换到/etc/init.d目录下    cd /etc/init.d
    执行自启命令    chkconfig redisd on
    
    结果如下;
    [root@redisServer init.d]# chkconfig redisd on
    redisd 服务不支持 chkconfig
    
    解决方法:
    使用vim编辑redisd文件,在第一行加入如下两行注释,保存退出
    # chkconfig:   2345 90 10
    # description:  Redis is a persistent key-value database
    
    注释的意思是,redis服务必须在运行级2,3,4,5下被启动或关闭,启动的优先级是90,关闭的优先级是10。
    再执行命令 chkconfig redisd on

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

    启动:service redisd start 

    [root@redisServer ~]# service redisd start
    Starting Redis server...
    1433:C 26 Jul 23:18:41.623 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
    1433:C 26 Jul 23:18:41.623 # Redis version=4.0.6, bits=64, commit=00000000, modified=0, pid=1433, just started
    1433:C 26 Jul 23:18:41.623 # Configuration loaded

    关闭:service redisd stop

    [root@redisServer ~]# service redisd stop
    Stopping ...
    Redis stopped

    如果需要用远程连接还需要

      1.开放端口号 6379 , 开放方式在我的博客中有

      2.修改配置文件redis.conf 

    protected-mode yes
    修改为 protected-mode no


    在这行内容下找到 bind 127.0.0.1

    # IF YOU ARE SURE YOU WANT YOUR INSTANCE TO LISTEN TO ALL THE INTERFACES
    # JUST COMMENT THE FOLLOWING LINE.
    # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    将  bind 127.0.0.1
    修改为 #bind 127.0.0.1
    ---------------------------------------------持之以恒
  • 相关阅读:
    Java1:Chapter3
    css3圆角和阴影效果
    css3兼容各版本浏览器前缀
    DOM
    数组方法
    Math方法
    JSON
    字符串方法
    日期对象
    定时器
  • 原文地址:https://www.cnblogs.com/slbb/p/9371997.html
Copyright © 2020-2023  润新知