Browse Source

Merge branch 'master' into pr/27

pr/27
Petr Michalec 7 years ago
parent
commit
518b834ed5
7 changed files with 111 additions and 18 deletions
  1. +19
    -4
      README.rst
  2. +6
    -2
      galera/files/my.cnf
  3. +19
    -4
      galera/master.sls
  4. +1
    -0
      galera/meta/grafana.yml
  5. +9
    -0
      galera/meta/prometheus.yml
  6. +19
    -7
      galera/slave.sls
  7. +38
    -1
      tests/run_tests.sh

+ 19
- 4
README.rst View File

- all privileges - all privileges


Additional check params: Additional check params:
========================


.. code-block:: yaml .. code-block:: yaml


- available_when_readonly: 1 - available_when_readonly: 1
- port 9200 - port 9200


InnoDB parameters
=================

- **innodb_buffer_pool_size** - the default value is 35% of the available ram

Usage:
.. code-block:: yaml

galera:
master:
innodb_buffer_pool_size: 1024M
slave:
innodb_buffer_pool_size: 1024M



Usage Usage
===== =====


.. code-block:: bash .. code-block:: bash


Enter current password for root (enter for none):
Enter current password for root (enter for none):
OK, successfully used password, moving on... OK, successfully used password, moving on...


Setting the root password ensures that nobody can log into the MySQL Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation. root user without the proper authorisation.


Set root password? [Y/n] y Set root password? [Y/n] y
New password:
Re-enter new password:
New password:
Re-enter new password:
Password updated successfully! Password updated successfully!
Reloading privilege tables.. Reloading privilege tables..
... Success! ... Success!
Cleaning up... Cleaning up...


5. service mysql stop 5. service mysql stop
6. uncomment all wsrep* lines except first server, where leave only in my.cnf wsrep_cluster_address='gcomm://';
6. uncomment all wsrep* lines except first server, where leave only in my.cnf wsrep_cluster_address='gcomm://';
7. start first node 7. start first node
8. Start third node which is connected to first one 8. Start third node which is connected to first one
9. Start second node which is connected to third one 9. Start second node which is connected to third one

+ 6
- 2
galera/files/my.cnf View File



innodb_file_format=Barracuda innodb_file_format=Barracuda
innodb_file_per_table=1 innodb_file_per_table=1
innodb_buffer_pool_size=3138M
{%- if service.innodb_buffer_pool_size is not defined %}
{% set buffer_pool_size = '%.0fM'%(grains['mem_total']*0.35) %}
{%- else %}
{% set buffer_pool_size = service.innodb_buffer_pool_size %}
{%- endif %}
innodb_buffer_pool_size={{ buffer_pool_size }}
innodb_log_file_size=627M innodb_log_file_size=627M
innodb_read_io_threads=8 innodb_read_io_threads=8
innodb_write_io_threads=8 innodb_write_io_threads=8
innodb_doublewrite=0 innodb_doublewrite=0
innodb_autoinc_lock_mode=2 innodb_autoinc_lock_mode=2
innodb_locks_unsafe_for_binlog=1 innodb_locks_unsafe_for_binlog=1

wsrep_cluster_address="gcomm://{% for member in service.members %}{{ member.host}}:4567{% if not loop.last %},{% endif %}{% endfor %}/?pc.wait_prim=no" wsrep_cluster_address="gcomm://{% for member in service.members %}{{ member.host}}:4567{% if not loop.last %},{% endif %}{% endfor %}/?pc.wait_prim=no"
wsrep_provider={{ service.wsrep_provider }} wsrep_provider={{ service.wsrep_provider }}
wsrep_cluster_name="openstack" wsrep_cluster_name="openstack"

+ 19
- 4
galera/master.sls View File

- require: - require:
- pkg: galera_packages - pkg: galera_packages


{%- endif %}
{%- endif %}


galera_init_script: galera_init_script:
file.managed: file.managed:
- require: - require:
- cmd: galera_bootstrap_set_root_password - cmd: galera_bootstrap_set_root_password


galera_bootstrap_stop_service_pre:
cmd.run:
- name: mysqladmin -h localhost -u root -p{{ master.admin.password }} shutdown
{%- if not grains.get('noservices', False) %}
- ignore_retcode: true
- require:
- cmd: mysql_bootstrap_update_maint_password
{%- else %}
- onlyif: /bin/false
{%- endif %}

galera_bootstrap_stop_service: galera_bootstrap_stop_service:
service.dead: service.dead:
- name: {{ master.service }} - name: {{ master.service }}
{%- if not grains.get('noservices', False) %}
- require: - require:
- cmd: mysql_bootstrap_update_maint_password
- cmd: galera_bootstrap_stop_service_pre
{%- else %}
- onlyif: /bin/false
{%- endif %}


galera_bootstrap_init_config: galera_bootstrap_init_config:
file.managed: file.managed:
- source: salt://galera/files/my.cnf.init - source: salt://galera/files/my.cnf.init
- mode: 644 - mode: 644
- template: jinja - template: jinja
- require:
- require:
- service: galera_bootstrap_stop_service - service: galera_bootstrap_stop_service


galera_bootstrap_start_service_final: galera_bootstrap_start_service_final:
- source: salt://galera/files/my.cnf - source: salt://galera/files/my.cnf
- mode: 644 - mode: 644
- template: jinja - template: jinja
- require_in:
- require_in:
- service: galera_service - service: galera_service


galera_service: galera_service:

+ 1
- 0
galera/meta/grafana.yml View File

format: json format: json
template: galera/files/grafana_dashboards/mysql_influxdb.json template: galera/files/grafana_dashboards/mysql_influxdb.json
main: main:
datasource: influxdb
row: row:
ost-middleware: ost-middleware:
title: Middleware title: Middleware

+ 9
- 0
galera/meta/prometheus.yml View File

{% raw %} {% raw %}
server: server:
alert: alert:
GaleraServiceDown:
if: >-
mysql_up != 1
labels:
severity: warning
service: mysql
annotations:
summary: 'Galera service down'
description: 'Galera service is down on node {{ $labels.host }}'
GaleraNodeNotReady: GaleraNodeNotReady:
if: 'mysql_wsrep_ready != 1' if: 'mysql_wsrep_ready != 1'
for: 1m for: 1m

+ 19
- 7
galera/slave.sls View File

{%- if grains.get('noservices') %} {%- if grains.get('noservices') %}
- onlyif: /bin/false - onlyif: /bin/false
{%- endif %} {%- endif %}
- require:
- require:
- file: galera_run_dir - file: galera_run_dir
- file: galera_init_script - file: galera_init_script
- timeout: 1800 - timeout: 1800
- require: - require:
- cmd: galera_bootstrap_set_root_password - cmd: galera_bootstrap_set_root_password


galera_bootstrap_stop_service_pre:
cmd.run:
- name: mysqladmin -h localhost -u root -p{{ slave.admin.password }} shutdown
{%- if not grains.get('noservices', False) %}
- ignore_retcode: true
- require:
- cmd: mysql_bootstrap_update_maint_password
{%- else %}
- onlyif: /bin/false
{%- endif %}

galera_bootstrap_stop_service: galera_bootstrap_stop_service:
service.dead: service.dead:
- name: {{ slave.service }} - name: {{ slave.service }}
{%- if grains.get('noservices') %}
{%- if not grains.get('noservices', False) %}
- require:
- cmd: galera_bootstrap_stop_service_pre
{%- else %}
- onlyif: /bin/false - onlyif: /bin/false
{%- endif %} {%- endif %}
- require:
- cmd: mysql_bootstrap_update_maint_password


galera_bootstrap_init_config: galera_bootstrap_init_config:
file.managed: file.managed:
- source: salt://galera/files/my.cnf - source: salt://galera/files/my.cnf
- mode: 644 - mode: 644
- template: jinja - template: jinja
- require:
- require:
- service: galera_bootstrap_stop_service - service: galera_bootstrap_stop_service


galera_bootstrap_start_service_final: galera_bootstrap_start_service_final:
{%- if grains.get('noservices') %} {%- if grains.get('noservices') %}
- onlyif: /bin/false - onlyif: /bin/false
{%- endif %} {%- endif %}
- require:
- require:
- file: galera_bootstrap_init_config - file: galera_bootstrap_init_config
- file: galera_bootstrap_script - file: galera_bootstrap_script
- timeout: 1800 - timeout: 1800
- source: salt://galera/files/my.cnf - source: salt://galera/files/my.cnf
- mode: 644 - mode: 644
- template: jinja - template: jinja
- require_in:
- require_in:
- service: galera_service - service: galera_service


galera_service: galera_service:

+ 38
- 1
tests/run_tests.sh View File

CURDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" CURDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
METADATA=${CURDIR}/../metadata.yml METADATA=${CURDIR}/../metadata.yml
FORMULA_NAME=$(cat $METADATA | python -c "import sys,yaml; print yaml.load(sys.stdin)['name']") FORMULA_NAME=$(cat $METADATA | python -c "import sys,yaml; print yaml.load(sys.stdin)['name']")
FORMULA_META_DIR=${CURDIR}/../${FORMULA_NAME}/meta


## Overrideable parameters ## Overrideable parameters
PILLARDIR=${PILLARDIR:-${CURDIR}/pillar} PILLARDIR=${PILLARDIR:-${CURDIR}/pillar}
BUILDDIR=${BUILDDIR:-${CURDIR}/build} BUILDDIR=${BUILDDIR:-${CURDIR}/build}
VENV_DIR=${VENV_DIR:-${BUILDDIR}/virtualenv} VENV_DIR=${VENV_DIR:-${BUILDDIR}/virtualenv}
MOCK_BIN_DIR=${MOCK_BIN_DIR:-${CURDIR}/mock_bin}
DEPSDIR=${BUILDDIR}/deps DEPSDIR=${BUILDDIR}/deps


SALT_FILE_DIR=${SALT_FILE_DIR:-${BUILDDIR}/file_root} SALT_FILE_DIR=${SALT_FILE_DIR:-${BUILDDIR}/file_root}
SALT_CONFIG_DIR=${SALT_CONFIG_DIR:-${BUILDDIR}/salt} SALT_CONFIG_DIR=${SALT_CONFIG_DIR:-${BUILDDIR}/salt}
SALT_CACHE_DIR=${SALT_CACHE_DIR:-${SALT_CONFIG_DIR}/cache} SALT_CACHE_DIR=${SALT_CACHE_DIR:-${SALT_CONFIG_DIR}/cache}


SALT_OPTS="${SALT_OPTS} --retcode-passthrough --local -c ${SALT_CONFIG_DIR}"
SALT_OPTS="${SALT_OPTS} --retcode-passthrough --local -c ${SALT_CONFIG_DIR} --log-file=/dev/null"


if [ "x${SALT_VERSION}" != "x" ]; then if [ "x${SALT_VERSION}" != "x" ]; then
PIP_SALT_VERSION="==${SALT_VERSION}" PIP_SALT_VERSION="==${SALT_VERSION}"
pip install salt${PIP_SALT_VERSION} pip install salt${PIP_SALT_VERSION}
} }


setup_mock_bin() {
# If some state requires a binary, a lightweight replacement for
# such binary can be put into MOCK_BIN_DIR for test purposes
if [ -d "${MOCK_BIN_DIR}" ]; then
PATH="${MOCK_BIN_DIR}:$PATH"
export PATH
fi
}

setup_pillar() { setup_pillar() {
[ ! -d ${SALT_PILLAR_DIR} ] && mkdir -p ${SALT_PILLAR_DIR} [ ! -d ${SALT_PILLAR_DIR} ] && mkdir -p ${SALT_PILLAR_DIR}
echo "base:" > ${SALT_PILLAR_DIR}/top.sls echo "base:" > ${SALT_PILLAR_DIR}/top.sls
for pillar in ${PILLARDIR}/*; do for pillar in ${PILLARDIR}/*; do
grep ${FORMULA_NAME}: ${pillar} &>/dev/null || continue
state_name=$(basename ${pillar%.sls}) state_name=$(basename ${pillar%.sls})
echo -e " ${state_name}:\n - ${state_name}" >> ${SALT_PILLAR_DIR}/top.sls echo -e " ${state_name}:\n - ${state_name}" >> ${SALT_PILLAR_DIR}/top.sls
done done


echo "base:" > ${SALT_FILE_DIR}/top.sls echo "base:" > ${SALT_FILE_DIR}/top.sls
for pillar in ${PILLARDIR}/*.sls; do for pillar in ${PILLARDIR}/*.sls; do
grep ${FORMULA_NAME}: ${pillar} &>/dev/null || continue
state_name=$(basename ${pillar%.sls}) state_name=$(basename ${pillar%.sls})
echo -e " ${state_name}:\n - ${FORMULA_NAME}" >> ${SALT_FILE_DIR}/top.sls echo -e " ${state_name}:\n - ${FORMULA_NAME}" >> ${SALT_FILE_DIR}/top.sls
done done
file_client: local file_client: local
cachedir: ${SALT_CACHE_DIR} cachedir: ${SALT_CACHE_DIR}
verify_env: False verify_env: False
minion_id_caching: False


file_roots: file_roots:
base: base:
[ -d ${BUILDDIR} ] && mkdir -p ${BUILDDIR} [ -d ${BUILDDIR} ] && mkdir -p ${BUILDDIR}


which salt-call || setup_virtualenv which salt-call || setup_virtualenv
setup_mock_bin
setup_pillar setup_pillar
setup_salt setup_salt
install_dependencies install_dependencies


run() { run() {
for pillar in ${PILLARDIR}/*.sls; do for pillar in ${PILLARDIR}/*.sls; do
grep ${FORMULA_NAME}: ${pillar} &>/dev/null || continue
state_name=$(basename ${pillar%.sls}) state_name=$(basename ${pillar%.sls})
salt_run grains.set 'noservices' False force=True salt_run grains.set 'noservices' False force=True

echo "Checking state ${FORMULA_NAME}.${state_name} ..."
salt_run --id=${state_name} state.show_sls ${FORMULA_NAME} || (log_err "Execution of ${FORMULA_NAME}.${state_name} failed"; exit 1) salt_run --id=${state_name} state.show_sls ${FORMULA_NAME} || (log_err "Execution of ${FORMULA_NAME}.${state_name} failed"; exit 1)

# Check that all files in 'meta' folder can be rendered using any valid pillar
for meta in `find ${FORMULA_META_DIR} -type f`; do
meta_name=$(basename ${meta})
echo "Checking meta ${meta_name} ..."
salt_run --out=quiet --id=${state_name} cp.get_template ${meta} ${SALT_CACHE_DIR}/${meta_name} \
|| (log_err "Failed to render meta ${meta} using pillar ${FORMULA_NAME}.${state_name}"; exit 1)
cat ${SALT_CACHE_DIR}/${meta_name}
done
done
}

real_run() {
for pillar in ${PILLARDIR}/*.sls; do
state_name=$(basename ${pillar%.sls})
salt_run --id=${state_name} state.sls ${FORMULA_NAME} || (log_err "Execution of ${FORMULA_NAME}.${state_name} failed"; exit 1)
done done
} }


run) run)
run run
;; ;;
real-run)
real_run
;;
*) *)
prepare prepare
run run

Loading…
Cancel
Save