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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Alain Takoudjou
slapos
Commits
85b637cf
Commit
85b637cf
authored
May 04, 2020
by
Alain Takoudjou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
repman: when restart mariadb/proxy update config first, option to autorejoin standalone node
parent
b91c7cd8
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
89 additions
and
29 deletions
+89
-29
software/repman/buildout.hash.cfg
software/repman/buildout.hash.cfg
+5
-5
software/repman/instance-mariadb.cfg.jinja2.in
software/repman/instance-mariadb.cfg.jinja2.in
+18
-15
software/repman/instance-repman-input-schema.json
software/repman/instance-repman-input-schema.json
+14
-2
software/repman/instance-repman.cfg.jinja2.in
software/repman/instance-repman.cfg.jinja2.in
+39
-6
software/repman/templates/config.toml.in
software/repman/templates/config.toml.in
+8
-1
software/repman/templates/mysqld-need-start.sh.in
software/repman/templates/mysqld-need-start.sh.in
+3
-0
software/repman/templates/proxy-need-start-stop.sh.in
software/repman/templates/proxy-need-start-stop.sh.in
+2
-0
No files found.
software/repman/buildout.hash.cfg
View file @
85b637cf
...
...
@@ -18,11 +18,11 @@ md5sum = da50540b1c0fc69ffbf8f6e345a3baad
[instance-repman.cfg]
_update_hash_filename_ = instance-repman.cfg.jinja2.in
md5sum = 3
b858324e8940a08379956bf76fb88b
d
md5sum = 3
d8199bbae01915267a441f47f25ef0
d
[config-toml.in]
_update_hash_filename_ = templates/config.toml.in
md5sum =
3adc842de5c0e8c94e90ac5f41ecab6c
md5sum =
5cfa75ca5a0048a050c0041dfe541f3d
[config-cluster-toml.in]
_update_hash_filename_ = templates/cluster-config.toml.in
...
...
@@ -34,7 +34,7 @@ md5sum = 0eeb24c6aa0760f0d33c4cc2828ddf30
[template-mariadb.cfg]
_update_hash_filename_ = instance-mariadb.cfg.jinja2.in
md5sum =
0c6e9a3220cf6e8b096e523d0d1f407a
md5sum =
7049767810d8b8a6a16668512672f5a3
[template-my-cnf]
_update_hash_filename_ = templates/my.cnf.in
...
...
@@ -62,8 +62,8 @@ md5sum = d623a4c684578602b9d8ee49034aebfa
[mysqld-need-start.sh.in]
_update_hash_filename_ = templates/mysqld-need-start.sh.in
md5sum =
76b984ef5e37248bc3a8010a74b24de
5
md5sum =
e9bcee5dc1318fe3acda2663472214f
5
[proxy-need-start-stop.sh.in]
_update_hash_filename_ = templates/proxy-need-start-stop.sh.in
md5sum =
1ee3d69f0866605b33eac7ea596b21c3
md5sum =
455aaf369bf5141758dc57f2c0e67b08
software/repman/instance-mariadb.cfg.jinja2.in
View file @
85b637cf
...
...
@@ -275,10 +275,8 @@ command = ${dbjobs-executable:rendered}
< = jinja2-template-executable
rendered = ${directory:bin}/mysqld_restart
template = inline:#!/bin/sh
${mariadb-controller-bin:wrapper-path} status
${mariadb-controller-bin:wrapper-path} restart mariadb
sleep 1
${mariadb-controller-bin:wrapper-path} status
# This script is disabled on SlapOS
echo "RESTART FROM dbjbos WAS DISABLED"
[{{ section('mariadb-need-start') }}]
recipe = slapos.cookbook:cron.d
...
...
@@ -293,6 +291,7 @@ rendered = ${directory:bin}/mysqld_need_start
template = {{ parameter_dict['template-mysqld-need-start'] }}
context =
key mariadb_controller mariadb-controller-bin:wrapper-path
key update_config mysql-get-config:rendered
raw username {{ slapparameter_dict['repman-user'] }}
raw repman_url {{ slapparameter_dict['repman-url'] }}
raw jq_bin {{ jq_bin }}
...
...
@@ -303,21 +302,25 @@ context =
raw curl_bin {{ curl_bin }}
# Donwnload mariadb configuration from repman
[
{{ section('install-mysql-config') }}
]
recipe = plone.recipe.command
stop-on-error = true
[
mysql-get-config
]
< = jinja2-template-executable
rendered = ${directory:bin}/mysqld-update-config
cluster = {{ slapparameter_dict['cluster'] }}
config = ${directory:etc}/mysql/my.cnf
command =
template = inline:#!{{ bash_bin }}
cd ${directory:config-tmp} &&
{{ curl_bin }} -o config.tar.gz {{ slapparameter_dict['repman-url'] }}/api/clusters/${:cluster}/servers/{{ host }}/{{ port }}/config
&&
tar -xzf config.tar.gz
&&
cp -r data/.system ${directory:mysql}
&&
rm -rf ${directory:etc}/mysql
&&
cp -r etc/mysql ${directory:etc}
&&
ln -sf ${directory:mysql}/.system ${directory:var}/system
&&
{{ curl_bin }} -o config.tar.gz {{ slapparameter_dict['repman-url'] }}/api/clusters/${:cluster}/servers/{{ host }}/{{ port }}/config
tar -xzf config.tar.gz
cp -r data/.system ${directory:mysql}
rm -rf ${directory:etc}/mysql
cp -r etc/mysql ${directory:etc}
ln -sf ${directory:mysql}/.system ${directory:var}/system
ln -sf ${my-cnf:rendered} ${directory:etc}/mysql/custom/01_mariadb.cnf
[{{ section('install-mysql-config') }}]
recipe = plone.recipe.command
stop-on-error = true
config = ${directory:etc}/mysql/my.cnf
command = ${mysql-get-config:rendered}
update-command = ${:command}
[dash]
...
...
software/repman/instance-repman-input-schema.json
View file @
85b637cf
...
...
@@ -101,6 +101,18 @@
"type"
:
"integer"
,
"default"
:
4
},
"autorejoin"
:
{
"title"
:
"Automatic rejoin a failed master"
,
"description"
:
"Automatic rejoin a failed master (default true)"
,
"type"
:
"boolean"
,
"default"
:
true
},
"autoseed"
:
{
"title"
:
"Automatic join a standalone node"
,
"description"
:
"Automatic join a standalone node"
,
"type"
:
"boolean"
,
"default"
:
true
},
"repman-cluster-dict"
:
{
"title"
:
"Replication Manager clusters definition"
,
"description"
:
"Replication Manager clusters definition"
,
...
...
@@ -166,13 +178,13 @@
"title"
:
"Mysqldump backup cron definition."
,
"description"
:
"Logical backup cron expression represents a set of times, using cron format."
,
"type"
:
"string"
,
"default"
:
"0
1 * * 6
"
"default"
:
"0
21 * * *
"
},
"physical-backup-cron"
:
{
"title"
:
"Mariabackup cron definition"
,
"description"
:
"Physical backup cron expression represents a set of times, using cron format."
,
"type"
:
"string"
,
"default"
:
"0
0
* * *"
"default"
:
"0
1
* * *"
},
"proxy-cpu-cores"
:
{
"title"
:
"Proxy Cpu cores"
,
...
...
software/repman/instance-repman.cfg.jinja2.in
View file @
85b637cf
...
...
@@ -39,11 +39,28 @@ cert-file = ${slap-connection:cert-file}
computer-id = ${slap-connection:computer-id}
partition-id = ${slap-connection:partition-id}
[download-proxy-config]
recipe = slapos.recipe.template:jinja2
template = inline:#!{{ bash_bin }}
NAME=$1
HOST=$2
PORT=$3
CONFIG=$4
if [ -z "$CONFIG" ]; then
CONFIG="${repman:proxies}/proxysql-$NAME.cnf"
fi
mkdir -p ${repman:config-tmp}/proxies
cd ${repman:config-tmp}/proxies
{{ curl_bin }} -o proxies-$NAME.tar.gz ${nginx-parameter:repman-url}/api/clusters/$NAME/servers/$HOST/$PORT/config
tar -xzf proxies-$NAME.tar.gz
cp conf/proxysql.cnf $CONFIG
rendered = ${directory:bin}/update-proxysql-config
mode = 755
{% do mariadb_dict.__setitem__('computer-memory-percent-threshold', 80) -%}
{% set default_parameter_dict = {"cluster1": {"name": "cluster1", "db-prefered-master": "",
"database-amount": 2, "proxysql-user": "external", "proxy-tags": "pkg,masterslave,linux,noreadwritesplit",
"logical-backup-cron": "0
1 * * 6", "physical-backup-cron": "0 0
* * *"}} -%}
"logical-backup-cron": "0
21 * * *", "physical-backup-cron": "0 1
* * *"}} -%}
{% 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)) -%}
...
...
@@ -164,12 +181,8 @@ stop-on-error = false
config = ${repman:proxies}/proxysql-{{ name }}.cnf
data = ${repman:proxy-data}/{{ name }}
command =
mkdir -p ${repman:config-tmp}/proxies &&
mkdir -p ${:data} &&
cd ${repman:config-tmp}/proxies &&
{{ curl_bin }} -o proxies.tar.gz ${nginx-parameter:repman-url}/api/clusters/{{ name }}/servers/{{ ipv4 }}/{{ '${' ~ name ~ '-cluster-parameter:proxy-admin-port}' }}/config &&
tar -xzf proxies.tar.gz &&
cp conf/proxysql.cnf ${:config}
${download-proxy-config:rendered} {{ name }} {{ ipv4 }} {{ '${' ~ name ~ '-cluster-parameter:proxy-admin-port}' }} ${:config}
update-command = ${:command}
[proxysql-{{ name }}-wrapper]
...
...
@@ -183,6 +196,23 @@ command-line =
wrapper-path = ${directory:controller}/proxysql-{{ name }}
wait-for-files =
${repman:bootstrap}/{{ name }}_bootstrapped
depends =
{{ '${proxysql-' ~ name ~ '-admin-promise:recipe}' }}
{{ '${proxysql-' ~ name ~ '-promise:recipe}' }}
[proxysql-{{ name }}-admin-promise]
<= monitor-promise-base
module = check_port_listening
name = proxysql-{{ name }}-admin-port-listening
config-hostname= {{ ipv4 }}
config-port = {{ '${' ~ name ~ '-cluster-parameter:proxy-admin-port}' }}
[proxysql-{{ name }}-promise]
<= monitor-promise-base
module = check_port_listening
name = proxysql-{{ name }}-port-listening
config-hostname= {{ ipv4 }}
config-port = {{ '${' ~ name ~ '-cluster-parameter:proxy-port}' }}
{% set service_name = "proxysql-" ~ name -%}
{% set proxysql_dict = {"name": service_name, "command": "${" ~ service_name ~ "-wrapper:wrapper-path}",
...
...
@@ -256,6 +286,8 @@ ipv4 = ${instance-parameter:ipv4-random}
username = admin
password = ${publish-early:repman-password}
cluster-d = ${repman:clusters}
autorejoin = {{ slapparameter_dict.get("autorejoin", True) }}
autoseed = {{ slapparameter_dict.get("autoseed", True) }}
mysql-bin-dir = {{ mariadb_location }}/bin
mysqlbinlog-path = {{ mariadb_location }}/bin/mysqlbinlog
mysqlclient-path = {{ mariadb_location }}/bin/mysql
...
...
@@ -455,6 +487,7 @@ cluster-list = !py![{{ cluster_list | join(', ') }}]
context =
key proxysql_controller {{proxysql_controller}}-bin:wrapper-path
key repman_url nginx-parameter:backend-url
key get_proxy_config download-proxy-config:rendered
key cluster_list :cluster-list
raw jq_bin {{ jq_bin }}
raw bash_bin {{ bash_bin }}
...
...
software/repman/templates/config.toml.in
View file @
85b637cf
{% macro setbool(value) -%}
{% if value in ['true', 'True'] %} true {% else %} false {% endif -%}
{% endmacro -%}
[Default]
api-bind = "{{ parameter_dict['ipv4'] }}"
http-bind-address = "{{ parameter_dict['ipv4'] }}"
...
...
@@ -8,7 +11,11 @@ monitoring-save-config = false
api-https-bind = true
api-credentials = "{{ parameter_dict['username'] }}:{{ parameter_dict['password'] }}"
include = "{{ parameter_dict['cluster-d'] }}"
autorejoin = true
autorejoin = {{ setbool(parameter_dict['autorejoin']) }}
autoseed = {{ setbool(parameter_dict['autoseed']) }}
{% if parameter_dict['autoseed'] in ['true', 'True'] -%}
autorejoin-logical-backup = true
{% endif -%}
db-servers-binary-path = "{{ parameter_dict['mysql-bin-dir'] }}"
# Database list of hosts to ignore in election
#db-servers-ignored-hosts =
...
...
software/repman/templates/mysqld-need-start.sh.in
View file @
85b637cf
...
...
@@ -11,6 +11,9 @@ curl () {
CODE=$(curl -o /dev/null -w "%{http_code}" {{ repman_url }}/api/clusters/{{ cluster }}/servers/{{ db_host }}/{{ db_port }}/need-start)
if [ $CODE -eq 200 ]; then
echo "$CODE: Updating mysql configuration..."
# update mysql configuration
{{ update_config }}
echo "$CODE: Starting mariadb service..."
# print current status, can be useful for debug...
{{ mariadb_controller }} status mariadb
...
...
software/repman/templates/proxy-need-start-stop.sh.in
View file @
85b637cf
...
...
@@ -28,6 +28,8 @@ check_stop_cluster () {
CODE=$(curl -o /dev/null -w "%{http_code}" {{ repman_url }}/api/clusters/$NAME/servers/$HOST/$PORT/need-stop)
if [ $CODE -eq 200 ]; then
echo "$CODE: updating proxysql config $HOST:$PORT..."
{{ get_proxy_config }} $NAME $HOST $PORT
echo "$CODE: Stoping proxysql $HOST:$PORT..."
{{ proxysql_controller }} stop proxysql-$NAME
sleep 1
...
...
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