美文网首页
Redis3.2.11安装 CentOS7.2

Redis3.2.11安装 CentOS7.2

作者: adeng2016 | 来源:发表于2017-12-29 15:11 被阅读52次

    安装步骤

    官网下载,执行命令如下:

    $ wget http://download.redis.io/releases/redis-3.2.11.tar.gz
    $ tar xzf redis-3.2.11.tar.gz
    $ cd redis-3.2.11
    $ make
    

    The binaries that are now compiled are available in the src directory. Run Redis with:

    $ src/redis-server
    

    You can interact with Redis using the built-in client:

    $ src/redis-cli
    redis> set foo bar
    OK
    redis> get foo
    "bar"
    

    配置文件

    一般按端口号复制一份cp redis.conf redis_6379.conf,进行编辑vi redis_6379.conf,常用配置项如下:

    # bind 127.0.0.1  //屏蔽bind 127.0.0.1运行远程访问
    protected-mode no //设置no 3.2之后需要关闭才能远程访问
    requirepass myPassword  //设置密码 开启验证
    daemonize no //是否后台启动,如果需要配合systemctl则设置no
    

    开机启动

    添加开机启动项vi /etc/systemd/system/redis-server.service,内容如下:

    [Unit]
    Description=The redis-server Process Manager
    After=syslog.target network.target
    
    [Service]
    Type=simple
    PIDFile=/var/run/redis_6379.pid
    ExecStart=/usr/local/redis/redis-server /usr/local/redis/redis.conf         
    ExecReload=/bin/kill -USR2 $MAINPID
    ExecStop=/bin/kill -SIGINT $MAINPID
    
    [Install]
    WantedBy=multi-user.target
    

    设置开机启动

    systemctl daemon-reload 
    systemctl start redis-server.service 
    systemctl enable redis-server.service
    

    检查是否安装成功

    $ ps -A | grep redis
      477 ?        00:00:00 redis-server
    

    问题1

    make过程中报错 make[3]: gcc:命令未找到 , 安装gcc如下:

    yum -y install gcc automake autoconf libtool make
    

    问题2

    按照gcc后安装,又报错 redis安装zmalloc.h:50:31: 致命错误:jemalloc/jemalloc.h:没有那个文件或目录 。原因参考这篇文章,解决方式如下:

    make MALLOC=libc
    

    问题3

    安装成功后执行make test,报错You need tcl 8.5 or newer in order to run the Redis test, 解决方式如下:

    wget http://downloads.sourceforge.net/tcl/tcl8.6.1-src.tar.gz  
    sudo tar xzvf tcl8.6.1-src.tar.gz  -C /usr/local/  
    cd  /usr/local/tcl8.6.1/unix/  
    sudo ./configure  
    sudo make  
    sudo make install  
    

    终于\o/ All tests passed without errors! OK了。

    参考

    centOS6.3 安装redis make报错 zmalloc.h:50:31: 错误:jemalloc/jemalloc.h:没有那个文件或目录
    Linux CentOS 7编译redis报错"cc:未找到命令"解决方案
    Ubuntu 14.04下Redis安装报错:“You need tcl 8.5 or newer in order to run the Redis test”问题解决
    centos7 安装redis 开机启动
    redis开启远程访问

    相关文章

      网友评论

          本文标题:Redis3.2.11安装 CentOS7.2

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