1.3. Быстрый запуск #
- 1.3.1. Конфигурация кластера
- 1.3.2. Подготовка
- 1.3.3. Развёртывание кластера etcd
- 1.3.4. Развёртывание узлов Shardman
- 1.3.5. Инициализация кластера Shardman
- 1.3.6. Добавление узлов в кластер Shardman
- 1.3.7. Проверка состояния кластера Shardman
- 1.3.8. Подключение к кластеру Shardman
- 1.3.9. Создание сегментированных таблиц
- 1.3.10. Пример: развёртывание кластера etcd с несколькими узлами
- 1.3.4. Развёртывание узлов Shardman
Shardman состоит из следующих программных компонентов:
СУБД PostgreSQL 14 с набором изменений.
Расширение Shardman.
Инструменты и службы управления, включая встроенный менеджер stolon для обеспечения отказоустойчивости.
Конфигурации Shardman и stolon хранятся в кластере etcd, поэтому можно использовать существующий или развернуть новый простой кластер etcd с одним узлом.
Демон shardmand контролирует конфигурацию кластера Shardman и управляет кластерами stolon, которые обеспечивают отказоустойчивость сегментов. Общая конфигурация Shardman (shardmand, stolon) хранится в кластере etcd.
В настоящее время пакеты Shardman доступны для следующих ОС:
Ubuntu 22.04
Debian 12
РЕД ОС 7.3/8
1.3.1. Конфигурация кластера #
Минимальная конфигурация представляет собой один узел etcd и два узла Postgres Pro Shardman. Здесь рассмотрим более сложную конфигурацию с кластером etcd из двух узлов и кластером Postgres Pro Shardman из двух узлов.
Допустим, у нас есть следующие имена узлов и IP-адреса:
192.0.1.1 etcd - первый узел etcd 192.0.1.2 etcd - второй узел etcd 192.0.1.20 sdm01 - первый узел Shardman 192.0.1.21 sdm02 - второй узел Shardman 192.0.1.100 ntp - сервер синхронизации местного времени (необязательно)
Характеристики каждого узла: 4Gb RAM, 20GB HDD, 2CPU и ОС Ubuntu 22.04.
1.3.2. Подготовка #
1.3.2.1. Добавление имён узлов в /etc/hosts #
Этот шаг следует выполнить на всех узлах.
sudo /bin/sh -c 'cat << EOF >> /etc/hosts 192.0.1.1 etcd1 192.0.1.2 etcd2 192.0.1.20 sdm01 192.0.1.21 sdm02 EOF'
1.3.2.2. Синхронизация по времени #
Этот шаг следует выполнить на всех узлах.
Установите и запустите демон chrony на всех узлах.
sudo apt install -y chrony
По умолчанию chrony получает время с доступных серверов в Интернете или с локального сервера времени. Проверить доступные серверы времени можно следующим образом:
chronyc sources MS Name/IP address Stratum Poll Reach LastRx Last sample =============================================================================== ^? 192.0.1.100 1 6 7 1 -98us[ -98us] +/- 11ms ^* time.cloudflare.com 3 6 7 1 +139us[ +163us] +/- 11ms ^+ tms04.deltatelesystems.ru 1 6 7 1 -381us[ -357us] +/- 17ms
Желательно синхронизировать время с вашим сервером или локальным сервером для кластера. В данном случае это сервер ntp. Для этого внесите в конфигурацию chrony следующие изменения:
sudo tee "/etc/chrony/chrony.conf" > /dev/null << 'EOF' server 192.0.1.100 iburst keyfile /etc/chrony.keys driftfile /var/lib/chrony/chrony.drift log tracking measurements statistics logdir /var/log/chrony EOF systemctl restart chrony
Проверьте, что демон chrony подключён к нужному серверу.
chronyc sources MS Name/IP address Stratum Poll Reach LastRx Last sample =============================================================================== ^? 192.0.1.100 8 6 17 37 +14us[ +70us] +/- 161us chronyc tracking Reference ID : 0A80000C (ntp.local) Stratum : 9 Ref time (UTC) : Wed Nov 15 11:58:52 2023 System time : 0.000000004 seconds slow of NTP time Last offset : -0.000056968 seconds RMS offset : 0.000056968 seconds Frequency : 10.252 ppm fast Residual freq : -2.401 ppm Skew : 364.419 ppm Root delay : 0.000455358 seconds Root dispersion : 0.010503666 seconds Update interval : 2.1 seconds Leap status : Normal
1.3.3. Развёртывание кластера etcd #
Данные шаги необходимо выполнить на всех узлах etcd.
Установите следующие пакеты:
sudo apt install -y vim curl
Для подключения к репозиторию Shardman:
Запустите скрипт (указав имя пользователя и пароль)
curl -fsSL -u "<user>:<password>" https://repo.postgrespro.ru/sdm/sdm-14/keys/pgpro-repo-add.sh > pgpro-repo-add.sh chmod +x pgpro-repo-add.sh
Задайте свой логин и пароль для репозитория
pgpro-repo-add.sh.ex -s -c "%s/REPOUSER=/REPOUSER=<user>/g" -c "wq" "pgpro-repo-add.sh" ex -s -c "%s/PASSWORD=/PASSWORD=<password>/g" -c "wq" "pgpro-repo-add.sh"
Выполните
sudo pgpro-repo-add.sh.sudo ./pgpro-repo-add.sh
Установите пакеты etcd-sdm:
sudo apt install -y etcd-sdm
Укажите значения переменных окружения в соответствующем файле:
sudo vim /etc/default/etcd-sdm
##следующие две строки должны содержать данные вашего узла
ETCD_NAME=<hostname>
ETCD_ADVERTISE_CLIENT_URLS=http://<host ip address>:2379
ETCD_LISTEN_CLIENT_URLS=http://0.0.0.0:2379
ETCD_MAX_SNAPSHOTS=5
ETCD_MAX_WALS=5
ETCD_AUTO_COMPACTION_MODE=periodic
ETCD_AUTO_COMPACTION_RETENTION=5m
ETCD_QUOTA_BACKEND_BYTES=6442450944
ETCD_DATA_DIR=/var/lib/etcd-sdm/sdm-14
#последующие параметры требуются только для кластера etcd с несколькими узлами
#замените на свои IP
ETCD_INITIAL_ADVERTISE_PEER_URLS=http://<host ip address>:2380
ETCD_INITIAL_CLUSTER=etcd1=http://etcd1:2380,etcd2=http://etcd2:2380
ETCD_INITIAL_CLUSTER_TOKEN=etcd-cluster-1
ETCD_INITIAL_CLUSTER_STATE=new
ETCD_LISTEN_PEER_URLS=http://0.0.0.0:2380Этот файл будет загружен при запуске etcd.
Очистите каталог данных etcd:
sudo rm -rf /var/lib/etcd-sdm/sdm-14/*
Перезапустите службу etcd-sdm:
sudo systemctl restart etcd-sdm
Для локального пользователя добавьте путь /opt/pgpro/sdm-14/bin в переменную окружения PATH:
echo "export PATH=$PATH:/opt/pgpro/sdm-14/bin" >> ~/.bashrc source ~/.bashrc
Проверьте правильность конфигурации etcd:
etcdctl endpoint --endpoints=http://192.0.1.1:2379 status health -w table +------------------------+------------------+---------+---------+-----------+------------+-----------+------------+--------------------+--------------------------------+ | ENDPOINT | ID | VERSION | DB SIZE | IS LEADER | IS LEARNER | RAFT TERM | RAFT INDEX | RAFT APPLIED INDEX | ERRORS | +------------------------+------------------+---------+---------+-----------+------------+-----------+------------+--------------------+--------------------------------+ | http://192.0.1.1:2379 | 9324a99282752a09 | 3.5.9 | 2.1 GB | true | false | 14 | 91459207 | 91459207 | memberID:10602785869456026121 | | | | | | | | | | | alarm:NOSPACE | +------------------------+------------------+---------+---------+-----------+------------+-----------+------------+--------------------+--------------------------------+
Кластер etcd с одним узлом правильно сконфигурирован и готов обрабатывать запросы.
Чтобы предотвратить раздувание при интенсивном использовании etcd, добавьте команду дефрагментации в cron:
sudo sh -c '
{ crontab -l; echo "@hourly /opt/pgpro/sdm-14/bin/etcdctl defrag"; }
| crontab'1.3.4. Развёртывание узлов Shardman #
Добавьте репозиторий Shardman на каждом узле Shardman:
Установите следующие пакеты:
sudo apt install -y vim curl jq
Запустите указанные скрипты:
curl -fsSL -u "<user>:<password>" https://repo.postgrespro.ru/sdm/sdm-14/keys/pgpro-repo-add.sh > pgpro-repo-add.sh | bash chmod +x pgpro-repo-add.sh
Задайте свой логин и пароль для репозитория
pgpro-repo-add.sh.ex -s -c "%s/REPOUSER=/REPOUSER=<user>/g" -c "wq" "pgpro-repo-add.sh" ex -s -c "%s/PASSWORD=/PASSWORD=<password>/g" -c "wq" "pgpro-repo-add.sh"
Выполните
sudo pgpro-repo-add.sh.sudo ./pgpro-repo-add.sh
Установите пакеты (на каждом узле):
sudo apt update sudo apt install -y postgrespro-sdm-14-server postgrespro-sdm-14-client postgrespro-sdm-14-contrib postgrespro-sdm-14-libs pg-probackup-sdm-14 shardman-services shardman-tools
Предположим, выбранное имя кластера — cluster0. Следующий шаг — поместить переменные окружения Shardman в каталог /etcd/shardman (на каждом узле):
sudo sh -c 'cat << EOF > /etc/shardman/shardmand-cluster0.env SDM_CLUSTER_NAME=cluster0 SDM_LOG_LEVEL=info # введите адреса своих etcd SDM_STORE_ENDPOINTS=http://etcd:2379 EOF'
Файл и каталог создаются с помощью команды sudo, однако в дальнейшем shardmanctl её не использует, поэтому доступ к файлу с переменными окружения отсутствует. Для получения доступа необходимо добавить переменные в систему через export или дать пользователю права доступа к файлу и каталогу.
Для локального пользователя добавьте путь /opt/pgpro/sdm-14/bin в переменную окружения PATH и экспортируйте переменную SDM_STORE_ENDPOINTS:
echo "export PATH=$PATH:/opt/pgpro/sdm-14/bin" >> ~/.bashrc # введите адрес(а) узла(ов) etcd echo "export SDM_STORE_ENDPOINTS=http://etcd:2379" >> ~/.bashrc source ~/.bashrc
Сгенерируйте пример конфигурации с помощью утилит Shardman (только на одном узле Shardman).
shardmanctl config generate > spec.json
На этом шаге можно внести некоторые изменения в спецификацию (конфигурацию) кластера, например изменить пароль или параметр PostgreSQL shared_buffers и так далее.
Для небольшого изменения кластера задайте для параметра Repfactor значение 0. За подробной информацией обратитесь к файлу конфигурации Shardman.
jq ' .Repfactor = 0 ' "spec.json" > tmp.json && mv tmp.json "spec.json"
1.3.5. Инициализация кластера Shardman #
Осталось несколько последних шагов. Сначала инициализируйте конфигурацию кластера в etcd (только на одном [любом] узле Shardman).
shardmanctl init -f spec.json
Ожидается такой результат:
2023-04-18T12:30:03.043Z DEBUG cmd/common.go:100 Waiting for metadata lock... 2023-04-18T12:30:03.048Z DEBUG cluster/cluster.go:365 DataDir is not specified, setting to default /var/lib/pgpro/sdm-14/data
Включите и запустите службу shardmand (на каждом узле Shardman):
sudo systemctl enable --now shardmand@cluster0 sudo systemctl status shardmand@cluster0
● shardmand@cluster0.service - deployment daemon for shardman
Loaded: loaded (/lib/systemd/system/shardmand@.service; enabled; vendor preset: enabled)
Active: active (running) since Tue 2023-04-18 12:28:18 UTC; 2min 13s ago
Docs: https://github.com/postgrespro/shardman
Main PID: 618 (shardmand)
Tasks: 10 (limit: 4571)
Memory: 32.0M
CPU: 422ms
CGroup: /system.slice/system-shardmand.slice/shardmand@cluster0.service
└─618 /opt/pgpro/sdm-14/bin/shardmand --cluster-name cluster0 --system-bus --user postgres1.3.6. Добавление узлов в кластер Shardman #
Следующую команду необходимо выполнить только на одном узле Shardman.
На этом шаге предполагается, что все предыдущие шаги выполнены успешно: кластер etcd работает нормально, время на всех узлах синхронизировано, и демон запущен на sdm01 и sdm02. На последнем шаге выполняется команда shardmanctl:
shardmanctl nodes add -n sdm01,sdm02 \
--cluster-name cluster0 \
--log-level debugОжидается такой результат:
2023-04-18T12:43:11.300Z DEBUG cmd/common.go:100 Waiting for metadata lock... 2023-04-18T12:43:11.306Z INFO cluster/store.go:277 Checking if shardmand on all nodes have applied current cluster configuration ✓ Waiting for shardmand on node sdm01 to apply current configuration: success 0.000s ✓ Waiting for shardmand on node sdm02 to apply current configuration: success 0.000s 2023-04-18T12:43:11.307Z INFO add/case.go:112 Initting Stolon instances... 2023-04-18T12:43:11.312Z INFO add/case.go:170 Waiting for Stolon daemons to start... make sure shardmand daemons are running on the nodes ✓ Waiting for Stolon daemons of rg clover-1-sdm01: success 31.012s ✓ Waiting for Stolon daemons of rg clover-1-sdm02: success 0.012s 2023-04-18T12:43:42.336Z INFO add/case.go:187 Adding repgroups... ✓ waiting rg 1 config apply: done 7.014s 2023-04-18T12:43:49.444Z DEBUG broadcaster/worker.go:33 start broadcaster worker for repgroup id=1 2023-04-18T12:43:49.453Z DEBUG broadcaster/worker.go:51 repgroup 1 connect established 2023-04-18T12:43:49.453Z DEBUG commands/addrepgroup.go:575 waiting for extension lock... 2023-04-18T12:43:49.453Z DEBUG commands/addrepgroup.go:137 Loading schema into replication group rg 1 ... 2023-04-18T12:44:25.665Z DEBUG rebalance/service.go:528 wait all tasks finish 2023-04-18T12:44:25.666Z DEBUG broadcaster/worker.go:75 finish broadcaster worker for repgroup id=1 2023-04-18T12:44:25.666Z DEBUG broadcaster/worker.go:75 finish broadcaster worker for repgroup id=2 2023-04-18T12:44:25.666Z INFO add/case.go:221 Successfully added nodes sdm01, sdm02 to the cluster
Сообщение «Successfully added nodes sdm01, sdm02 to the cluster» (Узлы sdm01, sdm02 успешно добавлены в кластер) означает, что всё в порядке и узлы sdm01 и sdm02 работают нормально.
1.3.7. Проверка состояния кластера Shardman #
Проверьте состояние узлов кластера:
shardmanctl status ┌──────────────────────────────────────────────────────────────────────────────────────────────────┐ │ == STORE STATUS == │ ├───────────┬──────────────────────────────────────────┬─────────────────────┬─────────────────────┤ │ STATUS │ MESSAGE │ REPLICATION GROUP │ NODE │ ├───────────┼──────────────────────────────────────────┼─────────────────────┼─────────────────────┤ │ Warning │ Store has only one member, consider │ │ │ │ │ deploying store cluster │ │ │ └───────────┴──────────────────────────────────────────┴─────────────────────┴─────────────────────┘ ┌─────────────────────────────────────────────────────────────────────────────────────────────────┐ │ == TOPOLOGY STATUS == │ ├───────────┬─────────────────────────────────────────┬─────────────────────┬─────────────────────┤ │ STATUS │ MESSAGE │ REPLICATION GROUP │ NODE │ ├───────────┼─────────────────────────────────────────┼─────────────────────┼─────────────────────┤ │ CROSS │ Topology placement policy is CROSS │ │ │ └───────────┴─────────────────────────────────────────┴─────────────────────┴─────────────────────┘ ┌─────────────────────────────────────────────────────────────────────────────────────────────────┐ │ == METADATA STATUS == │ ├───────────┬─────────────────────────────────────────┬─────────────────────┬─────────────────────┤ │ STATUS │ MESSAGE │ REPLICATION GROUP │ NODE │ ├───────────┼─────────────────────────────────────────┼─────────────────────┼─────────────────────┤ │ OK │ Metadata is OK │ │ │ └───────────┴─────────────────────────────────────────┴─────────────────────┴─────────────────────┘ ┌─────────────────────────────────────────────────────────────────────────────────────────────────┐ │ == SHARDMAND STATUS == │ ├───────────┬─────────────────────────────────────────┬─────────────────────┬─────────────────────┤ │ STATUS │ MESSAGE │ REPLICATION GROUP │ NODE │ ├───────────┼─────────────────────────────────────────┼─────────────────────┼─────────────────────┤ │ OK │ shardmand on node sdm01 is OK │ │ sdm01 │ ├───────────┼─────────────────────────────────────────┼─────────────────────┼─────────────────────┤ │ OK │ shardmand on node sdm02 is OK │ │ sdm02 │ └───────────┴─────────────────────────────────────────┴─────────────────────┴─────────────────────┘ ┌─────────────────────────────────────────────────────────────────────────────────────────────────┐ │ == REPLICATION GROUP STATUS == │ ├───────────┬─────────────────────────────────────────┬─────────────────────┬─────────────────────┤ │ STATUS │ MESSAGE │ REPLICATION GROUP │ NODE │ ├───────────┼─────────────────────────────────────────┼─────────────────────┼─────────────────────┤ │ OK │ Replication group clover-1-sdm01 is OK │ clover-1-sdm01 │ │ ├───────────┼─────────────────────────────────────────┼─────────────────────┼─────────────────────┤ │ OK │ Replication group clover-1-sdm02 is OK │ clover-1-sdm02 │ │ └───────────┴─────────────────────────────────────────┴─────────────────────┴─────────────────────┘ ┌──────────────────────────────────────────────────────────────────────────────────────────────────┐ │ == MASTER STATUS == │ ├───────────┬──────────────────────────────────────────┬─────────────────────┬─────────────────────┤ │ STATUS │ MESSAGE │ REPLICATION GROUP │ NODE │ ├───────────┼──────────────────────────────────────────┼─────────────────────┼─────────────────────┤ │ OK │ Replication group clover-1-sdm01 master │ clover-1-sdm01 │ sdm01:5432 │ │ │ is running on sdm01:5432 │ │ │ ├───────────┼──────────────────────────────────────────┼─────────────────────┼─────────────────────┤ │ OK │ Replication group clover-1-sdm02 master │ clover-1-sdm02 │ sdm02:5432 │ │ │ is running on sdm02:5432 │ │ │ └───────────┴──────────────────────────────────────────┴─────────────────────┴─────────────────────┘ ┌──────────────────────────────────────────────────────────────────────────────────────────────────┐ │ == DICTIONARY STATUS == │ ├───────────┬──────────────────────────────────────────┬─────────────────────┬─────────────────────┤ │ STATUS │ MESSAGE │ REPLICATION GROUP │ NODE │ ├───────────┼──────────────────────────────────────────┼─────────────────────┼─────────────────────┤ │ OK │ Replication group clover-1-sdm01 │ clover-1-sdm01 │ │ │ │ dictionary is OK │ │ │ ├───────────┼──────────────────────────────────────────┼─────────────────────┼─────────────────────┤ │ OK │ Replication group clover-1-sdm02 │ clover-1-sdm02 │ │ │ │ dictionary is OK │ │ │ └───────────┴──────────────────────────────────────────┴─────────────────────┴─────────────────────┘
1.3.8. Подключение к кластеру Shardman #
Для подключения к кластеру получите строку подключения на любом узле кластера (sdm01 или sdm02):
shardmanctl getconnstr
Пример вывода:
dbname=postgres host=sdm01,sdm02 password=!!!CHANGE_ME!!! port=5432,5432 user=postgres
Затем попробуйте подключиться:
psql -d 'dbname=postgres host=sdm01,sdm02 password=!!!CHANGE_ME!!! port=5432,5432 user=postgres'
Пример вывода:
psql (14.7) Type "help" for help. postgres=#
1.3.9. Создание сегментированных таблиц #
Создайте сегментированную таблицу и проверьте, всё ли работает корректно.
postgres=# create table x(id int primary key, t text) with (distributed_by='id',num_parts=2);
Пример вывода:
CREATE TABLE
postgres=# \d
List of relations
Schema | Name | Type | Owner
--------+---------+-------------------+----------
public | x | partitioned table | postgres
public | x_0 | table | postgres
public | x_1_fdw | foreign table | postgres
(3 rows)
postgres=# \d x_0
Table "public.x_0"
Column | Type | Collation | Nullable | Default
--------+---------+-----------+----------+---------
id | integer | | not null |
t | text | | |
Partition of: x FOR VALUES WITH (modulus 2, remainder 0)
Indexes:
"x_0_pkey" PRIMARY KEY, btree (id)
postgres=# \d x_1_fdw
Foreign table "public.x_1_fdw"
Column | Type | Collation | Nullable | Default | FDW options
--------+---------+-----------+----------+---------+-------------
id | integer | | not null | |
t | text | | | |
Partition of: x FOR VALUES WITH (modulus 2, remainder 1)
Server: shardman_rg_2
FDW options: (table_name 'x_1')
postgres=# insert into x values (1,'t'),(2,'t'),(3,'t');
INSERT 0 3
postgres=# select * from x_0;
id | t
----+---
1 | t
2 | t
(2 rows)
postgres=# select * from x_1_fdw;
id | t
----+---
3 | t
(1 row)Всё работает так, как и ожидалось.
1.3.10. Пример: развёртывание кластера etcd с несколькими узлами #
В примере используются следующие серверы:
192.0.1.1 etcd1 192.0.1.2 etcd2 192.0.1.3 etcd3
Установите необходимые пакеты на каждом сервере:
sudo apt install -y vim curl
Для подключения к репозиторию запустите на каждом сервере следующую команду:
sudo curl -fsSL https://repo.postgrespro.ru/sdm/sdm-14/keys/pgpro-repo-add.sh | bash
Установите пакеты etcd-sdm на каждом сервере:
sudo apt install -y etcd-sdm
Для каждого сервера отредактируйте файл со списком переменных окружения, заменив местозаполнители в угловых скобках конкретными значениями:
sudo vim /etc/default/etcd-sdm ETCD_NAME=<hostname> ETCD_LISTEN_PEER_URLS=http://0.0.0.0:2380 ETCD_LISTEN_CLIENT_URLS=http://0.0.0.0:2379 ETCD_ADVERTISE_CLIENT_URLS=http://<host ip address>:2379 ETCD_INITIAL_ADVERTISE_PEER_URLS=http://<host ip address>:2380 ETCD_INITIAL_CLUSTER_TOKEN=etcd-cluster-1 ETCD_INITIAL_CLUSTER_STATE=new ETCD_MAX_SNAPSHOTS=5 ETCD_MAX_WALS=5 ETCD_AUTO_COMPACTION_MODE=periodic ETCD_AUTO_COMPACTION_RETENTION=5m ETCD_QUOTA_BACKEND_BYTES=6442450944 ETCD_DATA_DIR=/var/lib/etcd-sdm/sdm-14 ETCD_INITIAL_CLUSTER=etcd1=http://<ip etcd1>:2380,etcd2=http://<ip etcd2>:2380,etcd3=http://<ip etcd3>:2380
Этот файл будет загружен при запуске etcd со своими собственными параметрами запуска на каждом сервере.
Очистите каталог данных etcd:
sudo rm -rf /var/lib/etcd-sdm/sdm-14/*
Перезапустите службы etcd-sdm на каждом сервере:
sudo systemctl restart etcd-sdm
Для локального пользователя добавьте путь /opt/pgpro/sdm-14/bin в переменную окружения PATH:
echo "export PATH=$PATH:/opt/pgpro/sdm-14/bin" >> ~/.bashrc source ~/.bashrc
Проверьте правильность конфигурации etcd:
etcdctl member list -w table +------------------+---------+-------+----------------------------+----------------------------+------------+ | ID | STATUS | NAME | PEER ADDRS | CLIENT ADDRS | IS LEARNER | +------------------+---------+-------+----------------------------+----------------------------+------------+ | 318be6342e6d9ac | started | etcd1 | http://192.0.1.1:2380 | http://192.0.1.1:2379 | false | | 9e49480544aedb89 | started | etcd2 | http://192.0.1.2:2380 | http://192.0.1.2:2379 | false | +------------------+---------+-------+----------------------------+----------------------------+------------+ etcdctl --endpoints=http://etcd1:2380,http://etcd2:2380 endpoint status health -w table +----------------------------+------------------+---------+---------+-----------+------------+-----------+------------+--------------------+--------+ | ENDPOINT | ID | VERSION | DB SIZE | IS LEADER | IS LEARNER | RAFT TERM | RAFT INDEX | RAFT APPLIED INDEX | ERRORS | +----------------------------+------------------+---------+---------+-----------+------------+-----------+------------+--------------------+--------+ | http://192.0.1.1:2380 | 318be6342e6d9ac | 3.5.9 | 5.7 MB | true | false | 13 | 425686 | 425686 | | | http://192.0.1.2:2380 | 9e49480544aedb89 | 3.5.9 | 5.7 MB | false | false | 13 | 425686 | 425686 | | +----------------------------+------------------+---------+---------+-----------+------------+-----------+------------+--------------------+--------+ -------+
Кластер etcd правильно сконфигурирован и готов обрабатывать запросы.
Чтобы предотвратить раздувание при интенсивном использовании etcd, добавьте команду дефрагментации в cron:
sudo { crontab -l; echo "@hourly /opt/pgpro/sdm-14/bin/etcdctl defrag"; } | crontabПоследняя строка с границами кластера etcd:
etcd1=http://<ip etcd1>:2380,etcd2=http://<ip etcd2>:2380,etcd3=http://<ip etcd3>:2380
Её следует указать в файле конфигурации /etc/shardman и в качестве параметра --store-endpoints shardmanctl.
1.3. Quickstart Guide #
- 1.3.1. Cluster Configuration
- 1.3.2. Preparation
- 1.3.3. Deploy an etcd Cluster
- 1.3.4. Deploy Shardman Nodes
- 1.3.5. Initialize the Shardman Cluster
- 1.3.6. Add Nodes to the Shardman Cluster
- 1.3.7. Check the Shardman Cluster Status
- 1.3.8. Connect to the Shardman Cluster
- 1.3.9. Create Sharded Tables
- 1.3.10. Example: Deploy a Multi-Node etcd Cluster
- 1.3.4. Deploy Shardman Nodes
Shardman is composed of several software components:
PostgreSQL 14 DBMS with a set of patches.
Shardman extension.
Management tools and services, including built-in stolon manager to provide high availability.
Shardman and stolon store their configuration in an etcd cluster. Therefore, we can use an existing etcd cluster, or we can deploy a simple one-node etcd cluster.
The shardmand daemon monitors the cluster configuration and manages stolon clusters, which are used to guarantee high availability of all shards. The common Shardman configuration (shardmand, stolon) is stored in an etcd cluster.
Currently Shardman packages are available for
Ubuntu 22.04
Debian 12
Red OS 7.3/8
1.3.1. Cluster Configuration #
The minimal configuration consists of 1 etcd node and 2 Shardman nodes. Here, let's consider a wider configuration with etcd two-node cluster and Shardman two-node cluster. For the minimal necessary scenario, disable this extra node from all the steps below.
Let’s suppose that we have the following node names and IP addresses:
192.0.1.1 etcd - first etcd node 192.0.1.2 etcd - second etcd node 192.0.1.20 sdm01 - Shardman node1 192.0.1.21 sdm02 - Shardman node2 192.0.1.100 ntp - local time sync server (optional)
Each node has 4Gb RAM, 20GB HDD, 2CPU and Ubuntu 22.04 installed.
1.3.2. Preparation #
1.3.2.1. Add host names to /etc/hosts #
This step must be performed on all nodes.
sudo /bin/sh -c 'cat << EOF >> /etc/hosts 192.0.1.1 etcd1 192.0.1.2 etcd2 192.0.1.20 sdm01 192.0.1.21 sdm02 EOF'
1.3.2.2. Time Synchronization #
This step must be performed on all nodes.
Deploy and start chrony daemon on all hosts.
sudo apt install -y chrony
By default, chrony gets the time from available servers on internet or the local time server. You can check available time servers as follows:
chronyc sources MS Name/IP address Stratum Poll Reach LastRx Last sample =============================================================================== ^? 192.0.1.100 1 6 7 1 -98us[ -98us] +/- 11ms ^* time.cloudflare.com 3 6 7 1 +139us[ +163us] +/- 11ms ^+ tms04.deltatelesystems.ru 1 6 7 1 -381us[ -357us] +/- 17ms
It is desirable to synchronize time with your server or the local server for the cluster. In this case, it is the ntp server. To do this, make changes similar to the following to chrony configuration:
sudo tee "/etc/chrony/chrony.conf" > /dev/null << 'EOF' server 192.0.1.100 iburst keyfile /etc/chrony.keys driftfile /var/lib/chrony/chrony.drift log tracking measurements statistics logdir /var/log/chrony EOF systemctl restart chrony
Check that chrony is connected to the appropriate server.
chronyc sources MS Name/IP address Stratum Poll Reach LastRx Last sample =============================================================================== ^? 192.0.1.100 8 6 17 37 +14us[ +70us] +/- 161us chronyc tracking Reference ID : 0A80000C (ntp.local) Stratum : 9 Ref time (UTC) : Wed Nov 15 11:58:52 2023 System time : 0.000000004 seconds slow of NTP time Last offset : -0.000056968 seconds RMS offset : 0.000056968 seconds Frequency : 10.252 ppm fast Residual freq : -2.401 ppm Skew : 364.419 ppm Root delay : 0.000455358 seconds Root dispersion : 0.010503666 seconds Update interval : 2.1 seconds Leap status : Normal
1.3.3. Deploy an etcd Cluster #
These steps must be applied to all etcd nodes.
Install the following packages:
sudo apt install -y vim curl
To connect a Shardman repository:
Run (and change username and password)
curl -fsSL -u "<user>:<password>" https://repo.postgrespro.ru/sdm/sdm-14/keys/pgpro-repo-add.sh > pgpro-repo-add.sh chmod +x pgpro-repo-add.sh
Specify your login and password for the
pgpro-repo-add.shrepository.ex -s -c "%s/REPOUSER=/REPOUSER=<user>/g" -c "wq" "pgpro-repo-add.sh" ex -s -c "%s/PASSWORD=/PASSWORD=<password>/g" -c "wq" "pgpro-repo-add.sh"
Run
sudo pgpro-repo-add.sh.sudo ./pgpro-repo-add.sh
Install etcd-sdm packages:
sudo apt install -y etcd-sdm
In the file that lists environment variables, insert specific values for them:
sudo vim /etc/default/etcd-sdm
#next two lines must contain your host data
ETCD_NAME=<hostname>
ETCD_ADVERTISE_CLIENT_URLS=http://<host ip address>:2379
ETCD_LISTEN_CLIENT_URLS=http://0.0.0.0:2379
ETCD_MAX_SNAPSHOTS=5
ETCD_MAX_WALS=5
ETCD_AUTO_COMPACTION_MODE=periodic
ETCD_AUTO_COMPACTION_RETENTION=5m
ETCD_QUOTA_BACKEND_BYTES=6442450944
ETCD_DATA_DIR=/var/lib/etcd-sdm/sdm-14
#the following parameters are only required for multi-node etcd
#enter your IPs
ETCD_INITIAL_ADVERTISE_PEER_URLS=http://<host ip address>:2380
ETCD_INITIAL_CLUSTER=etcd1=http://etcd1:2380,etcd2=http://etcd2:2380
ETCD_INITIAL_CLUSTER_TOKEN=etcd-cluster-1
ETCD_INITIAL_CLUSTER_STATE=new
ETCD_LISTEN_PEER_URLS=http://0.0.0.0:2380
This file will be loaded at etcd start.
Clear the etcd data directory:
sudo rm -rf /var/lib/etcd-sdm/sdm-14/*
Restart the etcd-sdm service:
sudo systemctl restart etcd-sdm
For your user, add /opt/pgpro/sdm-14/bin to the PATH environment variable:
echo "export PATH=$PATH:/opt/pgpro/sdm-14/bin" >> ~/.bashrc source ~/.bashrc
Check that etcd is properly configured:
etcdctl endpoint --endpoints=http://192.0.1.1:2379 status health -w table +------------------------+------------------+---------+---------+-----------+------------+-----------+------------+--------------------+--------------------------------+ | ENDPOINT | ID | VERSION | DB SIZE | IS LEADER | IS LEARNER | RAFT TERM | RAFT INDEX | RAFT APPLIED INDEX | ERRORS | +------------------------+------------------+---------+---------+-----------+------------+-----------+------------+--------------------+--------------------------------+ | http://192.0.1.1:2379 | 9324a99282752a09 | 3.5.9 | 2.1 GB | true | false | 14 | 91459207 | 91459207 | memberID:10602785869456026121 | | | | | | | | | | | alarm:NOSPACE | +------------------------+------------------+---------+---------+-----------+------------+-----------+------------+--------------------+--------------------------------+
etcd one-node cluster is properly configured and ready to serve requests.
To prevent bloat when etcd is intensively used, add a defragmentation command to cron:
sudo sh -c '
{ crontab -l; echo "@hourly /opt/pgpro/sdm-14/bin/etcdctl defrag"; }
| crontab'
1.3.4. Deploy Shardman Nodes #
Let’s add a Shardman repository on each Shardman node:
Install the following packages:
sudo apt install -y vim curl jq
Run
curl -fsSL -u "<user>:<password>" https://repo.postgrespro.ru/sdm/sdm-14/keys/pgpro-repo-add.sh > pgpro-repo-add.sh | bash chmod +x pgpro-repo-add.sh
Specify your login and password for the
pgpro-repo-add.shrepository.ex -s -c "%s/REPOUSER=/REPOUSER=<user>/g" -c "wq" "pgpro-repo-add.sh" ex -s -c "%s/PASSWORD=/PASSWORD=<password>/g" -c "wq" "pgpro-repo-add.sh"
Run
sudo pgpro-repo-add.sh.sudo ./pgpro-repo-add.sh
Next step is installation of packages (on each node):
sudo apt update sudo apt install -y postgrespro-sdm-14-server postgrespro-sdm-14-client postgrespro-sdm-14-contrib postgrespro-sdm-14-libs pg-probackup-sdm-14 shardman-services shardman-tools
Suppose we have chosen a default cluster name of cluster0. The next step is to put Shardman environment vars into the /etc/shardman directory (on each node):
sudo sh -c 'cat << EOF > /etc/shardman/shardmand-cluster0.env SDM_CLUSTER_NAME=cluster0 SDM_LOG_LEVEL=info # enter your etcd host(s) adress SDM_STORE_ENDPOINTS=http://etcd:2379 EOF'
The file and directory are created with sudo, but later shardmanctl does not use sudo, thus cannot access the file with the environment variables. To access it, either add the variables to the system with export, or grant user with access rights to the file and the directory.
For your user, add /opt/pgpro/sdm-14/bin to the PATH environment variable and export the SDM_STORE_ENDPOINTS variable:
echo "export PATH=$PATH:/opt/pgpro/sdm-14/bin" >> ~/.bashrc # enter your etcd host(s) adress echo "export SDM_STORE_ENDPOINTS=http://etcd:2379" >> ~/.bashrc source ~/.bashrc
Let’s generate a sample configuration with the Shardman utilities (only on one Shardman node).
shardmanctl config generate > spec.json
In this step, you can make some changes to the cluster specification (configuration), i.e., change the password or PostgreSQL shared_buffers parameter and so on.
For a simple cluster change Repfactor to 0. For more details, see Shardman configuration file.
jq ' .Repfactor = 0 ' "spec.json" > tmp.json && mv tmp.json "spec.json"
1.3.5. Initialize the Shardman Cluster #
Now we have some final steps. First, let's initialize the cluster configuration in etcd (only on one [any] Shardman node).
shardmanctl init -f spec.json
The expected output is:
2023-04-18T12:30:03.043Z DEBUG cmd/common.go:100 Waiting for metadata lock... 2023-04-18T12:30:03.048Z DEBUG cluster/cluster.go:365 DataDir is not specified, setting to default /var/lib/pgpro/sdm-14/data
Enable and start the shardmand service (on each Shardman node):
sudo systemctl enable --now shardmand@cluster0 sudo systemctl status shardmand@cluster0
● shardmand@cluster0.service - deployment daemon for shardman
Loaded: loaded (/lib/systemd/system/shardmand@.service; enabled; vendor preset: enabled)
Active: active (running) since Tue 2023-04-18 12:28:18 UTC; 2min 13s ago
Docs: https://github.com/postgrespro/shardman
Main PID: 618 (shardmand)
Tasks: 10 (limit: 4571)
Memory: 32.0M
CPU: 422ms
CGroup: /system.slice/system-shardmand.slice/shardmand@cluster0.service
└─618 /opt/pgpro/sdm-14/bin/shardmand --cluster-name cluster0 --system-bus --user postgres
1.3.6. Add Nodes to the Shardman Cluster #
The following command must be executed only on one Shardman node.
In this step we assume that all previous steps were executed successfully: etcd cluster is working properly, the time on all hosts is synchronized, and the daemon is launched on sdm01 and sdm02. The final step should be executed with shardmanctl command as follows:
shardmanctl nodes add -n sdm01,sdm02 \
--cluster-name cluster0 \
--log-level debug
The expected output should be:
2023-04-18T12:43:11.300Z DEBUG cmd/common.go:100 Waiting for metadata lock... 2023-04-18T12:43:11.306Z INFO cluster/store.go:277 Checking if shardmand on all nodes have applied current cluster configuration ✓ Waiting for shardmand on node sdm01 to apply current configuration: success 0.000s ✓ Waiting for shardmand on node sdm02 to apply current configuration: success 0.000s 2023-04-18T12:43:11.307Z INFO add/case.go:112 Initting Stolon instances... 2023-04-18T12:43:11.312Z INFO add/case.go:170 Waiting for Stolon daemons to start... make sure shardmand daemons are running on the nodes ✓ Waiting for Stolon daemons of rg clover-1-sdm01: success 31.012s ✓ Waiting for Stolon daemons of rg clover-1-sdm02: success 0.012s 2023-04-18T12:43:42.336Z INFO add/case.go:187 Adding repgroups... ✓ waiting rg 1 config apply: done 7.014s 2023-04-18T12:43:49.444Z DEBUG broadcaster/worker.go:33 start broadcaster worker for repgroup id=1 2023-04-18T12:43:49.453Z DEBUG broadcaster/worker.go:51 repgroup 1 connect established 2023-04-18T12:43:49.453Z DEBUG commands/addrepgroup.go:575 waiting for extension lock... 2023-04-18T12:43:49.453Z DEBUG commands/addrepgroup.go:137 Loading schema into replication group rg 1 ... 2023-04-18T12:44:25.665Z DEBUG rebalance/service.go:528 wait all tasks finish 2023-04-18T12:44:25.666Z DEBUG broadcaster/worker.go:75 finish broadcaster worker for repgroup id=1 2023-04-18T12:44:25.666Z DEBUG broadcaster/worker.go:75 finish broadcaster worker for repgroup id=2 2023-04-18T12:44:25.666Z INFO add/case.go:221 Successfully added nodes sdm01, sdm02 to the cluster
The “Successfully added nodes sdm01, sdm02 to the cluster” message means that everything is fine and nodes sdm01 and sdm02 are working properly.
1.3.7. Check the Shardman Cluster Status #
Let's check the status of the cluster nodes
shardmanctl status ┌──────────────────────────────────────────────────────────────────────────────────────────────────┐ │ == STORE STATUS == │ ├───────────┬──────────────────────────────────────────┬─────────────────────┬─────────────────────┤ │ STATUS │ MESSAGE │ REPLICATION GROUP │ NODE │ ├───────────┼──────────────────────────────────────────┼─────────────────────┼─────────────────────┤ │ Warning │ Store has only one member, consider │ │ │ │ │ deploying store cluster │ │ │ └───────────┴──────────────────────────────────────────┴─────────────────────┴─────────────────────┘ ┌─────────────────────────────────────────────────────────────────────────────────────────────────┐ │ == TOPOLOGY STATUS == │ ├───────────┬─────────────────────────────────────────┬─────────────────────┬─────────────────────┤ │ STATUS │ MESSAGE │ REPLICATION GROUP │ NODE │ ├───────────┼─────────────────────────────────────────┼─────────────────────┼─────────────────────┤ │ CROSS │ Topology placement policy is CROSS │ │ │ └───────────┴─────────────────────────────────────────┴─────────────────────┴─────────────────────┘ ┌─────────────────────────────────────────────────────────────────────────────────────────────────┐ │ == METADATA STATUS == │ ├───────────┬─────────────────────────────────────────┬─────────────────────┬─────────────────────┤ │ STATUS │ MESSAGE │ REPLICATION GROUP │ NODE │ ├───────────┼─────────────────────────────────────────┼─────────────────────┼─────────────────────┤ │ OK │ Metadata is OK │ │ │ └───────────┴─────────────────────────────────────────┴─────────────────────┴─────────────────────┘ ┌─────────────────────────────────────────────────────────────────────────────────────────────────┐ │ == SHARDMAND STATUS == │ ├───────────┬─────────────────────────────────────────┬─────────────────────┬─────────────────────┤ │ STATUS │ MESSAGE │ REPLICATION GROUP │ NODE │ ├───────────┼─────────────────────────────────────────┼─────────────────────┼─────────────────────┤ │ OK │ shardmand on node sdm01 is OK │ │ sdm01 │ ├───────────┼─────────────────────────────────────────┼─────────────────────┼─────────────────────┤ │ OK │ shardmand on node sdm02 is OK │ │ sdm02 │ └───────────┴─────────────────────────────────────────┴─────────────────────┴─────────────────────┘ ┌─────────────────────────────────────────────────────────────────────────────────────────────────┐ │ == REPLICATION GROUP STATUS == │ ├───────────┬─────────────────────────────────────────┬─────────────────────┬─────────────────────┤ │ STATUS │ MESSAGE │ REPLICATION GROUP │ NODE │ ├───────────┼─────────────────────────────────────────┼─────────────────────┼─────────────────────┤ │ OK │ Replication group clover-1-sdm01 is OK │ clover-1-sdm01 │ │ ├───────────┼─────────────────────────────────────────┼─────────────────────┼─────────────────────┤ │ OK │ Replication group clover-1-sdm02 is OK │ clover-1-sdm02 │ │ └───────────┴─────────────────────────────────────────┴─────────────────────┴─────────────────────┘ ┌──────────────────────────────────────────────────────────────────────────────────────────────────┐ │ == MASTER STATUS == │ ├───────────┬──────────────────────────────────────────┬─────────────────────┬─────────────────────┤ │ STATUS │ MESSAGE │ REPLICATION GROUP │ NODE │ ├───────────┼──────────────────────────────────────────┼─────────────────────┼─────────────────────┤ │ OK │ Replication group clover-1-sdm01 master │ clover-1-sdm01 │ sdm01:5432 │ │ │ is running on sdm01:5432 │ │ │ ├───────────┼──────────────────────────────────────────┼─────────────────────┼─────────────────────┤ │ OK │ Replication group clover-1-sdm02 master │ clover-1-sdm02 │ sdm02:5432 │ │ │ is running on sdm02:5432 │ │ │ └───────────┴──────────────────────────────────────────┴─────────────────────┴─────────────────────┘ ┌──────────────────────────────────────────────────────────────────────────────────────────────────┐ │ == DICTIONARY STATUS == │ ├───────────┬──────────────────────────────────────────┬─────────────────────┬─────────────────────┤ │ STATUS │ MESSAGE │ REPLICATION GROUP │ NODE │ ├───────────┼──────────────────────────────────────────┼─────────────────────┼─────────────────────┤ │ OK │ Replication group clover-1-sdm01 │ clover-1-sdm01 │ │ │ │ dictionary is OK │ │ │ ├───────────┼──────────────────────────────────────────┼─────────────────────┼─────────────────────┤ │ OK │ Replication group clover-1-sdm02 │ clover-1-sdm02 │ │ │ │ dictionary is OK │ │ │ └───────────┴──────────────────────────────────────────┴─────────────────────┴─────────────────────┘
1.3.8. Connect to the Shardman Cluster #
To connect to the cluster we should get the cluster connection string on any cluster node (sdm01 or sdm02):
shardmanctl getconnstr
Output example:
dbname=postgres host=sdm01,sdm02 password=!!!CHANGE_ME!!! port=5432,5432 user=postgres
And then let’s try to connect:
psql -d 'dbname=postgres host=sdm01,sdm02 password=!!!CHANGE_ME!!! port=5432,5432 user=postgres'
Output example:
psql (14.7) Type "help" for help. postgres=#
1.3.9. Create Sharded Tables #
Let's try to create a sharded table and check if everything is working properly.
postgres=# create table x(id int primary key, t text) with (distributed_by='id',num_parts=2);
Output example:
CREATE TABLE
postgres=# \d
List of relations
Schema | Name | Type | Owner
--------+---------+-------------------+----------
public | x | partitioned table | postgres
public | x_0 | table | postgres
public | x_1_fdw | foreign table | postgres
(3 rows)
postgres=# \d x_0
Table "public.x_0"
Column | Type | Collation | Nullable | Default
--------+---------+-----------+----------+---------
id | integer | | not null |
t | text | | |
Partition of: x FOR VALUES WITH (modulus 2, remainder 0)
Indexes:
"x_0_pkey" PRIMARY KEY, btree (id)
postgres=# \d x_1_fdw
Foreign table "public.x_1_fdw"
Column | Type | Collation | Nullable | Default | FDW options
--------+---------+-----------+----------+---------+-------------
id | integer | | not null | |
t | text | | | |
Partition of: x FOR VALUES WITH (modulus 2, remainder 1)
Server: shardman_rg_2
FDW options: (table_name 'x_1')
postgres=# insert into x values (1,'t'),(2,'t'),(3,'t');
INSERT 0 3
postgres=# select * from x_0;
id | t
----+---
1 | t
2 | t
(2 rows)
postgres=# select * from x_1_fdw;
id | t
----+---
3 | t
(1 row)
Everything works as expected.
1.3.10. Example: Deploy a Multi-Node etcd Cluster #
The process is described for the following servers:
192.0.1.1 etcd1 192.0.1.2 etcd2 192.0.1.3 etcd3
Install the needed packages on each server:
sudo apt install -y vim curl
To connect the repository, on each server, run:
sudo curl -fsSL https://repo.postgrespro.ru/sdm/sdm-14/keys/pgpro-repo-add.sh | bash
Install etcd-sdm packages on each server:
sudo apt install -y etcd-sdm
For each server, edit the file that lists environment variables, replacing placeholders in angle brackets with specific values:
sudo vim /etc/default/etcd-sdm ETCD_NAME=<hostname> ETCD_LISTEN_PEER_URLS=http://0.0.0.0:2380 ETCD_LISTEN_CLIENT_URLS=http://0.0.0.0:2379 ETCD_ADVERTISE_CLIENT_URLS=http://<host ip address>:2379 ETCD_INITIAL_ADVERTISE_PEER_URLS=http://<host ip address>:2380 ETCD_INITIAL_CLUSTER_TOKEN=etcd-cluster-1 ETCD_INITIAL_CLUSTER_STATE=new ETCD_MAX_SNAPSHOTS=5 ETCD_MAX_WALS=5 ETCD_AUTO_COMPACTION_MODE=periodic ETCD_AUTO_COMPACTION_RETENTION=5m ETCD_QUOTA_BACKEND_BYTES=6442450944 ETCD_DATA_DIR=/var/lib/etcd-sdm/sdm-14 ETCD_INITIAL_CLUSTER=etcd1=http://<ip etcd1>:2380,etcd2=http://<ip etcd2>:2380,etcd3=http://<ip etcd3>:2380
This file will be loaded at etcd start with its own start settings on each server.
Clear the etcd data directory:
sudo rm -rf /var/lib/etcd-sdm/sdm-14/*
Restart the etcd-sdm service on each server:
sudo systemctl restart etcd-sdm
For your user, add /opt/pgpro/sdm-14/bin to the PATH environment variable:
echo "export PATH=$PATH:/opt/pgpro/sdm-14/bin" >> ~/.bashrc source ~/.bashrc
Check that etcd is properly configured:
etcdctl member list -w table +------------------+---------+-------+----------------------------+----------------------------+------------+ | ID | STATUS | NAME | PEER ADDRS | CLIENT ADDRS | IS LEARNER | +------------------+---------+-------+----------------------------+----------------------------+------------+ | 318be6342e6d9ac | started | etcd1 | http://192.0.1.1:2380 | http://192.0.1.1:2379 | false | | 9e49480544aedb89 | started | etcd2 | http://192.0.1.2:2380 | http://192.0.1.2:2379 | false | +------------------+---------+-------+----------------------------+----------------------------+------------+ etcdctl --endpoints=http://etcd1:2380,http://etcd2:2380 endpoint status health -w table +----------------------------+------------------+---------+---------+-----------+------------+-----------+------------+--------------------+--------+ | ENDPOINT | ID | VERSION | DB SIZE | IS LEADER | IS LEARNER | RAFT TERM | RAFT INDEX | RAFT APPLIED INDEX | ERRORS | +----------------------------+------------------+---------+---------+-----------+------------+-----------+------------+--------------------+--------+ | http://192.0.1.1:2380 | 318be6342e6d9ac | 3.5.9 | 5.7 MB | true | false | 13 | 425686 | 425686 | | | http://192.0.1.2:2380 | 9e49480544aedb89 | 3.5.9 | 5.7 MB | false | false | 13 | 425686 | 425686 | | +----------------------------+------------------+---------+---------+-----------+------------+-----------+------------+--------------------+--------+ -------+
The etcd cluster is properly configured and ready to serve requests.
To prevent bloat when etcd is intensively used, add a defragmentation command to cron:
sudo { crontab -l; echo "@hourly /opt/pgpro/sdm-14/bin/etcdctl defrag"; } | crontab
The final endpoints string of the etcd cluster:
etcd1=http://<ip etcd1>:2380,etcd2=http://<ip etcd2>:2380,etcd3=http://<ip etcd3>:2380
It should be specified in /etc/shardman configuration file and as a --store-endpoints parameter of shardmanctl.