http://blog.yesican.tw/?p=139


 


coLinux在伺服器平台的應用





初看這個標題,或許您會認為這應該不是一個好主意。做為一個虛擬Linux,coLinux能夠擔此重任嗎?在我決定用coLinux架設伺服器前,我本身也是一堆疑問,可能嗎?可以嗎?然而當一切都配置妥當後,我愈來愈覺得這樣一個idea是在Windows視窗架設伺服器的一個絕佳方案。利用了coLinux,成功安裝了Ubuntu Linux,進而利用Ubuntu Linux成功配置了bind9、Apache2、postfix、mysql-server、php5….等伺服應用,完美吧?搞定了以上這些,要多少個網站、要多少個部落格、要多少個e-mail帳號就跟擁有一台Linux Server一樣都隨你高興,這是個人用Windows視窗能做的嗎?我只能說:coLinux,你讓Windows變神了!

一、基本安裝環境介紹:
作業系統為Microsoft Windows XP Professional Version 2002 Service Pack 2
採用的coLinux版本為:oLinux devel version 0.8.0 (20-MAY-2009)
coLinux devel version 0.8.0 20-MAY-2009
coLinux其他開發中版本
ubuntu Image版本:Images 2.6.x Ubuntu 7.10)
ubuntu Image版本(Images 2.6.x Ubuntu 7.10)
WinPcap版本:version 4.0.2
WinPcap版本(4.0.2 )
其他:coLinux檔案系統
coLinux file system
coLinux blank file system
coLinux swap file system
二、coLinux安裝:
安裝coLinux
安裝WinPcap
解壓ubuntu-7.10.ext3.2GB.7z


三、WinXP之相關網路設定:
說明:Real_ethernet為實體網卡,TAP為coLinux的虛擬網卡
設定Real_ethernet實體網卡
內容\進階\網際網路連線共用
選取[允許其他網路使用者透過這台電腦的網際網路連線來連線]核取方塊
TAP虛擬網卡的IP會自動設為192.168.0.1
變更Windows防火牆
進階\選取TAP 設定值
服務及ICMP之核取方塊全選
四、設定coLinux:
1.coLinux配置檔:
編輯如下之coLinux配置檔,取名為ubuntu.conf


kernel=d:\coLinux_devel\vmlinux
cobd0="d:\coLinux_devel\ubuntu\Ubuntu-7.10.ext3.2gb.fs"
cobd1="d:\coLinux\gentoo\linux-swap"
cofs0=d:\
cofs1=g:\
root=/dev/cobd0
ro
initrd="d:\coLinux_devel\initrd.gz"
mem=1024
cocon=120x40
eth0=ndis-bridge,"Real_ethernet"
eth1=tuntap,"TAP"

2.手動啟動coLinux(本例coLinux安裝於D槽coLinux_devel下)


d:\colinux\colinux-daemon.exe @d:\colinux_devel\ubuntu.conf

3.安裝及移除coLinux服務


d:\coLinux_devel\colinux-daemon.exe @d:\coLinux_devel\ubuntu.conf
--install-service "ubuntu"
d:\coLinux_devel\colinux-daemon.exe --remove-service "ubuntu"

4.啟動及停止coLinux


net start "ubuntu"
net stop "ubuntu"

5.開啟coLinux console終端機


d:\coLinux_devel\colinux-console-nt


or


d:\coLinux_devel\colinux-console-fltk

image

coLinux主控台畫面。

圖:colinux-console-fltk
6.查看driver


d:\coLinux_devel\colinux-daemon.exe --status-driver

7.將coLinux服務啟動類型由手動改成自動:
執行


%SystemRoot%\system32\services.msc /s

然後尋找ubuntu服務案右鍵選擇內容,將啟動類型由手動改成自動


8.新舊colinux版本切換(d:\coLinux_devel為新、d:\coLinux\為舊)


d:\coLinux_devel\colinux-daemon.exe --install-driver
d:\coLinux_devel\colinux-daemon.exe --remove-driver
d:\coLinux\colinux-daemon.exe --install-driver
d:\coLinux\colinux-daemon.exe --remove-driver

PS:devel-coLinux-20081130 用服務模式啟動時會將eth0和eth1改成eth2及eth3。
devel-coLinux-20090520 則變成改成eth6及eth7。

五、設定Ubuntu:
1.Ubuntu網路未設定好之前可利用colinux-console-fltk.exe及colinux-console-nt.exe兩隻程式登入。
2.coLinux預設root密碼為root,登入後請先更改root密碼


root@ubuntu:~# passwd

3.eth0、eth1問題排除:


root@ubuntu:~# dmesg | grep udev

udev: renamed network interface eth0 to eth2
udev: renamed network interface eth1 to eth3


似乎可以從
/etc/udev/rules.d/70-persistent-net.rules
此檔修正此一問題
目前暫時修改/etc/network/interfaces內容
eth0 –> eth2
eth1 –> eth3


root@ubuntu:~# nano -w /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
#auto eth0
#iface eth0 inet dhcp
auto eth2
iface eth2 inet dhcp

#The second netword interface
#auto eth1
#iface eth1 inet static
auto eth3
iface eth3 inet static
address 192.168.0.2
network 192.168.0.0
netmask 255.255.255.0
broadcast 192.168.0.255

2009/10/09新增:
正確解決方法為清除掉/etc/udev/rules.d/70-persistent-net.rules內存的歷史網卡編號,再重新booting即可。


4.重新啟動網路


root@ubuntu:~# /etc/init.d/networking restart

連外:


ifconfig eth0(eth2)

連內:


ifconfig eth1(eth3)

5.ping內部是否連線正常


root@ubuntu:~# ping -c 3 192.168.0.1

PING 192.168.0.1 (192.168.0.1) 56(84) bytes of data.
64 bytes from 192.168.0.1: icmp_seq=1 ttl=128 time=0.000 ms
64 bytes from 192.168.0.1: icmp_seq=2 ttl=128 time=0.000 ms
64 bytes from 192.168.0.1: icmp_seq=3 ttl=128 time=0.000 ms


— 192.168.0.1 ping statistics —
3 packets transmitted, 3 received, 0% packet loss, time 2000ms
rtt min/avg/max/mdev = 0.000/0.000/0.000/0.000 ms


6.ping外部是否連線正常


root@ubuntu:~# ping -c 3 google.com.tw

PING google.com.tw (72.14.207.104) 56(84) bytes of data.
64 bytes from eh-in-f104.google.com (72.14.207.104): icmp_seq=1 ttl=237 time=230 ms
64 bytes from eh-in-f104.google.com (72.14.207.104): icmp_seq=2 ttl=237 time=230 ms
64 bytes from eh-in-f104.google.com (72.14.207.104): icmp_seq=3 ttl=237 time=230 ms


— google.com.tw ping statistics —
3 packets transmitted, 3 received, 0% packet loss, time 2010ms
rtt min/avg/max/mdev = 230.003/230.003/230.003/0.000 ms


7.修改/etc/fstab內容


root@ubuntu:~# nano -w /etc/fstab
# /etc/fstab: static file system information.
#
#

proc /proc proc defaults 0 0
/dev/cobd0 / ext3 defaults,errors=remount-ro,relatime 0 1
/dev/cobd1 none swap sw 0 0
/dev/cobd2 /media/cdrom0 udf,iso9660 user,noauto,exec 0 0
#cofs0 /opt cofs defaults 0 0
cofs0 /mnt/disk_d cofs defaults 0 0
cofs1 /mnt/disk_g cofs defaults 0 0

8.reboot colinux檢查是否將WINxp的D:\及G:\掛載


root@ubuntu:~# df

Filesystem 1K-blocks Used Available Use% Mounted on
/dev/cobd0 2064208 529984 1429368 28% /
tmpfs 505576 0 505576 0% /lib/init/rw
varrun 505576 40 505536 1% /var/run
varlock 505576 0 505576 0% /var/lock
udev 505576 2776 502800 1% /dev
tmpfs 505576 0 505576 0% /dev/shm
cofs0 105771928 86199584 19572344 82% /mnt/disk_d
cofs1 232372160 216440072 15932088 94% /mnt/disk_g


9.調整時區:


root@ubuntu:~# nano -w /etc/default/rcS

將utc=yes改成utc=no


#
# /etc/default/rcS
#
# Default settings for the scripts in /etc/rcS.d/
#
# For information about these variables see the rcS(5) manual page.
#
# This file belongs to the "initscripts" package.

TMPTIME=0
SULOGIN=no
DELAYLOGIN=no
UTC=no
VERBOSE=no
FSCKFIX=no
RAMRUN=yes
RAMLOCK=yes
root@ubuntu:~# tzselect

選5) Asia –> 43) Taiwan
10.更換時區檔:


root@ubuntu:~# cp /usr/share/zoneinfo/Asia/Taipei /etc/localtime

11.時間校準:


root@ubuntu:~# ntpdate clock.stdtime.gov.tw

or
設定/etc/default/ntpdate


root@ubuntu:~#nano -w /etc/default/ntpdate
# The settings in this file are used by the program ntpdate-debian, but not
# by the upstream program ntpdate.

# Set to "yes" to take the server list from /etc/ntp.conf, from package ntp,
# so you only have to keep it in one place.
NTPDATE_USE_NTP_CONF=yes

# List of NTP servers to use (Separate multiple servers with spaces.)
# Not used if NTPDATE_USE_NTP_CONF is yes.
NTPSERVERS="clock.stdtime.gov.tw"
#NTPSERVERS="ntp.ubuntu.com"

# Additional options to pass to ntpdate
NTPOPTIONS=""

12.執行時間校準:


root@ubuntu:~# ntpdate-debian

六、更新Ubuntu:
1.更新/etc/apt/sources.list


root@ubuntu:~# apt-get update

2.安裝openssh-server:


root@ubuntu:~# apt-get install openssh-server

使用PuTTY連線測試sshd是否正常
內部:192.168.0.2
外部:DHCP所獲得的IP
colinux ubuntu (7.10)
3.查看ubuntu版本:


root@ubuntu:~# lsb_release -a

No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 7.10
Release: 7.10
Codename: gutsy


4.升級至 Ubuntu 8.04:
參考資料:


1. 安裝 update-manager-core:
apt-get install update-manager-core
2. 啟動 upgrade tool:
do-release-upgrade
3. 按照螢幕上的指示執行更新。


5.再查看ubuntu版本:


root@ubuntu:~# lsb_release -a

No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 8.04.1
Release: 8.04
Codename: hardy


6.升級至Ubuntu 8.10:
參考資料:


1. 安裝 update-manager-core :
aptitude install update-manager-core
2. 編輯/etc/update-manager/release-upgrades 並更改以下內容:
Prompt=normal
3. 啟動 upgrade tool:
do-release-upgrade
4. 按照螢幕上的指示執行更新.


7.再查看ubuntu版本:


root@ubuntu:~# lsb_release -a

No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 8.10
Release: 8.10
Codename: intrepid


8.升級至Ubuntu 9.04步驟亦同。
9.再查看ubuntu版本:


root@ubuntu:~# lsb_release -a

No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 9.04
Release: 9.04
Codename: intrepid


10.更新套件:
清除已安裝過的暫存檔案


root@yesican:~# apt-get clean

更新最新的套件資料


root@yesican:~# apt-get update

更新所有套件


root@yesican:~# apt-get upgrade

看那些套件會被更新,您可以加上 -s 選項執行一次upgrade


root@yesican:~# apt-get -s upgrade

七、結語:
經過了簡單的安裝及繁複的設定後,Ubuntu也更新至最新版本,接下來的步驟就跟在實體的Ubuntu下操作一模一樣,將於下一篇文章說明bind9、Apache2、postfix、mysql-server、php5….等伺服應用的做法。



 


arrow
arrow
    全站熱搜

    立你斯 發表在 痞客邦 留言(0) 人氣()


    留言列表 留言列表

    發表留言