2010年8月27日 星期五

Linux 動態路由設定方式

講師 : 陳祥輝
課程 : TCP/IP 網路通訊協定
2010/8/27 在文化上TCP/IP 陳祥輝老師教授如何設定動態路由,由於步驟繁複,特別記錄下來
以免忘記。
A – 192.168.100.0/27 – [B] – 192.168.100.32/27 – [C] – 192.168.100.64/27 – [D] – 192.168.100.96/27 -- E
A : eth0 100.1 / 27
B : eth0 100.30 / 27
eth1 100.33 / 27
C : eth0 100.34 / 27
eth1 100.65 / 27
D : eth0 100.66 / 27
eth1 100.126 / 27
E : eth0 100.97 / 27
B, C, D路由器安裝動態路由協定的套件
yum install quagga
為了避免網路出問題, 先將所有的網路卡IP清掉
ifconfig eth0 0.0.0.0
ifconfig eth1 0.0.0.0
將所有的設定檔ready
cd /etc/quagga
準備以下檔案
zebra.conf (已經存在)
vtysh.conf (已經存在)
ripd.conf ( cp ripd.conf.sample ripd.conf )
ospfd.conf ( cp ospfd.conf.sample ospfd.conf )
分別將[B], [C], [D]設定主機名稱 RB, RC, RD
vi vtysh.conf 編輯
hostname RB
或直接
echo “hostname RB” > vtysh.conf
啟動daemon
/etc/init.d/zebra start
/etc/init.d/ripd start
進入quagga的整合模式
vtysh
線上查詢使用 ?
進入模組模式
config terminal ( config t )
進入網路介面卡 eth0 設定
RB(config) interface eth0
RB(config-if) ip address 192.168.100.30/27 ( 設定IP位址 )
RB(config-if) no shutdown ( 啟動此介面卡 )
RB(config-if) exit ( 回上一層 )
進入網路介面卡 eth1 設定
RB(config) interface eth1
RB(config-if) ip address 192.168.100.33/27
RB(config-if) no shutdown
RB(config-if) exit
RB(config)
RB,RC,RD都要設好
exit : 回到上一層
Ctrl-Z : 回到第一層
請注意以下所在位置 RB#
查詢目前執行的設定
RB# show running-config
查詢啟動時的設定
RB# show startup-config
查詢目前的路由表
RB# show ip route
啟動 rip
RB# config t
RB(config)# router rip
RB(config-router)# version 2
RB(config- router)# network 192.168.100.0/27
RB(config- router)# network 192.168.100.32/27
若是輸入錯誤要刪除掉
RB(config- router)# no network 192.168.100.32/27
別忘了要啟動路由器的 ip forwarding 功能
RB(config)# ip forwarding
RB(config)# exit
RB# show ip route (看看你的路由表是否OK)
--- RIP 動態路由協定完成 ----
--- OSPF 動態路由協定開始 ---
重新啟動 daemon
/etc/init.d/zebra stop (zebra服務關閉)
/etc/init.d/ripd stop ( ripd服務關閉)
/etc/init.d/zebra start (啟動 zebra)
/etc/init.d/ospfd start (啟動 ospfd)
設定IP方式與前面完全相同

啟動 ospf
RB# config t
RB(config)# router ospf
RB(config-router)# network 192.168.100.0/27 area 0
RB(config-router)# network 192.168.100.32/27 area 1
注意你規劃的網路拓樸, 該網路是屬於哪一個 area, 並非全為 0 ^O^
別忘了要啟動路由器的 ip forwarding 功能
RB(config)# ip forwarding
RB(config)# exit
RB# show ip route (看看你的路由表是否OK)

2010年8月20日 星期五

修改VMware Guest OS MAC

本篇來自軟體工匠的文章
VMware Player 有一套演算法來自動決定 Guest OS 虛擬網路卡的 MAC address。這個機制運作得很好不會有問題,但有時候我們就是想自己指定這些 MAC address。要這樣作,只要修改 .vmx 檔就可以了。

首先,把以下這幾行刪除 (或以 # 「註」掉):
#ethernet0.addressType = "generated"
#ethernet0.generatedAddress = "00:0c:29:12:34:56"
#ethernet0.generatedAddressOffset = "0"
然後,增加以下兩行:
ethernet0.addressType = "static"
ethernet0.address = "00:50:56:03:06:14"
其中 ethernet0.address 一定要在這個範圍之內:00:50:56:00:00:00-00:50:56:3F:FF:FF。

當然,改完之後要重新啟動 GuestOS 才可以生效。

參考資料

2010年8月10日 星期二

ubuntu加入套件金鑰

在做套件庫(sudo apt-get update)更新時常會出現以下錯誤:
W: GPG error: http://ppa.launchpad.net hardy Release: 由於無法取得它們的公鑰,以下簽章無法進行驗證: NO_PUBKEY 6AF0E1940624A220

由於公鑰是用來驗證正確的套件來源,雖然還是可以使用,但是為了保護自己的電腦
最好還是使用官方驗證過的套件來源

方法:
sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com [ID]
ID:即為錯誤碼中的 6AF0E1940624A220

2010年5月2日 星期日

Ubuntu 10.04 ubuntu one無法使用

話說MAX最近重灌電腦,把系統升級成ubuntu 10.04 64 bit
很棒的新版本~可是卻發現Ubuntu one不能用了
找了很久終於找到解決方法~特別紀錄一下以免忘記

1. $ps aux |grep ubuntuone #結果應該會出現:


marcus 1552 0.1 0.7 124084 30108 ? Sl 14:01 0:28 /usr/bin/python /usr/lib/ubuntuone-client/ubuntuone-syncdaemon
marcus 4027 0.1 0.7 251440 31064 ? S 15:09 0:22 /usr/bin/python /usr/lib/ubuntuone-client/ubuntuone-login

將這兩個行程都停掉後,再執行一次ubuntuone-preferences
登入ubtutu one應該就會出現add computer webpage嚕

2010年3月28日 星期日

LAMP安裝設定-UBUNTU

在ubuntu上安裝LAMP非常簡單
1.Synaptic套件管理裡面選擇LAMP sever安裝即可

2.apt-get

安裝後可在/var/www/建立test.php
內容打入:

查看php版本,並檢視有無正常支援
如果一直出現叫你下載
請到/etc/apache2/mods-enabled/ 檢查
php5.conf , php5.load 這兩個檔案有沒存在
若沒有,請下指令
$sudo a2enmod php5
加入
然後重起Apache在測試

2010年2月9日 星期二

HDLM install on RHEL5.2

為了測試MultipathCluster,我準備了以下環境
主機1



Hostname
node1.tedpc.com

IP
10.101.24.182


192.168.0.1

Share Lun
10GB*2(Multipath)
主機2



Hostname
node2.tedpc.com

IP
10.101.24.183


192.168.0.2

Share Lun
10GB*2(Multipath)
Storage

USP100

HDLM6.0 install procedure
1.License Key 改名hdlm_license後放在/var/tmp
#mv license.plk /var/tmp/hdlm_license

2.產生安裝之Key
#mkdir /etc/opt/DynamicLinkManager
#echo "
license-key" >/etc/opt/DynamicLinkManager/dlm.lic_key

3.掛載光碟或ISO
#mount /dev/cdrom /media/cdrom
or
#mount -t iso9660 -t loop HDLM.iso /media/cdrom

4.確認HDLM版本
#/media/cdrom/installhdlm -v

5.安裝HDLM
#/media/cdrom/installhdlm
KAPL09210-I installhdlm will now start.
KAPL09093-I HDLM x.x.x-xx will be installed. Is this OK ? [y/n]: y
Preparing packages for installation...
KAPL09076-I The permanent license was installed.
HDLM-x.x.x.x.xxx-xx
KAPL09043-I The installation of HDLM-x.x.x.x.xxx-xx completed successfully.
KAPL09211-I installhdlm completed successfully.


6.安裝完成,檢查是否安裝成功
#rpm –qi HDLM
Name : HDLM Relocations: (not relocatable)
Version : 6.0.0.1.801 Vendor: Hitachi, Ltd.
Release : 1 Build Date: 西元20080509(週五) 231449
Install Date: 西元20100208(週一) 164636Build Host: inspire.hitachi.co.jp
Group : System Environment/Driver Source RPM: HDLM-6.0.0.1.801-1.src.rpm
Size : 13653222 License: All Rights Reserved. Copyright (C) 2003, 2008, Hitachi, Ltd.
Signature : (none)
Packager : Hitachi, Ltd.
Summary : I/O Path Management Software
Description :
HDLM manages paths between a host and storage subsystem.
HDLM evenly distributes the load across paths and switches to another path if there is a failure in a path being used, thus improving system reliability.

7.載入HDLM alert driver and the filter driver.
#/opt/DynamicLinkManager/bin/dlminsadrv
#modprobe sddlmfdrv

8.執行HDLM設定程式設定LDEV
#/sbin/dlmcfgmgr -r

9.啟動HDLM
#/etc/init.d/DLMManager start

10.增加HDLM環境變數
When the BourneAgain shell or Korn shell is used:
#PATH=$PATH:/opt/DynamicLinkManager/bin ; export PATH
When the C shell is used:
#set path= ( $path /opt/DynamicLinkManager/bin )

11.執行dlnkmgr確認HDLM詳細狀況與設定
# /opt/DynamicLinkManager/bin/dlnkmgr view -sys
HDLM Version : 6.0.0-01
Service Pack Version :
Load Balance : on(rr)
Support Cluster :
Elog Level : 3
Elog File Size (KB) : 9900
Number Of Elog Files : 2
Trace Level : 0
Trace File Size (KB) : 1000
Number Of Trace Files : 4
Path Health Checking : on(30)
Auto Failback : on(1)
Reservation Status :
Intermittent Error Monitor : off
HDLM Manager Ver WakeupTime
Alive 6.0.0-01 2010/02/08 17:10:28
HDLM Alert Driver Ver WakeupTime ElogMem Size
Alive 6.0.0-01 2010/02/08 17:09:17 1000
HDLM Driver Ver WakeupTime
Alive 6.0.0-01 2010/02/08 17:09:40
License Type Expiration
Permanent -
KAPL01001-I The HDLM command completed normally. Operation name = view, completion time = 2010/02/09 15:00:43

firefox調整與加入好用插件

最近在調整firefox與加入插件,作個紀錄以免忘記:

1.about:config
javascript.options.jit.content true (加速)
javascript.options.jit.chrome true (加速)

2.加入好用插件
新同文堂 (繁簡翻譯)
adblock (廣告阻擋)
Xmark (書籤同步)
FireFTP (整合FTP功能)
Download Statusbar (下載管理)
gTranslate (線上翻譯)





2010年1月22日 星期五

RHEL 與 SAN

在Linux上遇到SAN環境時,要如何處理一些常見的問題:

1.OS 版本:
#uname -a
and
#cat /etc/*-release

1.查出HBA廠牌與型號:
#lspci |grep -i fib

2.查出driver版本
Qlogic:
#lsmod |grep -i gla
Emulex:
#lsmod |grep -i lpfc

2.查出所有HBA WWN
#systool -av -c fc_host
or
#cat /sys/class/fc_host/hostX/port_name (一次單張卡,X請自己代入card no.)
#cat /sys/class/fc_host/hostX/node_name

3.不重開機即可scan HBA 上的LUN
#echo "1" > /sys/class/fc_host/hostX/issue_lip (X請自己代入card no.)
#echo "- - -" > /sys/class/scsi_host/hostX/scan

4.File system Check:
#fdisk -l

5.File system Create:
#mkfs -t ext3 /dev/sdX (sdX以fdisk抓到的為準,給錯會消除原有資料,請小心)

6.開機掛載:
#vim /etc/fstab
加入
/dev/sdx /mountpoint ext3 defaults 0 0

**注意:修改fstab的行為可能會造成系統無法開機,請謹慎處理,不要修改到其他參數**

2009年12月25日 星期五

Kickstart 操作

為了玩RHEL5 cluster方便安裝,順便玩了一下kickstart大量佈署方式安裝系統
參考文件:
1.鳥哥網站的網友分享篇裡面彥明大的幾篇文章
2.CentOS官網

設定方式如下:
1.DHCP server (如已有可跳過)
# cp /usr/share/doc/dhcp-3.0pl2/dhcpd.conf.sample /etc/dhcpd.conf
# more /etc/dhcpd.conf 內容如下根據自己需求更改
ddns-update-style interim;
ignore client-updates;
subnet 192.168.0.0 netmask 255.255.255.0 {
# --- default gateway
option routers 192.168.0.1;
option subnet-mask 255.255.255.0;
option nis-domain "domain.org";
option domain-name "domain.org";
option domain-name-servers 192.168.1.1;
option time-offset -18000; # Eastern Standard Time
# option ntp-servers 192.168.1.1;
# option netbios-name-servers 192.168.1.1;
# --- Selects point-to-point node (default is hybrid). Don't change this unless
# -- you understand Netbios very well
# option netbios-node-type 2;
range dynamic-bootp 192.168.0.128 192.168.0.254;
default-lease-time 21600;
max-lease-time 43200;
#/etc/init.d/dhcpd restart
#chkconfig dhcpd on

2.準備install server (建議與DHCP server放一起,可以再建立yum)
可以使用httpftpnfs方式來作,我測試以ftp為主,可以設定帳密來登入:
#yum install vsftpd
#chkconfig vsftpd on
#/etc/init.d/vsftpd restart (預設有開匿名登入,可根據自己需求調整)
#mount -t iso9660 -o loop CentOS.iso /mnt (放光碟或mount ISO)
#mkdir /var/ftp/pub/CentOS (建立資料夾)
#cp -av /mnt/. /var/ftp/pub/CentOS (將安裝資料放到ftp)
#yum install system-config-kickstart (設定kickstart參數的gui)
#system-config-kickstart (設定安裝相關資料)
GUI畫面下設定完成後選file → save 可存成一個自動安奘的文字檔
我的設定如下
#platform=x86, AMD64, or Intel EM64T
# System authorization information
auth --useshadow --enablemd5
# System bootloader configuration
bootloader --location=mbr
# Clear the Master Boot Record
zerombr
# Partition clearing information
clearpart --all --initlabel
# Use graphical install
graphical
# Firewall configuration
firewall --enabled --ssh --trust=eth0
# Run the Setup Agent on first boot
#firstboot --enable
# System keyboard
keyboard us
# System language
lang zh_TW.UTF-8
#Language modules to install
langsupport en_US --default=zh_TW.UTF-8
# Installation logging level
logging --level=info
# Use network installation
url --url=ftp://10.101.20.244/pub/mnt
# Network information
network --bootproto=dhcp --device=eth0 --onboot=on
# Reboot after installation
reboot
#Root password
rootpw --iscrypted $1$FZr8YqVs$W4ykp.eMFp97IIkE8xIvn.


# SELinux configuration
selinux --disabled
# System timezone
timezone Asia/Taipei
# Install OS instead of upgrade
install
# X Window System configuration information
xconfig --defaultdesktop=GNOME --depth=8 --resolution=800x600 --startxonboot
# Disk partitioning information
part /boot --bytes-per-inode=4096 --fstype="ext3" --size=100
part swap --bytes-per-inode=4096 --fstype="swap" --size=2048
part / --bytes-per-inode=4096 --fstype="ext3" --grow --size=1


%packages
@chinese-support
@office
@editors
@text-internet
@gnome-desktop
@dialup
@core
@base
@games
@base-x
@graphics
@printing
@sound-and-video
@graphical-internet
device-mapper-multipath
xorg-x11-server-Xnest
libsane-hpaio
-sysreport
將此檔案跟開機光碟燒在一起,也可以放在ftp

3.安裝:
放入做好之開機光碟,開機
執行:
linux ks=/cdrom
or
(將檔案放在ftp)

這樣應該會自己安裝好嚕

kickstart檔案內容可參考:http://www.redhat.com/docs/manuals/enterprise/RHEL-4-Manual/sysadmin-guide/s1-kickstart2-file.html

2009年12月14日 星期一

Rsync Server建置

我最近幫部門的FTP Server搬家,也順便做了自動化備份,設定流程如下:

一、Server端設定:

1.確定xinet服務有安裝並開機有啟動
  #chkconfig xinet --list

如果找不到表示沒有安裝,則輸入
  #yum install xinet
開機啟用
  #chkconfig xinet on
  #chkconfig rsync on

2.自己建立rsync server config檔
  #vim /etc/rsyncd.conf
 
port = 873            #rsync server啟用的port
#max connections=3
log file = /var/log/rsyncd.log    #放log的位置
pid file = /var/run/rsyncd.pid
lock file = /var/run/rsyncd.lock

[ftpbackup]           #module名稱,極重要,每個Client都有自己的module名稱
uid = root            #用哪個user啟用服務
gid = root
use chroot = no
path = /samba_win      #要跟本機哪個目錄作rsync
comment = BACKUP for FTP
#ignore errors
read only = no          #如果會寫入資料,則不可使用read only
#list = no
auth users = tedpc      #Client登入時帳號,可以非本機帳號
secrets file = /root/rsync.secrets    #帳號的密碼放置位置

3.建立密碼檔,位置可以隨自己放置,但必須與設定檔同一位置
  格式為:username1:password1 (可多組)
        
  #vim /root/rsync.secrets
 tedpc:1qaz2wsx

更改密碼檔權限,最好只有root可以看,確保安全姓
  #chmod 600 /root/rsync.secrets

二、Client 設定
基本上Client只要能使用rsync指令來跑就ok嚕
1.Windows:
基本上可以安裝cwRsync,至於怎樣安裝及設定請自行研究

2.Linux:
基本上裝好應該都有嚕,沒有請打
  RH:
  #yum install rsync
  ubuntu:
  $sudo apt=get install rsync

裝好後請建立密碼檔,只要給密碼就可以嚕
#vim /root/rsync.secrets
1qaz2wsx

#rsync -av --password-file=/root/rsync.secrets /Data/ tedpc@IP::ftpbackup
這樣如果沒有錯誤即可將其配合crontab來使用

參考資料:http://samba.anu.edu.au/rsync/documentation.html