Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1ZggQr-00014r-Qa for pgsql-pkg-yum@arkaria.postgresql.org; Mon, 28 Sep 2015 21:58:01 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1ZggQq-0006oP-U3 for pgsql-pkg-yum@arkaria.postgresql.org; Mon, 28 Sep 2015 21:58:00 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1ZggQq-0006oI-GN for pgsql-pkg-yum@postgresql.org; Mon, 28 Sep 2015 21:58:00 +0000 Received: from smtp-out-02c.arnet.com.ar ([200.45.0.211]) by magus.postgresql.org with esmtp (Exim 4.84) (envelope-from ) id 1ZggQe-0005bA-Rn for pgsql-pkg-yum@postgresql.org; Mon, 28 Sep 2015 21:57:56 +0000 X-Arnet-Anti-Spam: Activado X-Arnet-AV: Activado X-IPAS-Result: A2BGDABGtwlW/wXdqMBdHQEBgwVUhBOqBZIKC4dNTQEBAQEBAYELQQOECgQvSxQWCwIEBwMCAQIBJxgYAQgBARiIFKcRj2uVAItwh32BQwWVcIJLgWCKM4cmJwySFQJjghEcgW4khw9cgWkBAQE Received: from unknown (HELO smtp-client-04.arnet.com.ar) ([192.168.221.5]) by smtp-route-05.arnet.com.ar with ESMTP; 28 Sep 2015 18:57:08 -0300 X-IPAS-Result: A2D3CwCZtglW/2l9fbpdgyRUhBO8GodNTQEBAQEBAYELQQOECgQvXxYLAgQHAwIBAgEnGBgBCAEBGIgUpxCPa5UAi3CHfYFDBZVwgkuBYIozhyYzkhUCY4IRHIFuJIcPXIFpAQEB Received: from host105.186-125-125.telecom.net.ar (HELO mail.marquesminen.com.ar) ([186.125.125.105]) by smtp-client-04.arnet.com.ar with ESMTP; 28 Sep 2015 18:14:41 -0300 Received: from localhost (localhost.localdomain [127.0.0.1]) by mail.marquesminen.com.ar (Postfix) with ESMTP id 8E338120C2C for ; Mon, 28 Sep 2015 18:57:07 -0300 (ART) X-Virus-Scanned: amavisd-new at example.com Received: from mail.marquesminen.com.ar ([127.0.0.1]) by localhost (endor.marques [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Dsa0tzic6RvO for ; Mon, 28 Sep 2015 18:57:03 -0300 (ART) Received: from coruscant.marques (unknown [192.168.0.46]) by mail.marquesminen.com.ar (Postfix) with ESMTP id 8A44D120C21 for ; Mon, 28 Sep 2015 18:57:03 -0300 (ART) To: pgsql-pkg-yum@postgresql.org From: =?UTF-8?Q?Mart=c3=adn_Marqu=c3=a9s?= Subject: repmgr init script X-Enigmail-Draft-Status: N1110 Message-ID: <5609B7AF.3010903@2ndquadrant.com> Date: Mon, 28 Sep 2015 18:57:03 -0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------070705050708090504030207" X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-pkg-yum Precedence: bulk Sender: pgsql-pkg-yum-owner@postgresql.org This is a multi-part message in MIME format. --------------070705050708090504030207 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Hi all, I've been going over the configuration of an already installed repmgr cluster from PGDG rpms and found that the init-script doesn't seem to be performing the correct commands. I found a dangling dash which I have no idea what it's there for. So, mainly I think the start exec should be changed to something like: $SU -l $REPMGRD_USER -c "${REPMGRD_BIN} ${REPMGRD_OPTS} \ -p ${REPMGRD_PIDFILE} &" >> "${REPMGRD_LOG}" 2>&1 < /dev/null This means having all the repmgrd options set in ${REPMGRD_OPTS} in a sysconfig file instead of placing them one by one in the init script. This would mean that all the configuration should be set in sysconfig/repmgrd, not by editing the init script. Attached is a patch for EL-6, plus the missing sysconfig file. On EL-7 we need to have a nice systemd file. I'll see if I can get that done later. Also, the init script's service should be called repmgrd, not repmgr. Kind regards, -- Martín Marqués http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services --------------070705050708090504030207 Content-Type: text/x-diff; name="repmgr.init.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="repmgr.init.diff" diff --git a/rpm/redhat/9.4/repmgr/EL-6/repmgr.init b/rpm/redhat/9.4/repmgr/EL-6/repmgr.init index c900170..fd0fdd2 100644 --- a/rpm/redhat/9.4/repmgr/EL-6/repmgr.init +++ b/rpm/redhat/9.4/repmgr/EL-6/repmgr.init @@ -29,32 +29,63 @@ user=repmgr prog=repmgrd pidfile=/var/run/repmgr/repmgrd-9.4.pid lockfile=/var/lock/subsys/$prog +REPMGRD_ENABLED=no +REPMGRD_OPTS= REPMGRDCONF=/etc/repmgr/9.4/repmgr.conf REPMGRDLOG=/var/log/repmgr/repmgrd-9.4.log # Get config. . /etc/sysconfig/network +# Read configuration variable file if it is present +[ -r /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog + +# For SELinux we need to use 'runuser' not 'su' +if [ -x /sbin/runuser ] +then + SU=runuser +else + SU=su +fi + +test -x $exec || exit 0 + +case "$REPMGRD_ENABLED" in + [Yy]*) + break + ;; + *) + exit 0 + ;; +esac + +if [ -z "${REPMGRD_OPTS}" ] +then + echo "Not starting ${prog}, REPMGRD_OPTS not set in /etc/sysconfig/${prog}" + exit 0 +fi + # Check that networking is up. [ "${NETWORKING}" = "no" ] && exit 6 start(){ [ -x $exec ] || exit 5 - [ -f "$REPMGRDCONF" ] || exit 6 + [ -f "${REPMGRDCONF}" ] || exit 6 echo -n "Starting $prog: " # Make sure startup-time log file is valid - if [ ! -e "$REPMGRDLOG" -a ! -h "$REPMGRDLOG" ] + if [ ! -e "${REPMGRDLOG}" -a ! -h "${REPMGRDLOG}" ] then - touch "$REPMGRDLOG" || exit 1 - chown $user: "$REPMGRDLOG" - chmod go-rwx "$REPMGRDLOG" - [ -x /usr/bin/chcon ] && /usr/bin/chcon -u system_u -r object_r -t postgresql_log_t "$REPMGRDLOG" 2>/dev/null + touch "${REPMGRDLOG}" || exit 1 + chown $user: "${REPMGRDLOG}" + chmod go-rwx "${REPMGRDLOG}" + [ -x /usr/bin/chcon ] && /usr/bin/chcon -u system_u -r object_r -t postgresql_log_t "${REPMGRDLOG}" 2>/dev/null fi mkdir -p $(dirname $pidfile) chown $user: $(dirname $pidfile) - su -l repmgr -c "$exec -f $REPMGRDCONF -p $pidfile -d ->> $REPMGRDLOG 2>&1" $user # --monitoring-history --verbose + ${SU} -l -c "${exec} -f ${REPMGR_CONF} ${REPMGRD_OPTS} -p ${pidfile} >> ${REPMGRDLOG} 2>&1" ${user} < /dev/null + sleep 2 retval=$? [ $retval -eq 0 ] && success echo --------------070705050708090504030207 Content-Type: text/plain; charset=UTF-8; name="repmgrd.sysconfig" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="repmgrd.sysconfig" IyBkZWZhdWx0IHNldHRpbmdzIGZvciByZXBtZ3JkLiBUaGlzIGZpbGUgaXMg c291cmNlIGJ5IC9iaW4vc2ggZnJvbQojIC9ldGMvaW5pdC5kL3JlcG1ncmQK CiMgZGlzYWJsZSByZXBtZ3JkIGJ5IGRlZmF1bHQgc28gaXQgd29uJ3QgZ2V0 IHN0YXJ0ZWQgdXBvbiBpbnN0YWxsYXRpb24KIyB2YWxpZCB2YWx1ZXM6IHll cy9ubwpSRVBNR1JEX0VOQUJMRUQ9bm8KCiMgUmVwbWdyIGNvbmYgZmlsZQpS RVBNR1JfQ09ORj0vdmFyL2xpYi9wZ3NxbC9yZXBtZ3IvcmVwbWdyLmNvbmYK CiMgT3B0aW9ucyBmb3IgcmVwbWdyZCAocmVxdWlyZWQpCiNSRVBNR1JEX09Q VFM9Ii0tdmVyYm9zZSAtZCAiCgojIFVzZXIgdG8gcnVuIHJlcG1ncmQgYXMK I1JFUE1HUkRfVVNFUj1wb3N0Z3JlcwoKIyByZXBtZ3JkIGJpbmFyeQojUkVQ TUdSRF9CSU49L3Vzci9iaW4vcmVwbWdyZAoKIyBwaWQgZmlsZQojUkVQTUdS RF9QSURGSUxFPS92YXIvbGliL3Bnc3FsL3JlcG1nci9yZXBtZ3JkLnBpZAoK IyBsb2cgZmlsZQojUkVQTUdSRF9MT0c9L3Zhci9saWIvcGdzcWwvcmVwbWdy L3JlcG1ncmQubG9nCg== --------------070705050708090504030207 Content-Type: text/plain Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 -- Sent via pgsql-pkg-yum mailing list (pgsql-pkg-yum@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-pkg-yum --------------070705050708090504030207--