首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Linux容器内redis.conf中的IP绑定地址

Linux容器内redis.conf中的IP绑定地址
EN

Stack Overflow用户
提问于 2021-07-24 21:40:43
回答 1查看 24关注 0票数 0

在Ubuntu 20.04中,我创建了一个Linux容器,我称之为"ubuntuone",Ubuntu 20.04也是如此。

在Linux Container中,我安装了Redis,但我得到的是Could not connect to Redis at 127.0.0.1:6379

代码语言:javascript
复制
(base) raphy@pc:~$ lxc exec ubuntuone -- /bin/bash
root@ubuntuone:~# redis-cli
Could not connect to Redis at 127.0.0.1:6379: Connection refused
not connected> 

这是linux容器中ifconfig的输出:

代码语言:javascript
复制
(base) raphy@pc:~$ lxc exec ubuntuone -- /bin/bash
root@ubuntuone:~# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 10.65.116.195  netmask 255.255.255.0  broadcast 10.65.116.255
        inet6 fe80::216:3eff:fe5b:de10  prefixlen 64  scopeid 0x20<link>
        inet6 fd42:2159:3d69:bcae:216:3eff:fe5b:de10  prefixlen 64  scopeid 
0x0<global>
        ether 00:16:3e:5b:de:10  txqueuelen 1000  (Ethernet)
        RX packets 2004  bytes 903491 (903.4 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 2419  bytes 1053136 (1.0 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 8  bytes 496 (496.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 8  bytes 496 (496.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

我还尝试在/etc/redis/redis.conf中进行设置:

代码语言:javascript
复制
bind 10.65.116.195 ::1

但是我得到了同样的错误

更新1)

redis-server已安装,但redis-service.service守护程序有一些问题:

代码语言:javascript
复制
root@ubuntuone:~# systemctl status redis-server.service
● redis-server.service - Advanced key-value store
     Loaded: loaded (/lib/systemd/system/redis-server.service; 
enabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Wed 2021-07-28 
08:41:03 UTC; 3min 54s ago
       Docs: http://redis.io/documentation,
             man:redis-server(1)
   Main PID: 2640 (code=exited, status=1/FAILURE)
     Status: "Redis is loading..."

Jul 28 08:41:03 ubuntuone systemd[1]: Starting Advanced key-value 
store...
Jul 28 08:41:03 ubuntuone systemd[1]: redis-server.service: Main 
process exited, code=exited, status=1/FAILURE
Jul 28 08:41:03 ubuntuone systemd[1]: redis-server.service:    
Failed with result 'exit-code'.
Jul 28 08:41:03 ubuntuone systemd[1]: Failed to start Advanced 
key-value store.



root@ubuntuone:~# journalctl -xe
-- Subject: A start job for unit redis-server.service has begun 
execution
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
-- 
-- A start job for unit redis-server.service has begun execution.
-- 
-- The job identifier is 2538.
Jul 28 08:41:03 ubuntuone systemd[1]: redis-server.service: Main    
process exited, code=exited, status=1/FAILURE
-- Subject: Unit process exited
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
-- 
-- An ExecStart= process belonging to unit redis-server.service 
has exited.
-- 
-- The process' exit code is 'exited' and its exit status is 1.
Jul 28 08:41:03 ubuntuone systemd[1]: redis-server.service:   
Failed with result 'exit-code'.
-- Subject: Unit failed
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
-- 
-- The unit redis-server.service has entered the 'failed' state 
with result 'exit-code'.
Jul 28 08:41:03 ubuntuone systemd[1]: Failed to start Advanced 
key-value store.
-- Subject: A start job for unit redis-server.service has failed
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
-- 
-- A start job for unit redis-server.service has finished with a 
failure.
-- 
-- The job identifier is 2538 and the job result is failed.
Jul 28 08:44:39 ubuntuone systemd[1]: Reloading.
Jul 28 08:44:39 ubuntuone systemd[1]: systemd-udevd.service:     
Attaching egress BPF program to cgroup /sys/fs/cgro>
Jul 28 08:44:39 ubuntuone systemd[1]: systemd-journald.service:    
Attaching egress BPF program to cgroup /sys/fs/c>
Jul 28 08:44:39 ubuntuone systemd[1]: systemd-logind.service:     
Attaching egress BPF program to cgroup /sys/fs/cgr>

如何解决这个问题?

EN

回答 1

Stack Overflow用户

发布于 2021-07-28 16:03:21

在阅读您的评论后,似乎Redis服务只是安装了,而没有启动。您可以使用redis-server二进制文件启动它。启动后,您将能够连接。

此外,您也不需要在Ubuntu容器中安装redis服务器。在Debian或其他软件上已经有了预建的redis镜像。请查看Redis Docker Hub

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/68510532

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档