如何自动配置 Tarantool Cartridge 集群?
How to config Tarantool Cartridge cluster automatically?
我有一个在 Tarantool Cartridge 上开发的应用程序。我的集群由 12 个 Tarantool 实例组成,分为 4 个副本集(一些是路由器,一些是存储)。现在从头开始设置这个集群,我在 Web UI 管理应用程序上手动配置这个集群:创建副本集,bootstrap 存储,配置故障转移模式。
如何自动执行此配置?什么是最好的方法?
有这样的工具:
- Ansible 角色:https://github.com/tarantool/ansible-cartridge
- Kubernetes 操作员:https://github.com/tarantool/tarantool-operator
您可以启动所有应包含在集群中的 tarantool 实例,通过 tarantoolctl 连接到其中一个并执行确定集群拓扑的脚本,通过 vshard 初始化分片,并配置故障转移模式(在示例中, 通过 etcd).
cartridge = require('cartridge')
replicasets = { {
alias = 'router1',
roles = { 'router', 'vshard-router', 'failover-coordinator' },
join_servers = { { uri = '172.20.0.2:3301' } }
}, {
alias = 'router2',
roles = { 'router', 'vshard-router', 'failover-coordinator' },
join_servers = { { uri = '172.20.0.3:3301' } }
}, {
alias = 'router3',
roles = { 'router', 'vshard-router', 'failover-coordinator' },
join_servers = { { uri = '172.20.0.4:3301' } }
}, {
alias = 'storage1',
roles = { 'storage', 'vshard-storage' },
join_servers = { { uri = '172.20.0.2:3302' },
{ uri = '172.20.0.3:3302' },
{ uri = '172.20.0.4:3302' } }
}, {
alias = 'storage2',
roles = { 'storage', 'vshard-storage' },
join_servers = { { uri = '172.20.0.3:3303' },
{ uri = '172.20.0.2:3303' },
{ uri = '172.20.0.4:3303' } }
}, {
alias = 'storage3',
roles = { 'storage', 'vshard-storage' },
join_servers = { { uri = '172.20.0.4:3304' },
{ uri = '172.20.0.2:3304' },
{ uri = '172.20.0.3:3304' } }
} }
cartridge.admin_edit_topology({ replicasets = replicasets })
cartridge.admin_bootstrap_vshard()
cartridge.failover_set_params({
mode = 'stateful',
state_provider = 'etcd2',
etcd2_params = {
prefix = '/',
lock_delay = 10,
endpoints = { '172.20.0.2:2379', '172.20.0.3:2379', '172.20.0.4:2379' }
}
})
我有一个在 Tarantool Cartridge 上开发的应用程序。我的集群由 12 个 Tarantool 实例组成,分为 4 个副本集(一些是路由器,一些是存储)。现在从头开始设置这个集群,我在 Web UI 管理应用程序上手动配置这个集群:创建副本集,bootstrap 存储,配置故障转移模式。 如何自动执行此配置?什么是最好的方法?
有这样的工具:
- Ansible 角色:https://github.com/tarantool/ansible-cartridge
- Kubernetes 操作员:https://github.com/tarantool/tarantool-operator
您可以启动所有应包含在集群中的 tarantool 实例,通过 tarantoolctl 连接到其中一个并执行确定集群拓扑的脚本,通过 vshard 初始化分片,并配置故障转移模式(在示例中, 通过 etcd).
cartridge = require('cartridge')
replicasets = { {
alias = 'router1',
roles = { 'router', 'vshard-router', 'failover-coordinator' },
join_servers = { { uri = '172.20.0.2:3301' } }
}, {
alias = 'router2',
roles = { 'router', 'vshard-router', 'failover-coordinator' },
join_servers = { { uri = '172.20.0.3:3301' } }
}, {
alias = 'router3',
roles = { 'router', 'vshard-router', 'failover-coordinator' },
join_servers = { { uri = '172.20.0.4:3301' } }
}, {
alias = 'storage1',
roles = { 'storage', 'vshard-storage' },
join_servers = { { uri = '172.20.0.2:3302' },
{ uri = '172.20.0.3:3302' },
{ uri = '172.20.0.4:3302' } }
}, {
alias = 'storage2',
roles = { 'storage', 'vshard-storage' },
join_servers = { { uri = '172.20.0.3:3303' },
{ uri = '172.20.0.2:3303' },
{ uri = '172.20.0.4:3303' } }
}, {
alias = 'storage3',
roles = { 'storage', 'vshard-storage' },
join_servers = { { uri = '172.20.0.4:3304' },
{ uri = '172.20.0.2:3304' },
{ uri = '172.20.0.3:3304' } }
} }
cartridge.admin_edit_topology({ replicasets = replicasets })
cartridge.admin_bootstrap_vshard()
cartridge.failover_set_params({
mode = 'stateful',
state_provider = 'etcd2',
etcd2_params = {
prefix = '/',
lock_delay = 10,
endpoints = { '172.20.0.2:2379', '172.20.0.3:2379', '172.20.0.4:2379' }
}
})