gomigrator

package module
v0.0.0-...-7fe940f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 12, 2016 License: MIT Imports: 9 Imported by: 0

README

gomigrator is a simple replication transmitter built using go-mysql. Basically, the library reads binlog stream from master DB, parses data, and then does insert/update/delete operation on target database which can either be a replica or another master.

You might find this project useful for doing database migration when it's not possible to set replica facing external master.

Example:

package main

import "github.com/jinarusha/gomigrator"

func main() {

	migrator := gomigrator.Migrator{
		MasterHost:         "masterDBHostUrl",
		MasterPort:         3306,
		MasterDatabaseName: "masterDatabaseName",
		MasterUser:         "masterUser",
		MasterPassword:     "masterPassword",

		SlaveHost:         "targetDBHostUrl",
		SlavePort:         3306,
		SlaveDatabaseName: "targetDatabaseName",
		SlaveUser:         "targetUser",
		SlavePassword:     "targetPassword",

		BinlogFilename: "mariadb-bin.000478",
		BinlogPosition: 16287,
		
		// If it's too large, you might run out of memory
		MaxQueueSize: 500000,
	}

  // for MySQL, set "mariadb" -> "mysql"
  	var slaveServerId uint32 = 100
	migrator.StartSync(slaveServerId, "mariadb")
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Migrator

type Migrator struct {
	MasterHost         string
	MasterPort         uint16
	MasterUser         string
	MasterDatabaseName string
	MasterPassword     string

	SlaveHost         string
	SlavePort         uint16
	SlaveDatabaseName string
	SlaveUser         string
	SlavePassword     string

	BinlogFilename string
	BinlogPosition uint32

	MaxQueueSize int
	// contains filtered or unexported fields
}

func (*Migrator) StartSync

func (m *Migrator) StartSync(serverId uint32, serverType string) error

Starts replication

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL