Federation with new installed Master and existing Slave Issue

Hi,

i am planning a new OpenNebula Federation with a newly installed Master (4.12x) and a
existing Slave-Installation (4.10.x). The existing Slave have several Hosts, vDC`s and ~150 VM.

Because it`s a production environment i set-up a Testlab with virtual machines on my laptop.
First, i installed the existing slave with a database dump of the real slave as vm.
Everyting works.

No i upgraded from 4.10x to 4.12.x.
Everyting is fine.

Now i installed the new master from scratch and followed this guide: http://docs.opennebula.org/4.12/advanced_administration/data_center_federation/federationconfig.html#federationconfig

But after initializing the MySQL replication my slave instance is empty.
After some investigation i found following query right after the “START SLAVE”:

150524 14:19:13	    1 Query	slave start
	   38 Connect Out	one-xxx-xxx@10.211.55.16:3306
	   39 Query	drop database opennebula
	   39 Query	create database opennebula
	   39 Query	CREATE DATABASE IF NOT EXISTS opennebula
	   39 Query	BEGIN
	   39 Query	COMMIT /* implicit, from Xid_log_event */
	   39 Query	BEGIN
	   39 Query	COMMIT /* implicit, from Xid_log_event */
	   39 Query	BEGIN

The Problem is the “drop database opennebula” Query.

Question: Is it a “bug” - or a known behaviour?

The Guide says:

If the OpenNebula to be added as a Slave is an existing installation, and you need to preserve its database (users, groups, VMs, hosts…), you need to import the contents with the onedb command.

As workaround i will create a dump of my existing slave and import the needed tables manually. But i think, there should be a short information for other users in the guide. Am i wrong?

This is already mentioned in the docs, see: OpenNebula Federation Configuration — OpenNebula 4.12.1 documentation

Stop the slave OpenNebula. Make sure the master OpenNebula is also stopped.
Run the onedb import-slave command. Use -h to get an explanation of each option.

So, I believe your use case is already explained in the documentation.

Really?

If the OpenNebula to be added as a Slave is an existing installation, and you need to preserve its database (users, groups, VMs, hosts...), you need to import the contents with the onedb command.

The onedb import-slave command only imports the “federation tables” (user_pool,group_pool,vdc_pool,zone_pool,db_versioning,acl).

After this step the MySQL replication is started. This action drops the dababase of the existing slave.
Only the replicated federation tables exists for now in the slave opennebula database.
I had to import the “old” production tables manually by importing a SQL dump.

Am I wrong?

Hi,

Looking at your log file:

150524 14:19:13	    1 Query	slave start
   38 Connect Out	one-xxx-xxx@10.211.55.16:3306
   39 Query	drop database opennebula
   39 Query	create database opennebula
   39 Query	CREATE DATABASE IF NOT EXISTS opennebula

It looks like the first two queries were executed manually in the master mysql server before OpenNebula did the first bootstrap. OpenNebula does not execute a drop + create, it only does the ‘create if not exists’. I admit we didn’t take this scenario into account, all our tests are done with databases managed entirely through OpenNebula.

Probably there is a way to tell the slave to start the replication from a certain position in the master binary log. I think we should fix this issue updating the documentation to instruct admins to look for the first ‘create if not exists’, and use that as the first query to replicate.

What do you guys think? Do you agree, or am I missing something?