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
Labels
Merge Requests
107
Merge Requests
107
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
nexedi
slapos
Commits
20cb186b
Commit
20cb186b
authored
Apr 28, 2020
by
Alain Takoudjou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
repman: check need-start instead of restart job for databases
parent
5b4f9ea8
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
69 additions
and
14 deletions
+69
-14
software/repman/buildout.hash.cfg
software/repman/buildout.hash.cfg
+8
-4
software/repman/instance-mariadb.cfg.jinja2.in
software/repman/instance-mariadb.cfg.jinja2.in
+25
-2
software/repman/instance-repman-input-schema.json
software/repman/instance-repman-input-schema.json
+2
-2
software/repman/instance-repman.cfg.jinja2.in
software/repman/instance-repman.cfg.jinja2.in
+8
-5
software/repman/instance.cfg.in
software/repman/instance.cfg.in
+1
-0
software/repman/software.cfg
software/repman/software.cfg
+4
-0
software/repman/templates/dbjobs.in
software/repman/templates/dbjobs.in
+1
-1
software/repman/templates/mysqld-need-start.sh.in
software/repman/templates/mysqld-need-start.sh.in
+20
-0
No files found.
software/repman/buildout.hash.cfg
View file @
20cb186b
...
@@ -14,11 +14,11 @@
...
@@ -14,11 +14,11 @@
# not need these here).
# not need these here).
[instance.cfg]
[instance.cfg]
filename = instance.cfg.in
filename = instance.cfg.in
md5sum =
8f3e5d9c0de16006cb36f0b8121fc11a
md5sum =
bc4f2f33c18d5372f2ecfa6940cf1b0d
[instance-repman.cfg]
[instance-repman.cfg]
_update_hash_filename_ = instance-repman.cfg.jinja2.in
_update_hash_filename_ = instance-repman.cfg.jinja2.in
md5sum =
2688b8aa946d4878d3f1c4fa08375cfe
md5sum =
dc86b3d180cb002919d1b4faf680b256
[config-toml.in]
[config-toml.in]
_update_hash_filename_ = templates/config.toml.in
_update_hash_filename_ = templates/config.toml.in
...
@@ -34,7 +34,7 @@ md5sum = 0eeb24c6aa0760f0d33c4cc2828ddf30
...
@@ -34,7 +34,7 @@ md5sum = 0eeb24c6aa0760f0d33c4cc2828ddf30
[template-mariadb.cfg]
[template-mariadb.cfg]
_update_hash_filename_ = instance-mariadb.cfg.jinja2.in
_update_hash_filename_ = instance-mariadb.cfg.jinja2.in
md5sum =
10dea9ec48ce889315202d112a66f121
md5sum =
7d7738da2974578f393130b97acdcab7
[template-my-cnf]
[template-my-cnf]
_update_hash_filename_ = templates/my.cnf.in
_update_hash_filename_ = templates/my.cnf.in
...
@@ -58,4 +58,8 @@ md5sum = 99324b56192003254081ef336dcee94c
...
@@ -58,4 +58,8 @@ md5sum = 99324b56192003254081ef336dcee94c
[dbjobs-in]
[dbjobs-in]
_update_hash_filename_ = templates/dbjobs.in
_update_hash_filename_ = templates/dbjobs.in
md5sum = 1e250376c55f9a5c19409b200f9b45a3
md5sum = d623a4c684578602b9d8ee49034aebfa
[mysqld-need-start.sh.in]
_update_hash_filename_ = templates/mysqld-need-start.sh.in
md5sum = ec15a9ca52ee3497885c85aa2a7a9008
software/repman/instance-mariadb.cfg.jinja2.in
View file @
20cb186b
...
@@ -275,16 +275,39 @@ command = ${dbjobs-executable:rendered}
...
@@ -275,16 +275,39 @@ command = ${dbjobs-executable:rendered}
< = jinja2-template-executable
< = jinja2-template-executable
rendered = ${directory:bin}/mysqld_restart
rendered = ${directory:bin}/mysqld_restart
template = inline:#!/bin/sh
template = inline:#!/bin/sh
${mariadb-controller-bin:wrapper-path} status
${mariadb-controller-bin:wrapper-path} restart mariadb
${mariadb-controller-bin:wrapper-path} restart mariadb
sleep 1
sleep 1
${mariadb-controller-bin:wrapper-path} status
${mariadb-controller-bin:wrapper-path} status
[{{ section('mariadb-need-start') }}]
recipe = slapos.cookbook:cron.d
cron-entries = ${cron:cron-entries}
name = mariadb-need-start
frequency = * * * * *
command = ${template-mysqld-need-start:rendered}
[template-mysqld-need-start]
< = jinja2-template-executable
rendered = ${directory:bin}/mysqld_need_start
template = {{ parameter_dict['template-mysqld-need-start'] }}
context =
key mariadb_controller mariadb-controller-bin:wrapper-path
raw username {{ slapparameter_dict['repman-user'] }}
raw password {{ slapparameter_dict['repman-passwd'] }}
raw secure_url {{ slapparameter_dict['repman-secure-url'] }}
raw jq_bin {{ jq_bin }}
raw cluster {{ slapparameter_dict['cluster'] }}
raw db_host {{ host }}
raw db_port {{ port }}
raw bash_bin {{ bash_bin }}
raw curl_bin {{ curl_bin }}
# Donwnload mariadb configuration from repman
# Donwnload mariadb configuration from repman
[{{ section('install-mysql-config') }}]
[{{ section('install-mysql-config') }}]
recipe = plone.recipe.command
recipe = plone.recipe.command
stop-on-error = true
stop-on-error = true
# XXX - for now, we make only one cluster
cluster = {{ slapparameter_dict['cluster'] }}
cluster = cluster1
config = ${directory:etc}/mysql/my.cnf
config = ${directory:etc}/mysql/my.cnf
command =
command =
cd ${directory:config-tmp} &&
cd ${directory:config-tmp} &&
...
...
software/repman/instance-repman-input-schema.json
View file @
20cb186b
...
@@ -237,9 +237,9 @@
...
@@ -237,9 +237,9 @@
},
},
"failover-mode"
:
{
"failover-mode"
:
{
"title"
:
"Failover mode"
,
"title"
:
"Failover mode"
,
"description"
:
"Failover is manual or automatic (default
\"
automatic
\"
)."
,
"description"
:
"Failover is manual or automatic (default
\"
manual
\"
)."
,
"type"
:
"string"
,
"type"
:
"string"
,
"default"
:
"
automatic
"
,
"default"
:
"
manual
"
,
"enum"
:
[
"enum"
:
[
"manual"
,
"manual"
,
"automatic"
"automatic"
...
...
software/repman/instance-repman.cfg.jinja2.in
View file @
20cb186b
...
@@ -64,21 +64,24 @@ maximum = 7132
...
@@ -64,21 +64,24 @@ maximum = 7132
{% for i in range(0, db_amount) -%}
{% for i in range(0, db_amount) -%}
{% do mariadb_dict.__setitem__('tcp-port', 2099 + (i * 100)) -%}
{% do mariadb_dict.__setitem__('tcp-port', 2099 + (i * 100)) -%}
{% set section = 'request-mariadb-' ~ i -%}
{% set section = 'request-mariadb-' ~ i -%}
{% set name = 'Mariadb-' ~ i -%}
{% set
db
name = 'Mariadb-' ~ i -%}
[{{ section }}]
[{{ section }}]
<= request-common
<= request-common
software-type = mariadb
software-type = mariadb
name = {{ name }}
name = {{
db
name }}
sla-computer_guid = {{ dumps(parameter_dict.get('-sla-' ~ i ~'-computer_guid', '')) }}
sla-computer_guid = {{ dumps(parameter_dict.get('-sla-' ~ i ~'-computer_guid', '')) }}
{% for key, value in mariadb_dict.items() -%}
{% for key, value in mariadb_dict.items() -%}
config-{{ key }} = {{ dumps(value) }}
config-{{ key }} = {{ dumps(value) }}
{% endfor -%}
{% endfor -%}
config-monitor-passwd = ${publish-early:monitor-password}
config-monitor-passwd = ${publish-early:monitor-password}
config-root-password = ${publish-early:db-root-password}
config-root-password = ${publish-early:db-root-password}
config-repman-user = ${repman-parameter:username}
config-repman-passwd = ${repman-parameter:password}
config-repman-url = ${nginx-parameter:backend-url}
config-repman-url = ${nginx-parameter:backend-url}
config-repman-secure-url = ${nginx-parameter:backend-url}
config-repman-secure-url = ${nginx-parameter:backend-ssl-url}
config-name = {{ name }}
config-cluster = {{ name }}
config-name = {{ dbname }}
return =
return =
database-host
database-host
monitor-base-url
monitor-base-url
...
@@ -123,7 +126,7 @@ db-memory = {{ parameter_dict.get("db-memory", 256) }}
...
@@ -123,7 +126,7 @@ db-memory = {{ parameter_dict.get("db-memory", 256) }}
db-memory-shared-pct = {{ parameter_dict.get("db-memory-shared-pct", "threads:16,innodb:60,myisam:10,aria:10,rocksdb:1,tokudb:1,s3:1,archive:1,querycache:0") }}
db-memory-shared-pct = {{ parameter_dict.get("db-memory-shared-pct", "threads:16,innodb:60,myisam:10,aria:10,rocksdb:1,tokudb:1,s3:1,archive:1,querycache:0") }}
db-memory-threaded-pct = {{ parameter_dict.get("db-memory-threaded-pct", "tmp:70,join:20,sort:10") }}
db-memory-threaded-pct = {{ parameter_dict.get("db-memory-threaded-pct", "tmp:70,join:20,sort:10") }}
# failover
# failover
failover-mode = {{ parameter_dict.get('failover-mode', '
automatic
') }}
failover-mode = {{ parameter_dict.get('failover-mode', '
manual
') }}
failover-limit = {{ parameter_dict.get('failover-limit', 5) }}
failover-limit = {{ parameter_dict.get('failover-limit', 5) }}
failover-falsepositive-heartbeat = {{ parameter_dict.get('failover-falsepositive-heartbeat', True) }}
failover-falsepositive-heartbeat = {{ parameter_dict.get('failover-falsepositive-heartbeat', True) }}
failover-falsepositive-heartbeat-timeout = {{ parameter_dict.get('failover-falsepositive-heartbeat-timeout', 3) }}
failover-falsepositive-heartbeat-timeout = {{ parameter_dict.get('failover-falsepositive-heartbeat-timeout', 3) }}
...
...
software/repman/instance.cfg.in
View file @
20cb186b
...
@@ -81,6 +81,7 @@ template-mariadb-initial-setup = {{ template_mariadb_initial_setup }}
...
@@ -81,6 +81,7 @@ template-mariadb-initial-setup = {{ template_mariadb_initial_setup }}
template-mariadb-init-root = {{ template_init_root_sql }}
template-mariadb-init-root = {{ template_init_root_sql }}
template-init-root-wrapper = {{ template_init_root_wrapper }}
template-init-root-wrapper = {{ template_init_root_wrapper }}
template-mysqld-wrapper = {{ template_mysqld_wrapper }}
template-mysqld-wrapper = {{ template_mysqld_wrapper }}
template-mysqld-need-start = {{ mysqld_start_template }}
link-binary = {{ dumps(mariadb_link_binary) }}
link-binary = {{ dumps(mariadb_link_binary) }}
check-computer-memory-binary = {{ bin_directory }}/check-computer-memory
check-computer-memory-binary = {{ bin_directory }}/check-computer-memory
bin-directory = {{ bin_directory }}
bin-directory = {{ bin_directory }}
...
...
software/repman/software.cfg
View file @
20cb186b
...
@@ -62,6 +62,7 @@ context =
...
@@ -62,6 +62,7 @@ context =
key template_monitor monitor2-template:rendered
key template_monitor monitor2-template:rendered
key mariadb_link_binary template-mariadb.cfg:link-binary
key mariadb_link_binary template-mariadb.cfg:link-binary
key mariadb_location mariadb:location
key mariadb_location mariadb:location
key mysqld_start_template mysqld-need-start.sh.in:target
key nginx_conf_in nginx.conf.in:target
key nginx_conf_in nginx.conf.in:target
key nginx_location nginx:location
key nginx_location nginx:location
key percona_toolkit_location percona-toolkit:location
key percona_toolkit_location percona-toolkit:location
...
@@ -142,6 +143,9 @@ link-binary =
...
@@ -142,6 +143,9 @@ link-binary =
[dbjobs-in]
[dbjobs-in]
<= download-file
<= download-file
[mysqld-need-start.sh.in]
<= download-file
# Pin versions of eggs used that are not already pinned by stack/slapos.cfg
# Pin versions of eggs used that are not already pinned by stack/slapos.cfg
[versions]
[versions]
slapos.recipe.template = 4.3
slapos.recipe.template = 4.3
...
...
software/repman/templates/dbjobs.in
View file @
20cb186b
...
@@ -7,7 +7,7 @@ SLOWLOG={{ parameter_dict['mysql-dir']}}/.system/logs/sql-slow
...
@@ -7,7 +7,7 @@ SLOWLOG={{ parameter_dict['mysql-dir']}}/.system/logs/sql-slow
BACKUPDIR={{ parameter_dict['mysql-dir'] }}/.system/backup
BACKUPDIR={{ parameter_dict['mysql-dir'] }}/.system/backup
DATADIR={{ parameter_dict['mysql-dir'] }}/
DATADIR={{ parameter_dict['mysql-dir'] }}/
export PATH={{ parameter_dict['socat-location'] }}/bin:{{ parameter_dict['mysql-location'] }}/bin:$PATH
export PATH={{ parameter_dict['socat-location'] }}/bin:{{ parameter_dict['mysql-location'] }}/bin:$PATH
JOBS=( "xtrabackup" "mariabackup" "error" "slowquery" "zfssnapback" "optimize" "reseedxtrabackup" "reseedmariabackup" "reseedmysqldump" "flashbackxtrabackup" "flashbackmariadbackup" "flashbackmysqldump" "stop" "start"
"restart"
)
JOBS=( "xtrabackup" "mariabackup" "error" "slowquery" "zfssnapback" "optimize" "reseedxtrabackup" "reseedmariabackup" "reseedmysqldump" "flashbackxtrabackup" "flashbackmariadbackup" "flashbackmysqldump" "stop" "start")
doneJob()
doneJob()
{
{
...
...
software/repman/templates/mysqld-need-start.sh.in
0 → 100644
View file @
20cb186b
#!{{ bash_bin }}
curl () {
{{ curl_bin }} -k --silent -H "Accept: application/json" "$@"
}
TOKEN=$(curl -s -X POST --data '{"username":"{{ username }}","password":"{{ password }}"}' {{ secure_url }}/api/login | {{ jq_bin }} -r '.token')
# Checking if mariadb start is needed
CODE=$(curl -H "Authorization: Bearer ${TOKEN}" -o /dev/null -w "%{http_code}" {{ secure_url }}/api/clusters/{{ cluster }}/servers/{{ db_host }}/{{ db_port }}/need-start)
if [ $CODE -eq 200 ]; then
echo "$CODE: Starting mariadb service..."
# print current status, can be useful for debug...
{{ mariadb_controller }} status mariadb
{{ mariadb_controller }} start mariadb
sleep 5
# check again if the service is still up...
{{ mariadb_controller }} status mariadb
fi
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