美文网首页
解决-ubuntu18.04 安装redis无法启动

解决-ubuntu18.04 安装redis无法启动

作者: Zero_75 | 来源:发表于2019-01-25 16:10 被阅读0次

    环境

    Ubuntu 18.04
    Port 6379
    Redis version 5:4.0.9-1

    1-安装

    apt install redis
    

    2-安装完成-自启时提示启动服务失败

    Errors were encountered while processing:
     redis-server
     redis
    E: Sub-process /usr/bin/dpkg returned an error code (1)
    W: Operation was interrupted before it could finish
    root@iZ2zeiudkwjc07o9jfa4fgZ:/var/log/nginx# systemctl status redis-server.service
    ● redis-server.service - Advanced key-value store
       Loaded: loaded (/lib/systemd/system/redis-server.service; disabled; vendor preset: enabled)
       Active: activating (start) since Fri 2019-01-25 15:15:44 CST; 20s ago
         Docs: http://redis.io/documentation,
               man:redis-server(1)
      Process: 28248 ExecStart=/usr/bin/redis-server /etc/redis/redis.conf (code=exited, status=0/SUCCESS)
        Tasks: 0 (limit: 2325)
       CGroup: /system.slice/redis-server.service
    
    Jan 25 15:15:44 iZ2zeiudkwjc07o9jfa4fgZ systemd[1]: Starting Advanced key-value store...
    Jan 25 15:15:44 iZ2zeiudkwjc07o9jfa4fgZ systemd[1]: redis-server.service: Can't open PID file /var/run/redis/redis-server.pid (yet?) after start: No such file or directory
    

    3-查看日志信息

    cat /var/log/redis/redis-server.log
    #提示
     Creating Server TCP listening socket ::1:6379: bind: Cannot assign requested address
     oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
    

    4-初步分析

    主机上禁用了IPv6,而Ubuntu的redis-server软件包(版本5:4.0.9-1)附带了:绑定127.0.0.1 :: 1

    5-解决办法

    修改redis配置文件中的 bind 地址;注释 bind 地址或将 bind 地址修改为 0.0.0.0

    vim /etc/redis/redis.conf
    // 注释bind地址
    #bind 127.0.0.1 ::1
    //或修改bind地址-并允许其开放访问
    bind 0.0.0.0
    

    6-启动redis 服务

    service redis-server start
    

    7-检查服务及端口

    systemctl status redis-server
    //提示信息
    #redis-server.service - Advanced key-value store
    #Active: active (running) since Fri 2019-01-25 15:24:47 CST; 41min ago
    
    netstat -ntpl | grep 6379
    //提示信息
    #tcp        0      0 0.0.0.0:6379            0.0.0.0:*               LISTEN      28507/redis-server
    

    相关文章

      网友评论

          本文标题:解决-ubuntu18.04 安装redis无法启动

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