Skip to content

Instantly share code, notes, and snippets.

@tkuchiki
tkuchiki / stop-instances
Last active August 29, 2015 14:02
同じアカウントの instance を全て stop する(-i INSTANCE_NAME, ... で stop 対象から外す
#!/usr/bin/env python
# coding: utf-8
import json
import re
import sys
import subprocess
from optparse import OptionParser
parser = OptionParser()
parser.add_option("-i", "--ignores", dest="ignores",
@tkuchiki
tkuchiki / gist:49142585c4860e773a42
Created June 24, 2014 02:54
General Purpose SSD パーティション拡張方法
$ parted /dev/xvda
GNU Parted 2.1
/dev/xvda を使用
GNU Parted へようこそ! コマンド一覧を見るには 'help' と入力してください。
(parted) help
  align-check TYPE N                        check partition N for TYPE(min|opt) alignment
  check NUMBER                  ファイルシステムの簡単なチェックする
  cp [転送元デバイス] 転送元NUMBER 転送先NUMBER
             ファイルシステムを他のパーティションにコピーする
@tkuchiki
tkuchiki / redis_replication.md
Last active August 29, 2015 14:03
Redis Replication 作成手順

Redis Replication 作成手順

master = 6379, slave = 6380 で構築する。
どちらも 127.0.0.1 で起動。

6379, 6380 port で起動した直後

$ redis-cli -p 6379 info | grep Replication -A 4
# Replication
@tkuchiki
tkuchiki / gist:2d76656991140bc8a6f4
Created July 25, 2014 02:48
[EC2] ephemeral disk を mount する
#!/bin/sh
set -e
EPHEMERAL_DIR="/media/ephemeral0"
DISK="/dev/xvdb"
if ! mountpoint -q $EPHEMERAL_DIR; then
mkfs.ext4 $DISK
mount -t ext4 $DISK $EPHEMERAL_DIR
@tkuchiki
tkuchiki / td-agent.conf
Last active August 29, 2015 14:04
zabbix_server の log について(例 : fluent-plugin-zabbix)
<match foo.**>
type copy
<store>
type flowcounter
unit minute
count_keys *
tag flowcount.bar
</store>
</match>
@tkuchiki
tkuchiki / gist:dc040e642bf75e2b8831
Created August 5, 2014 19:59
find で指定ディレクトリより下の1階層を表示したい場合は、maxdepth と mindepth を指定する
$ tree /tmp/foo
/tmp/foo
├── bar
│   ├── fuga
│   └── piyo
└── hoge
2 directories, 2 files
$ find /tmp/foo/ -maxdepth 1
@tkuchiki
tkuchiki / get_group_name_by_gid
Last active August 29, 2015 14:05
GID から group name (UID から username) を取得する
awk -F ':' -v gid=GID '$3 == gid { print $1 }' /etc/group
@tkuchiki
tkuchiki / install.md
Last active August 29, 2015 14:05
install LXC (CentOS 6.5)

install

# epel required
wget --no-check-certificate https://linuxcontainers.org/downloads/lxc-1.0.5.tar.gz
tar zxvf lxc-1.0.5.tar.gz
rpmdev-setuptree
cp ./lxc-1.0.5.tar.gz ~/rpmbuild/SOURCES/
cp lxc-1.0.5/lxc.spec ~/rpmbuild/SPECS/
yum install -y libcap-devel docbook2X graphviz
@tkuchiki
tkuchiki / _.md
Last active August 29, 2015 14:06
EC2 の DHCP Option Sets (consul 用)

dhcp option sets 作成

$ aws ec2 create-dhcp-options --dhcp-configuration file://dhcp.json
{
    "DhcpOptions": {
        "DhcpConfigurations": [
            {
                "Values": [
 "node.consul service.consul ap-northeast-1.compute.internal"
@tkuchiki
tkuchiki / installation.md
Created September 9, 2014 01:44
Install bats
$ add-apt-repository ppa:duggan/bats --yes
gpg: keyring `/tmp/tmp_ijpu6ti/secring.gpg' created
gpg: keyring `/tmp/tmp_ijpu6ti/pubring.gpg' created
gpg: requesting key 5F28EA3F from hkp server keyserver.ubuntu.com
gpg: /tmp/tmp_ijpu6ti/trustdb.gpg: trustdb created
gpg: key 5F28EA3F: public key "Launchpad PPA for Ross Duggan" imported
gpg: Total number processed: 1
gpg:               imported: 1  (RSA: 1)
OK