This page looks plain and unstyled because you're using a non-standard compliant browser. To see it in its best form, please upgrade to a browser that supports web standards. It's free and painless.

修性不修命,萬劫陰靈難入聖; 修命不修性,猶有家財無主柄
Album | Blog | Comment | Profile | Control Panel
aquatower | 10 July,2009 0:59

Unit1
Lab

1. create server1.repo

/etc/yum.repos.d/server1.repo
---略---

2. yum update kernel-PAE

vi /boot/grub/grub.conf
change default = X

3. yum list, yum install, yum remove [package]

4. rpm --import /etc/pki/rpm-gpg/PRM-GPG-KEY-redhat-release

5. rpm -K [package] ---check gpg

[root@server1 tmp]# rpm -K mutt-1.4.2.2-3.0.2.el5.i386.rpm
mutt-1.4.2.2-3.0.2.el5.i386.rpm: (sha1) dsa sha1 md5 gpg OK

[root@server1 tmp]# cat '/bin/date' >> mutt*

[root@server1 tmp]# rpm -K mutt-1.4.2.2-3.0.2.el5.i386.rpm
mutt-1.4.2.2-3.0.2.el5.i386.rpm: (sha1) dsa sha1 MD5 GPG NOT OK

6. rpm -qf [file] VS. #yum provides [file]

[root@server1 sysconfig]# rpm -qf /etc/inittab
initscripts-8.45.19.EL-1
[root@server1 sysconfig]# yum provides /etc/inittab
Loading "security" plugin
Loading "rhnplugin" plugin
This system is not registered with RHN.
RHN support will be disabled.
filelists.xml.gz 100% |=========================| 2.2 MB 00:00
initscripts.i386 : The inittab file and the /etc/init.d scripts.
initscripts.i386 : The inittab file and the /etc/init.d scripts

%/etc/hosts, NO RPM provides, because created by Anaconda during installation

aquatower | 10 July,2009 0:15

Repositories
-----------------------------

1. file in /etc/yum.repos.d/*.repo

2. server1.repo

[Server1]
name=Red Hat Enterprise Linux 5Server - Server1
baseurl=ftp://192.168.0.254/pub/RHEL5/Server
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release


[repo-name]
name = a nice description
baseurl = [http, ftp] 不支援nfs
enabled = [0, 1] 1: 表示啟用 0: 關閉, 若此行不寫, 預設: 1
gpgcheck =1 檢查rpm的gpg


3. cached in /var/cache/yum/*

#yum clean [dbcache| all]
清除暫存檔案

[root@server1 yum]# yum clean all
Loading "security" plugin
Loading "rhnplugin" plugin
Cleaning up Everything

#yum list
重新下載放在/var/cache/yum/*
[root@server1 yum]# ll *

Server1:
total 6376
-rw-r--r-- 1 root root 0 Jul 10 00:26 cachecookie
drwxr-xr-x 2 root root 4096 Jul 10 00:26 packages
-rw-r--r-- 1 root root 725830 Jul 10 00:26 primary.xml.gz
-rw-r--r-- 1 root root 5753856 Jul 10 00:26 primary.xml.gz.sqlite
-rw-r--r-- 1 root root 1314 Jul 10 00:26 repomd.xml
---略---

4. rpm in /var/lib/rpm/*

[root@server1 rpm]# ll
total 31956
-rw-r--r-- 1 rpm rpm 2777088 Jul 8 20:45 Basenames
-rw-r--r-- 1 rpm rpm 12288 Jul 8 20:45 Conflictname
-rw-r--r-- 1 root root 24576 Jul 9 23:57 __db.001
-rw-r--r-- 1 root root 1318912 Jul 9 23:57 __db.002
-rw-r--r-- 1 root root 450560 Jul 9 23:57 __db.003
-rw-r--r-- 1 rpm rpm 1171456 Jul 8 20:45 Dirnames
-rw-r--r-- 1 rpm rpm 5160960 Jul 8 20:45 Filemd5s
-rw-r--r-- 1 rpm rpm 24576 Jul 8 20:45 Group
-rw-r--r-- 1 rpm rpm 20480 Jul 8 20:45 Installtid
-rw-r--r-- 1 rpm rpm 40960 Jul 8 20:45 Name
-rw-r--r-- 1 rpm rpm 22953984 Jul 8 20:45 Packages
-rw-r--r-- 1 rpm rpm 167936 Jul 8 20:45 Providename
-rw-r--r-- 1 rpm rpm 90112 Jul 8 20:45 Provideversion
-rw-r--r-- 1 rpm rpm 12288 Jul 6 23:17 Pubkeys
-rw-r--r-- 1 rpm rpm 233472 Jul 8 20:45 Requirename
-rw-r--r-- 1 rpm rpm 163840 Jul 8 20:45 Requireversion
-rw-r--r-- 1 rpm rpm 90112 Jul 8 20:45 Sha1header
-rw-r--r-- 1 rpm rpm 45056 Jul 8 20:45 Sigmd5
-rw-r--r-- 1 rpm rpm 12288 Jul 8 20:45 Triggername

A-B-C.D.E
zsh-4.2.6-1.i386.rpm

A:套件名稱
B:版本
C:發行次數
D:平台(i386, noarch(不分平台), x86, ppc....., etc)
E: rpm

%安裝套件以yum進行安裝, 會主動安裝相依套件, 若用rpm安裝, 則要自行將相依套件先裝好(要拜訪各山頭去下載rpm)


5. rpm

#rpm -qa

[root@server1 Server]# rpm -qa|grep dhcp
dhcpv6-client-1.0.10-4.el5
dhcp-3.0.5-13.el5

#rpm -q [package]

[root@server1 Server]# rpm -q dhcp
dhcp-3.0.5-13.el5

#rpm -qf file_path_name(絕對路徑)

[root@server1 Server]# rpm -qf /etc/dhcpd.conf
dhcp-3.0.5-13.el5

#rpm -qp rpmfile(不常使用, 因為要打rpm的全部名稱..)

#rpm -ql [package] ----list of files in package

[root@server1 Server]# rpm -ql dhcp
/etc/dhcpd.conf
/etc/rc.d/init.d/dhcpd
/etc/rc.d/init.d/dhcrelay
/etc/sysconfig/dhcpd
/etc/sysconfig/dhcrelay
/usr/bin/omshell
---略---

#rpm -V [package]

[root@server1 Server]# rpm -V dhcp
S.5....T c /etc/dhcpd.conf


from the package header, followed by the file name. Each of the 8
characters denotes the result of a comparison of attribute(s) of the
file to the value of those attribute(s) recorded in the database. A
single "." (period) means the test passed, while a single "?" (question
mark) indicates the test could not be performed (e.g. file permissions
prevent reading). Otherwise, the (mnemonically emBoldened) character
denotes failure of the corresponding --verify test:

S file Size differs
M Mode differs (includes permissions and file type)
5 MD5 sum differs
D Device major/minor number mismatch
L readLink(2) path mismatch
U User ownership differs
G Group ownership differs
T mTime differs

6. Kernel rpm

% Do not user rpm -U or rpm -F!!!!
% Use rpm -i

change default
# vi /boot/grub/grup.conf

# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE: You have a /boot partition. This means that
# all kernel and initrd paths are relative to /boot/, eg.
# root (hd0,0)
# kernel /vmlinuz-version ro root=/dev/VolGroup00/LogVol00
# initrd /initrd-version.img
#boot=/dev/sda
default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title Red Hat Enterprise Linux Server (2.6.18-92.el5xen)
root (hd0,0)
kernel /xen.gz-2.6.18-92.el5
module /vmlinuz-2.6.18-92.el5xen ro root=/dev/VolGroup00/LogVol00 rhgb quiet
module /initrd-2.6.18-92.el5xen.img
title Red Hat Enterprise Linux Server (2.6.18-92.el5PAE)
root (hd0,0)
kernel /vmlinuz-2.6.18-92.el5PAE ro root=/dev/VolGroup00/LogVol00 rhgb quiet
---略---

aquatower | 9 July,2009 23:59

yum: installation and removal

1. #yum install [package] ----安裝套件, 如果己經安裝, 就不會再安裝

2. #yum groupinstall [packagegroup]

3, #yum remove [package]

4, #yum update [package] ----舊版會被移除, 安裝新的版本

5, #yum list [all | package_glob]

6. #yum info [package]

[root@server1 ~]# yum info evince
Loading "security" plugin
Loading "rhnplugin" plugin
This system is not registered with RHN.
RHN support will be disabled.
Installed Packages
Name : evince
Arch : i386
Version: 0.6.0
Release: 8.el5
Size : 2.7 M
Repo : installed
Summary: Document viewer
Description:
evince is a GNOME-based document viewer.

7. #yum groupinfo [packagegroup]

[root@server1 ~]# yum groupinfo office
Loading "security" plugin
Loading "rhnplugin" plugin
This system is not registered with RHN.
RHN support will be disabled.
Setting up Group Process

Group: Office/Productivity
Description: The applications include office suites, PDF viewers, and more.
Default Packages:
evince
Optional Packages:
tetex-xdvi

8. #yum whatprovides [filename]

[root@server1 ~]# yum whatprovides /etc/hosts.allow
Loading "security" plugin
Loading "rhnplugin" plugin
This system is not registered with RHN.
RHN support will be disabled.
setup.noarch : A set of system configuration and setup files.
setup.noarch : A set of system configuration and setup files.

9. #youm grouplist

[root@server1 ~]# yum grouplist
Loading "security" plugin
Loading "rhnplugin" plugin
This system is not registered with RHN.
RHN support will be disabled.
Setting up Group Process
Installed Groups:
Office/Productivity
Administration Tools
Editors
System Tools
Text-based Internet
Virtualization
Legacy Network Server
---略---

aquatower | 7 July,2009 22:09

Lab3: Server1部署
Target: Creating Virtual Machine- vserver


1. 準備kickstart檔案: vserver.cfg


可以從/root/anaconda-ks.cfg , 複製為vserver.cfg , 再修改

# Kickstart file automatically generated by anaconda.

install
nfs --server=192.168.0.254 --dir=/var/ftp/pub/RHEL5
key --skip
lang en_US.UTF-8
keyboard us
xconfig --driver vesa --resolution 800x600 --depth 16
network --device eth0 --bootproto dhcp
rootpw --iscrypted $1$lvU6kOK5$wzGy5BlTgkfyXjFO8C0Qo0
firewall --disabled
authconfig --enableshadow --enablemd5
selinux --enforcing
..略.....

2. virt-manager建立Virtual Machine
(1)可由圖形介面建立 #virt-manager
(2) 文字模式下: virt-install (詳請查#man virt-install)

[root@server1 conf]# cat virt-install_vserver.sh
#!/bin/bash
virt-install --paravirt --location=ftp://192.168.0.254/pub/RHEL5 --file=/var/lib/xen/images/vserver.img --name=vserver --vcpus=1 --ram=256 --bridge=xenbr0 --extra-args="text ks=ftp://192.168.0.254/pub/conf/vserver.cfg"

3. 建立空白file: 4G, 放在/var/lib/xen/images/目錄
#dd if=/dev/zero of=/var/lib/xen/images/vserver.img bs=1M count=4000
4000+0 records in
4000+0 records out
4194304000 bytes (4.2 GB) copied, 81.4794 seconds, 51.5 MB/s

4. 準備好了,就開始安裝啦
#./virt-install_vserver.sh (把virt-install長長指令寫成script, 以免打錯字)

如果很順利是不會卡住,如果有...就只好TroubleShoot囉
TroubleShoot:
%因為vserver.cfg是用nfs去捉Packages, 故nfs server必須要先設定好再啟動
%IP 分享器的dhcp無法提供, 虛擬PC旳網卡xenbr0:IP Adddress, 必須設定好dhcp server, 由server1提供dhcp服務(IP分享器的dhcp要關閉)
%檢查Firewall, 必要的port都要打開, 進行安裝時才不會卡住(小弟的慘痛經歷...=.=", 找了半天才發現是Firewall....偶是豬頭)
...(No Trouble....)

5. 檢查vserver
[root@server1 images]# xm list
Name ID Mem(MiB) VCPUs State Time(s)
Domain-0 0 713 1 r----- 2973.8
vserver 14 255 1 -b---- 33.4


[root@server1 images]# ssh 192.168.0.118
root@192.168.0.118's password:
Last login: Thu Jul 9 00:29:13 2009 from 192.168.0.254
[root@server118 ~]#

6. 為了後面的Lab. 必須設定固定IP(192.168.0.118),修改Hostname(server118.example.com)
至於為什麼要設18...是偶上課座號, 習慣囉^^


aquatower | 7 July,2009 21:38

Lab2: Server1部署
Target: Running the Xen Virtualization Environment

1. 確認Hardware, CPU是否有支援

[root@server1 ~]# grep pae /proc/cpuinfo
flags : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss tm pbe nx lm constant_tsc up pni monitor ds_cpl tm2 cx16 xtpr lahf_lm
[root@server1 ~]# yum list |grep xen


2. 安裝套件: kernel-xen, xen, virt-manager

[root@server1 ~]# yum list |grep -e xen -e virt
This system is not registered with RHN.
RHN support will be disabled.
kernel-xen.i686 2.6.18-92.el5 base
kernel-xen-devel.i686 2.6.18-92.el5 base
kmod-ipw3945-xen.i686 1.2.0-4.8.el5 Supplementary
libvirt.i386 0.3.3-7.el5 VT
libvirt-devel.i386 0.3.3-7.el5 VT
libvirt-python.i386 0.3.3-7.el5 VT
python-virtinst.noarch 0.300.2-8.el5 VT
virt-manager.i386 0.5.3-8.el5 VT
virt-viewer.i386 0.0.2-2.el5 VT
xen.i386 3.0.3-64.el5 VT
xen-devel.i386 3.0.3-64.el5 VT
xen-libs.i386 3.0.3-64.el5 base


[root@server1 ~]# yum install xen kernel-xen
---
[root@server1 ~]# yum install virt-manager
---

3.
#vi /boot/grub/grub.conf

default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title Red Hat Enterprise Linux Server (2.6.18-92.el5xen)
root (hd0,0)
kernel /xen.gz-2.6.18-92.el5
module /vmlinuz-2.6.18-92.el5xen ro root=/dev/VolGroup00/LogVol00 rhgb quiet
module /initrd-2.6.18-92.el5xen.img
title Red Hat Enterprise Linux Server (2.6.18-92.el5PAE)
root (hd0,0)
kernel /vmlinuz-2.6.18-92.el5PAE ro root=/dev/VolGroup00/LogVol00 rhgb quiet

defalut=0, 使用kernel-xen

4. #reboot

5 #uame -r 是否有套用kernel-xen
[root@server1 ~]# uname -r
2.6.18-92.el5xen


Xen的環境己經準備好啦,接下來要安裝虛擬PC~~