Redis: создать кластер с Redis-Cli не в интерактивном режиме - PullRequest
1 голос
/ 17 марта 2019

При попытке создать кластер с redis-cli следующим образом

redis-cli --cluster create

появляется запрос на подтверждение конфигурации?

Есть ли способ написать это (желательно на ansible) и запустить его неинтерактивно?

Мне известна эта тема однако она касается манипулирования данными, что не входит в сферу этого вопроса.

Ответы [ 2 ]

1 голос
/ 21 июня 2019

Начиная с текущей версии Redis (5.0.5), под --cluster нет флага, который мог бы заставить замолчать или автоматически ответить на интерактивный вопрос:

$ redis-cli --cluster help
Cluster Manager Commands:
  create         host1:port1 ... hostN:portN
                 --cluster-replicas <arg>
  check          host:port
                 --cluster-search-multiple-owners
  info           host:port
  fix            host:port
                 --cluster-search-multiple-owners
  reshard        host:port
                 --cluster-from <arg>
                 --cluster-to <arg>
                 --cluster-slots <arg>
                 --cluster-yes
                 --cluster-timeout <arg>
                 --cluster-pipeline <arg>
                 --cluster-replace
  rebalance      host:port
                 --cluster-weight <node1=w1...nodeN=wN>
                 --cluster-use-empty-masters
                 --cluster-timeout <arg>
                 --cluster-simulate
                 --cluster-pipeline <arg>
                 --cluster-threshold <arg>
                 --cluster-replace
  add-node       new_host:new_port existing_host:existing_port
                 --cluster-slave
                 --cluster-master-id <arg>
  del-node       host:port node_id
  call           host:port command arg arg .. arg
  set-timeout    host:port milliseconds
  import         host:port
                 --cluster-from <arg>
                 --cluster-copy
                 --cluster-replace
  help

Используя echo, вы можете выполнить команду и автоматически ответить на приглашение:

echo "yes" | redis-cli --cluster create host1:6379 host2:6379 host3:6379

Модуль по умолчанию * Ansible Redis поддерживает только несколько команд, а не --cluster, поэтому вам придется создавать собственную логику с задачами команда / оболочка:

- name: Create cluster
  shell: echo "yes" | redis-cli --cluster create host1:6379 host2:6379 host3:6379
  run_once: true
  when: not cluster_setup_done
0 голосов
/ 09 апреля 2019

Ну, я не знаю об ансбле.Но Redis официальный сайт предоставляет способ создать кластер со скриптом в небольшом интерактивном режиме .

Создание кластера Redis с помощью create-clusterскрипт (пожалуйста, обратитесь к документации для получения более подробной информации)

If you don't want to create a Redis Cluster by configuring and executing individual instances manually as explained above, there is a much simpler system (but you'll not learn the same amount of operational details).

    Just check utils/create-cluster directory in the Redis distribution. There is a script called create-cluster inside (same name as the directory it is contained into), it's a simple bash script. In order to start a 6 nodes cluster with 3 masters and 3 slaves just type the following commands:

    create-cluster start
    create-cluster create
    Reply to yes in step 2 when the redis-cli utility wants you to accept the cluster layout.

    You can now interact with the cluster, the first node will start at port 30001 by default. When you are done, stop the cluster with:

    create-cluster stop.
    Please read the README inside this directory for more information on how to run the script.

Вы можете попробовать реализовать это, если это поможет вам в любом случае!Приветствия:)

...