Build(Customize) Windows QEMU Guest Agent

參考資料:

https://wiki.qemu.org/Hosts/W32

http://www.cnblogs.com/silvermagic/p/7666143.html

  1. Prepare(Install) Fedora 26 Virual Machine
  2. Prepare mingw64 envionment
    yum install mingw64-pixman mingw64-glib2  mingw64-gmp mingw64-SDL mingw64-pkg-config
    yum install mingw64-winpthreads-static
  3. Download VSS SDK
    http://www.microsoft.com/en-us/download/details.aspx?id=23490
    from QEMU source

    ./qemu/scripts/extract-vsssdk-headers setup.exe
  4. Download and build from QEMU source
    git clone https://github.com/qemu/qemu
    cd qemu
    git submodule update --init dtc
    ./configure --enable-guest-agent --cross-prefix=x86_64-w64-mingw32- --with-vss-sdk=/root/vss
    make msi -j
    
  5. Copy qemu-ga-x86_64.msi to Windows VM and install it.
  6. Test query VM IP from KVM Host.
    virsh
    list (Get VM Name or ID)
    qemu-agent-command <Name or Id> '{"execute":"guest-info"}'
    qemu-agent-command <Name or Id> '{"execute":"guest-network-get-interfaces"}'

 

 

 

 

 

 

Download: qemu-ga-x86_64(v2.10.50)

CentOS 7 調整text console解析度

環境

XenServer 7.0下面的CentOS7虛擬機

  • 編輯/etc/default/grub,加入video=640×480
  • GRUB_TIMEOUT=5
    GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
    GRUB_DEFAULT=saved
    GRUB_DISABLE_SUBMENU=true
    GRUB_TERMINAL_OUTPUT="console"
    GRUB_CMDLINE_LINUX="crashkernel=auto rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb quiet video=640x480"
    GRUB_DISABLE_RECOVERY="true"
    

     

  • grub2-mkconfig -o /boot/grub2/grub.cfg
  • reboot

 

參考

  • https://www.centos.org/forums/viewtopic.php?t=48413

透過CentOS 6 Linux ipmitool設定Dell C6100 IPMI IP Address

參考資料:
http://www.thomas-krenn.com/en/wiki/Configuring_IPMI_under_Linux_using_ipmitool

#安裝ipmitool
yum -y install ipmitool

# 啟動IPMI kernel module
# ref: http://serverfault.com/questions/480371/ipmitool-cant-find-dev-ipmi0-or-dev-ipmidev-0
modprobe ipmi_devintf
#modprobe ipmi_si

#列出目前設定
ipmitool lan print

#使用固定IP方式設定
ipmitool lan set 1 ipsrc static
ipmitool lan set 1 ipaddr 172.31.10.21
ipmitool lan set 1 netmask 255.255.255.0
ipmitool lan set 1 defgw ipaddr 172.31.10.254

#修改密碼
#ref: http://serverfault.com/questions/85042/is-it-possible-to-reset-the-password-on-a-supermicro-ipmi-interface
ipmitool user list 1
ipmitool -I open user set password 2 mypassword

 

Linux CentOS 6安裝nagios監控

安裝環境檢查

  • Linux CentOS 6.5 x86_64 (本範例採用環境)
  • 確定已安裝好EPEL repository
    • rpm -qa|grep epel (檢查是否已有epel)
    • 若沒有安裝請使用下面指令安裝EPEL
      rpm -ivh http://mirror01.idc.hinet.net/epel/6/x86_64/epel-release-6-8.noarch.rpm

安裝nagios

#安裝nagios相關RPM
yum -y install nagios nagios-plugins-all

#設定nagiosadmin預設密碼
htpasswd -m /etc/nagios/passwd nagiosadmin (執行後輸入要修改的密碼)

#設定開機自動啟動nagios
chkconfig nagios on

#檢查nagios相關設定是否正確 (修改設定後建議都先跑一次)
nagios -v /etc/nagios/nagios.cfg

#啟動nagios服務
service nagios start

 

 

 

內部網路使用postfix發送/管理信件

參考資料:
http://blog.miniasp.com/post/2008/03/24/How-to-delete-undelivered-email-in-Postfix.aspx

 

新增/etc/postfix/transport-private-cloud檔案加入下面內容

*               smtp:10.160.1.1

 

執行下列指令

cd /etc/postfix
postmap hash:/etc/postfix/transport-private-cloud

 

修改/etc/postfix/main.cf增加下面設定

#透過command line發信時會帶test.chtos.info網域如root@test.chtos.info
#許多郵件主機會有防SPAM機制,若發信網域不存在mail會直接被reject
mydomain = test.chtos.info
myorigin = $mydomain

#設定mail relay
transport_maps = hash:/etc/postfix/transport-private-cloud

重新啟動postfix

service postfix restart

 

測試command line或是nagios發信

刪除mail queue (轉發自http://blog.miniasp.com/post/2008/03/24/How-to-delete-undelivered-email-in-Postfix.aspx)

# 刪除所有在 Queue 中的郵件
postsuper -d ALL

# 刪除所有正在 deferred 佇列中的郵件 ( 刪除曾經發送失敗的信 )
postsuper -d ALL deferred

# 刪除所有正在 deferred 佇列中的郵件 ( 可看出哪些信被刪除了 )
find /var/spool/postfix/deferred -type f -exec rm -vf \{\} \;

# 刪掉「三天以前」無法發出的郵件
find /var/spool/postfix/deferred -type f -mtime +3 -exec rm -f \{\} \;

# 列出目前所有無法發出的郵件
find /var/spool/postfix/deferred -type f -exec ls -l --time-style=+%Y-%m-%d_%H:%M:%S {} \;

# 刪除超過 5 天的 "defer" 佇列中的退信紀錄
find /var/spool/postfix/defer -type f -mtime +5 -exec rm -f \{\} \;

 

 

bash script – 透過SNMP檢查VMWare Host NTP同步狀態

#!/bin/bash

for i in 18 19 21 22 23 24 25 26 27 28 29 30 31 32
do
  echo -n "  UCS:`printf %03d $i` "
  snmpwalk -c public -v 2c -Ov 172.24.2.$i hrSystemDate.0
done

for j in 2 3 4 5 6 7 8 18 19 20 21 22 23 24 34 35 36 37 38 39 40 50 51 52 53
do
  echo -n "Blade:`printf %03d $j` "
  snmpwalk -c public -v 2c -Ov 172.24.18.$j hrSystemDate.0
done

for k in {9..15} {25..31} {41..48} 54 {55..56}
do
  echo -n "Blade:`printf %03d $k` "
  snmpwalk -c public -v 2c -Ov 172.24.18.$k hrSystemDate.0
done

 

cacti thold plugin微調

預設Cacti thold plugin在發送告警email時rrd圖檔顯示的內容為1day週期,因特殊需求需調整成2hrs,需修改/usr/share/cacti/plugins/thold/thold_functions.php

2811,2815c2811
<                       #$graph_data_array = array('output_flag'=> RRDTOOL_OUTPUT_STDOUT);
<                         $graph_end_time = date("U");
<                         $graph_start_time = $graph_end_time - 7200;
<                         $graph_data_array = array('output_flag'=> RRDTOOL_OUTPUT_STDOUT, 'graph_start'=>$graph_start_time, 'graph_end'=>$graph_end_time);
<
---
>                       $graph_data_array = array('output_flag'=> RRDTOOL_OUTPUT_STDOUT);

 

用Linux架設SLB(負載平衡)設備

參考資料:
http://kb.hyve.com/wiki/Setup%20a%20Loopback%20adaptor%20in%20Windows%202008%20for%20loadbalancer%20VIP

網路架構 (todo):

 

SLB主機安裝:
1. 灌好CentOS 6.5 OS
2. yum -y install ipvsadm keepalived
3. 編輯/etc/keepalived/keepalived.conf,範例如下

! Configuration File for keepalived

global_defs {
   notification_email {
     your-email@email.com
   }
   notification_email_from email-sender@email.com
   smtp_server 10.10.10.1
   smtp_connect_timeout 30
   router_id LVS_TF4F
}

#vrrp_instance VI_1 {
#    state MASTER
#    interface eth0
#    virtual_router_id 51
#    priority 100
#    advert_int 1
#    authentication {
#        auth_type PASS
#        auth_pass yourpassword
#    }
#    virtual_ipaddress {
#       127.0.0.5
#    }
#}

virtual_server 10.176.20.152 80 {
    delay_loop 6
    lb_algo rr
    lb_kind DR
    persistence_timeout 1200
    protocol TCP
    virtualhost slb.idc.local
    real_server 10.176.20.131 80 {
        weight 1
        HTTP_GET {
            url {
              path /iisstart.htm
              digest dfbd1ee66a4e792349591b88660c0956
            }
        }
    }
    real_server 10.176.20.132 80 {
        weight 1
        HTTP_GET {
            url {
              path /iisstart.htm
              digest dfbd1ee66a4e792349591b88660c0956
            }
        }

    }
    real_server 10.176.20.153 80 {
        weight 0
        HTTP_GET {
            url {
              path /slb.php
              digest 509f04652b5e1b2d2b9e6bc121a87e50
            }
        }
    }
}

4.啟動keepalived

  chkconfig keepalived on
  service keepalived start

5.觀看目前SLB連線狀態

 ipvsadm -Ln

 

Real Server安裝(CentOS 5/6 Linux)

編輯/etc/sysctl.conf加入下面兩行,設定後記得使用sysctl -p生效

net.ipv4.conf.all.arp_ignore = 1
net.ipv4.conf.all.arp_announce = 2

新增/etc/sysconfig/ifcfg-lo:0檔案並加入下面內容

DEVICE=lo:0
IPADDR=10.176.20.152
NETMASK=255.255.255.255
ONBOOT=yes

啟動loopback網卡

ifup lo:0

 

Real Server安裝(Windows 2008 R2) (todo)
1.新增Loopback Interface
1

 

 

 

 

 

 

 

 

 

 

 

 

 

2 3 4 5 6 7

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

最後請執行下面指令

netsh interface ipv4 set interface "區域連線" weakhostreceive=enabled
netsh interface ipv4 set interface "Loopback" weakhostreceive=enabled
netsh interface ipv4 set interface "Loopback" weakhostsend=enabled

 

 

 

 

 

 

 

 

 

MySQL mysql-bin log檔案如何rotate/remove?

Ref:
http://dev.mysql.com/doc/refman/5.0/en/log-file-maintenance.html
http://dev.mysql.com/doc/refman/5.0/en/server-system-variables.html#sysvar_expire_logs_days
http://dev.mysql.com/doc/refman/5.0/en/purge-binary-logs.html

環境
CentOS 5 x86_64 with MySQL 5.0.95

問題
為了提升MySQL效能有將/etc/my.cnf改成使用/usr/share/mysql/my-huge.cnf
套用/usr/share/mysql/my-huge.cnf後就會enable mysql bin log (for replication/cluster)

# Replication Master Server (default)
# binary logging is required for replication
log-bin=mysql-bin

此設定預設沒有啟動自動logrotate機制跑久了硬碟鐵定爆炸

解法1.1 (自動定期刪除)(修改設定檔)(是否正確生效待驗證)
於/etc/my.cnf加入下面這行 (超過3天的自動移除)

expire_logs_days=3

解法1.2 (自動定期刪除)(動態修改系統變數)

SHOW VARIABLES WHERE Variable_Name='expire_logs_days';
SET GLOBAL expire_logs_days = 1;
SHOW VARIABLES WHERE Variable_Name='expire_logs_days';

 

解法2 (人工刪除)

PURGE BINARY LOGS TO 'mysql-bin.000010';
PURGE BINARY LOGS BEFORE '2008-04-02 22:46:26';

 

Todo
CentOS 6驗證