zoukankan      html  css  js  c++  java
  • linux安装redis详解

    安装:

    1.获取redis资源

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

    2.切换到/usr/local目录下,解压

    cd /usr/local
    
    tar xzvf redis-4.0.8.tar.gz

    3.重命名

    mv /redis-4.0.8 redis

    3.安装

    cd redis-4.0.8
    
    make
    
    cd src
    
    make install PREFIX=/usr/local/redis

    4.移动配置文件到安装目录下

    cd ../
    
    mkdir /usr/local/redis/etc
    
    mv redis.conf /usr/local/redis/etc

     5.配置redis为后台启动

    vi /usr/local/redis/etc/redis.conf 
    --将daemonize no 改成daemonize yes

    6.将redis加入到开机启动

    vi /etc/rc.local 
    # 添加命令
    /usr/local/redis/bin/redis-server /usr/local/redis/etc/redis.conf

    7.开启redis

    /usr/local/redis/bin/redis-server /usr/local/redis/etc/redis.conf 

    常用命令  

      redis-server /usr/local/redis/etc/redis.conf //启动redis

      pkill redis  //停止redis

      卸载redis:

        rm -rf /usr/local/redis //删除安装目录

        rm -rf /usr/bin/redis-* //删除所有redis相关命令脚本

        rm -rf /root/download/redis-4.0.4 //删除redis解压文件夹

    FAQ:安装过程中会遇到一些问题?

    1、执行make install 提示"make: *** No rule to make target `install'. "

    答:出现此种情况,是linux系统没有安装先决条件。依次安装以下依赖包

                yum install gcc

                yum install pcre pcre-devel

                yum install zlib zlib-devel

               yum install openssl openssl-devel

      

    网上还有种方法,一次性安装比较全的依赖:

    yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5-devel libidn libidn-devel openssl openssl-devel nss_ldap openldap openldap-devel  openldap-clients openldap-servers libxslt-devel libevent-devel ntp  libtool-ltdl bison libtool vim-enhanced  

    2、安装先决条件后,再执行make install,报错“zmalloc.h:50:31: fatal error: jemalloc/jemalloc.h: No such file or directory”

    原因分析:

    在README 有这个一段话。

    Allocator
    ———
    
    Selecting a non-default memory allocator when building Redis is done by setting
    the `MALLOC` environment variable. Redis is compiled and linked against libc
    malloc by default, with the exception of jemalloc being the default on Linux
    systems. This default was picked because jemalloc has proven to have fewer
    fragmentation problems than libc malloc.
    
    To force compiling against libc malloc, use:
    
    % make MALLOC=libc
    
    To compile against jemalloc on Mac OS X systems, use:
    
    % make MALLOC=jemalloc
    
    说关于分配器allocator, 如果有MALLOC 这个 环境变量, 会有用这个环境变量的 去建立Redis。
    
    而且libc 并不是默认的 分配器, 默认的是 jemalloc, 因为 jemalloc 被证明 有更少的 fragmentation problems 比libc。
    
    但是如果你又没有jemalloc 而只有 libc 当然 make 出错。 所以加这么一个参数

    解决办法: 使用以下命令

    make MALLOC=libc

               

  • 相关阅读:
    将代码托管到github服务器之SSH验证
    将代码托管到github服务器之HTTPS验证
    git的基本介绍和使用
    iOS之UITableView组头组尾视图/标题悬停
    iOS事件传递->处理->响应
    NSRunLoop
    Podfile使用说明
    cocoapods安装
    block
    自定义UIBarButtonItem
  • 原文地址:https://www.cnblogs.com/Jungle1219/p/13091666.html
Copyright © 2011-2022 走看看