Percona-XtraDB-Cluster-garbd-3-3.9-1.3494.rhel7.x86_64 systemd init script broken, fix added

Bug #1444007 reported by Quentin on 2015-04-14
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Percona XtraDB Cluster moved to https://jira.percona.com/projects/PXC
Status tracked in 5.6
5.5
New
Undecided
Unassigned
5.6
Fix Released
Undecided
Unassigned

Bug Description

On the default installation of Percona-XtraDB-Cluster-garbd-3-3.9-1.3494.rhel7.x86_64 the provided systemd-init script is broken. It seems the garbd-systemd doesn't read the config file in /etc/sysconfig/garb. It does the checks on the default installation line, but it does not read the variables in the config file such as: GALERA_NODES et cetera.

I fixed it to add the following line in /usr/bin/garb-systemd right after config=/etc/sysconfig/garb:
source /etc/sysconfig/garb

So the /usr/bin/garb-systemd looks like this now:

#!/bin/bash -ue
#

config=/etc/sysconfig/garb
source /etc/sysconfig/garb

log_failure() {
    echo " ERROR! $@"
}

program_start() {
 echo "Starting garbd"
        /usr/bin/garbd $*
}

start() {

 if grep -q -E '^# REMOVE' $config;then
     log_failure "Garbd config $config is not configured yet"
     return 0
 fi

 # Check that node addresses are configured
 set -x
 if [[ -z "${GALERA_NODES:-}" ]]; then
  log_failure "List of GALERA_NODES is not configured"
  return 6
 fi
 if [[ -z "${GALERA_GROUP:-}" ]]; then
  log_failure "GALERA_GROUP name is not configured"
  return 6
 fi

 GALERA_PORT=${GALERA_PORT:-4567}

 # Find a working node
 for ADDRESS in ${GALERA_NODES} 0; do
  HOST=$(echo $ADDRESS | cut -d \: -f 1 )
  PORT=$(echo $ADDRESS | cut -s -d \: -f 2 )
  PORT=${PORT:-$GALERA_PORT}
  if [[ -x `which nc` ]] && nc -h 2>&1 | grep -q -- '-z';then
                    nc -z $HOST $PORT >/dev/null && break
                elif [[ -x `which nmap` ]];then
                    nmap -Pn -p$PORT $HOST | awk "\$1 ~ /$PORT/ {print \$2}" | grep -q open && break
                else
                    log_failure "Neither netcat nor nmap are present for zero I/O scanning"
                    return 1
                fi
 done
 if [ ${ADDRESS} == "0" ]; then
  log_failure "None of the nodes in $GALERA_NODES is accessible"
  return 1
 fi

 OPTIONS=" -a gcomm://$ADDRESS "
 [ -n "${GALERA_GROUP:-}" ] && OPTIONS="$OPTIONS -g $GALERA_GROUP"
 [ -n "${GALERA_OPTIONS:-}" ] && OPTIONS="$OPTIONS -o $GALERA_OPTIONS"
 [ -n "${LOG_FILE:-}" ] && OPTIONS="$OPTIONS -l $LOG_FILE"

 program_start $OPTIONS
}

# See how we were called.
case "$1" in
  start)
 start
 ;;
  *)
 echo $"Usage: $0 {start}"
 exit 2
esac

exit $?

Confirmed.

[root@localhost ~]# rpm -qa | grep -i garbd
Percona-XtraDB-Cluster-garbd-3-3.9-1.3494.rhel7.x86_64
[root@localhost ~]#

[root@localhost ~]# cat /etc/sysconfig/garb
# Copyright (C) 2012 Codership Oy
# This config file is to be sourced by garb service script.

# A space-separated list of node addresses (address[:port]) in the cluster
GALERA_NODES="192.168.7.104"

# Galera cluster name, should be the same as on the rest of the nodes.
GALERA_GROUP="my_centos7_cluster"

# Optional Galera internal options string (e.g. SSL settings)
# see http://www.codership.com/wiki/doku.php?id=galera_parameters
GALERA_OPTIONS=""

# Log file for garbd. Optional, by default logs to syslog
# Deprecated for CentOS7, use journalctl to query the log for garbd
LOG_FILE="/root/garbd.log"

[root@localhost ~]#

[root@localhost ~]# head -7 /usr/bin/garb-systemd
#!/bin/bash -ue
#

config=/etc/sysconfig/garb

log_failure() {
    echo " ERROR! $@"
[root@localhost ~]#

[root@localhost ~]# garb-systemd start
 ERROR! List of GALERA_NODES is not configured
[root@localhost ~]#

[root@localhost ~]# head -7 /usr/bin/garb-systemd
#!/bin/bash -ue
#

config=/etc/sysconfig/garb
source /etc/sysconfig/garb

log_failure() {
[root@localhost ~]#

[root@localhost ~]# garb-systemd start
Starting garbd
terminate called after throwing an instance of 'gu::NotSet'
/usr/bin/garb-systemd: line 13: 4742 Aborted (core dumped) /usr/bin/garbd $*
[root@localhost ~]#

Changed in percona-xtradb-cluster:
status: New → Confirmed
Alex Yurchenko (ayurchen) wrote :

Nilnandan, this is a different error. I happened because you quoted values in your config file: https://github.com/codership/galera/issues/186

Hi Alex, I tested without the quotes and got the same result like above.

[root@localhost ~]# cat /etc/sysconfig/garb
# Copyright (C) 2012 Codership Oy
# This config file is to be sourced by garb service script.

# A space-separated list of node addresses (address[:port]) in the cluster
GALERA_NODES=192.168.1.213

# Galera cluster name, should be the same as on the rest of the nodes.
GALERA_GROUP=my_centos7_cluster

# Optional Galera internal options string (e.g. SSL settings)
# see http://www.codership.com/wiki/doku.php?id=galera_parameters
GALERA_OPTIONS=""

# Log file for garbd. Optional, by default logs to syslog
# Deprecated for CentOS7, use journalctl to query the log for garbd
LOG_FILE=/root/garbd.log

[root@localhost ~]#

[root@localhost ~]# garb-systemd start
Starting garbd
terminate called after throwing an instance of 'gu::NotSet'
/usr/bin/garb-systemd: line 13: 4048 Aborted (core dumped) /usr/bin/garbd $*
[root@localhost ~]#

Can you try to check the same thing with CentOS 7?

Btw: problem here is not error, but systemd init scrip doesn't read the config file with config=/etc/sysconfig/garb option. So, you have to add "source /etc/sysconfig/garb" in the init script.

Percona now uses JIRA for bug reports so this bug report is migrated to: https://jira.percona.com/browse/PXC-1820

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers