Skip to content

Commit 344ba58

Browse files

25 files changed

+1696
-156
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Centralized migrations with tt
2+
3+
Sample applications demonstrating how to use the centralized migration mechanism
4+
for Tarantool EE clusters via the tt utility. Learn more at [Centralized configuration storages](https://www.tarantool.io/en/doc/latest/platform/https://www.tarantool.io/en/doc/latest/platform/ddl_dml/migrations/).
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/env bash
2+
3+
# 1. Remove the 'default.etcd' directory to reset etcd to initial state.
4+
# 2. Start etcd by executing the 'etcd' command.
5+
# 3. Execute this script to enable authentication.
6+
7+
etcdctl user add root:topsecret
8+
etcdctl role add app_config_manager
9+
etcdctl role grant-permission app_config_manager --prefix=true readwrite /myapp/
10+
etcdctl user add app_user:config_pass
11+
etcdctl user grant-role app_user app_config_manager
12+
etcdctl auth enable
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
config:
2+
etcd:
3+
endpoints:
4+
- http://localhost:2379
5+
prefix: /myapp/
6+
username: app_user
7+
password: config_pass
8+
http:
9+
request:
10+
timeout: 3
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
router-001-a:
2+
storage-001-a:
3+
storage-001-b:
4+
storage-002-a:
5+
storage-002-b:
6+
storage-003-a:
7+
storage-003-b:
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
router-001-a:
2+
storage-001-a:
3+
storage-001-b:
4+
storage-002-a:
5+
storage-002-b:
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package = 'myapp'
2+
version = 'scm-1'
3+
4+
source = {
5+
url = '/dev/null',
6+
}
7+
8+
dependencies = {
9+
'crud == 1.5.2',
10+
}
11+
12+
build = {
13+
type = 'none';
14+
}
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
credentials:
2+
users:
3+
client:
4+
password: 'secret'
5+
roles: [super]
6+
replicator:
7+
password: 'secret'
8+
roles: [replication]
9+
storage:
10+
password: 'secret'
11+
roles: [sharding]
12+
13+
iproto:
14+
advertise:
15+
peer:
16+
login: replicator
17+
sharding:
18+
login: storage
19+
20+
sharding:
21+
bucket_count: 3000
22+
23+
groups:
24+
routers:
25+
sharding:
26+
roles: [router]
27+
roles: [roles.crud-router]
28+
replicasets:
29+
router-001:
30+
instances:
31+
router-001-a:
32+
iproto:
33+
listen:
34+
- uri: localhost:3301
35+
advertise:
36+
client: localhost:3301
37+
storages:
38+
sharding:
39+
roles: [storage]
40+
roles: [roles.crud-storage]
41+
replication:
42+
failover: manual
43+
replicasets:
44+
storage-001:
45+
leader: storage-001-a
46+
instances:
47+
storage-001-a:
48+
iproto:
49+
listen:
50+
- uri: localhost:3302
51+
advertise:
52+
client: localhost:3302
53+
storage-001-b:
54+
iproto:
55+
listen:
56+
- uri: localhost:3303
57+
advertise:
58+
client: localhost:3303
59+
storage-002:
60+
leader: storage-002-a
61+
instances:
62+
storage-002-a:
63+
iproto:
64+
listen:
65+
- uri: localhost:3304
66+
advertise:
67+
client: localhost:3304
68+
storage-002-b:
69+
iproto:
70+
listen:
71+
- uri: localhost:3305
72+
advertise:
73+
client: localhost:3305
74+
storage-003:
75+
leader: storage-003-a
76+
instances:
77+
storage-003-a:
78+
iproto:
79+
listen:
80+
- uri: localhost:3306
81+
advertise:
82+
client: localhost:3306
83+
storage-003-b:
84+
iproto:
85+
listen:
86+
- uri: localhost:3307
87+
advertise:
88+
client: localhost:3307
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
credentials:
2+
users:
3+
client:
4+
password: 'secret'
5+
roles: [super]
6+
replicator:
7+
password: 'secret'
8+
roles: [replication]
9+
storage:
10+
password: 'secret'
11+
roles: [sharding]
12+
13+
iproto:
14+
advertise:
15+
peer:
16+
login: replicator
17+
sharding:
18+
login: storage
19+
20+
sharding:
21+
bucket_count: 3000
22+
23+
groups:
24+
routers:
25+
sharding:
26+
roles: [router]
27+
roles: [roles.crud-router]
28+
replicasets:
29+
router-001:
30+
instances:
31+
router-001-a:
32+
iproto:
33+
listen:
34+
- uri: localhost:3301
35+
advertise:
36+
client: localhost:3301
37+
storages:
38+
sharding:
39+
roles: [storage]
40+
roles: [roles.crud-storage]
41+
replication:
42+
failover: manual
43+
replicasets:
44+
storage-001:
45+
leader: storage-001-a
46+
instances:
47+
storage-001-a:
48+
iproto:
49+
listen:
50+
- uri: localhost:3302
51+
advertise:
52+
client: localhost:3302
53+
storage-001-b:
54+
iproto:
55+
listen:
56+
- uri: localhost:3303
57+
advertise:
58+
client: localhost:3303
59+
storage-002:
60+
leader: storage-002-a
61+
instances:
62+
storage-002-a:
63+
iproto:
64+
listen:
65+
- uri: localhost:3304
66+
advertise:
67+
client: localhost:3304
68+
storage-002-b:
69+
iproto:
70+
listen:
71+
- uri: localhost:3305
72+
advertise:
73+
client: localhost:3305
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
local helpers = require('tt-migrations.helpers')
2+
3+
local function apply_scenario()
4+
local space = box.schema.space.create('writers')
5+
6+
space:format({
7+
{name = 'id', type = 'number'},
8+
{name = 'bucket_id', type = 'number'},
9+
{name = 'name', type = 'string'},
10+
{name = 'age', type = 'number'},
11+
})
12+
13+
space:create_index('primary', {parts = {'id'}})
14+
space:create_index('bucket_id', {parts = {'bucket_id'}})
15+
16+
helpers.register_sharding_key('writers', {'id'})
17+
end
18+
19+
return {
20+
apply = {
21+
scenario = apply_scenario,
22+
},
23+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
local function apply_scenario()
2+
local space = box.space['writers']
3+
4+
space:create_index('age', {parts = {'age'}})
5+
end
6+
7+
return {
8+
apply = {
9+
scenario = apply_scenario,
10+
},
11+
}

0 commit comments

Comments
 (0)