<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=us-ascii"><meta name=Generator content="Microsoft Word 15 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:#0563C1;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:#954F72;
text-decoration:underline;}
span.EmailStyle17
{mso-style-type:personal;
font-family:"Calibri",sans-serif;
color:windowtext;}
span.EmailStyle18
{mso-style-type:personal;
font-family:"Calibri",sans-serif;
color:#1F497D;}
span.EmailStyle19
{mso-style-type:personal;
font-family:"Calibri",sans-serif;
color:#1F497D;}
span.EmailStyle20
{mso-style-type:personal-reply;
font-family:"Calibri",sans-serif;
color:#1F497D;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-US link="#0563C1" vlink="#954F72"><div class=WordSection1><p class=MsoNormal><span style='color:#1F497D'>Hi Donald!<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>This is how it works on my setup. I run MariaDB as Generic-MySQL mode “gmysql” in PowerDNS.<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>In pdns.conf should add:<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>launch=gmysql<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>gmysql-host=localhost<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>gmysql-dbname=powerdns<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>gmysql-user=powerdns_user<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>gmysql-password=powerdns_password<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>gmysql-dnssec=yes<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>Now go to MySQL settings on MASTER 192.168.0.1 (where slave will be 192.168.0.2):<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>#Binlog should be in ROW or MIXED format.<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'># Login to MySQL and set in mysql line:<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>mysql -u root -p<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>mysql> SET GLOBAL binlog_format = 'ROW';<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'># OR<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>mysql> SET GLOBAL binlog_format = 'MIXED' <o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>mysql>quit<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>#<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'># Edit your /etc/mysql/my.cnf file<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>nano /etc/mysql/my.cnf<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>#<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>[mariadb]<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>log-bin = mysql-bin<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>bind-address=0.0.0.0 /this allows to listen from any IP, ETH ports and Loopback<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>server_id=1<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>log-basename=master1<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>skip-networking=0<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='color:#1F497D'># at mysql prompt enter:<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>mysql> GRANT REPLICATION SLAVE ON *.* TO 'replication_user'@'slave_host' IDENTIFIED BY 'password'; <o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>FLUSH PRIVILEGES;<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>#<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'># or enter alternative commands<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>GRANT REPLICATION SLAVE ON *.* TO replication_user;<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>GRANT ALL PRIVILEGES ON *.* TO 'replication_user'@'192.168.0.2' IDENTIFIED BY 'password' WITH GRANT OPTION;<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>#<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>#To check replication status:<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>SHOW SLAVE STATUS \G<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>#<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>### Now, allow 127.0.0.1, and slave SQL 192.168.0.2 ###<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>iptables -A INPUT -p tcp -s 127.0.0.1 --dport 3306 -j ACCEPT<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>iptables -A INPUT -p tcp -s 192.168.0.2 --dport 3306 -j ACCEPT<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>## Block all other connections to 3306 ##<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>iptables -A INPUT -p tcp --dport 3306 -j DROP<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>#Save iptables<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>sudo iptables-save > /etc/iptables/rules.v4<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>#<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>service mysql restart<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>###The Slave settings 192.168.0.2 where maters is 192.168.0.1<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>#<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>#Now we head over to the Slave. Open the /etc/mysql/my.cnf file and add the following at the bottom:<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>[mariadb]<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>server-id = 2<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>bind-address=0.0.0.0<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>#issue sql restart<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>service mysql restart<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>#<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'># Login MySQL<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>mysql -u root -p<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>mysql > CHANGE MASTER TO master_host="192.168.0.1", master_user="replication_user", master_password="password" master_use_gtid=slave_pos;<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>#Start slave replication:<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>START SLAVE;<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>#To check replication status:<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>SHOW SLAVE STATUS;<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='color:#1F497D'># alternatively you can start replication with the following command from client (192.168.0.2) to connect to 192.168.0.1:3306, enter:<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>>mysql -u replication_user -h 192.168.0.1 -P 3306 -p pasword<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>#<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>Regards<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>Alex.<o:p></o:p></span></p><div><div style='border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in'><p class=MsoNormal><b>From:</b> Pdns-users [mailto:pdns-users-bounces@mailman.powerdns.com] <b>On Behalf Of </b>Donald Jayawardena<br><b>Sent:</b> Monday, December 18, 2017 8:52 AM<br><b>To:</b> pdns-users@mailman.powerdns.com<br><b>Subject:</b> [Pdns-users] Master slave replication<o:p></o:p></p></div></div><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><span lang=EN-AU style='color:#1F497D'>Hi,<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-AU style='color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-AU style='color:#1F497D'>I have an issue replicating data through powerdns on two mysql databases.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-AU style='color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-AU style='color:#1F497D'>I could replicate data when I update data manually on the master. But data does not get thorugh to slave if I use powerdns (using curl) to update slave data records from the master.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-AU style='color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-AU style='color:#1F497D'>The error says:<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-AU style='color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-AU style='color:#1F497D'>Could not execute Delete_rows event on table powerdns.records; Can't find record in 'records', Error_code: 1032; handler error HA_ERR_KEY_NOT_FOUND; the event's master log mysql-bin.000001, end_log_pos 1655<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-AU style='color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-AU style='color:#1F497D'>Please let me know if any solution for this.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-AU style='color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-AU style='color:#1F497D'>Donald Jayawardena<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-AU style='color:#1F497D'><o:p> </o:p></span></p></div></body></html>