Skip to content

Instantly share code, notes, and snippets.

View s-tajima's full-sized avatar

Satoshi Tajima s-tajima

View GitHub Profile
@s-tajima
s-tajima / failover.rb
Created November 30, 2013 04:32
Check DNS Failover, and exec promote read replica.
#!/usr/bin/env ruby
require 'rubygems'
require 'aws-sdk'
require 'resolv'
require 'pp'
$target_fqdn = 'target-fqen.example.com'
$target_elb = 'target-elb-XXXXXX.ap-northeast-1.elb.amazonaws.com'
$access_key_id = 'YOUR ACCESS KEY ID'
@s-tajima
s-tajima / kibana-proxy.cfg
Created February 19, 2014 03:30
Settings for ElasticSearch + Kibana3 Access Controll
ProxyPass /es http://localhost:9200/
ProxyPassReverse /es http://localhost:9200/
<Location />
AuthType Basic
AuthBasicProvider ldap
AuthName "Authentication for Kibana3"
AuthLDAPURL ldaps://HOST/LDAP_QUERY
Require valid-user
</Location>
@s-tajima
s-tajima / out_forward.rb
Last active August 29, 2015 13:56
fluentd source code for explain dns cache behavior.
def resolved_host
case @expire_dns_cache
when 0
# cache is disabled
return resolve_dns!
when nil
# persistent cache
return @resolved_host ||= resolve_dns!
@s-tajima
s-tajima / td-agent.conf
Created February 19, 2014 09:15
Fluentd source code for explain dns cache behavior.
<match stream.**>
type forward
flush_interval 10s
buffer_type file
buffer_path /var/log/td-agent/buffer/${tag}
<server>
host aggregator.ec2
</server>
</match>
@s-tajima
s-tajima / td-agent.conf
Created February 28, 2014 04:01
Configs for benchmarking of ElasticSearch compress.
<match *>
type copy
<store>
type forest
subtype elasticsearch
<template>
id es-test01.${tag}
include_tag_key true
tag_key @tag
host 127.0.0.1
@s-tajima
s-tajima / remove_old_indices.rb
Created March 3, 2014 03:13
Remove old indices on ElasticSearch
#!/usr/bin/env ruby
require 'pp'
require 'net/http'
require 'date'
require 'json'
endpoint = "http://<HOST>:<PORT>/"
expire_days = 7
@s-tajima
s-tajima / manager.conf
Last active August 29, 2015 13:57
/etc/mha4mysql/manager.conf
[server default]
user=root
password=mysqlrootpass
manager_workdir=/var/log/mha4mysql/
manager_log=/var/log/mha4mysql/manager.log
remote_workdir=/var/log/mha4mysql/
#enable later
#master_ip_failover_script=/etc/mha4mysql/scripts/rewrite_haproxy_config.rb
@s-tajima
s-tajima / haproxy.cfg
Last active August 29, 2015 13:57
main config and rewrite script for HAproxy.
global
log 127.0.0.1 local2
chroot /var/lib/haproxy
pidfile /var/run/haproxy.pid
maxconn 1000
user haproxy
group haproxy
daemon
stats socket /var/lib/haproxy/stats
@s-tajima
s-tajima / manager.log
Created March 11, 2014 08:16
MHA FailOver log.
Mon Mar 10 17:41:08 2014 - [warning] Got error on MySQL ping: 2006 (MySQL server has gone away)
ssh: connect to host 10.0.0.1 port 22: Connection refused
Mon Mar 10 17:41:08 2014 - [warning] HealthCheck: SSH to mysqlserver-a is NOT reachable.
Mon Mar 10 17:41:11 2014 - [warning] Got error on MySQL connect: 2013 (Lost connection to MySQL server at 'reading initial communication packet', system error: 111)
Mon Mar 10 17:41:11 2014 - [warning] Connection failed 1 time(s)..
Mon Mar 10 17:41:14 2014 - [warning] Got error on MySQL connect: 2013 (Lost connection to MySQL server at 'reading initial communication packet', system error: 111)
Mon Mar 10 17:41:14 2014 - [warning] Connection failed 2 time(s)..
Mon Mar 10 17:41:17 2014 - [warning] Got error on MySQL connect: 2013 (Lost connection to MySQL server at 'reading initial communication packet', system error: 111)
Mon Mar 10 17:41:17 2014 - [warning] Connection failed 3 time(s)..
Mon Mar 10 17:41:17 2014 - [warning] Master is not reachable from health checker!
@s-tajima
s-tajima / command_log.txt
Created March 11, 2014 10:25
Command log of test for MHA failover.
= t1 -------------------------------------------------------------------------------------------------------------------------------------------
mysqlserver-a> select * from test_table01;
+----+---------------------+---------------------------+
| id | time | text |
+----+---------------------+---------------------------+
| 1 | 2014-03-10 15:33:42 | cva3fiwqey0owkoosc4c04kk4 |
| 2 | 2014-03-10 15:33:42 | 4bbdnnjqxr0gkw48kkgc8k8sc |
| 3 | 2014-03-10 15:33:42 | 6515bxq6eyw4w8ksoogogo4wo |
+----+---------------------+---------------------------+