海运的博客

PXE启动KickStart全自动安装系统

发布时间:November 4, 2012 // 分类:PXE // No Comments

关于PXE服务器配置、客户端引导见之前文章:使用TFTP/PXE引导安装Centos系统
通过KickStart自动安装只需修改最后PXE引导菜单配置文件:

cat /tftpboot/pxelinux.cfg/default 
#www.haiyun.me
timeout 5
default menu.c32

menu title ########## PXE Boot Menu ##########
label 1
   menu label ^1) Install CentOS 6
   kernel centos6/vmlinuz
   append initrd=centos6/initrd.img ks=nfs:192.168.1.3:/tftpboot/ks.cf 
#引导获取KickStart配置文件,然后在KickStart文件中配置安装源。

KickStart配置文件可使用图形化配置,需安装桌面或开启X-Windows环境转发

yum install system-config-kickstart 

kickstart图形化配置工具.png
KickStart配置文件示例:

text
install
nfs --server=192.168.1.3 --dir=/mnt
#光盘镜像挂载目录
#url --url=http://192.168.1.3/mnt/ #可使用http或ftp
keyboard us
lang zh_CN.UTF-8
network --device eth0 --bootproto static --ip 192.168.1.30 --netmask 255.255.255.0 
--gateway 192.168.1.1 --nameserver 192.168.1.1 --hostname centos5.7-x64
firewall --disabled
rootpw onovps
authconfig --enableshadow --passalgo=sha512
selinux --disabled
timezone Aisa/Shang_Hai
bootloader --location=mbr
zerombr
clearpart --all --initlabel
part /boot --fstype ext4 --fsoptions="noatime" --size=200
part pv.1 --size 1 --grow
volgroup vg0 --pesize=4096 pv.1
logvol / --fstype ext4 --fsoptions="noatime" --name=root --vgname=vg0 --grow --size=8192
logvol swap --fstype swap --name=swap --vgname=vg0 --size 2048
 
%post
%end
%packages
@base
%end

这样局域网下机器以PXE启动就自动安装为相应的系统了。

Centos安装TFTP/NFS/PXE服务器网络引导安装系统

发布时间:November 3, 2012 // 分类:PXE // No Comments

客户端网卡要求支持以PXE启动,配置都在服务端进行,通过PXE网络启动安装系统流程:

客户端以PXE启动发送DHCP请求;
服务器DHCP应答,包括客户端的IP地址,引导文件所在TFTP服务器;
客户端通过TFTP会话下载网络引导文件;
进入PXE引导菜单选项,加载镜像启动安装进程。

1.安装DHCP服务器:

yum install dhcp

DHCP配置:

cat /etc/dhcpd.conf 
#www.haiyun.me
ddns-update-style none;
ignore client-updates; 
default-lease-time           259200;
max-lease-time               518400;
option routers               192.168.1.254;
option domain   www.haiyun.me;
option domain-name-servers   192.168.1.254;

subnet 192.168.1.0 netmask 255.255.255.0 {
    range 192.168.1.101 192.168.1.200; 
    next-server 192.168.1.3; #TFTP服务器
    allow booting;
    allow bootp;
    filename "pxelinux.0"; #启动引导文件,后续会介绍。
}

host pc {
    hardware ethernet    08:00:27:11:EB:C2;
    fixed-address        192.168.1.130;
    option root-path     "/client/pc01";
    }

2.安装TFTP服务器:

yum install tftp-server

TFTP以xinetd启动,配置如下:

cat /etc/xinetd.d/tftp 
service tftp
{
    socket_type        = dgram
    protocol        = udp
    wait            = yes
    user            = root
    server            = /usr/sbin/in.tftpd
    server_args        = -s /tftpboot
    disable            = no
    per_source        = 11
    cps            = 100 2
    flags            = IPv4
}

3.NFS服务器安装,挂载ISO安装光盘:

yum install nfs
mount -t iso9660 -o loop /dev/cdrom /mnt/
cp /mnt/images/pxeboot/* /tftpboot/

NFS配置:

cat /etc/exports 
/mnt *(rw,no_root_squash)

4.安装syslinux配置网络启动,相当于GRUB。

yum install syslinux
cp /usr/lib/syslinux/pxelinux.0 /tftpboot/

5.PXE引导菜单配置,相当于GRUB配置文件,可根据客户端MAC定义名称。

cp /usr/lib/syslinux/menu.c32 /tftpboot/
mkdir /tftpboot/pxelinux.cfg/
cat /tftpboot/pxelinux.cfg/default 
timeout 100
default menu.c32

menu title ########## PXE Boot Menu ##########
label 1
   menu label ^1) Install CentOS 6
   kernel vmlinuz
   append initrd=initrd.img method=nfs:192.168.1.3:/mnt
   #method为安装光盘目录,可使用FTP/HTTP多种方式
label 2
   menu label ^2) Boot from local drive
   localboot

6.客户端开机以PXE引导启动即可进入Centos安装界面。
PXE网络引导安装Centos.png
后续可通过kickstart无人值守安装系统

Centos安装Flashcache使用SSD缓存

发布时间:October 28, 2012 // 分类:备份存储 // No Comments

Flashcache是Facebook技术团队开发的一个内核模块,通过在文件系统(VFS)和设备驱动之间新增一次缓存层,可以用SSD作为介质的缓存,通过将传统硬盘上的热门数据缓存到SSD上,加速服务器磁盘读写性能。
flashcache使用ssd缓存图解.jpg
Centos5.7下安装Flashcache,查看系统及内核版本:

uname -a
Linux master.www.haiyun.me 2.6.18-274.17.1.el5 #1 SMP Tue Jan 10 17:25:58 EST 2012 x86_64 x86_64 x86_64 GNU/Linux
cat /etc/issue
CentOS release 5.7 (Final)

下载安装内核源码树:

#https://www.haiyun.me
yum install rpm-build redhat-rpm-config unifdef
lftp -c "pget -n 10  http://vault.centos.org/5.7/os/SRPMS/kernel-2.6.18-274.el5.src.rpm"
rpm -i kernel-2.6.18-274.el5.src.rpm
cd /usr/src/redhat/SPECS/
rpmbuild -bp --target=$(uname -m) kernel.spec

内核模块编译准备:

cd /usr/src/redhat/BUILD/kernel-2.6.18/linux-2.6.18-274.*
make oldconfig
make prepare
make modules_prepare

下载编译Flashcache:

wget --no-check-certificate -O flashcache.tar.gz https://github.com/facebook/flashcache/tarball/master
tar zxvf flashcache.tar.gz 
cd facebook-flashcache-c4bddf6/
make install

加载Flashcache模块:

insmod /lib/modules/2.6.18-274.17.1.el5/extra/flashcache/flashcache.ko 
lsmod |grep flashcache
flashcache            112320  0 
dm_mod                102289  12 flashcache,dm_multipath,dm_raid45,dm_snapshot,dm_zero,dm_mirror,dm_log

创建Flashcache卷:

flashcache_create [-v] [-p back|thru|around] [-b block size] [-m md block size] [-s cache size] [-a associativity] cachedev ssd_devname disk_devname

挂载Flashcache卷:

mount /dev/mapper/cachedev  /home/wwwroot/

Centos5/Linux安装Nfdump和Nfsen图形界面分析netflow数据

发布时间:October 20, 2012 // 分类:流量监控 // 9 Comments

Nfdumplinuxnetflow数据采集分析工具,Nfsen是基于nfdump是web界面工具,服务器需先安装web服务器和php环境。
安装rrdtool及所需组件:

yum install perl-rrdtool rrdtool rrdtool-devel rrdutils flex byacc

安装所需perl模块:

yum install perl-Socket6 perl-MailTools perl-Mail-Sender

安装Nfdump工具:

cd /usr/local/src/
wget http://downloads.sourceforge.net/project/nfdump/stable/nfdump-1.6.6/nfdump-1.6.6.tar.gz
tar zxvf nfdump-1.6.6.tar.gz 
cd nfdump-1.6.6/
./configure --enable-nfprofile --with-rrdpath=/usr/bin
make
make install
cd ../

下载配置Nfsen:

mkdir -p /usr/local/nfsen
wget http://downloads.sourceforge.net/project/nfsen/stable/nfsen-1.3.6p1/nfsen-1.3.6p1.tar.gz
tar zxvf nfsen-1.3.6p1.tar.gz 
cd nfsen-1.3.6p1/
cp etc/nfsen-dist.conf etc/nfsen.conf

修改Nfsen配置文件:

cat etc/nfsen.conf
#https://www.haiyun.me
$BASEDIR = "/usr/local/nfsen";
$HTMLDIR    = "/var/www/html/nfsen/";
$USER    = "apache";
$WWWUSER  = "apache";
$WWWGROUP = "apache";
%sources = (
    'upstream1'    => { 'port' => '9995', 'col' => '#0000ff', 'type' => 'netflow' },
);

安装Nfsen:

./install.pl etc/nfsen.conf 

启动Nfsen:

/usr/local/nfsen/bin/nfsen start

配置路由或交换机将netflow数据发送到nfsen配置的端口,然后访问www.haiyun.me/nfsen/nfsen.php即可通过Nfsen浏览netflow数据。
nfsen分析netflow.png

Centos服务器安全配置SSH使用Google Authenticator二次验证

发布时间:August 30, 2012 // 分类:网络安全 // 2 Comments

CentOS安装所需组件:

yum -y install mercurial pam-devel

安装Google Authenticator:

#https://www.haiyun.me
wget --no-check-certificate https://google-authenticator.googlecode.com/files/libpam-google-authenticator-1.0-source.tar.bz2
tar jxvf libpam-google-authenticator-1.0-source.tar.bz2 
cd libpam-google-authenticator-1.0
make
make install

SSH登录时调用google-authenticator模块,编辑:

/etc/pam.d/sshd

第一行添加:

auth       required     pam_google_authenticator.so

修改SSH配置文件:

vim /etc/ssh/sshd_config

添加或修改以下内容:

ChallengeResponseAuthentication yes
UsePAM yes

重启SSH:

/etc/init.d/sshd restart

生成google-authenticator配置,运行:

google-authenticator 
Do you want authentication tokens to be time-based (y/n) y
https://www.google.com/chart?chs=200x200&chld=M|0&cht=qr&chl=otpauth://totp/root@node1.www.haiyun.me%3Fsecret%3DABEXG5K6CVB56BXY
#此网址为生成的二维码,客户端扫描
Your new secret key is: www.haiyun.me
Your verification code is 582849
Your emergency scratch codes are:
  30776626
  14200155
  80795568
  23936997
  21919909
#上面几行数字为应急码
Do you want me to update your "/root/.google_authenticator" file (y/n) y
#更新配置文件
Do you want to disallow multiple uses of the same authentication
token? This restricts you to one login about every 30s, but it increases
your chances to notice or even prevent man-in-the-middle attacks (y/n) y
#禁止一个口令多用
By default, tokens are good for 30 seconds and in order to compensate for
possible time-skew between the client and the server, we allow an extra
token before and after the current time. If you experience problems with poor
time synchronization, you can increase the window from its default
size of 1:30min to about 4min. Do you want to do so (y/n) n
#客户端与服务器时间误差
If the computer that you are logging into isn't hardened against brute-force
login attempts, you can enable rate-limiting for the authentication module.
By default, this limits attackers to no more than 3 login attempts every 30s.
Do you want to enable rate-limiting (y/n) y
#次数限制

Android安装google-authenticator客户端,扫描添加上方网址的二维码,以后在登录服务器时输入账号密码的同时还需输入google-authenticator即时生成的验证码才能登录。

ssh www.haiyun.me
Verification code: 
Password: 
分类
最新文章
最近回复
  • 海运: 恩山有很多。
  • swsend: 大佬可以分享一下固件吗,谢谢。
  • Jimmy: 方法一 nghtp3步骤需要改成如下才能编译成功: git clone https://git...
  • 海运: 地址格式和udpxy一样,udpxy和msd_lite能用这个就能用。
  • 1: 怎么用 编译后的程序在家里路由器内任意一台设备上运行就可以吗?比如笔记本电脑 m参数是笔记本的...
  • 孤狼: ups_status_set: seems that UPS [BK650M2-CH] is ...
  • 孤狼: 擦。。。。apcupsd会失联 nut在冲到到100的时候会ONBATT进入关机状态,我想想办...
  • 海运: 网络,找到相应的url编辑重发请求,firefox有此功能,其它未知。
  • knetxp: 用浏览器F12网络拦截或监听后编辑重发请求,修改url中的set为set_super,将POS...
  • Albert: 啊啊啊啊啊啊啊啊啊 我太激动了,终于好了英文区搜索了半天,翻遍了 pve 论坛没找到好方法,博...