2010年7月6日 星期二

CentOS 5 + Virtual BOX 下安裝 OpenVZ

1.下載 http://download.openvz.org/openvz.repo 並將它放置在 /etc/yum.repos.d/

2.匯入 OpenVZ 的金鑰
rpm --import http://download.openvz.org/RPM-GPG-Key-OpenVZ

3.安裝 OpenVZ 核心
yum install ovzkernel.i386 或 yum install ovzkernel.x86_64

4.檢視 /etc/grub.conf 確定已預設所需的核心

5.編輯 /etc/sysctl.conf 來啟用 OpenVZ 所需的某些核心功能
# 啟用封包轉發及停用代理 arp
net.ipv4.ip_forward = 1
net.ipv4.conf.default.proxy_arp = 0

# 啟用來源路由檢驗

net.ipv4.conf.all.rp_filter = 1

# 啟用 magic-sysrq

kernel.sysrq = 1

# TCP Explict Congestion Notification

# net.ipv4.tcp_ecn = 0
# 停用所有網絡介面送出轉遞
net.ipv4.conf.default.send_redirects = 1
net.ipv4.conf.all.send_redirects = 0

6.修改 /etc/sysconfig/selinux 這個設定檔並將它設定為停用:
SELINUX=disabled

7.重新開機

8.安裝 OpenVZ 的工具程式
yum install vzctl vzquota

9.安裝 OpenVZ 核心開發程式
yum install ovzkernel-devel

10.重新編譯 Virtual BOX
/etc/init.d/vboxdrv setup

2010年5月17日 星期一

shc, a generic script compiler

shc, a generic script compiler
可將 shell script 原始碼編碼,避免原始碼外洩。

使用範例:
shc -v -r -T -f myscript

參考資料:
http://www.datsi.fi.upm.es/~frosal/
http://www.datsi.fi.upm.es/~frosal/sources/shc.html
http://www.datsi.fi.upm.es/~frosal/sources/shc-3.8.7.tgz

2010年5月14日 星期五

LEAF VLAN 和 Cisco 3750 交換器建立10 個以上獨立網段的防火牆應用

LEAF 是使用電腦設備作為防火牆的軟體,所能提供的網段數量取決於實體的網路卡界面,但一般電腦設備不管以任何方式增加網路卡,能提供10個以上的網路卡界面的硬體成本所費不低,要提供 20,30 以上的網段更是不容易。

在LEAF 上應用 VLAN 技術,並搭配 Cisco 交換器 VLAN 功能,可以較少的實體網路界面來達成所需。

以下使用 Cisco 3750 交換器及一組網路界面的LEAF,實作兩個網路界面的防火牆架構

線路連接方式:
LEAF-eth0 <--> Cisco 3750-port 24
192.168.6.x <--> Cisco 3750-port 6
192.168.7.x <--> Cisco 3750-port 7

Cisco 3750 交換器設定如下:
interface GigabitWthernet1/0/6 設定如下
switchport access vlan 6
switchport mode access

interface GigabitWthernet1/0/7 設定如下
switchport access vlan 7
switchport mode access

interface GigabitWthernet1/0/24 設定如下
switchport trunk encapsulation dot1q
switchport mode trunk

LEAF 上的設定如下:
1.安裝 VLAN 相關程式 vlan.lrp

2.載入 802.1q模組 (位置 2.4.34/kernel/net/8021q/8021q.o)

3.建立 VLAN 6,VLAN 7,並給定 IP
ip link set eth0 up

vconfig add eth0 6
ip link set eth0.6 up
ip addr add 192.168.6.1/24 dev eth0.6

vconfig add eth0 7
ip link set eth0.7 up
ip addr add 192.168.7.1/24 dev eth0.7

4.其他
1.LEAF 上設定(如SHOREWALL),有關網路界面裝置名稱的使用,使用 eth0.6、eth0.7,勿使用 eth0
2.eth0.6及eth0.7為VLAN 界面,必須透過 Cisco 3750 Port 24(trunk設定支援802.1Q協定) 才能讓封包通過,不能直接連接到一般的HUB。
3./etc/network/interfaces 中,直接使用 eth0.6、eth0.7指定開機時的IP設定,不用使用vconfig建立vlan

2010年5月11日 星期二

Hello World.Simple

第一個 Android Simple 程式-Hello World

編輯 C:\simple\HelloWorld\simpleproject\simpleproject 內容如下
main=com.mydomain.HelloWorld.HelloWorld
name=HelloWorld
assets=../assets
source=../src
build=../build

編輯 C:\simple\HelloWorld\src\com\mydomain\HelloWorld\HelloWorld.simple 內容如下
Event HelloWorld.Initialize()

End Event

$Properties
$Source $Form
$Define HelloWorld $As Form
Layout = 1
Layout.Orientation = 1
Title = "HelloWorld"
$Define StatusPanel $As Panel
Layout = 1
Layout.Orientation = 0
BackgroundColor = &HFF444444
Width = -2
$Define ScoreLabel $As Label
BackgroundColor = &HFF444444
FontSize = 16.0
FontTypeface = 3
Text = "HelloWorld"
TextColor = &HFFFFFFFF
$End $Define
$End $Define
$End $Define
$End $Properties

執行以下指令
C:\simple>simplec HelloWorld/simpleproject/project.properties
C:\simple>C:\android-sdk-windows\tools\adb install -r HelloWorld/build/deploy/HelloWorld.apk

執行結果

2010年5月10日 星期一

Android Simple 開發環境建置筆記

一、下載安裝以下軟體
1.Java SDK 1.6 以上版本,安裝目錄 c:\java
2.Android SDK 1.5 以上版本,安裝目錄 C:\android-sdk-windows
3.Ant version 1.7 以上版本,安裝目錄 c:\apache-ant-1.8.0
4.Simple-windows-0.1.1.zip,安裝目錄 c:\simple

二、將目錄 C:\android-sdk-windows\platforms\android-3 更改為 C:\android-sdk-windows\platforms\android-1.5

三、設置環境變數
JAVA_HOME 指向 java 安裝目錄 c:\java
ANDROID_HOME 指向 android sdk 安裝目錄 c:\android-sdk-windows
SIMPLE_HOME 指向 Simple-windows-0.1.1.zip 安裝目錄 c:\simple
PATH 加入 C:\apache-ant-1.8.0\bin

四、在 c:\simple 目錄下執行下列指令產生測試檔案
newsimpleproject com.mydomain.test.Test
simplec Test/simpleproject/project.properties

五、建立 android AVD 及 啟動 android 下的模擬器,模擬器啟動需等待一段時間

六、執行以下指令測試
C:\android-sdk-windows\tools\adb install -r Test/build/deploy/Test.apk

參考資料:
http://code.google.com/p/simple/wiki/HowToBuildTheSimpleCompiler

2010年4月20日 星期二

Cisco PIX 模擬器 PEMU Windows XP 安裝筆記

1.下載 PEMU (http://www.blindhog.net/pemu-cisco-pix-emulator/)。

2.取得 PIX IOS(若是 pix7xx.bin 必須解壓縮,取得未壓縮的影像檔)。

3.編輯 pemu.ini 內容如下
serial=0x12345678
image=pix724 <---- 根據 PIX IOS 檔案名稱修改
key=0x00000000,0x00000000,0x0000000,0x00000000
bios1=mybios_d8000
bios2=bios.bin
bios_checksum=1

4.下載安裝 openvpn (http://openvpn.net/release/openvpn-2.1.1-install.exe)
目的為建立兩個 TAP-Win32 Adapter 網路界面,供模擬器使用。

5.將 兩個 TAP-Win32 Adapter 網路界面更改名稱為 tap0,tap1。

6.執行指令
pemu -net nic,macaddr=00:11:00:00:02:01 -net tap,ifname=tap0 -net nic,macaddr=00:11:00:00:02:02 -net tap,ifname=tap1 -net nic,macaddr=00:11:00:00:02:03 -serial telnet::4444,server

7.telnet 127.0.0.1 4444

其他
1.不適用 Cisco ASA IOS。
2.較舊版本的 IOS 不適用 (ex:pix634)。
3.執行時CPU 負載高,可以搭配使用 BES(Battle Encoder Shirase http://mion.faireal.net/BES/),限制 CPU資源。

2010年3月31日 星期三

Heartbeat HA 設定摘要-以HTTP服務為例

環境說明:
以兩台主機做 HA,當一設備無法提供服務後,另一台自動提供服務

OS: CentOS 5.1
兩部主機 master,slave 及相關 IP 如下
master: 192.168.6.103
slave: 192.168.6.102
服務 ip: 192.168.6.104
ping_ip: 192.168.6.253
提供服務 http
master、slave /etc/hosts 加入下面內容
192.168.6.103 master
192.168.6.102 slave


1.master、slave 安裝 heartbeat
yum install heartbeat


2.master、slave 設定 authkeys
新增 /etc/ha.d/authkeys 內容如下
auth 1
1 sha1 YourSecreKey

改變權限
chmod 600 /etc/ha.d/authkeys


3.master、slave 設定 ha.cf
新增 /etc/ha.d/ha.cf 內容
# File to write other messages
logfile /var/log/ha.log

# Facility to use for syslog()/logger
logfacility local0

# keepalive: how long between heartbeats?
keepalive 2

#deadtime: how long-to-declare-host-dead?
deadtime 30

# Very first dead time (initdead)
initdead 120

# What interfaces to broadcast heartbeats over?
bcast eth0

# What UDP port to use for bcast/ucast communication?
udpport 694

# auto_failback: determines whether a resource will
# automatically fail back to its "primary" node, or remain
# on whatever node is serving it until that node fails, or
# an administrator intervenes.
#
# The possible values for auto_failback are:
# on - enable automatic failbacks
# off - disable automatic failbacks
# legacy - enable automatic failbacks in systems
# where all nodes do not yet support
# the auto_failback option.
auto_failback on

# Tell what machines are in the cluster
# node nodename ... -- must match uname -n
node master
node slave

# Treats IP as a psuedo-cluster-member
# Used together with ipfail below...
# note: don't use a cluster node as ping node
ping 192.168.6.253

# Processes started and stopped with heartbeat. Restarted unless
# they exit with rc=100
respawn hacluster /usr/lib/heartbeat/ipfail

# Access control for client api
# default is no access
apiauth ipfail gid=haclient uid=hacluster


4.master、slave 設定 haresources
新增 /etc/ha.d/haresources 內容
# HA 的主要電腦的 hostname 虛擬介面 IP 服務名稱
server1 192.168.6.104 httpd


其他說明
1.當master 上線時,master ping ping_ip 可以回應,但 master 上 httpd 因故發生無法服務的狀態時,httpd 服務並不會自動轉移至 slave。
2.防火牆相關設定: udp/694