Debian
Debian 5.04 第二天
四 24th
作者: reistlin 来源: reistlin.com 更新时间: 2010.04
版权: 原创文章.转载请保留作者信息和原文完整.谢绝任何方式的摘要

Debian 5.04 安装常用软件包:
# 编译工具
apt-get install gcc make
# 系统工具
apt-get install vim aptitude lrzsz sudo rcconf modconf psmisc sysstat locate
# 远程管理
apt-get install openssh-server openssh-client openssl
# 压缩/解压缩工具
apt-get install bzip2 rar unrar zip unzip
# 网络工具
apt-get install curl dnsutils tcpdump vnstat iperf iftop dnstop snmp
Debian 5.04 系统初始化配置:
设置系统时区和时间:
# 北京时间
cp -a /usr/share/zoneinfo/Asia/Taipei /etc/localtime
# 小时:分钟
date -s HH:MM
关闭系统UTC同步:
vim /etc/default/rcS
# off UTC syn
UTC=no
关闭Linux System Beep声音:
vim /etc/profile
# off system beep
setterm -blength 0
vimrc 配置文件:
vim /etc/vim/vimrc
# 语法高亮
syntax on
# 搜索关键字高亮
set hlsearch
# 显示行号
set number
.bashrc 配置文件:
# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
eval "`dircolors -b`"
alias ls='ls --color=auto'
alias dir='dir --color=auto'
alias vdir='vdir --color=auto'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
fi
# some more ls aliases
alias ll='ls -l'
alias la='ls -A'
alias l='ls -CF'
# history time
# 增加命令行历史记录2000行, 并且记录命令行执行时间
HISTFILESIZE=2000
HISTFILESIZE=2000
HISTTIMEFORMAT="%Y-%m-%d %H:%M:%S "
export HISTTIMEFORMAT
Debian 5.04 第一天
四 24th
作者: reistlin 来源: reistlin.com 更新时间: 2010.04
版权: 原创文章.转载请保留作者信息和原文完整.谢绝任何方式的摘要

Debian 5.04 台湾官方下载 (ISO):
[ftp://ftp.tw.debian.org/debian-cd/5.0.4/i386/iso-cd/debian-504-i386-CD-1.iso]
Debian 5.04 配置基本系统:
IP地址设置: /etc/network/interface
# 动态DHCP获得IP地址
# 启动系统激活设备
# Loop回环地址
auto lo
iface lo inet loopback
# 启动系统激活设备
# 网卡eth0设置为DHCP类型
auto eth0
iface eth0 inet dhcp
# 静态STATIC指定IP地址
# 启动系统激活设备
# Loop回环地址
auto lo
iface lo inet loopback
# 启动系统激活设备
# 网卡eth0设置为Static类型
auto eth0
iface eth0 inet static
# 指定IP地址.子网掩码.子网.广播.网关
address 192.168.0.1
netmask 255.255.255.0
network 192.168.0.0
broadcast 192.168.0.255
gateway 192.168.0.1
重新启动网络服务:
/etc/init.d/networking restart
# 禁用网卡 eth0:
ifdown eth0
# 启用网卡 eth0:
ifup eth0
DNS服务器设置: /etc/resolv.conf
# Google DNS
dns-nameservers 8.8.8.8
dns-nameservers 8.8.4.4
# OpenDNS
dns-nameservers 208.67.222.222
dns-nameservers 208.67.220.220
主机名设置(1): /etc/hosts
127.0.0.1 localhost
192.168.0.1 hostname
主机名设置(2): /etc/hostname
hostname
apt-get 源: /etc/apt/sources.list
网易镜像 [http://mirrors.163.com]
搜狐镜像 [http://mirrors.sohu.com]
deb http://mirrors.163.com/debian/ lenny main non-free contrib
deb http://mirrors.163.com/debian/ lenny-proposed-updates main non-free contrib
deb-src http://mirrors.163.com/debian/ lenny main non-free contrib
deb-src http://mirrors.163.com/debian/ lenny-proposed-updates main non-free contrib
deb http://mirrors.sohu.com/debian/ lenny main non-free contrib
deb http://mirrors.sohu.com/debian/ lenny-proposed-updates main non-free contrib
deb-src http://mirrors.sohu.com/debian/ lenny main non-free contrib
deb-src http://mirrors.sohu.com/debian/ lenny-proposed-updates main non-free contrib
apt-get 命令:
apt-get update 更新软件包列表
apt-get upgrade 更新所有软件包
apt-get dist-upgrade 更新所有软件包并且更新Release版本
apt-cache search
apt-cache show
apt-get install 安装指定软件包
apt-get remove 移除指定软件包(不移除配置文件)
apt-get purge 彻底移除软件包
apt-get autoremove 自动删除多余(没有依赖关系的)软件包
Apache 1.3 启用 Mod_fastcgi
八 17th
1. 下载:
Apache 1.3:
[http://labs.xiaonei.com/apache-mirror/httpd/apache_1.3.41.tar.gz]
Fastcgi (Apache Mod):
[http://www.fastcgi.com/dist/mod_fastcgi-2.4.6.tar.gz]
2. 编译:
# 解压缩 Apaache
tar zxvf apache_1.3.41.tar.gz
# 解压缩 mod_fastcgi
tar zxvf mod_fastcgi-2.4.6.tar.gz
# 移动 mod_fastcgi 到 Apache 的 Modules 目录
mv mod_fastcgi-2.4.6 apache_1.3.41/src/modules/fastcgi
# 开始编译安装
./configure –prefix=/home/apache \
–enable-module=so \
–enable-module=rewrite \
–activate-module=src/modules/fastcgi/libfastcgi.amake
make install
3. 配置:
# 复制 apachectl 文件到系统启动目录.
cp /home/apache/bin/apachectl /etc/init.d/httpd
# 编辑 /etc/init.d/httpd 文件. 添加 chkconfig 自动启动参数
vi /etc/init.d/httpd
#!/bin/sh
#
# chkconfig: – 85 15
# description: Apache 1.3.41 World Wide Web Server
4. 测试:
# 启动 Apache 服务
services httpd restart
# 查看 Fastcgi 进程
ps -eLf | grep “fcgi” | grep -v “grep”
nobody /home/apache/bin/fcgi-
# 查看 Apache 编译模块
/home/apache/bin/httpd -l
mod_fastcgi.c
Apache 1.3 启用 Mod_Rewrite
八 17th
1. 编译:
./configure –prefix=/home/apache \
–enable-module=so \
–enable-module=rewrite \
–activate-module=src/modules/fastcgi/libfastcgi.a
2. 配置:
vi /home/apache/conf/httpd.conf
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory><IfModule mod_rewrite.c>
RewriteEngine On
RewriteLog /home/apache/logs/rewrite_log
RewriteLogLevel 0</IfModule>
3. 测试:
# 重新启动Apache
/etc/init.d/httpd restart
# 检查Apache静态编译模块
/home/apache/bin/httpd -l
设置 Local Time Zone 时区
三 29th
方法1:
使用 tzselect 命令. 选择 Asia (5)-> China (9) -> east China – Shanghai (1). 选择完成后提示你输入设置命令行: TZ=’Asia/Shanghai’; export TZ 你可以将此命令行增加到你的用户主目录/.profile 文件中. 注销重新登陆即可.
方法2: [推荐]
sudo cp /usr/share/zoneinfo/Asia/Taipei /etc/localtime
相关链接: [关闭 Linux UTC 同步]
Debian Linux LVM 配置手册
三 25th
摘要: 使用 Debian Linux 下的 lvm2 配置 LVM 磁盘系统
作者: By REISTLIN [雷斯林] MSN: Rexxxxxx@hotmail.com QQ: 3A984
版权: 原创文章.转载请保留作者信息和原文完整.谢绝任何方式的摘要.
LVM 介绍:
LVM – Logical Volume Manager 是Linux系统下最强大的磁盘管理技术之一.它将您从不得不思考物理容量中解脱出来,代之以逻辑形式来思考这些容量. 当您需要考虑如何替用户数据和系统文件分配空间的时候,LVM可以让您彻底忘记传统的分区做法.
简单地来说,LVM就是将众多物理设备组合成一个大的虚拟设备,用户只需思考如何在虚拟设备上做传统的空间分配策略,而将物理设备的管理交由LVM自己去处理.这个由物理设备组合所成的虚拟设备称为卷组(Volume Group),简称为VG;而用户在卷组VG上所划分的磁盘空间则称为逻辑卷(Logical Volume),简称为LV;而原始物理设备必须经过初始化处理才能加入卷组集合,这种经过特别处理的原始设备或磁盘空间则称为物理卷(Physical Volume),简称为PV.
LVM磁盘空间管理系统允许您在需要的时候重新调整大小, 这也就意味着在管理磁盘空间资源方面, 您将获得极大程度的自由. 基本上这是很有诱惑力的, 但您应该留心硬盘出错的情况,如果您没有在LVM管理中为出现这种情况而做好计划,那么您可能会丢失大量数据.
LVM 术语:
PV – Physical Volume 物理卷,例如一个硬盘,或一个Software RAID设备;
VG – Volume Group 卷组,将一组物理卷收集为一个管理单元;
LV – Logical Volume 逻辑卷,等同于传统分区,可看作便准的块设备,以容纳文件系统;
PE – Physical Extent 物理块,划分物理卷的数据块;
LE – Logical Extent 逻辑块,划分逻辑卷的数据块;
LVM 结构:
为了让大家了解关于LVM的概念和结构.实现方式等.作者花了整整一天时间画了一个图.
突然发现自己的”设计”水准很前卫很潮流. (谁说图片不好看谁就不要看文章了! :-))
说明: /boot 这个挂载分区不能存在于VG卷组里.所以我们一般是建议单独分区.
使用LVM的基本步骤如下:
1. 安装lvm2 ( apt-get install lvm2 )
2. 使用fdisk分区指定的物理硬盘
3. 使用lvm管理工具进行lvm配置 (建立PV / VG / LV)
4. 格式化已经设置好的LV逻辑卷.挂载到指定目录.
5. 关于如何增加/删除/修改LV逻辑卷大小.请期待第2季.
LVM 配置步骤:
// 查看物理磁盘状态 – 硬盘(容量1GB) /dev/sdb 已经识别
Debian:/home/reistlin# fdisk -l
Disk /dev/sda: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0×0002db3aDevice Boot Start End Blocks Id System
/dev/sda1 1 1033 8297541 83 Linux
/dev/sda2 1034 1305 2184840 82 Linux swap / SolarisDisk /dev/sdb: 1073 MB, 1073741824 bytes
128 heads, 32 sectors/track, 512 cylinders
Units = cylinders of 4096 * 512 = 2097152 bytes
Disk identifier: 0×00000000Disk /dev/sdb doesn’t contain a valid partition table
// 使用 fdisk 对 /dev/sdb 分区
Debian:/home/reistlin# fdisk /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0×4e896764.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won’t be recoverable.Warning: invalid flag 0×0000 of partition table 4 will be corrected by w(rite)
Command (m for help): new
Command action
e extended
p primary partition (1-4)p
Partition number (1-4): 1
First cylinder (1-512, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-512, default 512):
Using default value 512Command (m for help): m
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition’s system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)Command (m for help): w
The partition table has been altered!Calling ioctl() to re-read partition table.
Syncing disks.
// 查看分区后的物理磁盘信息 – /dev/sdb1 状态正常
Debian:/home/reistlin# fdisk -l
Disk /dev/sda: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0×0002db3aDevice Boot Start End Blocks Id System
/dev/sda1 1 1033 8297541 83 Linux
/dev/sda2 1034 1305 2184840 82 Linux swap / SolarisDisk /dev/sdb: 1073 MB, 1073741824 bytes
128 heads, 32 sectors/track, 512 cylinders
Units = cylinders of 4096 * 512 = 2097152 bytes
Disk identifier: 0×4e896764Device Boot Start End Blocks Id System
/dev/sdb1 1 512 1048560 83 Linux
// 进入 LVM 模式
Debian:/home/reistlin# lvm
// 查看 LVM 磁盘状态 – 目前没有任何 LVM 磁盘信息
lvm> lvmdiskscan
/dev/ram0 [ 8.00 MB]
/dev/ram1 [ 8.00 MB]
/dev/root [ 7.91 GB]
/dev/ram2 [ 8.00 MB]
/dev/sda2 [ 2.08 GB]
/dev/ram3 [ 8.00 MB]
/dev/ram4 [ 8.00 MB]
/dev/ram5 [ 8.00 MB]
/dev/ram6 [ 8.00 MB]
/dev/ram7 [ 8.00 MB]
/dev/ram8 [ 8.00 MB]
/dev/ram9 [ 8.00 MB]
/dev/ram10 [ 8.00 MB]
/dev/ram11 [ 8.00 MB]
/dev/ram12 [ 8.00 MB]
/dev/ram13 [ 8.00 MB]
/dev/ram14 [ 8.00 MB]
/dev/ram15 [ 8.00 MB]
/dev/sdb [ 1.00 GB]
2 disks
17 partitions
0 LVM physical volume whole disks
0 LVM physical volumes
// 查看 LVM 配置文件 – dump 模式
lvm> dumpconfig
devices {
dir=”/dev”
scan=”/dev”
preferred_names=[]
filter=”a/.*/”
cache_dir=”/etc/lvm/cache”
cache_file_prefix=”"
write_cache_state=1
sysfs_scan=1
md_component_detection=1
ignore_suspended_devices=0
}
activation {
missing_stripe_filler=”/dev/ioerror”
reserved_stack=256
reserved_memory=8192
process_priority=-18
mirror_region_size=512
readahead=”auto”
mirror_log_fault_policy=”allocate”
mirror_device_fault_policy=”remove”
}
global {
umask=63
test=0
units=”h”
activation=1
proc=”/proc”
locking_type=1
fallback_to_clustered_locking=1
fallback_to_local_locking=1
locking_dir=”/var/lock/lvm”
}
shell {
history_size=100
}
backup {
backup=1
backup_dir=”/etc/lvm/backup”
archive=1
archive_dir=”/etc/lvm/archive”
retain_min=10
retain_days=30
}
log {
verbose=0
syslog=1
overwrite=0
level=0
indent=1
command_names=0
prefix=” ”
}
// 创建 Physical Volume (PV)
lvm> pvcreate
Please enter a physical volume path
lvm> pvcreate /dev/sdb1
Physical volume “/dev/sdb1″ successfully created
// 查看 Physical Volume (PV) 状态
lvm> pvdisplay
CTRL-c detected: giving up waiting for lock
— Physical volume —
PV Name /dev/sdb1
VG Name vg_test
PV Size 1023.98 MB / not usable 3.98 MB
Allocatable yes (but full)
PE Size (KByte) 4096
Total PE 255
Free PE 0
Allocated PE 255
PV UUID SwfyW5-veGN-1Ptd-VIUo-0I3I-CdVB-QF7BwC
// 再次查看 LVM 磁盘状态
lvm> lvmdiskscan
/dev/ram0 [ 8.00 MB]
/dev/ram1 [ 8.00 MB]
/dev/root [ 7.91 GB]
/dev/ram2 [ 8.00 MB]
/dev/sda2 [ 2.08 GB]
/dev/ram3 [ 8.00 MB]
/dev/ram4 [ 8.00 MB]
/dev/ram5 [ 8.00 MB]
/dev/ram6 [ 8.00 MB]
/dev/ram7 [ 8.00 MB]
/dev/ram8 [ 8.00 MB]
/dev/ram9 [ 8.00 MB]
/dev/ram10 [ 8.00 MB]
/dev/ram11 [ 8.00 MB]
/dev/ram12 [ 8.00 MB]
/dev/ram13 [ 8.00 MB]
/dev/ram14 [ 8.00 MB]
/dev/ram15 [ 8.00 MB]
/dev/sdb1 [ 1023.98 MB] LVM physical volume
1 disk
17 partitions
0 LVM physical volume whole disks
1 LVM physical volume
// 创建 Volume Group (VG)
lvm> vgcreate vg_test
Please enter physical volume name(s)
lvm> vgcreate vg_test /dev/sdb1
Volume group “vg_test” successfully created
// 查看 Volume Group (VG) 状态
lvm> vgdisplay
— Volume group —
VG Name vg_test
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 1
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 0
Open LV 0
Max PV 0
Cur PV 1
Act PV 1
VG Size 1020.00 MB
PE Size 4.00 MB
Total PE 255
Alloc PE / Size 0 / 0
Free PE / Size 255 / 1020.00 MB
VG UUID Dbm7gQ-HDao-0z2Z-2u3q-XK9A-bmEv-ES3qC0
// 创建 Logical Volume (LV) – 如果需要使用全部VG空间. 输入 -l <Total PE> 的值.
// <Total PE> 的值可以使用 vgdisplay 命令查看: Total PE = 255
lvm> lvcreate -l 255 vg_test -n lv_test
Logical volume “lv_test” created
// 查看 Logical Volume (LV) 状态
lvm> lvdisplay
— Logical volume —
LV Name /dev/vg_test/lv_test
VG Name vg_test
LV UUID l3GUct-M3nG-m837-wOe2-4EWo-ZPU6-xskaq8
LV Write Access read/write
LV Status available
# open 0
LV Size 1020.00 MB
Current LE 255
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 254:0
// 输入 exit 退出 LVM 配置模式. Ext3 格式化 lv_test 逻辑卷
Debian:/home/reistlin# mkfs -t ext3 -j /dev/vg_test/lv_test
mke2fs 1.41.3 (12-Oct-2008)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
65280 inodes, 261120 blocks
13056 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=268435456
8 block groups
32768 blocks per group, 32768 fragments per group
8160 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376Writing inode tables: done
Creating journal (4096 blocks): done
Writing superblocks and filesystem accounting information: doneThis filesystem will be automatically checked every 25 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
// 挂载 lv_test 逻辑卷到 /mnt 目录. 你也可以挂载到 /home 目录
Debian:/home/reistlin# mount /dev/vg_test/lv_test /mnt
Debian:/home/reistlin# cd /mnt
// 测试文件读写. Reistlin.Com. OKay.
Debian:/mnt# vim Reistlin.Com
Debian:/mnt# cat Reistlin.Com
Welcome to Reistlin.Com
Ubuntu Server 启用 Apache Mod_Rewrite
十一 13th
sudo a2enmod rewrite
Enabling module rewrite.
Run ‘/etc/init.d/apache2 restart’ to activate new configuration!sudo vim /etc/apache2/sites-enabled/default
AllowOverride All
Debian Linux GDM 登录窗口的字体设置
十 6th
在Debian Linux环境下.默认GDM Thems的主题路径是: /usr/share/gdm/themes/ 我们使用其中一个主题“Debian MoreBlue” 来做演示.配置文件路径如下:
/usr/share/gdm/themes/debian-moreblue/debian-moreblue.xml
方法:
使用 vim 修改 “Debian MoreBlue” GDM主题配置文件:
sudo mousepad debian-moreblue.xml
查找字段 “font” 比如:
<normal color=”#ffffff” font=”Sans Bold 11″/>
提示: color=”字体颜色” font=”字体名称 字体效果(粗/斜) 字体大小”
修改为文泉驿字体如下:
<normal color=”#ffffff” font=”WenQuanYi Bitmap Song Bold 11″/>
搜索xml文件的所有的”font”字段.全部修改后保存即可.
Debian Linux 安装 ATI 9800PRO 显卡
十 6th
系统: Debian 4.0 Lenny + Xfce 4.4.2
硬件: P4 3.0C / 2G RAM / ATI 9800PRO
1.安装fglrx-driver驱动程序
apt-get install fglrx-driver
2.安装glxinfo和glxgears程序
apt-get install fglrx-glx mesa-utils
3.修改ATI官方驱动程序权限
chmod 755 ati-driver-installer-8-9-x86.x86_64.run
ATI官方驱动程序 V8.9 [下载地址]:
http://ati.amd.com/support/drivers/linux/linux-radeon.html
4.安装ATI官方驱动程序
sudo ./ati-driver-installer-8-9-x86.x86_64.run
5.[重要] 使用aticonfig初始化/etc/X11/xore.conf
sudo aticonfig –initial -f
测试1:
# glxinfo
OpenGL vendor string: ATI Technologies Inc.
OpenGL renderer string: RADEON 9800 PRO
OpenGL version string: 2.1.7979 Release
测试2:
# glxgears
32416 frames in 5.0 seconds = 6483.182 FPS
32276 frames in 5.0 seconds = 6455.035 FPS
32258 frames in 5.0 seconds = 6451.411 FPS
