Bug 1337146

Summary: mysql: replication_port parameter not used
Product: Red Hat Enterprise Linux 6 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: 6.8CC: agk, cluster-maint, cluster-qe, fdinitto, mnovacek
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: resource-agents-3.9.5-36.el6 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: 1337124 Environment:
Last Closed: 2017-03-21 09:27:55 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: 1337124    
Bug Blocks:    

Description Oyvind Albrigtsen 2016-05-18 11:58:06 UTC
+++ This bug was initially created as a clone of Bug #1337124 +++

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 3 Oyvind Albrigtsen 2016-09-08 14:23:13 UTC
Tested and working as expected.

Comment 5 michal novacek 2017-01-17 17:33:51 UTC
I have verified that the replication_port parameter is not ignored when changed
in resource-agents-3.9.5-43.el6.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-34.el6.x86_64)
=======================================================
resource is started but mysql slave uses default port and will not connect

$ pcs resource enable mysql-master
$ sleep 60
$ pcs status
...
 Master/Slave Set: mysql-master [mysql]
     Masters: [ virt-282.ipv4.cluster-qe.lab.eng.brq.redhat.com ]
     Slaves: [ virt-291.ipv4.cluster-qe.lab.eng.brq.redhat.com ]
...
$ ssh virt-291 'mysql -u root -e "show slave status\G;"'
*************************** 1. row ***************************
               Slave_IO_State: Connecting to master
                  Master_Host: virt-282.cluster-qe.lab.eng.brq.redhat.com
                  Master_User: replication_user
>                  Master_Port: 3306
                Connect_Retry: 60
              Master_Log_File: mysql-bin.000014
          Read_Master_Log_Pos: 106
               Relay_Log_File: mysqld-relay-bin.000001
                Relay_Log_Pos: 4
        Relay_Master_Log_File: mysql-bin.000014
             Slave_IO_Running: No
            Slave_SQL_Running: Yes
                            ...
>                Last_IO_Errno: 2013
>                Last_IO_Error: error connecting to master 'replication_user.lab.eng.brq.redhat.com:3306' - retry-time: 60  retries: 86400
>               Last_SQL_Errno: 0
>               Last_SQL_Error: 

$ ssh virt-282 'mysql -u root -e "show master status\G;"'
Warning: Permanently added 'virt-282,10.34.71.153' (RSA) to the list of known hosts.
*************************** 1. row ***************************
            File: mysql-bin.000014
        Position: 106
    Binlog_Do_DB: tdb
Binlog_Ignore_DB:


> after the patch (resource-agents-3.9.5-43.el6.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-282.ipv4.cluster-qe.lab.eng.brq.redhat.com ]
     Slaves: [ virt-291.ipv4.cluster-qe.lab.eng.brq.redhat.com ]
...

# ssh virt-282 "mysql -u root -e 'show master status\G;'"
*************************** 1. row ***************************
>           File: mysql-bin.000035
>       Position: 106
    Binlog_Do_DB: tdb
Binlog_Ignore_DB:

$ ssh virt-291 'mysql -u root -e "show slave status\G;"'
*************************** 1. row ***************************
               Slave_IO_State: Waiting for master to send event
                  Master_Host: virt-282.cluster-qe.lab.eng.brq.redhat.com
                  Master_User: replication_user
>                 Master_Port: 3307
                Connect_Retry: 60
              Master_Log_File: mysql-bin.000035
>         Read_Master_Log_Pos: 106
               Relay_Log_File: mysqld-relay-bin.000002
                Relay_Log_Pos: 251
>       Relay_Master_Log_File: mysql-bin.000035
             Slave_IO_Running: Yes
                            ...
                Last_IO_Errno: 0
                Last_IO_Error: 
               Last_SQL_Errno: 0
               Last_SQL_Error: 

>>(ports selinux)
The following commands have been run on all nodes of the cluster:

# getenforce
Enforcing
# semanage port -a -t mysqld_port_t -p tcp 3307
# semanage port -l | grep mysqld_port
mysqld_port_t                  tcp      3307, 1186, 3306, 63132-63164

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

>>(mysql replication setup)
[root@virt-282 ~]# ssh virt-282 'mysql -u root -e "show slave status\G;" | head'
*************************** 1. row ***************************
               Slave_IO_State: Connecting to master
                  Master_Host: virt-282.cluster-qe.lab.eng.brq.redhat.com
                  Master_User: replication_user
                  Master_Port: 3307
                Connect_Retry: 60
              Master_Log_File: mysql-bin.000018
          Read_Master_Log_Pos: 106
               Relay_Log_File: mysqld-relay-bin.000001
                Relay_Log_Pos: 4

[root@virt-282 ~]# ssh virt-291 'mysql -u root -e "show master status\G;"'
*************************** 1. row ***************************
            File: mysql-bin.000018
        Position: 106
    Binlog_Do_DB: tdb
Binlog_Ignore_DB:

>>(pcs status)
[root@virt-282 my.cnf.d]# pcs status
Cluster name: STSRHTS4183
Stack: cman
Current DC: virt-282.ipv4.cluster-qe.lab.eng.brq.redhat.com (version 1.1.15-4.el6-e174ec8) - partition with quorum
Last updated: Tue Jan 17 18:31:47 2017          Last change: Tue Jan 17 18:31:42 2017 by root via crm_resource on virt-282.ipv4.cluster-qe.lab.eng.brq.redhat.com

2 nodes and 4 resources configured: 2 resources DISABLED and 0 BLOCKED from being started due to failures

Online: [ virt-282.ipv4.cluster-qe.lab.eng.brq.redhat.com virt-291.ipv4.cluster-qe.lab.eng.brq.redhat.com ]

Full list of resources:

 fence-virt-282 (stonith:fence_xvm):    Started virt-282.ipv4.cluster-qe.lab.eng.brq.redhat.com
 fence-virt-291 (stonith:fence_xvm):    Started virt-291.ipv4.cluster-qe.lab.eng.brq.redhat.com
 Master/Slave Set: mysql-master [mysql]
     Stopped (disabled): [ virt-282.ipv4.cluster-qe.lab.eng.brq.redhat.com virt-291.ipv4.cluster-qe.lab.eng.brq.redhat.com ]

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


>>(pcs resource)
[root@virt-282 ~]# pcs resource show mysql-master
 Master: mysql-master
  Meta Attrs: notify=true target-role=Stopped 
  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 2017-03-21 09:27:55 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-2017-0602.html