美文网首页我爱编程
Centos6.9 安装Redis

Centos6.9 安装Redis

作者: 9995857 | 来源:发表于2017-05-15 14:25 被阅读0次

    安装Redis

    将redis-stable.tar 拷贝到 /soft 下

    1. 解压并安装
      tar -xvf redis-stable.tar
      cd redis-stable
      make
      make install

    2. 修改配置文件
      mkdir -p /var/redis
      cd /var/redis
      mkdir data log run
      mkdir -p /etc/redis
      cp /soft/redis-stable/redis.conf /etc/redis/
      vi /etc/redis/redis.conf

    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 10.211.55.3 #这里直接注释掉,说明任何IP均可以访问

    bind 127.0.0.1

    1. 修改端口

    Accept connections on the specified port, default is 6379 (IANA #815344).

    If port 0 is specified Redis will not listen on a TCP socket.

    port 6379

    port 8079

    1. redis在后台运行

    By default Redis does not run as a daemon. Use 'yes' if you need it.

    Note that Redis will write a pid file in /var/run/redis.pid when daemonized.

    daemonize no

    daemonize yes

    1. 修改pid目录为新建目录

    Creating a pid file is best effort: if Redis is not able to create it

    nothing bad happens, the server will start and run normally.

    pidfile /var/run/redis_6379.pid

    pidfile /var/redis/run/redis.pid

    1. 修改dump目录为新建目录

    The Append Only File will also be created inside this directory.

    Note that you must specify a directory here, not a file name.

    dir ./

    dir /var/redis/data

    1. 修改log存储目录为新建目录

    Specify the log file name. Also the empty string can be used to force

    Redis to log on the standard output. Note that if you use standard

    output for logging but daemonize, logs will be sent to /dev/null

    logfile ""

    logfile /var/redis/log/redis.log

    1. 修改密码

    requirepass foobared

    requirepass rongstone.com

    1. 启动Redis
      redis-server /etc/redis/redis.conf

    2. 制作成服务
      cp utils/redis_init_script /etc/init.d/redis
      chmod +x /etc/init.d/redis
      vi /etc/init.d/redis

    REDISPORT=6379
    EXEC=/usr/local/bin/redis-server
    CLIEXEC=/usr/local/bin/redis-cli

    PIDFILE=/var/run/redis_${REDISPORT}.pid

    CONF="/etc/redis/${REDISPORT}.conf"

    PIDFILE=/var/redis/run/redis.pid
    CONF="/etc/redis/redis.conf"

    1. 设置自启动
      chkconfig redis on
      vi /etc/init.d/redis

    !/bin/sh

    chkconfig: 2345 90 10

    description: Redis is a persistent key-value database

    Simple Redis init.d script conceived to work on Linux systems as it does use of the /proc filesystem.

    1. 启动/停止Redis服务
      service redis start
      service redis stop

    2. 测试连接
      redis-cli -h 127.0.0.1 -p 6379 -a **********
      -a 密码

    相关文章

      网友评论

        本文标题:Centos6.9 安装Redis

        本文链接:https://www.haomeiwen.com/subject/gtrhxxtx.html