How to add a new node to my Elasticsearch cluster

TIPS TO ADD ANOTHER NODE: 1) VERSIONS: It is a good advise to check all of your nodes for the status: http://elastic-node1:9200/ Keep in mind that in most cases: VERSION NEED TO BE THE SAME, EVEN MINOR { “name” : “node2”, “cluster_name” : “xxxxxxxxxxx”, “cluster_uuid” : “n-xxxxxxxxxxxxxxx”, “version” : { “number” : “5.2.2”, “build_hash” : … Read more

Updating AUTO_INCREMENT value of all tables in a MySQL database

Using: ALTER TABLE some_table AUTO_INCREMENT = 0 …will reset the auto_increment value to be the next value based on the highest existing value in the auto_increment column. To run this over all the tables, you’ll need to use MySQL’s dynamic SQL syntax called PreparedStatements because you can’t supply the table name for an ALTER TABLE … Read more

How to split read-only and read-write transactions with JPA and Hibernate

Spring transaction routing First, we will create a DataSourceType Java Enum that defines our transaction routing options: public enum DataSourceType { READ_WRITE, READ_ONLY } To route the read-write transactions to the Primary node and read-only transactions to the Replica node, we can define a ReadWriteDataSource that connects to the Primary node and a ReadOnlyDataSource that … Read more

How to check the replication delay in PostgreSQL?

Alf162 mentioned a good solution in the comments to Craig Ringer’s answer; so I’m adding this to clarify. PostgreSQL has an administrative function pg_last_xact_replay_timestamp() which returns time stamp of the last transaction replayed during recovery. This is the time at which the commit or abort WAL record for that transaction was generated on the primary. … Read more

How to delete replication slot in postgres 9.4

Use pg_drop_replication_slot: select pg_drop_replication_slot(‘bottledwater’); See the docs and this blog. The replication slot must be inactive, i.e. no active connections. So if there’s a streaming replica using the slot you must stop the streaming replica. Or you can change its recovery.conf so it doesn’t use a slot anymore and restart it.

INSERT … ON DUPLICATE KEY UPDATE with WHERE?

I suggest you to use IF() to do that. Refer: conditional-duplicate-key-updates-with-mysql INSERT INTO daily_events (created_on, last_event_id, last_event_created_at) VALUES (‘2010-01-19’, 23, ‘2010-01-19 10:23:11’) ON DUPLICATE KEY UPDATE last_event_id = IF(last_event_created_at < VALUES(last_event_created_at), VALUES(last_event_id), last_event_id);

How can I slow down a MySQL dump as to not affect current load on the server?

I have very large databases with tens of thousands of tables some of which have up to 5GB of data in 10’s of millions of entries. (I run a popular service)… I’ve always had headaches when backing up these databases. Using default mysqldump it quickly spirals the server load out of control and locks up … Read more