Linux 綜合實驗項目報告
一.項目要求:
因公司規模擴展Tarena公司新購四臺Dell R710服務器,購買域名tarena.com。想實現如下服務:
官網服務:www.tarena.com
郵件服務:mail.tarena.com
文件服務:ftp.tarena.com
二.項目要點:
1.主機名與ip地址規劃
moni01.tarena.com 192.168.10.253/24
web01.tarena.com 192.168.10.10/24
web02.tarena.com 192.168.10.11/24
mail01.tarena.com 192.168.10.251/24
2.所用到的服務與技術:
在這次的服務器搭建中會用到如下幾個服務跟技術:
DNS 實現域名的解析,主從DNS的搭建。
NTP 實現本網絡中時間的同步。
FTP 實現YUM軟件源在本網絡中的軟件共享與資料共享。
HTTP web服務的實現,網頁的搭建。
Mail 郵件服務器的搭建與實現。
3.各主機名的大體服務的搭建:
moni01.tarena.com dns1.tarena.com ntp.tarena.com ftp.tarena.com
web01.tarena.com www.tarena.com
web02.tarena.com www.tarena.com
mail01.tarena.com mail.tarena.com dns2.tarena.com nfs.tarena.com
4.各主機服務器的簡單解釋:
moni01.tarena.com:
dns1.tarena.com 爲整個項目提供dns解析,做爲主dns
ntp.tarena.com 做爲時間服務器,爲整個網絡主機同步時間
ftp.tarena.com 提供YUM源以及公共資源下載,提供上傳權限,容許運維人員將更新網站內容傳到monil上面。php
web01.tarena.com web02.tarena.com :
www.tarena.com web 共同提供公司靜態網站服務。web
mail01.tarena.com:
mail.tarena.com 提供mail服務,容許公司人員經過web收發郵件。
dns2.tarena.com 提供備份dns服務。
nfs.tarena.com 提供公共區域共享,做爲web服務器的網站根目錄。
5. 每一個服務器要指DNS解析文件
[root@moni01 ~]# vim /etc/resolv.conf //編輯該文件
nameserver 192.168.10.253 //主DNS服務器的ip
[root@moni01 ~]# host -t mx tarena.com //檢測
tarena.com mail is handled by 5 mail.tarena.com. //表明設置成功
[root@moni01 ~]# host mail.tarena.com //檢測
mail.tarena.com has address 192.168.10.251 //解析成功
三.實驗步驟:
1.配置ip地址並修改主機名稱
[root@moni01 ~]# hostnam moni01.tarena.com //更名字
[root@moni01 ~]# vim /etc/sysconfig/network //更名字
[root@moni01 ~]# cat /etc/sysconfig/network //查看
NETWORKING=yes
NETWORKING_IPV6=yes
HOSTNAME=moni01.tarena.com //主機名字
[root@moni01 ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth0 //編輯網卡設備eh0
[root@moni01 ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0 //查看
# Virtio Network Device
DEVICE=eth0 //網卡設備名字
BOOTPROTO=none //狀態通用狀態
ONBOOT=yes
HWADDR=52:54:00:6d:6e:22 //MAC地址
IPADDR=192.168.10.253 //ip
GATEWAY=192.168.10.1 //網關
NETMASK=255.255.255.0 //子網
[root@moni01 ~]# service network restart //重啓該服務
[root@moni01 ~]# chkconfig network on //啓動該服務
備註:四個服務器ip的配置與更名方法相同就是名字不同因此就不一一截圖羅。
2. moni01服務器FTP的配置
[root@moni01 ~]#vim /etc/yum.repos.d/rhel-debuginfo.repo //編輯配置文件
[rhel-debuginfo] //名字
name=Red Hat Enterprise Linux $releasever - $basearch - Debug //介紹
baseurl=ftp://172.30.6.125/pub/iso/RedHat/5.10/Server //路徑
enabled=1 //是否開啓此功能
gpgcheck=0 //是否開啓驗證
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release //密鑰文件存放路徑
~ //0表明關閉1 表明開啓
備註:由於鏡像光盤比較大複製到該虛擬機上機器直接掛,因此就沒有複製而已物理機的FTP裏的東西爲YUM的軟件指定位置。
3. moni01服務器NDS的配置
[root@moni01 ~]# rpm -q bind bind-chroot caching-nameserver //檢測是否安裝羅該軟件
package bind is not installed
package bind-chroot is not installed
package caching-nameserver is not installed //not 表明沒有安裝此軟件
[root@moni01 ~]# yum -y install bind bind-chroot caching-nameserver //yum庫安裝該軟件能夠省去關聯軟件的挑選安裝,直接關聯軟件整套安裝
[root@moni01 ~]# rpm -q bind bind-chroot caching-nameserver //檢測
bind-9.3.6-20.P1.el5_8.6
bind-chroot-9.3.6-20.P1.el5_8.6
caching-nameserver-9.3.6-20.P1.el5_8.6 //表示此軟件已安裝
[root@moni01 ~]# cd /var/named/chroot/etc/ //切換到該目錄
[root@moni01 etc]# cp -p named.caching-nameserver.conf named.conf //複製模板並更名,加-p 保留原文件全部權限複製
[root@moni01 etc]# vim named.conf //編輯配置文件
15 listen-on port 53 { 192.168.10.253; }; //監聽端口號,本地ip
27 allow-query { any; }; //any 本機的意思
28 allow-query-cache { any; }; //any 本機的意思
37 match-clients { any; }; //any 本機的意思
38 match-destinations { any; }; //any 本機的意思
[root@moni01 etc]# vim named.rfc1912.zones //編輯該文件
50 zone "tarena.com" IN { //括號內填寫域名
51 type master;
52 file "tarena.com.zone"; //正向解析的文件存放名
53 allow-transfer { 192.168.10.251; }; //贊成該ip從本機同步解析
[root@moni01 etc]# named-checkconf named.rfc1912.zones //檢測該文件是否有語法錯誤
[root@moni01 etc]# cd /var/named/chroot/var/named/ //切換到該目錄
[root@moni01 named]# cp -p named.local tarena.com.zone //複製並更名-p保留原來文件的權限
[root@moni01 named]# vim tarena.com.zone //編輯正向文件
$TTL 86400
@ IN SOA dns01.tarena.com. root.tarena.com. ( //域名可寫可不寫用默認的也行
2014062801 ; Serial //版本號每次修改加1
28800 ; Refresh
14400 ; Retry
3600000 ; Expire
86400 ) ; Minimum
IN NS dns01.tarena.com. //域名
IN NS dns02.tarena.com.
IN MX 5 mail.tarena.com.
dns01 IN A 192.168.10.253 //正向域名解析
mail IN A 192.168.10.251 //郵箱域名的解析
www IN A 192.168.10.253
dns02 IN A 192.168.10.251 //從DNS的解析
www IN A 192.168.10.10
www IN A 192.168.10.11
www IN A 192.168.10.251
~
[root@moni01 named]# service named restart //重啓該服務
4. moni01服務器NTP的配置
[root@moni01 named]# rpm -q ntp //檢測
ntp-4.2.2p1-15.el5_7.1 //表明已安裝
[root@moni01 named]# vim /etc/ntp.conf //修改該文件
3 restrict default kod nomodify notrap nopeer noquery
4 restrict -6 default kod nomodify notrap nopeer noquery
5 restrict 192.168.10.0 mask 255.255.255.0 nomodify //添加一行這個表示容許該網段的ip從我這同步時間
[root@moni01 named]# service ntpd restart //重啓
測試:
[root@web01 ~]# date 200622102014 //打亂系統的時間
[root@web01 ~]# date //查看
[root@web01 ~]# ntpdate 192.168.10.253 //向服務器同步時間
[root@web01 ~]# date //再次查看確認
//要確保本機的該服務爲開啓的否則同步失敗修改時間的順序是:日。月。時。分。年 在測試時不要讓時間相差太遠否則就等不能很快看見效果。
5. moni01服務器FTP的配置
[root@moni01 named]# rpm -q ftp //檢測
ftp-0.17-38.el5 //表示已安裝此軟件
[root@moni01 named]# cd /etc/vsftpd/ //切換
[root@moni01 vsftpd]# vim vsftpd.conf //編輯
...... .....
12 anonymous_enable=NO //拒絕匿名用戶登陸,默認是容許的
...... .....
[root@moni01 vsftpd]# service vsftpd restart //重啓
6. web01服務器上配置HTTP
[root@web01 ~]# rpm -q httpd //檢測
package httpd is not installed //沒有安裝此軟件
[root@web01 ~]# yum -y install httpd //安裝
[root@web01 ~]# rpm -q httpd //檢測
httpd-2.2.3-82.el5_9 //表示安裝此軟件了
[root@web01 ~]# vim /etc/httpd/conf/httpd.conf //編輯
265 ServerName www.tarena.com:80 // 本站點的名字(本網站的名字)後面是端口號
266
[root@web01 ~]# service httpd restart //重啓
備註:四個服務器都要配置http服務方法同樣因此就不一一指出了。web02服務器跟這個配置同樣就不一一寫出羅。
7. mail01服務器從DNS的配置
[root@mail01 ~]# rpm -q bind bind-chroot caching-nameserver //檢測
package bind is not installed
package bind-chroot is not installed
package caching-nameserver is not installed //沒有安裝此軟件
[root@mail01 ~]# yum -y install bind bind-chroot caching-nameserver //安裝 -y表示容許
[root@mail01 ~]# rpm -q bind bind-chroot caching-nameserver //檢測
bind-9.3.6-20.P1.el5_8.6
bind-chroot-9.3.6-20.P1.el5_8.6
caching-nameserver-9.3.6-20.P1.el5_8.6 //表明安裝此軟件了
[root@mail01 ~]# cd /var/named/chroot/etc/ //切換
[root@mail01 etc]# cp -p named.caching-nameserver.conf named.conf //複製模板並更名-p保留原來文件的權限
[root@mail01 etc]# vim named.conf //編輯
listen-on port 53 { 192.168.10.251; }; //本機ip監聽的端口號
allow-query { any; };
allow-query-cache { any; };
match-clients { any; };
match-destinations { any; }; //any本機的意思
[root@mail01 etc]# vim named.rfc1912.zones //編輯
zone "tarena.com" IN { //域名
type slave; //類型是從DNS
file "slaves/tarena.com.zone"; //該文件存放在此目錄下
masters { 192.168.10.253; }; //從該ip同步
};
[root@mail01 etc]# service named restart //重啓
測試:
[root@mail01 etc]# ls /var/named/chroot/var/named/slaves/
tarena.com.zone //查看是否同步到文件若是沒有同步到而且語法檢測沒有錯誤看複製文件時是否加-p,通常沒有加-p的話報錯只顯示啓動失敗。
8. mail01服務器mail郵件系統的搭建
[root@mail01 ~]# rpm -q postfix //檢測
package postfix is not installed //沒有安裝此軟件
[root@mail01 ~]# yum -y install postfix //安裝
[root@mail01 ~]# rpm -q postfix //檢測
postfix-2.3.3-6.el5 //表示安裝
[root@mail01 ~]# cd /etc/postfix/ //切換到該目錄下
[root@mail01 postfix]# ls //查看
access header_checks makedefs.out post-install virtual
bounce.cf.default LICENSE master.cf relocated
canonical main.cf postfix-files TLS_LICENSE
generic main.cf.default postfix-script transport
[root@mail01 postfix]# postconf -n > tmp.txt //重定向該文件內容到該文件中
[root@mail01 postfix]# mv main.cf main.cf.bak //修更名字
[root@mail01 postfix]# mv tmp.txt main.cf //修更名字
[root@mail01 postfix]# vim main.cf //編輯
8 #inet_interfaces = localhost //監聽的端口默認是本地,直接禁用
20 myhostname = mail.tarena.com //郵件服務器主機名
21 mydomain = tarena.com //郵件服務器所在的區域 //域名
22 myorigin = $mydomain //發件人DNS後綴 //同上的意思
23 mydestination = $mydomain //指定Postfix容許處理的郵件 //同上的意思
24 home_mailbox = Maildir/ //郵箱類型
25 mynetwork = 192.168.10.0/24 //設置容許哪些客戶端直接將須要轉發到外部區域的郵件提交給Postfix
//前面的解釋是=前的解釋 //後面的是=後的解釋
[root@mail01 postfix]# postfix check //語法的檢測
[root@mail01 postfix]# netstat -tulnp | grep :25 //檢測端口號默認的該端口是sendmail佔用先停用他。
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 2345/sendmail
[root@mail01 postfix]# service sendmail stop //禁用該服務
[root@mail01 postfix]# service postfix restart //重啓該服務
9. mail01服務器搭建Webmail系統
[root@mail01 postfix]# rpm -q squirrelmail //檢測
package squirrelmail is not installed //表示沒有安裝此軟件
[root@mail01 postfix]# yum -y install squirrelmail //安裝此軟件
[root@mail01 postfix]# rpm -q squirrelmail //檢測
squirrelmail-1.4.8-21.el5 //表示安裝此軟件
[root@mail01 ~]# vim /etc/squirrelmail/config.php //編輯
26 $squirrelmail_default_language = 'zh_CN'; //語言
28 $domain = 'tarena.com'; //域名
29 $imapServerAddress = '192.168.10.251'; //本地ip
32 $smtpServerAddress = '192.168.10.251' //本地ip
[root@mail01 ~]# service httpd restart //重啓
測試:找個瀏覽器輸入http://mail.tarena.com/webmail 出現登陸界面表明成功
10. 天天早晨7:00自動同步ntp server 的時間。
[root@web01 ~]# crontab -e //編輯
0 7 * * * /sbin/ntpdate 192.168.10.253 //天天的7:00同步此ip的時間
[root@web01 ~]# service crond restart //重啓
[root@web01 ~]# chkconfig crond on
備註:除了服務器另外三臺所有設置,方法同樣就不一一寫出。
四. 項目總結:
在這個項目中整體來講沒有什麼難度,就是各個知識的熟練運用與他的原理的理解與運用,在構架中思路的明確與程序直接的相互關係的運用能夠很快速的搭建完成。對各個程序軟件的瞭解也是很重要的。該項目實現了DNS的解析備份,web服務器的負載均衡,以及郵件的發送跟時間的每日同步。
vim