Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3.0 configuration #3825

Merged
merged 5 commits into from
Nov 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions doc/book/admin/start_stop_instance.rst
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ With a single ``tt`` call, you can:
* connect to a specific instance of an application
* stop a specific instance of an application or all its instances

.. _admin-start_stop_instance-multi-instance-layout:

Application layout
~~~~~~~~~~~~~~~~~~

Expand Down
11 changes: 11 additions & 0 deletions doc/code_snippets/snippets/config/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Configuration

A sample application demonstrating various features related to Tarantool [configuration](https://www.tarantool.io/en/doc/latest/concepts/configuration/).

## Running

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:

```console
$ tt start application
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
app:
file: 'myapp.lua'
cfg:
greeting: 'Hello'

groups:
group001:
replicasets:
replicaset001:
instances:
instance001:
iproto:
listen: "3301"
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
instance001:
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-- myapp.lua --
local log = require('log').new("myapp")
local config = require('config')
log.info("%s from app, %s!", config:get('app.cfg.greeting'), box.info.name)
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
config:
etcd:
endpoints:
- http://localhost:2379
prefix: /example
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
instance001:
instance002:
instance003:
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
config:
etcd:
endpoints:
- http://localhost:2379
prefix: /example
username: testuser
password: foobar
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ssl:
ca_file: ca.crt
http:
request:
timeout: 3
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
instance001:
instance002:
instance003:
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
iproto:
listen: "3301"

groups:
group001:
replicasets:
replicaset001:
instances:
instance001: {}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
instance001:
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
groups:
group001:
iproto:
listen: "3301"
replicasets:
replicaset001:
instances:
instance001: {}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
instance001:
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
groups:
group001:
replicasets:
replicaset001:
instances:
instance001:
iproto:
listen: "3301"
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
instance001:
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
groups:
group001:
replicasets:
replicaset001:
iproto:
listen: "3301"
instances:
instance001: {}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
instance001:
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
groups:
group001:
replicasets:
replicaset001:
instances:
instance001:
snapshot:
dir: ./var/{{ instance_name }}/snapshots
wal:
dir: ./var/{{ instance_name }}/wals
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
instance001:
63 changes: 63 additions & 0 deletions doc/code_snippets/snippets/config/tt.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
tt:
modules:
# Directory where the external modules are stored.
directory: "modules"

app:
# Directory that stores various instance runtime
# artifacts like console socket, PID file, etc.
run_dir: "var/run"

# Directory that stores log files.
log_dir: var/log

# The maximum size in MB of the log file before it gets rotated.
log_maxsize: 100

# The maximum number of days to retain old log files.
log_maxage: 8

# The maximum number of old log files to retain.
log_maxbackups: 10

# Restart instance on failure.
restart_on_failure: false

# Directory where write-ahead log (.xlog) files are stored.
wal_dir: "var/lib"

# Directory where memtx stores snapshot (.snap) files.
memtx_dir: "var/lib"

# Directory where vinyl files or subdirectories will be stored.
vinyl_dir: "var/lib"

# Directory that stores binary files.
bin_dir: "bin"

# Directory that stores Tarantool header files.
inc_dir: "include"

# Path to directory that stores all applications.
# The directory can also contain symbolic links to applications.
instances_enabled: "instances.enabled"

# Tarantoolctl artifacts layout compatibility: if set to true tt will not create application
# sub-directories for control socket, pid files, log files, etc.. Data files (wal, vinyl,
# snap) and multi-instance applications are not affected by this option.
tarantoolctl_layout: false

# Path to file with credentials for downloading Tarantool Enterprise Edition.
# credential_path: /path/to/file
ee:
credential_path: ""

templates:
# The path to templates search directory.
- path: "templates"

repo:
# Directory where local rocks files could be found.
rocks: ""
# Directory that stores installation files.
distfiles: "distfiles"
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
credentials:
users:
replicator:
password: 'topsecret'
roles: [replication]

iproto:
advertise:
peer: replicator@

replication:
failover: election

groups:
group001:
replicasets:
replicaset001:
instances:
instance001:
iproto:
listen: 127.0.0.1:3301
instance002:
iproto:
listen: 127.0.0.1:3302
instance003:
iproto:
listen: 127.0.0.1:3303

# Load sample data
app:
file: 'data.lua'
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
function create_space()
box.schema.space.create('bands')
box.space.bands:format({
{ name = 'id', type = 'unsigned' },
{ name = 'band_name', type = 'string' },
{ name = 'year', type = 'unsigned' }
})
box.space.bands:create_index('primary', { parts = { 'id' } })
end

function create_sync_space()
box.schema.space.create('bands', { is_sync = true })
box.space.bands:format({
{ name = 'id', type = 'unsigned' },
{ name = 'band_name', type = 'string' },
{ name = 'year', type = 'unsigned' }
})
box.space.bands:create_index('primary', { parts = { 'id' } })
end

function load_data()
box.space.bands:insert { 1, 'Roxette', 1986 }
box.space.bands:insert { 2, 'Scorpions', 1965 }
box.space.bands:insert { 3, 'Ace of Base', 1987 }
box.space.bands:insert { 4, 'The Beatles', 1960 }
box.space.bands:insert { 5, 'Pink Floyd', 1965 }
box.space.bands:insert { 6, 'The Rolling Stones', 1962 }
box.space.bands:insert { 7, 'The Doors', 1965 }
box.space.bands:insert { 8, 'Nirvana', 1987 }
box.space.bands:insert { 9, 'Led Zeppelin', 1968 }
box.space.bands:insert { 10, 'Queen', 1970 }
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
instance001:
instance002:
instance003:
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
credentials:
users:
replicator:
password: 'topsecret'
roles: [replication]
client:
password: 'secret'
roles: [super]

iproto:
advertise:
peer: replicator@

replication:
failover: manual

groups:
group001:
replicasets:
replicaset001:
leader: instance001
instances:
instance001:
iproto:
listen: 127.0.0.1:3301
instance002:
iproto:
listen: 127.0.0.1:3302
instance003:
iproto:
listen: 127.0.0.1:3303

# Load sample data
app:
file: 'myapp.lua'
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
instance001:
instance002:
instance003:
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
function create_space()
box.schema.space.create('bands')
box.space.bands:format({
{ name = 'id', type = 'unsigned' },
{ name = 'band_name', type = 'string' },
{ name = 'year', type = 'unsigned' }
})
box.space.bands:create_index('primary', { parts = { 'id' } })
end

function create_sync_space()
box.schema.space.create('bands', { is_sync = true })
box.space.bands:format({
{ name = 'id', type = 'unsigned' },
{ name = 'band_name', type = 'string' },
{ name = 'year', type = 'unsigned' }
})
box.space.bands:create_index('primary', { parts = { 'id' } })
end

function load_data()
box.space.bands:insert { 1, 'Roxette', 1986 }
box.space.bands:insert { 2, 'Scorpions', 1965 }
box.space.bands:insert { 3, 'Ace of Base', 1987 }
box.space.bands:insert { 4, 'The Beatles', 1960 }
box.space.bands:insert { 5, 'Pink Floyd', 1965 }
box.space.bands:insert { 6, 'The Rolling Stones', 1962 }
box.space.bands:insert { 7, 'The Doors', 1965 }
box.space.bands:insert { 8, 'Nirvana', 1987 }
box.space.bands:insert { 9, 'Led Zeppelin', 1968 }
box.space.bands:insert { 10, 'Queen', 1970 }
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
credentials:
users:
replicator:
password: 'topsecret'
roles: [replication]

iproto:
advertise:
peer: replicator@

replication:
failover: off

groups:
group001:
replicasets:
replicaset001:
instances:
instance001:
database:
mode: rw
iproto:
listen: 127.0.0.1:3301
instance002:
database:
mode: rw
iproto:
listen: 127.0.0.1:3302
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
instance001:
instance002:
Loading