Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
slapos
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Levin Zimmermann
slapos
Commits
5869a6fe
Commit
5869a6fe
authored
Jul 15, 2022
by
Alain Takoudjou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
repman: requesting slave database can be done in a specific cluster
parent
07014f95
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
26 additions
and
14 deletions
+26
-14
software/repman/buildout.hash.cfg
software/repman/buildout.hash.cfg
+2
-2
software/repman/instance-repman-slave-input-schema.json
software/repman/instance-repman-slave-input-schema.json
+1
-1
software/repman/instance-repman.cfg.jinja2.in
software/repman/instance-repman.cfg.jinja2.in
+20
-11
software/repman/publish-database-slave-parameters.cfg.in
software/repman/publish-database-slave-parameters.cfg.in
+3
-0
No files found.
software/repman/buildout.hash.cfg
View file @
5869a6fe
...
...
@@ -18,7 +18,7 @@ md5sum = 55c7fd4dd6a39b31878889fbfb00f995
[instance-repman.cfg]
_update_hash_filename_ = instance-repman.cfg.jinja2.in
md5sum =
884e14bc349a341ad7125e449029ee9c
md5sum =
3c0c3a6ec74e997ae16a7425a56fe806
[config-toml.in]
_update_hash_filename_ = templates/config.toml.in
...
...
@@ -46,7 +46,7 @@ md5sum = 47b76144e1b116580c8acf08274af976
[template-publish-slave-information]
_update_hash_filename_ = publish-database-slave-parameters.cfg.in
md5sum =
9616477ff993c55c2b43bf8797db69
94
md5sum =
2e9f3afde619e20f08803013a4225e
94
[mariadb-init-root-sql]
_update_hash_filename_ = templates/mariadb_init_root.sql.in
...
...
software/repman/instance-repman-slave-input-schema.json
View file @
5869a6fe
...
...
@@ -37,7 +37,7 @@
],
"default"
:
""
},
"cluster
-
id"
:
{
"cluster
_
id"
:
{
"title"
:
"Replication Manager Cluster Name"
,
"description"
:
"When a cluster Name is given, Try to request the slave in the specified cluster name. If the cluster is not found, the slave is requested in the first cluster."
,
"type"
:
"string"
,
...
...
software/repman/instance-repman.cfg.jinja2.in
View file @
5869a6fe
...
...
@@ -9,8 +9,6 @@
"pfs", "linux", "readonly", "diskmonitor", "sqlerror", "compressbinlog", "bm4ci",
"mroonga", "utctime", "readcommitted", "nohandshake", "ssl"] -%}
{% set frontend_parameter_dict = slapparameter_dict.get('slave-frontend', {}) -%}
{% set database_slave_list = [] -%}
{% set db_name_list = [] -%}
{% set count = namespace(value=2) %}
{% set caucase_bind = '[' ~ ip ~ ']:8890' -%}
{% set caucase_url = 'http://' ~ caucase_bind -%}
...
...
@@ -18,6 +16,10 @@
{% set default_parameter_dict = {"cluster1": {"db-prefered-master": "",
"database-amount": 2, "proxysql-user": "external",
"logical-backup-cron": "0 21 * * *", "physical-backup-cron": "0 1 * * *"}} -%}
{% set cluster_name_list = slapparameter_dict.get('repman-cluster-dict', default_parameter_dict).keys() -%}
{% set database_slave_dict = {} -%}
{% set db_name_dict = {} -%}
{% set default_slave_cluster_id = list(cluster_name_list)[0] -%}
{% macro password(name) -%}
[{{ name }}-password]
...
...
@@ -49,8 +51,10 @@ recipe = slapos.cookbook:mkdirectory
home = ${buildout:directory}/proxy
config = ${directory:etc}/proxysql
ssl = ${:config}/default-ssl
{% for cluster in
slapparameter_dict.get('repman-cluster-dict', default_parameter_dict).keys()
-%}
{% for cluster in
cluster_name_list
-%}
{{ cluster }} = ${:home}/{{ cluster }}
{% do database_slave_dict.__setitem__(cluster, []) -%}
{% do db_name_dict.__setitem__(cluster, []) -%}
{% endfor -%}
{% import "supervisord_lib" as supervisord_lib with context %}
...
...
@@ -95,6 +99,7 @@ inline =
cp etc/proxysql/proxysql.cnf $CONFIG
output = ${directory:bin}/update-proxysql-config
{% set slave_information_list = [] -%}
{% for instance_dict in slave_instance_list -%}
{% set slave_dict = {
'name': 'db_%s' % instance_dict['slave_reference'].replace('-', '_').lower(),
...
...
@@ -102,23 +107,26 @@ output = ${directory:bin}/update-proxysql-config
'password': instance_dict.get('db_password', '${' ~ instance_dict['slave_reference'] ~ '-password:passwd}'),
'slave_reference': instance_dict['slave_reference'],
'charset': instance_dict.get('db_charset', ''),
'cluster_id': instance_dict.get('cluster_id', default_slave_cluster_id),
'require_ssl': True
} -%}
{% do database_slave_list.append(slave_dict) -%}
{% do db_name_list.append([slave_dict['name'], slave_dict['user']]) -%}
{% do slave_information_list.append(slave_dict) -%}
{% do database_slave_dict[slave_dict['cluster_id']].append(slave_dict) -%}
{% do db_name_dict[slave_dict['cluster_id']].append([slave_dict['name'], slave_dict['user']]) -%}
{{ password(instance_dict['slave_reference']) }}
{% endfor %}
# set each database dict which will be used to publish slave information
[database-slave-information]
{% for slave_dict in
database_slave
_list -%}
{% for slave_dict in
slave_information
_list -%}
{{ slave_dict['name'] }} = !py!{{ slave_dict }}
{% endfor %}
{% set db_list = db_name_list -%}
{% do mariadb_dict.__setitem__('computer-memory-percent-threshold', 80) -%}
{% for name, parameter_dict in slapparameter_dict.get('repman-cluster-dict', default_parameter_dict).items() -%}
{% do mariadb_dict.__setitem__('innodb-file-per-table', parameter_dict.get('innodb-file-per-table', 1)) -%}
{% do mariadb_dict.__setitem__('use-ipv6', parameter_dict.get('use-ipv6', True)) -%}
{% set db_list = db_name_dict[name] -%}
# Request mariadb instances
{% set db_amount = parameter_dict.get('database-amount', 2) -%}
...
...
@@ -153,7 +161,7 @@ config-repman-url = ${nginx-parameter:backend-url}
config-repman-secure-url = ${nginx-parameter:backend-ssl-url}
config-cluster = {{ name }}
config-name = {{ dbname }}
config-database-list = !py!{{ database_slave_
list
}}
config-database-list = !py!{{ database_slave_
dict[name]
}}
config-database-name = {{ dumps(db_list) }}
config-require-ssl = {{ dumps(slapparameter_dict.get('require-ssl', False)) }}
return =
...
...
@@ -328,6 +336,7 @@ context =
key proxy_port {{ name }}-cluster-parameter:proxy-port
raw eggs_directory {{ eggs_directory }}
raw develop_eggs_directory {{ develop_eggs_directory }}
raw cluster {{ name }}
raw ipv6 {{ ip }}
raw ipv4 {{ ipv4 }}
section slave_dict database-slave-information
...
...
@@ -624,7 +633,7 @@ recipe = slapos.cookbook:publish-early
monitor-password monitor-htpasswd:passwd
db-root-password gen-root-password:passwd
repman-password repman-password:passwd
database-
list = {{ db_lis
t }}
database-
dict = {{ db_name_dic
t }}
[publish-connection-parameter]
<= monitor-publish
...
...
@@ -633,7 +642,7 @@ recipe = slapos.cookbook:publish
backend-url = ${nginx-parameter:backend-ssl-url}
url = ${repman-frontend:connection-secure_access}
username = ${repman-parameter:username}
database-
list = {{ db_lis
t }}
database-
dict = {{ db_name_dic
t }}
{% for name, value in publish_dict.items() -%}
{{ name }} = {{ value }}
{% endfor %}
...
...
software/repman/publish-database-slave-parameters.cfg.in
View file @
5869a6fe
...
...
@@ -11,6 +11,7 @@ cert_file = ${slap-connection:cert-file}
{% for _, database in slave_dict.items() -%}
{% if database['cluster_id'] == cluster -%}
{% set slave_reference = database['slave_reference'] -%}
{% do part_list.append('publish-slave-' ~ slave_reference) -%}
...
...
@@ -24,6 +25,8 @@ url = {{ "mysql://" ~ database['user'] ~ ":" ~ database['password'] ~ "@[" ~ ipv
url = {{ "mysql://" ~ ipv4 ~ ":" ~ proxy_port ~ database['name'] }}
url_v6 = {{ "mysql://[" ~ ip ~ "]:" ~ proxy_port ~ database['name'] }}
{% endif -%}
cluster = {{ database['cluster_id'] }}
{% endif -%}
{% endfor %}
[buildout]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment