Skip to content

Instantly share code, notes, and snippets.

@jayjanssen
jayjanssen / gist:1076304
Created July 11, 2011 17:14
node-zookeeper 100% cpu (curl against it 3 times)
require.paths.unshift('../');
var ZK = require ('zookeeper').ZooKeeper;
var connect = require('connect');
var Storage = (function() {
var that = {};
// connection manager object is responsible for maintaining the connection to zk
var connection_manager = (function() {
@jayjanssen
jayjanssen / gist:2911398
Created June 11, 2012 17:16
Monitor checkpoint age on any Innodb server
#!/usr/bin/perl
#LOG
#---
#Log sequence number 248 2222568315
#Log flushed up to 248 2222533410
#Last checkpoint at 248 1843690869
#
use strict;
@jayjanssen
jayjanssen / gist:3061311
Created July 6, 2012 16:57
Find pt-table-checksum diffs that are not MEMORY tables and in a specific schema
SELECT db, tbl, SUM(this_cnt) AS total_rows, COUNT(*) AS chunks
FROM percona.checksums, information_schema.tables
WHERE
percona.checksums.db=information_schema.tables.TABLE_SCHEMA AND
percona.checksums.tbl=information_schema.tables.TABLE_NAME AND
information_schema.tables.ENGINE != 'MEMORY' AND
percona.checksums.db='myDB' AND
(
master_cnt <> this_cnt
OR master_crc <> this_crc
@jayjanssen
jayjanssen / gist:3975836
Created October 29, 2012 19:15
keepalived
vrrp_script chk_haproxy {
script "killall -0 haproxy"
interval 2
weight 5
}
vrrp_instance VI_PXC_DB {
interface eth1
state MASTER
virtual_router_id 60
@jayjanssen
jayjanssen / gist:3988460
Created October 31, 2012 17:22
ulimit -- percona server /PXC
[percona@db1 ~]$ cat /etc/security/limits.d/91-mysql.conf
* soft nofile 4096
* hard nofile 4096
* soft nproc 204800
* hard nproc 204800
@jayjanssen
jayjanssen / gist:4002241
Created November 2, 2012 15:57
PXC config file example
[client]
socket=/data/mysql/mysql.sock
[mysqld_safe]
# connect this node up to the cluster
wsrep_urls = gcomm://10.1.6.10:4567,gcomm://10.1.6.11:4567,gcomm://10.1.6.12:4567
[mysqld]
@jayjanssen
jayjanssen / gist:4018968
Last active October 12, 2015 11:18
haproxy config -- shared healthchecks PXC
global
log 127.0.0.1 local2
chroot /var/lib/haproxy
pidfile /var/run/haproxy.pid
maxconn 20000
user haproxy
group haproxy
daemon
#nbproc 2
@jayjanssen
jayjanssen / gist:4118362
Created November 20, 2012 14:47
split mydumper output file into chunks
awk -v lines=1000000 -v fmt="database.table.%06d.sql" '{print>sprintf(fmt,1+int((NR-1)/lines))}' ../export-20121119-062335/database.table.sql
@jayjanssen
jayjanssen / gist:4226660
Last active October 13, 2015 16:48
All tables without PRIMARY keys
select all_tables.*
FROM
(select table_schema, table_name from information_schema.statistics group by table_schema, table_name ) all_tables
LEFT JOIN
(select table_schema, table_name from information_schema.statistics where index_name='PRIMARY' group by table_schema, table_name ) primary_tables
USING ( table_schema, table_name)
WHERE primary_tables.table_name is null;
@jayjanssen
jayjanssen / gist:4276856
Created December 13, 2012 14:51
Size of all databases
SELECT table_schema,
CONCAT(ROUND(sum(table_rows) / 1000000, 2), 'M') rows,
CONCAT(ROUND(sum(data_length) / ( 1024 * 1024 * 1024 ), 2), 'G') DATA,
CONCAT(ROUND(sum(index_length) / ( 1024 * 1024 * 1024 ), 2), 'G') idx,
CONCAT(ROUND(( sum(data_length) + sum(index_length) ) / ( 1024 * 1024 * 1024 ), 2), 'G') total_size,
ROUND(sum(index_length) / sum(data_length), 2) idxfrac
FROM information_schema.TABLES
group by table_schema
ORDER BY data_length + index_length DESC