能否在容器中部署tidb集群

为提高效率,提问时请提供以下信息,问题描述清晰可优先响应。

  • 【TiDB 版本】:单机版/生产v3 +
  • 【问题描述】:
    1.打算使用容器来部署单机版的tidb集群进行测试,发现无法启动docker服务进程,有无适用容器为底层搭建单机版集群的方案呢?
    2.能否使用容器替代物理机搭建tidb生产集群?有无实际用例提供?性能效用如何?

1 tidb 容器单机版部署,可以使用 docker-compose 方案,可参见 https://github.com/pingcap/tidb-docker-compose 项目快速创建。注意,单机版不要用在生产环境中哦。https://pingcap.com/docs-cn/stable/how-to/get-started/deploy-tidb-from-docker-compose/

2 容器和非容器部署差异在进程实例的管理上。我们有基于 k8s 的整套方案,https://github.com/pingcap/tidb-operatorhttps://pingcap.com/docs-cn/stable/tidb-in-kubernetes/tidb-operator-overview/

我的意思是,我的底层本身已经是容器,不是物理机,然后安装了docker并无法启动 database-test-test.bombay app]# cd tidb-docker-compose && docker-compose pull Pulling pd0 (pingcap/pd:latest)… ERROR: Couldn’t connect to Docker daemon at http+docker://localunixsocket - is it running?

If it’s at a non-standard location, specify the URL with the DOCKER_HOST environment variable. 现在是不是支持在物理机上部署呢?

这个错误是 docker 无法连接其 daemon,与 tidb 部署没有关系。 需要先修复 docker 安装,让 docker info, docker ps 之类的命令都能正常工作。 可以参考 docker 安装文档:https://docs.docker.com/install/

所以问题就是docker里面不能再运行docker。问题无解?

docker 里可以运行 docker 。如果你是在 docker 的容器内运行 docker 出现这个命令的话,需要这个容器内有安装 docker 。需要专门的 docker in docker (DinD) 容器。

是这样,我们现在在做物理机的容器化,分发给我们的都是别人做好的容器。你这种需要特别定制DinD没办法提供。现在就导致我在容器中部署服务会出现服务无法使用守护进程运行,在部署的时候运行deploy.yml时候出现各种容器相关的报错。所以有没有能让服务在前台进行的办法呢?

1)ntpd服务无法启动

fatal: [10.144.101.21]: FAILED! => {“changed”: false, “msg”: “Make sure NTP service is running and ntpstat is synchronised to NTP server. See https://github.com/pingcap/docs/blob/master/dev/how-to/deploy/orchestrated/ansible.md#how-to-check-whether-the-ntp-service-is-normal .”} fatal: [10.144.96.250]: FAILED! => {“changed”: false, “msg”: “Make sure NTP service is running and ntpstat is synchronised to NTP server. See https://github.com/pingcap/docs/blob/master/dev/how-to/deploy/orchestrated/ansible.md#how-to-check-whether-the-ntp-service-is-normal .”} fatal: [10.144.96.249]: FAILED! => {“changed”: false, “msg”: “Make sure NTP service is running and ntpstat is synchronised to NTP server. See https://github.com/pingcap/docs/blob/master/dev/how-to/deploy/orchestrated/ansible.md#how-to-check-whether-the-ntp-service-is-normal .”}

2)PD无法ssh

fatal: [PD1]: UNREACHABLE! => {“changed”: false, “msg”: “Failed to connect to the host via ssh: Shared connection to 10.144.204.95 closed.”, “unreachable”: true}

[PD1]: Ansible UNREACHABLE! => playbook: deploy.yml; TASK: check_config : Check TiKV config; message: {“changed”: false, “msg”: “Failed to connect to the host via ssh: Shared connection to 10.144.204.95 closed.”, “unreachable”: true}

3)systemctl daemon-reload

[10.144.204.95]: Ansible FAILED! => playbook: deploy.yml; TASK: systemd : reload systemd; message: {“changed”: true, “cmd”: “systemctl daemon-reload”, “delta”: “0:00:01.177989”, “end”: “2020-02-21 14:47:18.997133”, “msg”: “non-zero return code”, “rc”: 1, “start”: “2020-02-21 14:47:17.819144”, “stderr”: “Failed to get D-Bus connection: Operation not permitted”, “stderr_lines”: [“Failed to get D-Bus connection: Operation not permitted”], “stdout”: “”, “stdout_lines”: []}

[10.144.101.21]: Ansible FAILED! => playbook: deploy.yml; TASK: systemd : reload systemd; message: {“changed”: true, “cmd”: “systemctl daemon-reload”, “delta”: “0:00:01.430386”, “end”: “2020-02-21 14:47:19.281460”, “msg”: “non-zero return code”, “rc”: 1, “start”: “2020-02-21 14:47:17.851074”, “stderr”: “Failed to get D-Bus connection: Operation not permitted”, “stderr_lines”: [“Failed to get D-Bus connection: Operation not permitted”], “stdout”: “”, “stdout_lines”: []}

[10.144.96.250]: Ansible FAILED! => playbook: deploy.yml; TASK: systemd : reload systemd; message: {“changed”: true, “cmd”: “systemctl daemon-reload”, “delta”: “0:00:01.406609”, “end”: “2020-02-21 14:47:19.301463”, “msg”: “non-zero return code”, “rc”: 1, “start”: “2020-02-21 14:47:17.894854”, “stderr”: “Failed to get D-Bus connection: Operation not permitted”, “stderr_lines”: [“Failed to get D-Bus connection: Operation not permitted”], “stdout”: “”, “stdout_lines”: []}

[10.144.96.249]: Ansible FAILED! => playbook: deploy.yml; TASK: systemd : reload systemd; message: {“changed”: true, “cmd”: “systemctl daemon-reload”, “delta”: “0:00:01.438233”, “end”: “2020-02-21 14:47:19.343576”, “msg”: “non-zero return code”, “rc”: 1, “start”: “2020-02-21 14:47:17.905343”, “stderr”: “Failed to get D-Bus connection: Operation not permitted”, “stderr_lines”: [“Failed to get D-Bus connection: Operation not permitted”], “stdout”: “”, “stdout_lines”: []}

里面不能运行 docker 的话,没办法直接使用我们分发的 tidb 镜像,容器部署不现实。

直接用 tidb-ansible 可能也不行,因为 tidb-ansible 假定了完整的 os 环境。

容器不是虚拟机,只是运行进程的一种方式。当做虚拟机来使用并不好。若一定需要这样,得自定义一些进程管理方案来运行 tidb 组件。

假如你们容器内启动了 systemd ,那么可以写 systemd service 配置来启动 tidb 组件。

此话题已在最后回复的 1 分钟后被自动关闭。不再允许新回复。