为什么我的 redis 服务器不活动 - Ubuntu 16.04

Why my redis-server is inactive - Ubunut 16.04

我已经在我的 ubuntu 机器上安装了 Redis 和 Redis 服务器,但问题是它们都不是 ACTIVE

命令:root@muhammad-mohsin:/# systemctl status redis.service

安装使用:Digital Oceans

● redis.service - Redis In-Memory Data Store
   Loaded: loaded (/etc/systemd/system/redis.service; enabled; vendor preset: enabled)
   Active: active (running) since Wed 2018-02-21 22:53:42 PKT; 5s ago
  Process: 12113 ExecStop=/usr/local/bin/redis-cli shutdown (code=exited, status=0/SUCCESS)
 Main PID: 12115 (redis-server)
   CGroup: /system.slice/redis.service
           └─12115 /usr/local/bin/redis-server 127.0.0.1:6379       

Feb 21 22:53:42 muhammad-mohsin redis-server[12115]:   `-._    `-._`-.__.-'_.-'    _.-'
Feb 21 22:53:42 muhammad-mohsin redis-server[12115]:       `-._    `-.__.-'    _.-'
Feb 21 22:53:42 muhammad-mohsin redis-server[12115]:           `-._        _.-'
Feb 21 22:53:42 muhammad-mohsin redis-server[12115]:               `-.__.-'
Feb 21 22:53:42 muhammad-mohsin redis-server[12115]: 12115:M 21 Feb 22:53:42.620 # WARNING: The TCP backlog setting of 511 cannot be enforced bec
Feb 21 22:53:42 muhammad-mohsin redis-server[12115]: 12115:M 21 Feb 22:53:42.620 # Server initialized
Feb 21 22:53:42 muhammad-mohsin redis-server[12115]: 12115:M 21 Feb 22:53:42.620 # WARNING overcommit_memory is set to 0! Background save may fai
Feb 21 22:53:42 muhammad-mohsin redis-server[12115]: 12115:M 21 Feb 22:53:42.620 # WARNING you have Transparent Huge Pages (THP) support enabled 
Feb 21 22:53:42 muhammad-mohsin redis-server[12115]: 12115:M 21 Feb 22:53:42.620 * DB loaded from disk: 0.000 seconds
Feb 21 22:53:42 muhammad-mohsin redis-server[12115]: 12115:M 21 Feb 22:53:42.620 * Ready to accept connections

命令:root@muhammad-mohsin:/# systemctl status redis-server.service

安装使用:apt-get install redis-server

● redis-server.service - Advanced key-value store
   Loaded: loaded (/lib/systemd/system/redis-server.service; enabled; vendor preset: enabled)
  Drop-In: /etc/systemd/system/redis-server.service.d
           └─redis.override.conf
   Active: inactive (dead) (Result: exit-code) since Wed 2018-02-21 22:53:12 PKT; 1min 2s ago
     Docs: http://redis.io/documentation,
           man:redis-server(1)
 Main PID: 16461 (code=exited, status=0/SUCCESS)

Feb 21 22:53:11 muhammad-mohsin systemd[1]: Failed to start Advanced key-value store.
Feb 21 22:53:11 muhammad-mohsin systemd[1]: redis-server.service: Unit entered failed state.
Feb 21 22:53:11 muhammad-mohsin systemd[1]: redis-server.service: Failed with result 'exit-code'.
Feb 21 22:53:12 muhammad-mohsin systemd[1]: redis-server.service: Service hold-off time over, scheduling restart.
Feb 21 22:53:12 muhammad-mohsin systemd[1]: Stopped Advanced key-value store.
Feb 21 22:53:12 muhammad-mohsin systemd[1]: redis-server.service: Start request repeated too quickly.
Feb 21 22:53:12 muhammad-mohsin systemd[1]: Failed to start Advanced key-value store.

如何让它们同时激活?

请问两者有什么区别吗?

另外,每次都需要在机器上安装什么? Redis 还是 Redis 服务器?

还有,为什么我无法使用 api:port 在浏览器中访问 Redis?

这些问题也请回复我。

"Redis" == "Redis Server"。他们的意思是一样的。区别在于版本号以及这两个安装的管理方式。

DigitalOcean 指南让您从源代码编译和安装 redis,为您提供最新版本的 redis(当前为 4.0.8)。这是一种非常手动的方法,不会给您留下自动更新机制。然而,如果你想要添加到 redis 的许多功能中的任何一个,因为旧版本 apt 将安装这是一个不错的选择。只知道您必须为每次更新重复该过程。

备选方案是您所做的另一件事:sudo apt install redis-server。这告诉 Ubuntu 的内置包管理器 apt 安装 redis 版本 3.0.6,它远远落后于最新的稳定版本:4.0.8.

真的,除非您正在使用高级 Redis 功能并且知道您需要 4.0 功能,否则我建议您坚持使用 apt 版本并禁用手动版本。您将获得坚如磐石的稳定性和自动安全更新。

如果您真的想同时拥有两个 运行 服务器,问题可能出在端口号上。每个服务器都需要单独的 redis.conf 文件。您可以更新 DigitalOcean 指南让您创建的 redis.service systemd 文件,以指向与手动安装的 /etc/redis/redis.conf 不同的配置文件。这些文件几乎完全相同,但需要将它们配置为使用不同的端口和不同的存储位置。