Merge pull request #617 from sileht/sileht/galera-tweak
Sileht/galera tweak
This commit is contained in:
@@ -26,6 +26,7 @@ class cloud::database::sql (
|
|||||||
$service_provider = 'sysv',
|
$service_provider = 'sysv',
|
||||||
$galera_master_name = 'mgmt001',
|
$galera_master_name = 'mgmt001',
|
||||||
$galera_internal_ips = ['127.0.0.1'],
|
$galera_internal_ips = ['127.0.0.1'],
|
||||||
|
$galera_gcache = '1G',
|
||||||
$keystone_db_host = '127.0.0.1',
|
$keystone_db_host = '127.0.0.1',
|
||||||
$keystone_db_user = 'keystone',
|
$keystone_db_user = 'keystone',
|
||||||
$keystone_db_password = 'keystonepassword',
|
$keystone_db_password = 'keystonepassword',
|
||||||
|
@@ -491,6 +491,7 @@ class cloud::loadbalancer(
|
|||||||
ipaddress => $galera_ip,
|
ipaddress => $galera_ip,
|
||||||
ports => 3306,
|
ports => 3306,
|
||||||
options => {
|
options => {
|
||||||
|
'maxconn' => '1000',
|
||||||
'mode' => 'tcp',
|
'mode' => 'tcp',
|
||||||
'balance' => 'roundrobin',
|
'balance' => 'roundrobin',
|
||||||
'option' => ['tcpka', 'tcplog', 'httpchk'], #httpchk mandatory expect 200 on port 9000
|
'option' => ['tcpka', 'tcplog', 'httpchk'], #httpchk mandatory expect 200 on port 9000
|
||||||
|
@@ -32,6 +32,7 @@ describe 'cloud::database::sql' do
|
|||||||
:api_eth => '10.0.0.1',
|
:api_eth => '10.0.0.1',
|
||||||
:galera_master_name => 'os-ci-test1',
|
:galera_master_name => 'os-ci-test1',
|
||||||
:galera_internal_ips => ['10.0.0.1','10.0.0.2','10.0.0.3'],
|
:galera_internal_ips => ['10.0.0.1','10.0.0.2','10.0.0.3'],
|
||||||
|
:galera_gcache => '1G',
|
||||||
:keystone_db_host => '10.0.0.1',
|
:keystone_db_host => '10.0.0.1',
|
||||||
:keystone_db_user => 'keystone',
|
:keystone_db_user => 'keystone',
|
||||||
:keystone_db_password => 'secrete',
|
:keystone_db_password => 'secrete',
|
||||||
@@ -88,8 +89,8 @@ describe 'cloud::database::sql' do
|
|||||||
context 'configure mysqlchk http replication' do
|
context 'configure mysqlchk http replication' do
|
||||||
it { should contain_file('/etc/xinetd.d/mysqlchk').with_mode('0755') }
|
it { should contain_file('/etc/xinetd.d/mysqlchk').with_mode('0755') }
|
||||||
it { should contain_file('/usr/bin/clustercheck').with_mode('0755') }
|
it { should contain_file('/usr/bin/clustercheck').with_mode('0755') }
|
||||||
it { should contain_file('/usr/bin/clustercheck').with_content(/MYSQL_USERNAME="#{params[:galera_clustercheck_dbuser]}"/)}
|
it { should contain_file('/usr/bin/clustercheck').with_content(/MYSQL_USERNAME='#{params[:galera_clustercheck_dbuser]}'/)}
|
||||||
it { should contain_file('/usr/bin/clustercheck').with_content(/MYSQL_PASSWORD="#{params[:galera_clustercheck_dbpassword]}"/)}
|
it { should contain_file('/usr/bin/clustercheck').with_content(/MYSQL_PASSWORD='#{params[:galera_clustercheck_dbpassword]}'/)}
|
||||||
it { should contain_file('/etc/xinetd.d/mysqlchk').with_content(/bind = #{params[:galera_clustercheck_ipaddress]}/)}
|
it { should contain_file('/etc/xinetd.d/mysqlchk').with_content(/bind = #{params[:galera_clustercheck_ipaddress]}/)}
|
||||||
|
|
||||||
end # configure mysqlchk http replication
|
end # configure mysqlchk http replication
|
||||||
|
@@ -206,6 +206,7 @@ describe 'cloud::loadbalancer' do
|
|||||||
:ipaddress => params[:galera_ip],
|
:ipaddress => params[:galera_ip],
|
||||||
:ports => '3306',
|
:ports => '3306',
|
||||||
:options => {
|
:options => {
|
||||||
|
'maxconn' => '1000',
|
||||||
'mode' => 'tcp',
|
'mode' => 'tcp',
|
||||||
'balance' => 'roundrobin',
|
'balance' => 'roundrobin',
|
||||||
'option' => ['tcpka','tcplog','httpchk'],
|
'option' => ['tcpka','tcplog','httpchk'],
|
||||||
|
@@ -4,35 +4,54 @@
|
|||||||
#
|
#
|
||||||
# Script to make a proxy (ie HAProxy) capable of monitoring Percona XtraDB Cluster nodes properly
|
# Script to make a proxy (ie HAProxy) capable of monitoring Percona XtraDB Cluster nodes properly
|
||||||
#
|
#
|
||||||
# Author: Olaf van Zandwijk olaf.vanzandwijk@nedap.com
|
# Author: Olaf van Zandwijk <olaf.vanzandwijk@nedap.com>
|
||||||
|
# Mehdi Abaakouk <mehdi.abaakouk@enovance.com>
|
||||||
|
#
|
||||||
# Documentation and download: https://github.com/olafz/percona-clustercheck
|
# Documentation and download: https://github.com/olafz/percona-clustercheck
|
||||||
#
|
#
|
||||||
# Based on the original script from Unai Rodriguez
|
# Based on the original script from Unai Rodriguez
|
||||||
#
|
#
|
||||||
|
MYSQL_USERNAME='<%= @galera_clustercheck_dbuser %>'
|
||||||
|
MYSQL_PASSWORD='<%= @galera_clustercheck_dbpassword %>'
|
||||||
|
|
||||||
MYSQL_USERNAME="<%= @galera_clustercheck_dbuser %>"
|
TIMEOUT=10
|
||||||
MYSQL_PASSWORD="<%= @galera_clustercheck_dbpassword %>"
|
|
||||||
ERR_FILE="/dev/null"
|
ERR_FILE="/dev/null"
|
||||||
AVAILABLE_WHEN_DONOR=0
|
AVAILABLE_WHEN_DONOR=0
|
||||||
|
|
||||||
#
|
MYSQL_CMDLINE="mysql -nNE --connect-timeout=$TIMEOUT --user=${MYSQL_USERNAME} --password=${MYSQL_PASSWORD} "
|
||||||
# Perform the query to check the wsrep_local_state
|
|
||||||
#
|
|
||||||
WSREP_STATUS=`mysql --user=${MYSQL_USERNAME} --password=${MYSQL_PASSWORD} -e "SHOW STATUS LIKE 'wsrep_local_state';" 2>${ERR_FILE} | awk '{if (NR!=1){print $2}}' 2>${ERR_FILE}`
|
|
||||||
|
|
||||||
if [[ "${WSREP_STATUS}" == "4" ]] || [[ "${WSREP_STATUS}" == "2" && ${AVAILABLE_WHEN_DONOR} == 1 ]]
|
mysql_get_status(){
|
||||||
then
|
( $MYSQL_CMDLINE -e "SHOW STATUS LIKE '$1';" | tail -1 ) 2>>${ERR_FILE}
|
||||||
# Percona XtraDB Cluster node local state is 'Synced' == return HTTP 200
|
}
|
||||||
/bin/echo -en "HTTP/1.1 200 OK\r\n"
|
mysql_get_var(){
|
||||||
|
( $MYSQL_CMDLINE -e "SHOW GLOBAL VARIABLES LIKE '$1';" | tail -1 ) 2>>${ERR_FILE}
|
||||||
|
}
|
||||||
|
|
||||||
|
http_response(){
|
||||||
|
status=$1
|
||||||
|
shift
|
||||||
|
msg="$@"
|
||||||
|
if [ "$status" == 200 ]; then
|
||||||
|
/bin/echo -en "HTTP/1.1 200 OK\r\n"
|
||||||
|
else
|
||||||
|
/bin/echo -en "HTTP/1.1 503 Service Unavailable\r\n"
|
||||||
|
fi
|
||||||
/bin/echo -en "Content-Type: text/plain\r\n"
|
/bin/echo -en "Content-Type: text/plain\r\n"
|
||||||
/bin/echo -en "\r\n"
|
/bin/echo -en "\r\n"
|
||||||
/bin/echo -en "Mariadb Cluster Node is synced.\r\n"
|
/bin/echo -en "$msg\r\n"
|
||||||
/bin/echo -en "\r\n"
|
/bin/echo -en "\r\n"
|
||||||
else
|
}
|
||||||
# Percona XtraDB Cluster node local state is not 'Synced' == return HTTP 503
|
|
||||||
/bin/echo -en "HTTP/1.1 503 Service Unavailable\r\n"
|
|
||||||
/bin/echo -en "Content-Type: text/plain\r\n"
|
WSREP_LOCAL_STATE=$(mysql_get_status wsrep_local_state)
|
||||||
/bin/echo -en "\r\n"
|
WSREP_READY=$(mysql_get_status wsrep_ready)
|
||||||
/bin/echo -en "Mariadb Cluster Node is not synced.\r\n"
|
WSREP_CONNECTED=$(mysql_get_status wsrep_connected)
|
||||||
/bin/echo -en "\r\n"
|
READY_ONLY=$(mysql_get_var read_only)
|
||||||
fi
|
|
||||||
|
case ${AVAILABLE_WHEN_DONOR}-${WSREP_LOCAL_STATE}-${WSREP_READY}-${WSREP_CONNECTED}-${READY_ONLY} in
|
||||||
|
1-2-ON-ON-OFF|0-4-ON-ON-OFF) http_response 200 "Mariadb Cluster Node is synced, ready and connected." ;;
|
||||||
|
*-*-OFF-*-*) http_response 503 "Mariadb Cluster Node is not ready." ;;
|
||||||
|
*-*-*-OFF-*) http_response 503 "Mariadb Cluster Node is not connected" ;;
|
||||||
|
*-*-*-*-ON) http_response 503 "Mariadb Cluster Node is readonly" ;;
|
||||||
|
*) http_response 503 "Mariadb Cluster Node is not synced" ;;
|
||||||
|
esac
|
||||||
|
@@ -49,14 +49,16 @@ wsrep_provider = "<%= @wsrep_provider %>"
|
|||||||
wsrep_cluster_name = "galera_cluster"
|
wsrep_cluster_name = "galera_cluster"
|
||||||
wsrep_cluster_address = "gcomm://<%= @gcomm_definition %>"
|
wsrep_cluster_address = "gcomm://<%= @gcomm_definition %>"
|
||||||
wsrep_sst_auth = root:<%= @mysql_root_password %>
|
wsrep_sst_auth = root:<%= @mysql_root_password %>
|
||||||
wsrep_certify_nonPK = 1
|
|
||||||
wsrep_convert_LOCK_to_trx = 0
|
|
||||||
wsrep_auto_increment_control = 1
|
|
||||||
wsrep_drupal_282555_workaround = 0
|
wsrep_drupal_282555_workaround = 0
|
||||||
wsrep_causal_reads = 0
|
|
||||||
wsrep_sst_method = rsync
|
wsrep_sst_method = rsync
|
||||||
wsrep_node_address = "<%= @api_eth %>"
|
wsrep_node_address = "<%= @api_eth %>"
|
||||||
wsrep_node_incoming_address = "<%= @api_eth %>"
|
wsrep_node_incoming_address = "<%= @api_eth %>"
|
||||||
|
# This is the minimal value (proc*2)
|
||||||
|
wsrep_slave_threads = "<%= @processorcount.to_i * 2 %>"
|
||||||
|
|
||||||
|
# Thoses TWEAK assume that the galera cluster is used in master/slave mode
|
||||||
|
wsrep_provider_options = "gcache.size=<%= @galera_gcache %>;gcs.fc_master_slave=1;gcs.fc_limit=256;gcs.fc_factor=0.9"
|
||||||
|
|
||||||
# this value here are used by /usr/bin/innobackupex
|
# this value here are used by /usr/bin/innobackupex
|
||||||
# and wsrep_sst_xtrabackup take only one configuration file and use the last one
|
# and wsrep_sst_xtrabackup take only one configuration file and use the last one
|
||||||
# (/etc/mysql/my.cnf is not used)
|
# (/etc/mysql/my.cnf is not used)
|
||||||
|
Reference in New Issue
Block a user