码迷,mamicode.com
首页 > 其他好文 > 详细

Redis 安装手册

时间:2018-11-16 18:20:51      阅读:205      评论:0      收藏:0      [点我收藏+]

标签:page   1.2   command   ret   input   over   生效   maximum   rest   

本文档 以 redhat 6.2 版本为例安装(其他系统版本需自行下载相关文件)
  1. 创建用户
    adduser redis

  2. 修改用户密码

passwd redis

  1. 新建 tools 文件夹备份安装文件

mkdir /home/redis/tools

将本次安装会是用到的 tar、zip 、rpm 等文件 ftp 到该目录

  1. 解压安装文件并将解压后的文件夹移动到 /home/redis/ 下 ,重命名文件夹为 redis-master

tar -xzvf redis-3.2.9.tar.gz

mv ../redis-3.2.9

cd ../

mv redis-3.2.9 redis-master

  1. 在 /home/redis/redis-master 下创建相关目录

mkdir -p /home/redis/redis-master/bin
mkdir -p /home/redis/redis-master/log
mkdir -p /home/redis/redis-master/pid
mkdir -p /home/redis/redis-master/db
mkdir -p /home/redis/redis-master/sentinel
mkdir -p /home/redis/redis-master/conf

  1. 安装

    1). 安装 gcc 编译环境 (root 帐号操作)

    rpm -ivh kernel-headers-2.6.32-220.el6.x86_64.rpm
    rpm -ivh glibc-headers-2.12-1.47.el6.x86_64.rpm
    rpm -ivh glibc-devel-2.12-1.47.el6.x86_64.rpm
    rpm -ivh mpfr-2.4.1-6.el6.x86_64.rpm
    rpm -ivh ppl-0.10.2-11.el6.x86_64.rpm
    rpm -ivh cloog-ppl-0.15.7-1.2.el6.x86_64.rpm 
    rpm -ivh cpp-4.4.6-3.el6.x86_64.rpm
    rpm -ivh gcc-4.4.6-3.el6.x86_64.rpm
    
    按顺序安装上面的 rpm 包 
    
    rpm -ivh 包名

    2). 安装 tcl8.6.6 (root 帐号操作)

    unzip tcl866-src.zip
    
    mv tcl8.6.6 /opt/
    
    cd /opt/tcl8.6.6/unix
    
    ./configure
    
    make
    
    make install /opt/tcl8.6.6
    
    安装完成

    3). 安装 redis (redis 帐号操作)

    cd /home/redis/redis-master
    
    进入之前的 redis-master 目录
    
    PREFIX=/home/redis/redis-master make MALLOC=libc test // 测试安装 OK 
    
    PREFIX=/home/redis/redis-master/ make MALLOC=libc //正式安装
    
    PREFIX=/home/redis/redis-master/ make install
    
    安装完成
    
    修改 redis.conf 基础配置
    
        a. #bind 127.0.0.1  (注释掉)
    
        b. port 6379 (生产建议修改为其他端口)
    
        c. daemonize yes 设为后台运行程序
    
        d. pidfile /home/redis/redis-master/pid/redis.pid 设置 pid 目录
    
        e. logfile /home/redis/redis-master/log/redis.log 设置 log 目录
    
        f. dir /home/redis/redis-master/db 设置 db 目录
    
        g. requirepass redis 设置连接密码

    redis 功能优化配置 :

    1. root 编辑/etc/sysctl.conf ,修改 vm.overcommit_memory=1,然后执行 sysctl -p 使配置文件生效 (如果没有此配置项 ,请在末尾添加)
    2. root 执行 echo 511 > /proc/sys/net/core/somaxconn 并修改 /etc/rc.local ,在末尾添加 echo 511 > /proc/sys/net/core/somaxconn
    3. root 执行 echo never > /sys/kernel/mm/transparent_hugepage/enabled 并修改 /etc/rc.local , 在末尾添加 echo never > /sys/kernel/mm/transparent_hugepage/enabled
    4. root 编辑 /etc/security/limits.conf

      添加 
      redis soft nofile 65535
      redis hard nofile 65535
      
      注意: redis 为安装启动运行 redis 的用户 ,如果使用 xxx 用户安装启动则配置为

      xxx soft nofile 65535
      xxx hard nofile 65535

以上配置修改用于解决下面四个警告:
3711:S 02 Mar 09:42:28.018 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
3711:S 02 Mar 09:42:28.046 # 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.
3711:S 02 Mar 09:42:28.084 # 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.
4063:S 02 Mar 09:57:33.685 # You requested maxclients of 10000 requiring at least 10032 max file descriptors.
4063:S 02 Mar 09:57:33.687 # Server can‘t set maximum open files to 10032 because of OS error: Operation not permitted.
4063:S 02 Mar 09:57:33.687 # Current maximum open files is 4096. maxclients has been reduced to 4064 to compensate for low ulimit. If you need higher maxclients increase ‘ulimit -n‘.

root 开放端口
/sbin/iptables -I INPUT -p tcp --dport 6379 -j ACCEPT
/etc/rc.d/init.d/iptables save
/etc/init.d/iptables restart

Redis 安装手册

标签:page   1.2   command   ret   input   over   生效   maximum   rest   

原文地址:http://blog.51cto.com/jstorm/2318072

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!