Skip to content

Commit f1277cb

Browse files
3.0 configuration (#3825)
Document a new declarative configuration approach: local YAML file and etcd config
1 parent 7b587a0 commit f1277cb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1861
-451
lines changed

doc/book/admin/start_stop_instance.rst

+2
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@ With a single ``tt`` call, you can:
124124
* connect to a specific instance of an application
125125
* stop a specific instance of an application or all its instances
126126

127+
.. _admin-start_stop_instance-multi-instance-layout:
128+
127129
Application layout
128130
~~~~~~~~~~~~~~~~~~
129131

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Configuration
2+
3+
A sample application demonstrating various features related to Tarantool [configuration](https://www.tarantool.io/en/doc/latest/concepts/configuration/).
4+
5+
## Running
6+
7+
To run applications placed in [instances.enabled](instances.enabled), go to the `config` directory in the terminal and execute the `tt start` command, for example:
8+
9+
```console
10+
$ tt start application
11+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
app:
2+
file: 'myapp.lua'
3+
cfg:
4+
greeting: 'Hello'
5+
6+
groups:
7+
group001:
8+
replicasets:
9+
replicaset001:
10+
instances:
11+
instance001:
12+
iproto:
13+
listen: "3301"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
instance001:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
-- myapp.lua --
2+
local log = require('log').new("myapp")
3+
local config = require('config')
4+
log.info("%s from app, %s!", config:get('app.cfg.greeting'), box.info.name)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
config:
2+
etcd:
3+
endpoints:
4+
- http://localhost:2379
5+
prefix: /example
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
instance001:
2+
instance002:
3+
instance003:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
config:
2+
etcd:
3+
endpoints:
4+
- http://localhost:2379
5+
prefix: /example
6+
username: testuser
7+
password: foobar
8+
ssl:
9+
ca_file: ca.crt
10+
http:
11+
request:
12+
timeout: 3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
instance001:
2+
instance002:
3+
instance003:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
iproto:
2+
listen: "3301"
3+
4+
groups:
5+
group001:
6+
replicasets:
7+
replicaset001:
8+
instances:
9+
instance001: {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
instance001:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
groups:
2+
group001:
3+
iproto:
4+
listen: "3301"
5+
replicasets:
6+
replicaset001:
7+
instances:
8+
instance001: {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
instance001:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
groups:
2+
group001:
3+
replicasets:
4+
replicaset001:
5+
instances:
6+
instance001:
7+
iproto:
8+
listen: "3301"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
instance001:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
groups:
2+
group001:
3+
replicasets:
4+
replicaset001:
5+
iproto:
6+
listen: "3301"
7+
instances:
8+
instance001: {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
instance001:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
groups:
2+
group001:
3+
replicasets:
4+
replicaset001:
5+
instances:
6+
instance001:
7+
snapshot:
8+
dir: ./var/{{ instance_name }}/snapshots
9+
wal:
10+
dir: ./var/{{ instance_name }}/wals
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
instance001:
+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
tt:
2+
modules:
3+
# Directory where the external modules are stored.
4+
directory: "modules"
5+
6+
app:
7+
# Directory that stores various instance runtime
8+
# artifacts like console socket, PID file, etc.
9+
run_dir: "var/run"
10+
11+
# Directory that stores log files.
12+
log_dir: var/log
13+
14+
# The maximum size in MB of the log file before it gets rotated.
15+
log_maxsize: 100
16+
17+
# The maximum number of days to retain old log files.
18+
log_maxage: 8
19+
20+
# The maximum number of old log files to retain.
21+
log_maxbackups: 10
22+
23+
# Restart instance on failure.
24+
restart_on_failure: false
25+
26+
# Directory where write-ahead log (.xlog) files are stored.
27+
wal_dir: "var/lib"
28+
29+
# Directory where memtx stores snapshot (.snap) files.
30+
memtx_dir: "var/lib"
31+
32+
# Directory where vinyl files or subdirectories will be stored.
33+
vinyl_dir: "var/lib"
34+
35+
# Directory that stores binary files.
36+
bin_dir: "bin"
37+
38+
# Directory that stores Tarantool header files.
39+
inc_dir: "include"
40+
41+
# Path to directory that stores all applications.
42+
# The directory can also contain symbolic links to applications.
43+
instances_enabled: "instances.enabled"
44+
45+
# Tarantoolctl artifacts layout compatibility: if set to true tt will not create application
46+
# sub-directories for control socket, pid files, log files, etc.. Data files (wal, vinyl,
47+
# snap) and multi-instance applications are not affected by this option.
48+
tarantoolctl_layout: false
49+
50+
# Path to file with credentials for downloading Tarantool Enterprise Edition.
51+
# credential_path: /path/to/file
52+
ee:
53+
credential_path: ""
54+
55+
templates:
56+
# The path to templates search directory.
57+
- path: "templates"
58+
59+
repo:
60+
# Directory where local rocks files could be found.
61+
rocks: ""
62+
# Directory that stores installation files.
63+
distfiles: "distfiles"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
credentials:
2+
users:
3+
replicator:
4+
password: 'topsecret'
5+
roles: [replication]
6+
7+
iproto:
8+
advertise:
9+
peer: replicator@
10+
11+
replication:
12+
failover: election
13+
14+
groups:
15+
group001:
16+
replicasets:
17+
replicaset001:
18+
instances:
19+
instance001:
20+
iproto:
21+
listen: 127.0.0.1:3301
22+
instance002:
23+
iproto:
24+
listen: 127.0.0.1:3302
25+
instance003:
26+
iproto:
27+
listen: 127.0.0.1:3303
28+
29+
# Load sample data
30+
app:
31+
file: 'data.lua'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
function create_space()
2+
box.schema.space.create('bands')
3+
box.space.bands:format({
4+
{ name = 'id', type = 'unsigned' },
5+
{ name = 'band_name', type = 'string' },
6+
{ name = 'year', type = 'unsigned' }
7+
})
8+
box.space.bands:create_index('primary', { parts = { 'id' } })
9+
end
10+
11+
function create_sync_space()
12+
box.schema.space.create('bands', { is_sync = true })
13+
box.space.bands:format({
14+
{ name = 'id', type = 'unsigned' },
15+
{ name = 'band_name', type = 'string' },
16+
{ name = 'year', type = 'unsigned' }
17+
})
18+
box.space.bands:create_index('primary', { parts = { 'id' } })
19+
end
20+
21+
function load_data()
22+
box.space.bands:insert { 1, 'Roxette', 1986 }
23+
box.space.bands:insert { 2, 'Scorpions', 1965 }
24+
box.space.bands:insert { 3, 'Ace of Base', 1987 }
25+
box.space.bands:insert { 4, 'The Beatles', 1960 }
26+
box.space.bands:insert { 5, 'Pink Floyd', 1965 }
27+
box.space.bands:insert { 6, 'The Rolling Stones', 1962 }
28+
box.space.bands:insert { 7, 'The Doors', 1965 }
29+
box.space.bands:insert { 8, 'Nirvana', 1987 }
30+
box.space.bands:insert { 9, 'Led Zeppelin', 1968 }
31+
box.space.bands:insert { 10, 'Queen', 1970 }
32+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
instance001:
2+
instance002:
3+
instance003:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
credentials:
2+
users:
3+
replicator:
4+
password: 'topsecret'
5+
roles: [replication]
6+
client:
7+
password: 'secret'
8+
roles: [super]
9+
10+
iproto:
11+
advertise:
12+
peer: replicator@
13+
14+
replication:
15+
failover: manual
16+
17+
groups:
18+
group001:
19+
replicasets:
20+
replicaset001:
21+
leader: instance001
22+
instances:
23+
instance001:
24+
iproto:
25+
listen: 127.0.0.1:3301
26+
instance002:
27+
iproto:
28+
listen: 127.0.0.1:3302
29+
instance003:
30+
iproto:
31+
listen: 127.0.0.1:3303
32+
33+
# Load sample data
34+
app:
35+
file: 'myapp.lua'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
instance001:
2+
instance002:
3+
instance003:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
function create_space()
2+
box.schema.space.create('bands')
3+
box.space.bands:format({
4+
{ name = 'id', type = 'unsigned' },
5+
{ name = 'band_name', type = 'string' },
6+
{ name = 'year', type = 'unsigned' }
7+
})
8+
box.space.bands:create_index('primary', { parts = { 'id' } })
9+
end
10+
11+
function create_sync_space()
12+
box.schema.space.create('bands', { is_sync = true })
13+
box.space.bands:format({
14+
{ name = 'id', type = 'unsigned' },
15+
{ name = 'band_name', type = 'string' },
16+
{ name = 'year', type = 'unsigned' }
17+
})
18+
box.space.bands:create_index('primary', { parts = { 'id' } })
19+
end
20+
21+
function load_data()
22+
box.space.bands:insert { 1, 'Roxette', 1986 }
23+
box.space.bands:insert { 2, 'Scorpions', 1965 }
24+
box.space.bands:insert { 3, 'Ace of Base', 1987 }
25+
box.space.bands:insert { 4, 'The Beatles', 1960 }
26+
box.space.bands:insert { 5, 'Pink Floyd', 1965 }
27+
box.space.bands:insert { 6, 'The Rolling Stones', 1962 }
28+
box.space.bands:insert { 7, 'The Doors', 1965 }
29+
box.space.bands:insert { 8, 'Nirvana', 1987 }
30+
box.space.bands:insert { 9, 'Led Zeppelin', 1968 }
31+
box.space.bands:insert { 10, 'Queen', 1970 }
32+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
credentials:
2+
users:
3+
replicator:
4+
password: 'topsecret'
5+
roles: [replication]
6+
7+
iproto:
8+
advertise:
9+
peer: replicator@
10+
11+
replication:
12+
failover: off
13+
14+
groups:
15+
group001:
16+
replicasets:
17+
replicaset001:
18+
instances:
19+
instance001:
20+
database:
21+
mode: rw
22+
iproto:
23+
listen: 127.0.0.1:3301
24+
instance002:
25+
database:
26+
mode: rw
27+
iproto:
28+
listen: 127.0.0.1:3302
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
instance001:
2+
instance002:

0 commit comments

Comments
 (0)