繁体   English   中英

使用cassandra在集群中我的节点是否正常运行是检查ansible任务的最佳方法是什么

[英]What is the best way to check with an ansible task if my nodes are up and normal in a cluster using cassandra

我有一个运行cassandra 3.11.4且具有5个节点的群集。 我正在使用ansible运行任务,并且我有一个特定的任务,我只想在所有节点都正常运行的情况下运行。 我尝试使用nodetool statusnodetool describecluster并检查其输出,但是有更好的解决方案吗?

让我们在下面的库存

$ cat hosts
[nodes]
192.168.50.4  node0
192.168.50.5  node1
192.168.50.6  node2
192.168.50.7  node3
192.168.50.8  node4
192.168.50.9  node5

如果任何节点在超时秒内未在监控器端口响应,则下面的播放失败。 (使变量适合您的需求。)

- hosts: localhost
  vars:
    monitor: 7199
    timeout: 5
  tasks:
    - wait_for:
        port: "{{ monitor }}"
        host: "{{ item }}"
        timeout: "{{ timeout }}"
        msg: "{{ item }} is not running. End of play."
      loop: "{{ groups['nodes'] }}"

要检查所有节点是否忽略潜在错误,请注册并查看结果。

      ignore_errors: yes
      register: results

(未测试)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM