Skip to content

Instantly share code, notes, and snippets.

@kevinbin
kevinbin / check_virt.sh
Created May 17, 2013 05:01
check hardware support virtualization
#!/bin/bash
cpuinfo=`egrep '^flags.*(vmx|svm)' /proc/cpuinfo`
if [ "$cpuinfo" = "" ]; then
echo "There doesn't appear to be any hardware support for virtualization"
exit
fi
hardware=`dmesg | grep kvm | grep -i 'no hardware support'`
bios=`dmesg | grep kvm | grep -i 'disabled by bios'`
if [ "$hardware" != "" ]; then
echo "No hardware support for KVM"
# HAProxy configuration - haproxy-db.cfg
##
## FRONTEND ##
##
# Load-balanced IPs for DB writes and reads
#
frontend db_write
bind 172.16.0.50:3306
#!/bin/bash
#
# This script checks if a mysql server is healthy running on localhost. It will
# return:
#
# "HTTP/1.x 200 OK\r" (if mysql is running smoothly)
#
# - OR -
#
# "HTTP/1.x 500 Internal Server Error\r" (else)
#
# /etc/xinetd.d/mysqlchk
#
service mysqlchk_write
{
flags = REUSE
socket_type = stream
port = 9200
wait = no
user = nobody
@kevinbin
kevinbin / oracle_install.sh
Created January 20, 2014 02:51
oracle install script
#!/usr/bin/env bash
#set -x
#define oracle install dir
oracle_dir=""
if [ -z $oracle_dir ];then
echo "your need define oracle install PATH,please open this setting oracle_dir variables"
exit 0
fi
@kevinbin
kevinbin / nagios_install.sh
Created January 20, 2014 02:52
nagios install script
#!/bin/sh
# Any Failing Command Will Cause The Script To Stop
set -e
# Treat Unset Variables As Errors
set -u
NAGIOS_VERSION=3.5.0
PLUGIN_VERSION=1.4.16
@kevinbin
kevinbin / lvs_real.sh
Created January 20, 2014 02:54
LVS real server start/stop script
#!/bin/bash
#description : start realserver
VIP=172.16.6.8
/etc/init.d/functions
case "$1" in
start)
/sbin/ifconfig lo:0 $VIP broadcast $VIP netmask 255.255.255.255 up
/sbin/route add -host $SNS_VIP dev lo:0
echo "1" >/proc/sys/net/ipv4/conf/lo/arp_ignore
echo "2" >/proc/sys/net/ipv4/conf/lo/arp_announce
@kevinbin
kevinbin / monitor.sh
Created January 20, 2014 03:02
some os resource monitor function
#!/usr/bin/env bash
function GetPID #User #Name
{
PsUser=$1
PsName=$2
pid=`ps -u $PsUser|grep $PsName|grep -v grep|grep -v vi|grep -v dbx \
|grep -v tail|grep -v start|grep -v stop |sed -n 1p |awk '{print $1}'`
echo $pid
}
@kevinbin
kevinbin / mysql_db_rename.sh
Created January 20, 2014 03:04
mysql database rename script
#!/bin/bash
MYSQLCONN="mysql -uroot -pxxxx"
old_db_name="fff"
new_db_name="sj"
$MYSQLCONN -e "CREATE DATABASE $new_db_name"
params=$($MYSQLCONN -N -e "SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE table_schema='$old_db_name'")
for name in $params; do
$MYSQLCONN -e "RENAME TABLE $old_db_name.$name to $new_db_name.$name";
done;
@kevinbin
kevinbin / ndbmtd.sh
Created January 20, 2014 03:25
MySQL Cluster ndbmtd process init start script
#!/bin/bash
# chkconfig: 345 60 40
# description: datanode start/stop script
### BEGIN INIT INFO
# Provides: datanode
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 3 4 5