Skip to content

Instantly share code, notes, and snippets.

@jayjanssen
jayjanssen / semaphore.js
Created May 27, 2011 18:30
Node.js semaphores
var Semaphore = function(callback, context) {
this.semaphore = 0;
this.callback = callback;
this.context = context || this;
};
Semaphore.prototype.increment = function() {
this.semaphore++;
};
@jayjanssen
jayjanssen / denyhosts-remove-ip.sh
Created June 23, 2011 17:25
denyhosts ip removal script
#!/bin/sh
HOST=$1
cd /var/lib/denyhosts
for i in `ls`; do mv $i $i.old; grep -v $HOST $i.old >> $i; done
cp /etc/hosts.deny /tmp/hosts.deny
grep -v $HOST /tmp/hosts.deny > /etc/hosts.deny
@jayjanssen
jayjanssen / gist:1048955
Created June 27, 2011 14:27
node-zookeeper wrapper that handles the zookeeper server coming and going
// connection manager object is responsible for maintaining the connection to zk
var connection_manager = (function() {
var cm = {};
// Start connection immediately (global for all instances)
var zk_trying = false;
var zkclass;
var zk;
// tries to make a connection (if one isn't already being attempted), waits for timeout
@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:3453904
Last active January 30, 2019 03:44
Percona Server live query capture settings
set global slow_query_log = OFF;
set global long_query_time = 0;
set global log_slow_verbosity = full;
set global slow_query_log_timestamp_always = ON;
set global slow_query_log_timestamp_precision=microsecond;
set global slow_query_log_use_global_control="log_slow_filter,log_slow_rate_limit,log_slow_verbosity,long_query_time";
@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]