Merge "set unique galera server-id"

This commit is contained in:
Jenkins 2015-10-03 09:49:58 +00:00 committed by Gerrit Code Review
commit 34238d72d8
4 changed files with 33 additions and 1 deletions

View File

@ -72,6 +72,7 @@
tags:
- "system-crontab-coordination"
vars:
galera_server_id: "{{ inventory_hostname | string_2_int }}"
galera_wsrep_node_name: "{{ container_name }}"
galera_lb_address: "{{ internal_lb_vip_address }}"
ansible_hostname: "{{ container_name }}"

View File

@ -15,6 +15,7 @@
# (c) 2015, Kevin Carter <kevin.carter@rackspace.com>
import urlparse
import hashlib
"""Filter usage:
@ -88,6 +89,25 @@ def get_netorigin(url):
return '%s://%s' % (scheme, netloc)
def string_2_int(string):
"""Return the an integer from a string.
The string is hashed, converted to a base36 int, and the modulo of 10240
is returned.
:param string: string to retrieve an int from
:type string: ``str``
:returns: ``int``
"""
# Try to encode utf-8 else pass
try:
string = string.encode('utf-8')
except AttributeError:
pass
hashed_name = hashlib.sha256(string).hexdigest()
return int(hashed_name, 36) % 10240
class FilterModule(object):
"""Ansible jinja2 filters."""
@ -97,5 +117,6 @@ class FilterModule(object):
'bit_length_power_of_2': bit_length_power_of_2,
'netloc': get_netloc,
'netloc_no_port': get_netloc_no_port,
'netorigin': get_netorigin
'netorigin': get_netorigin,
'string_2_int': string_2_int
}

View File

@ -20,6 +20,13 @@ galera_lb_address: 127.0.0.1
galera_cluster_name: openstack_galera_cluster
# The galera server-id should be set on all cluster nodes to ensure
# that replication is handled correctly and the error
# "Warning: You should set server-id to a non-0 value if master_host is
# set; we will force server id to 2, but this MySQL server will not act
# as a slave." is no longer present.
# galera_server_id: 0
galera_existing_cluster: true
galera_running_and_bootstrapped: false

View File

@ -27,6 +27,9 @@ collation-server = utf8_unicode_ci
init-connect = 'SET NAMES utf8'
character-set-server = utf8
datadir = /var/lib/mysql
{% if galera_server_id is defined %}
server-id = {{ galera_server_id }}
{% endif %}
# LOGGING #
log-queries-not-using-indexes = {{ galera_unindexed_query_logging }}