Bug 1337124

Summary: mysql: replication_port parameter not used
Product: Red Hat Enterprise Linux 7 Reporter: Oyvind Albrigtsen <oalbrigt>
Component: resource-agentsAssignee: Oyvind Albrigtsen <oalbrigt>
Status: CLOSED ERRATA QA Contact: cluster-qe <cluster-qe>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 7.3CC: agk, cluster-maint, fdinitto, mnovacek
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: resource-agents-3.9.5-73.el7 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 1337146 (view as bug list) Environment:
Last Closed: 2016-11-04 00:03:15 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1337146    

Description Oyvind Albrigtsen 2016-05-18 10:51:54 UTC
Description of problem:
Setting replication_port doesnt have any effect

Version-Release number of selected component (if applicable):
3.9.5-54.el7_2.10

How reproducible:
Everytime

Steps to Reproduce:
1. Change port to non-standard port in my.cnf
2. Set replication_port to the non-standard port
2. Make the resource a master/slave
3. Check if resource fails

Actual results:
Slave fails trying to connect to default port instead of replication_port

Expected results:
Slave connects to correct port

Additional info:
Fix available at: https://github.com/ClusterLabs/resource-agents/pull/788

Comment 2 Oyvind Albrigtsen 2016-06-03 13:57:20 UTC
Patch working as expected.

Added following patch to include metadata info that the RELOAD action is also needed for the replication user:
https://github.com/ClusterLabs/resource-agents/commit/e78f106cc5edabc50eb3622ce384ed2493250ec5

Comment 4 Oyvind Albrigtsen 2016-06-07 13:52:19 UTC
Setup:
- Setup replication in MariaDB and set "port=3316" in /etc/my.cnf under "[mysqld]".
- Enable port 3316 in SELinux on both master and slave host:
# semanage port -a -t mysqld_port_t -p tcp 3316

- Create resource
# pcs resource create mysql mysql replication_user='replication_user' replication_passwd='...' --master meta notify=true


Before:
# mysql
MariaDB [(none)]> show slave status;
...
| Connecting to master | rhel7-X     | replication_user |        3306 |            60 | mysqld-bin.000041 |                 245 | mysqld-relay-bin.000001 |             4 | mysqld-bin.000041     | Connecting       | Yes               | tdb             |                     |                    |                        |                         |                             |          0 |            |            0 |                 245 |             245 | None            |                |             0 | No                 |                    |                    |                 |                   |                |                  NULL | No                            |          2003 | error connecting to master 'replication_user@rhel7-X:3306' - retry-time: 60  retries: 86400  message: Can't connect to MySQL server on 'rhel7-X' (111) |              0 |                |                             |                0 |

You can try to set the replication_port, but the setting is ignored.
# pcs resource update mysql replication_port=3316


After:
# pcs resource update mysql replication_port=3316
# mysql
MariaDB [(none)]> show slave status;
...
| Waiting for master to send event | rhel7-X     | replication_user |        3316 |            60 | mysqld-bin.000041 |                 245 | mysqld-relay-bin.000002 |           530 | mysqld-bin.000041     | Yes              | Yes               | tdb             |                     |                    |                        |                         |                             |          0 |            |            0 |                 245 |             825 | None            |                |             0 | No                 |                    |                    |                 |                   |                |                     0 | No                            |             0 |               |              0 |                |                             |                1 |

Comment 5 michal novacek 2016-09-15 17:09:34 UTC
I have verified that the replication_port parameter is not ignored when changed
in resource-agents-3.9.5-81.el7.x86_64.

---

common setup:

 * enable port 3307 to be used by mysql replication (ports selinux)
 * setup mysql replication on port 3307 as master/master and verify that it
     works correctly (mysql replication setup)
 * setup cluster (pcs status)
 * setup mysql resource agent as master/slave with different replication_port,
     replication_passwd and replication_user and disable it (pcs resource)

before the patch (resource-agents-3.9.5-54.el7_2.10.x86_64)
===========================================================
resource is started but mysql slave uses default port and will not connect
$ pcs resource enable mysql-master
$ sleep 60
$ ssh virt-048 'mysql -u root -e "show slave status\G;"'
*************************** 1. row ***************************
               Slave_IO_State: Connecting to master
                  Master_Host: virt-049.cluster-qe.lab.eng.brq.redhat.com
                  Master_User: replication_user
                  Master_Port: 3306
                Connect_Retry: 60
              Master_Log_File: master2-bin.000738
          Read_Master_Log_Pos: 245
               Relay_Log_File: mysqld-relay-bin.000001
                Relay_Log_Pos: 4
        Relay_Master_Log_File: master2-bin.000738
             Slave_IO_Running: Connecting
            Slave_SQL_Running: Yes
                            ...
Master_SSL_Verify_Server_Cert: No
                Last_IO_Errno: 2003
>                Last_IO_Error: error connecting to master
>                'replication_user.lab.eng.brq.redhat.com:3306'
>                - retry-time: 60  retries: 86400  message: Can't connect to
>                MySQL server on 'virt-049.cluster-qe.lab.eng.brq.redhat.com'
>                (111)

$ ssh virt-049 'mysql -u root -e "show master status\G;"'
*************************** 1. row ***************************
            File: master2-bin.000738
        Position: 245
    Binlog_Do_DB: tdb
Binlog_Ignore_DB:

after the patch (resource-agents-3.9.5-81.el7.x86_64)
=====================================================
resource can be started and the port settings is respected

$ pcs resource enable mysql-master
$ sleep 60
$ pcs status 
...
 Master/Slave Set: mysql-master [mysql]
     Masters: [ virt-049 ]
     Slaves: [ virt-048 ]
...
$ ssh virt-048 'mysql -u root -e "show slave status\G;"' | head
*************************** 1. row ***************************
               Slave_IO_State: Waiting for master to send event
                  Master_Host: virt-049.cluster-qe.lab.eng.brq.redhat.com
                  Master_User: replication_user
>                  Master_Port: 3307
                Connect_Retry: 60
              Master_Log_File: master2-bin.000735
>          Read_Master_Log_Pos: 245
               Relay_Log_File: mysqld-relay-bin.000002
                Relay_Log_Pos: 531
$ ssh virt-049 'mysql -u root -e "show master status\G;"'
*************************** 1. row ***************************
            File: master2-bin.000735
>        Position: 245
    Binlog_Do_DB: tdb
Binlog_Ignore_DB: 


>>(ports selinux)
[root@virt-048 my.cnf.d]# getenforce
Enforcing
[root@virt-048 my.cnf.d]# semanage port -a -t mysqld_port_t -p tcp 3307
[root@virt-048 my.cnf.d]# semanage port -l | grep mysqld
mysqld_port_t                  tcp      3307, 1186, 3306, 63132-63164

[root@virt-049 my.cnf.d]# getenforce
Enforcing
[root@virt-049 my.cnf.d]# semanage port -a -t mysqld_port_t -p tcp 3307
[root@virt-049 my.cnf.d]# semanage port -l | grep mysqld
mysqld_port_t                  tcp      3307, 1186, 3306, 63132-63164

>>(mysql replication setup)
[root@virt-048 my.cnf.d]# mysql -u root -e 'show slave status\G;' | head
*************************** 1. row ***************************
               Slave_IO_State: Waiting for master to send event
                  Master_Host: virt-049.cluster-qe.lab.eng.brq.redhat.com
                  Master_User: replication_user
                  Master_Port: 3307
                Connect_Retry: 60
              Master_Log_File: master2-bin.000734
          Read_Master_Log_Pos: 245
               Relay_Log_File: mysqld-relay-bin.000002
                Relay_Log_Pos: 531

[root@virt-049 my.cnf.d]# mysql -u root -e 'show master status\G;'
*************************** 1. row ***************************
            File: master2-bin.000734
        Position: 245
    Binlog_Do_DB: tdb
Binlog_Ignore_DB:

>>(pcs status)
[root@virt-049 my.cnf.d]# pcs status
Cluster name: STSRHTS7875
Last updated: Thu Sep 15 14:02:38 2016          Last change: Thu Sep 15 13:52:24 2016 by root via crm_attribute on virt-049
Stack: corosync
Current DC: virt-048 (version 1.1.13-10.el7_2.4-44eb2dd) - partition with quorum
2 nodes and 8 resources configured

Online: [ virt-048 virt-049 ]

Full list of resources:

 fence-virt-048 (stonith:fence_xvm):    Started virt-048
 fence-virt-049 (stonith:fence_xvm):    Started virt-049
 Clone Set: dlm-clone [dlm]
     Started: [ virt-048 virt-049 ]
 Clone Set: clvmd-clone [clvmd]
     Started: [ virt-048 virt-049 ]
 Master/Slave Set: mysql-master [mysql]
     Stopped: [ virt-049 virt-048 ]

PCSD Status:
  virt-048: Online
  virt-049: Online

Daemon Status:
  corosync: active/enabled
  pacemaker: active/enabled
  pcsd: active/enabled

>>(pcs resource)
[root@virt-049 my.cnf.d]# pcs resource show mysql-master
 Meta Attrs: notify=true
 Master: mysql-master
  Resource: mysql (class=ocf provider=heartbeat type=mysql)
   Attributes: replication_user=replication_user replication_port=3307 replication_passwd=password 
   Operations: start interval=0s timeout=120 (mysql-start-interval-0s)
               stop interval=0s timeout=120 (mysql-stop-interval-0s)
               promote interval=0s timeout=120 (mysql-promote-interval-0s)
               demote interval=0s timeout=120 (mysql-demote-interval-0s)
               monitor interval=30s (mysql-monitor-interval-30s)

Comment 7 errata-xmlrpc 2016-11-04 00:03:15 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://rhn.redhat.com/errata/RHBA-2016-2174.html