Coder Social home page Coder Social logo

pg-replicate-elastic's Introduction

Replication PostreSQL to Elasticsearch via Logical replication slots

pg-replicate-elastic

Demo

asciicast

Install (Python2)

$ pip install pg-replicate-elastic

wal2json

Note: Use my fork as we tested it to be 100% sure it work with it and no breaking changes happen, wal2json .

$ git clone https://github.com/hmilkovi/wal2json.git
$ PATH=/path/to/bin/pg_config:$PATH
$ USE_PGXS=1 make
$ USE_PGXS=1 make install

You need to set up at least two parameters at postgresql.conf:

wal_level = logical
max_replication_slots = 1

After changing these parameters, a restart is needed.

Usage

pg_replicate_elastic --config=<absolute path to json config>

Construct configuration file in json format where:

  • replication_slot json object for replication slot name and if is temporary
  • tables is array of tables we want to replicate
  • es_connection connection string to Elasticsearch
  • postgres json object for PostreSQL connection
  • inital_sync boolean for inital syncronization that needs to be done first time to replicate old data

Example configuration

{
	"replication_slot": {
		"name": "elasticsearch_slot",
		"is_temp": true
	},
	"tables": [{
		"name": "poc",
		"primary_key": "a"
		"exclude_columns": "c,z"
	}],
	"es_connection": "http://127.0.0.1:9200/",
	"postgres": {
		"port": 5432,
		"host": "127.0.0.1",
		"database": "poc",
		"username": "test",
		"password": "test"
	},
	"inital_sync": false
}

Note

wal2json is not my software so for licence check their licence

pg-replicate-elastic's People

Contributors

dependabot[bot] avatar dhenson02 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

pg-replicate-elastic's Issues

Configuration file does not exist!

Just face en issue when starting the command bellow:

pg_replicate_elastic --config=/Users/zhanglei/dbfiles/config.json

config.json content:

{
"replication_slot": {
"name": "test_slot",
"is_temp": true
},
"tables": [{
"name": "t_a",
"primary_key": "id"
"exclude_columns": "sku"
}],
"es_connection": "http://10.0.24.61:9200/",
"postgres": {
"port": 5432,
"host": "127.0.0.1",
"database": "osdba_new",
"username": "wal2json_user",
"password": "123..Com"
},
"inital_sync": false
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.