Skip to content

3.0 config: replication reference #3834

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

Merged
merged 12 commits into from
Nov 23, 2023
Merged
42 changes: 30 additions & 12 deletions doc/code_snippets/README.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,43 @@
# Tarantool code examples

The `doc/code_snippets` folder of a Tarantool documentation repository contains runnable code examples that show how to work with various Tarantool modules. Code from these examples is [referenced](#referencing-code-snippets) in corresponding documentation sections.
The `doc/code_snippets` folder of a Tarantool documentation repository contains runnable code examples that show how to work with Tarantool:

- The [snippets](snippets) folder contains sample applications that demonstrate how to configure a Tarantool cluster.
- The [test](test) folder contains testable Lua examples that show how to work with various Tarantool modules.

Code from these examples is [referenced](#referencing-code-snippets) in corresponding documentation sections.

## Prerequisites

First, install the [tt CLI utility](https://www.tarantool.io/en/doc/latest/reference/tooling/tt_cli/).
Then, go to the `doc/code_snippets` folder and install the following libraries:
- Install the [tt CLI utility](https://www.tarantool.io/en/doc/latest/reference/tooling/tt_cli/).
- To be able to run tests for samples from [test](test), go to the `doc/code_snippets` folder and install the following libraries:

- Install [luatest](https://github.com/tarantool/luatest):
```shell
tt rocks install luatest
```
- [luatest](https://github.com/tarantool/luatest):
```shell
tt rocks install luatest
```

- [luarapidxml](https://github.com/tarantool/luarapidxml):
```shell
tt rocks install luarapidxml
```

- Install [luarapidxml](https://github.com/tarantool/luarapidxml):
```shell
tt rocks install luarapidxml
```


## Running

### Running applications from 'snippets'

To run applications placed in [snippets](snippets), follow these steps:

1. Go to the directory containing samples for a specific feature, for example, [snippets/replication](snippets/replication).
2. To run applications placed in [instances.enabled](instances.enabled), execute the `tt start` command, for example:

```console
$ tt start auto_leader
```

## Running and testing examples
### Running and testing examples from 'test'

To test all the examples, go to the `doc/code_snippets` folder and execute the `luatest` command:

Expand Down
91 changes: 41 additions & 50 deletions doc/code_snippets/snippets/config/tt.yaml
Original file line number Diff line number Diff line change
@@ -1,63 +1,54 @@
tt:
modules:
# Directory where the external modules are stored.
directory: "modules"
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"
env:
# Restart instance on failure.
restart_on_failure: false

# Directory that stores log files.
log_dir: var/log
# Directory that stores binary files.
bin_dir: bin

# The maximum size in MB of the log file before it gets rotated.
log_maxsize: 100
# Directory that stores Tarantool header files.
inc_dir: include

# The maximum number of days to retain old log files.
log_maxage: 8
# Path to directory that stores all applications.
# The directory can also contain symbolic links to applications.
instances_enabled: instances.enabled

# The maximum number of old log files to retain.
log_maxbackups: 10
# Tarantoolctl artifacts layout compatibility: if set to true tt will not create application
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
# Tarantoolctl artifacts layout compatibility: if set to true tt will not create application
# Tarantoolctl artifacts layout compatibility: if set to true, tt will not create application

same for

  • doc/code_snippets/snippets/replication/tt.yaml
  • doc/code_snippets/snippets/sharding/tt.yaml

Copy link
Contributor Author

@andreyaksenov andreyaksenov Nov 23, 2023

Choose a reason for hiding this comment

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

Unfortunately, cannot fix this as tt.yaml is generated automatically using tt init. So, this is a reminder that we need to cteate a process for reviewing user-facing texts written by the tt development team.

# 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

# Restart instance on failure.
restart_on_failure: false
app:
# Directory that stores various instance runtime
# artifacts like console socket, PID file, etc.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
# artifacts like console socket, PID file, etc.
# artifacts such as console socket, PID file, etc.

same for

  • doc/code_snippets/snippets/replication/tt.yaml
  • doc/code_snippets/snippets/sharding/tt.yaml

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The same as above

run_dir: var/run

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

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

# Directory where vinyl files or subdirectories will be stored.
vinyl_dir: "var/lib"
# Directory where memtx stores snapshot (.snap) files.
memtx_dir: var/lib

# Directory that stores binary files.
bin_dir: "bin"
# Directory where vinyl files or subdirectories will be stored.
vinyl_dir: var/lib

# Directory that stores Tarantool header files.
inc_dir: "include"
# Path to file with credentials for downloading Tarantool Enterprise Edition.
# credential_path: /path/to/file
ee:
credential_path:

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

# 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"
repo:
# Directory where local rocks files could be found.
rocks:
# Directory that stores installation files.
distfiles: distfiles
11 changes: 11 additions & 0 deletions doc/code_snippets/snippets/replication/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Replication

A sample application demonstrating various replication features.

## Running

To run applications placed in [instances.enabled](instances.enabled), go to the `replication` directory in the terminal and execute the `tt start` command, for example:

```console
$ tt start auto_leader
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
credentials:
users:
replicator:
password: 'topsecret'
roles: [replication]

iproto:
advertise:
peer: replicator@

replication:
failover: election

groups:
group001:
replicasets:
replicaset001:
replication:
bootstrap_strategy: config
bootstrap_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
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
Expand Up @@ -3,9 +3,6 @@ credentials:
replicator:
password: 'topsecret'
roles: [replication]
client:
password: 'secret'
roles: [super]

iproto:
advertise:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
credentials:
users:
replicator:
password: 'topsecret'
roles: [replication]

replication:
peers:
- replicator:topsecret@127.0.0.1:3301
- replicator:topsecret@127.0.0.1:3302
- replicator:topsecret@127.0.0.1:3303
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
instance001:
instance002:
instance003:
91 changes: 41 additions & 50 deletions doc/code_snippets/snippets/replication/tt.yaml
Original file line number Diff line number Diff line change
@@ -1,63 +1,54 @@
tt:
modules:
# Directory where the external modules are stored.
directory: "modules"
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"
env:
# Restart instance on failure.
restart_on_failure: false

# Directory that stores log files.
log_dir: var/log
# Directory that stores binary files.
bin_dir: bin

# The maximum size in MB of the log file before it gets rotated.
log_maxsize: 100
# Directory that stores Tarantool header files.
inc_dir: include

# The maximum number of days to retain old log files.
log_maxage: 8
# Path to directory that stores all applications.
# The directory can also contain symbolic links to applications.
instances_enabled: instances.enabled

# The maximum number of old log files to retain.
log_maxbackups: 10
# 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

# Restart instance on failure.
restart_on_failure: false
app:
# Directory that stores various instance runtime
# artifacts like console socket, PID file, etc.
run_dir: var/run

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

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

# Directory where vinyl files or subdirectories will be stored.
vinyl_dir: "var/lib"
# Directory where memtx stores snapshot (.snap) files.
memtx_dir: var/lib

# Directory that stores binary files.
bin_dir: "bin"
# Directory where vinyl files or subdirectories will be stored.
vinyl_dir: var/lib

# Directory that stores Tarantool header files.
inc_dir: "include"
# Path to file with credentials for downloading Tarantool Enterprise Edition.
# credential_path: /path/to/file
ee:
credential_path:

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

# 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"
repo:
# Directory where local rocks files could be found.
rocks:
# Directory that stores installation files.
distfiles: distfiles
Loading