首页 > 代码库 > 2-8 无人值守安装服务器搭建 日志

2-8 无人值守安装服务器搭建 日志

无人值守安装服务器搭建
PXE + DHCP+TFTP+ Kickstart+ FTP
dhcp PXE tftp vsftpd system-config-kickstart

#####################################################
#####################################################
#####################################################
#####################################################
1. 查询系统安装环境
查询光驱挂载情况
[root@xiaogan120 ~]# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda2 10190136 1602468 8063380 17% /
tmpfs 502068 0 502068 0% /dev/shm
/dev/sda1 487652 31507 430545 7% /boot
/dev/sda5 7619708 488740 6737240 7% /var
/dev/sr0 6036800 6036800 0 100% /mnt
[root@xiaogan120 ~]# ls /mnt
CentOS_BuildTag isolinux RPM-GPG-KEY-CentOS-Debug-6
EFI Packages RPM-GPG-KEY-CentOS-Security-6
EULA RELEASE-NOTES-en-US.html RPM-GPG-KEY-CentOS-Testing-6
GPL repodata TRANS.TBL
images RPM-GPG-KEY-CentOS-6
[root@xiaogan120 ~]#

查询网络状态
[root@xiaogan120 ~]# ifconfig
eth0 Link encap:Ethernet HWaddr 00:0C:29:A1:20:66
inet addr:192.168.171.120 Bcast:192.168.171.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fea1:2066/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:621 errors:0 dropped:0 overruns:0 frame:0
TX packets:553 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:71067 (69.4 KiB) TX bytes:70929 (69.2 KiB)

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)

[root@xiaogan120 ~]# ping www.baidu.com
PING www.a.shifen.com (111.13.100.91) 56(84) bytes of data.
64 bytes from 111.13.100.91: icmp_seq=1 ttl=54 time=21.3 ms
64 bytes from 111.13.100.91: icmp_seq=2 ttl=54 time=15.4 ms
^C
--- www.a.shifen.com ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1538ms
rtt min/avg/max/mdev = 15.435/18.404/21.373/2.969 ms
[root@xiaogan120 ~]#


查询yum源配置情况
[root@xiaogan120 ~]# ls /etc/yum.repos.d/
centos6.repo CentOS-Debuginfo.repo CentOS-Media.repo Epel-6.repo
CentOS-Base.repo CentOS-fasttrack.repo CentOS-Vault.repo
[root@xiaogan120 ~]# cat /etc/yum.repos.d/centos6.repo
[CentOS6-SERVER]
name = CentOS 6.8 server
baseurl = file:///mnt
enable = 1
gpgcheck = 0
[root@xiaogan120 ~]# yum clean all && yum list && yum makecache


查询软件包
[root@xiaogan120 ~]# rpm -qa | grep tftp
[root@xiaogan120 ~]# rpm -qa | grep vsftp
[root@xiaogan120 ~]# rpm -qa | grep system-config-kickstart
[root@xiaogan120 ~]# rpm -qa | grep dhcp
dhcp-common-4.1.1-51.P1.el6.centos.x86_64
[root@xiaogan120 ~]# rpm -qa | grep dhcpd
[root@xiaogan120 ~]# yum list | grep system-config-kickstart
system-config-kickstart.noarch 2.8.6.6-1.el6 CentOS6-SERVER
[root@xiaogan120 ~]# yum list | grep vsftp
vsftpd.x86_64 2.2.2-21.el6 CentOS6-SERVER
[root@xiaogan120 ~]# yum list | grep tftp
syslinux-tftpboot.noarch 4.04-3.el6 CentOS6-SERVER
tftp.x86_64 0.49-8.el6 CentOS6-SERVER
tftp-server.x86_64 0.49-8.el6 CentOS6-SERVER
[root@xiaogan120 ~]# yum list | grep dhcp
dhcp-common.x86_64 12:4.1.1-51.P1.el6.centos @anaconda-CentOS-201605220104.x86_64/6.8
dhcp.x86_64 12:4.1.1-51.P1.el6.centos CentOS6-SERVER
dhcp-devel.i686 12:4.1.1-51.P1.el6.centos CentOS6-SERVER
dhcp-devel.x86_64 12:4.1.1-51.P1.el6.centos CentOS6-SERVER
dhcping.x86_64 1.2-13.el6 epel
nagios-plugins-dhcp.x86_64 2.0.3-3.el6 epel
sblim-cmpi-dhcp.i686 1.0-1.el6 CentOS6-SERVER
sblim-cmpi-dhcp.x86_64 1.0-1.el6 CentOS6-SERVER
sblim-cmpi-dhcp-devel.i686 1.0-1.el6 CentOS6-SERVER
sblim-cmpi-dhcp-devel.x86_64 1.0-1.el6 CentOS6-SERVER
sblim-cmpi-dhcp-test.x86_64 1.0-1.el6 CentOS6-SERVER
wide-dhcpv6.x86_64 20080615-13.1.el6 epel
[root@xiaogan120 ~]#


#####################################################
#####################################################
#####################################################
2. 安装system-config-kickstart 并生成ks.cfg
配置ks.cfg

安装system-config-kickstart
yum -y install system-config-kickstart

# 在xshell中:
#文件-->属性-->连接-->ssh-->隧道-->转发x11连接到--> Xmanager
# 设置中文图形界面:
#LANG=zh_CN.UTF-8

system-config-kickstart #启动配置程序
配置如下:
1. 基本配置
技术分享

2. 安装方法

技术分享

3. 引导装载程序选项

技术分享

4. 分区信息

技术分享

5. 网络配置

技术分享

6. 验证

技术分享

7. 防火墙配置

技术分享

8. 显示配置

技术分享

9. 软件包选择

技术分享

 

10. 预安装脚本(跳过)
11. 安装后台脚本

技术分享

文件-->保存-->/root/ks.cfg

[root@xiaogan120 ~]# system-config-kickstart
/usr/share/system-config-kickstart/kickstartGui.py:103: GtkWarning: GtkSpinButton: setting an adjustment with non-zero page size is deprecated
xml = gtk.glade.XML ("/usr/share/system-config-kickstart/system-config-kickstart.glade", domain="system-config-kickstart")
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* epel: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
/usr/share/system-config-kickstart/kickstartGui.py:220: GtkWarning: Attempting to store changes into `/root/.local/share/recently-used.xbel‘, but failed: Failed to create file ‘/root/.local/share/recently-used.xbel.4AXLNY‘: No such file or directory
gtk.main()
/usr/share/system-config-kickstart/kickstartGui.py:220: GtkWarning: Attempting to set the permissionsof `/root/.local/share/recently-used.xbel‘, but failed: No such file or directory
gtk.main()
/tmp/tmpmzpklH/var/lib/rpm: No such file or directory
[root@xiaogan120 ~]# echo $LANG
en_US.UTF-8
[root@xiaogan120 ~]# LANG=zh_CN.UTF-8
[root@xiaogan120 ~]# system-config-kickstart
/usr/share/system-config-kickstart/kickstartGui.py:103: GtkWarning: GtkSpinButton: setting an adjustment with non-zero page size is deprecated
xml = gtk.glade.XML ("/usr/share/system-config-kickstart/system-config-kickstart.glade", domain="system-config-kickstart")
/usr/lib/python2.6/site-packages/scdate/core/zonetab.py:227: RuntimeWarning: Untranslated time zone: Antarctica/Troll
entry = ZoneTabEntry (code, lat, long, tz, comments)
/usr/lib/python2.6/site-packages/scdate/core/zonetab.py:227: RuntimeWarning: Untranslated time zone: America/Kralendijk
entry = ZoneTabEntry (code, lat, long, tz, comments)
/usr/lib/python2.6/site-packages/scdate/core/zonetab.py:227: RuntimeWarning: Untranslated time zone: America/Creston
entry = ZoneTabEntry (code, lat, long, tz, comments)
/usr/lib/python2.6/site-packages/scdate/core/zonetab.py:227: RuntimeWarning: Untranslated time zone: America/Fort Nelson
entry = ZoneTabEntry (code, lat, long, tz, comments)
/usr/lib/python2.6/site-packages/scdate/core/zonetab.py:227: RuntimeWarning: Untranslated time zone: Europe/Busingen
entry = ZoneTabEntry (code, lat, long, tz, comments)
/usr/lib/python2.6/site-packages/scdate/core/zonetab.py:227: RuntimeWarning: Untranslated time zone: Pacific/Chuuk
entry = ZoneTabEntry (code, lat, long, tz, comments)
/usr/lib/python2.6/site-packages/scdate/core/zonetab.py:227: RuntimeWarning: Untranslated time zone: Pacific/Pohnpei
entry = ZoneTabEntry (code, lat, long, tz, comments)
/usr/lib/python2.6/site-packages/scdate/core/zonetab.py:227: RuntimeWarning: Untranslated time zone: America/Bahia Banderas
entry = ZoneTabEntry (code, lat, long, tz, comments)
/usr/lib/python2.6/site-packages/scdate/core/zonetab.py:227: RuntimeWarning: Untranslated time zone: Pacific/Bougainville
entry = ZoneTabEntry (code, lat, long, tz, comments)
/usr/lib/python2.6/site-packages/scdate/core/zonetab.py:227: RuntimeWarning: Untranslated time zone: Asia/Hebron
entry = ZoneTabEntry (code, lat, long, tz, comments)
/usr/lib/python2.6/site-packages/scdate/core/zonetab.py:227: RuntimeWarning: Untranslated time zone: Europe/Astrakhan
entry = ZoneTabEntry (code, lat, long, tz, comments)
/usr/lib/python2.6/site-packages/scdate/core/zonetab.py:227: RuntimeWarning: Untranslated time zone: Europe/Ulyanovsk
entry = ZoneTabEntry (code, lat, long, tz, comments)
/usr/lib/python2.6/site-packages/scdate/core/zonetab.py:227: RuntimeWarning: Untranslated time zone: Asia/Barnaul
entry = ZoneTabEntry (code, lat, long, tz, comments)
/usr/lib/python2.6/site-packages/scdate/core/zonetab.py:227: RuntimeWarning: Untranslated time zone: Asia/Chita
entry = ZoneTabEntry (code, lat, long, tz, comments)
/usr/lib/python2.6/site-packages/scdate/core/zonetab.py:227: RuntimeWarning: Untranslated time zone: Asia/Khandyga
entry = ZoneTabEntry (code, lat, long, tz, comments)
/usr/lib/python2.6/site-packages/scdate/core/zonetab.py:227: RuntimeWarning: Untranslated time zone: Asia/Ust-Nera
entry = ZoneTabEntry (code, lat, long, tz, comments)
/usr/lib/python2.6/site-packages/scdate/core/zonetab.py:227: RuntimeWarning: Untranslated time zone: Asia/Srednekolymsk
entry = ZoneTabEntry (code, lat, long, tz, comments)
/usr/lib/python2.6/site-packages/scdate/core/zonetab.py:227: RuntimeWarning: Untranslated time zone: Africa/Juba
entry = ZoneTabEntry (code, lat, long, tz, comments)
/usr/lib/python2.6/site-packages/scdate/core/zonetab.py:227: RuntimeWarning: Untranslated time zone: America/Lower Princes
entry = ZoneTabEntry (code, lat, long, tz, comments)
/usr/lib/python2.6/site-packages/scdate/core/zonetab.py:227: RuntimeWarning: Untranslated time zone: America/North Dakota/Beulah
entry = ZoneTabEntry (code, lat, long, tz, comments)
/usr/lib/python2.6/site-packages/scdate/core/zonetab.py:227: RuntimeWarning: Untranslated time zone: America/Sitka
entry = ZoneTabEntry (code, lat, long, tz, comments)
/usr/lib/python2.6/site-packages/scdate/core/zonetab.py:227: RuntimeWarning: Untranslated time zone: America/Metlakatla
entry = ZoneTabEntry (code, lat, long, tz, comments)
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* epel: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
Package ibus-table-cangjie is obsoleted by ibus-table-chinese-cangjie, trying to install ibus-table-chinese-cangjie-1.4.6-1.el6.noarch instead
Package ibus-table-erbi is obsoleted by ibus-table-chinese-erbi, trying to install ibus-table-chinese-erbi-1.4.6-1.el6.noarch instead
Package ibus-table-wubi is obsoleted by ibus-table-chinese-wubi-jidian, trying to install ibus-table-chinese-wubi-jidian-1.4.6-1.el6.noarch instead
/usr/share/system-config-kickstart/kickstartGui.py:220: GtkWarning: Attempting to store changes into `/root/.local/share/recently-used.xbel‘, but failed: 创建文件“/root/.local/share/recently-used.xbel.QX5TNY”失败:没有那个文件或目录
gtk.main()
/usr/share/system-config-kickstart/kickstartGui.py:220: GtkWarning: Attempting to set the permissionsof `/root/.local/share/recently-used.xbel‘, but failed: 没有那个文件或目录
gtk.main()
/usr/share/system-config-kickstart/kickstartGui.py:220: GtkWarning: Attempting to store changes into `/root/.local/share/recently-used.xbel‘, but failed: 创建文件“/root/.local/share/recently-used.xbel.AKEMNY”失败:没有那个文件或目录
gtk.main()
/tmp/tmpxEPXnu/var/lib/rpm: 没有那个文件或目录

#####################################################
#####################################################
#####################################################
3. 安装vsftp 并配置安装环境
拷贝ks.cfg
挂载光盘镜像到/var/ftp/pub目录下,并设置开机自动挂在

安装vsftpd服务
yum -y install vsftpd

cp ks.cfg /var/ftp/.
echo "/dev/sr0 /var/ftp/pub iso9660 defaults 0 0" >> /etc/fstab
mount /var/ftp/pub

[root@xiaogan120 ~]# chkconfig vsftpd on
[root@xiaogan120 ~]# chkconfig --list vsftpd
[root@xiaogan120 ~]# service vsftpd start

#####################################################
#####################################################
#####################################################
4. 安装tftp 并配置安装环境
拷贝光盘启动PXE引导文件
pxelinux.cfg/

yum -y install tftp tftp-server # xinetd 依赖安装

配置TFTP服务,tftp依赖xinetd管理
[root@xiaogan120 ~]# vim /etc/xinetd.d/tftp

service tftp
{
socket_type = dgram
protocol = udp
wait = yes
user = root
server = /usr/sbin/in.tftpd
server_args = -s /tftpboot # 修改共享目录/tftpboot
disable = no # 原为yes,默认不启动,改为no
per_source = 11
cps = 100 2
flags = IPv4
}

mkdir -p /tftpboot/pxelinux.cfg

cp /mnt/isolinux/isolinux.cfg /tftpboot/pxelinux.cfg/default
cp /mnt/images/pxeboot/initrd.img /tftpboot/
cp /mnt/images/pxeboot/vmlinuz /tftpboot/
cp /usr/share/syslinux/pxelinux.0 /tftpboot/
# 安装system-config-kickstart后,才会生成pxelinux-0文件
# rpm -qf /usr/share/syslinux/pxelinux.0
# ---> syslinux-nonlinux-4.04-3.el6.noarch

ls -lR /tftpboot/
/tftpboot/:
total 43936
-r--r--r-- 1 root root 40688737 Sep 14 08:17 initrd.img
-rw-r--r-- 1 root root 26759 Sep 14 08:17 pxelinux.0
drwxr-xr-x 2 root root 4096 Sep 14 08:17 pxelinux.cfg
-r-xr-xr-x 1 root root 4264528 Sep 14 08:17 vmlinuz
/tftpboot/pxelinux.cfg:
total 4
-r--r--r-- 1 root root 923 Sep 14 08:17 default

chmod 644 /tftpboot/pxelinux.cfg/default
vim /tftpboot/pxelinux.cfg/default
修改Line 1 如下:
default linux
修改line 22 如下:
append initrd=initrd.img ks=ftp://192.168.120.1/ks.cfg

chkconfig xinetd on
chkconfig --list xinetd
chkconfig --list tftp
/etc/init.d/xinetd start
service xinetd start

#####################################################
#####################################################
#####################################################
5. 安装dhcp 并配置安装环境
配置dhcpd服务器,本机网卡IP地址与上设置相符192.168.120.1
并设置下一跳 192.168.120.1 pxelinux.0

yum -y install dhcp

mv /etc/dhcp/dhcpd.conf /etc/dhcp/dhcpd.conf.bak
cp /usr/share/doc/dhcp-4.1.1/dhcpd.conf.sample /etc/dhcp/dhcpd.conf
vim /etc/dhcp/dhcpd.conf
最终配置文件修改如下:
# dhcpd.conf
# Use this to send dhcp log messages to a different log file (you also
# have to hack syslog.conf to complete the redirection).
log-facility local7;

# A slightly different configuration for an internal subnet.
subnet 192.168.120.0 netmask 255.255.255.0 {
range 192.168.120.100 192.168.120.200;
option domain-name-servers 192.168.120.1;
option domain-name "xiaogan.org";
option routers 192.168.120.1;
option broadcast-address 192.168.120.255;
default-lease-time 600;
max-lease-time 7200;
next-server 192.168.120.1;
filename "pxelinux.0";
}

添加网卡,使用网络vmnet6,并配置网卡IP=192.168.120.1
vim /etc/sysconfig/network-scripts/ifcfg-eth1

DEVICE=eth1
TYPE=Ethernet
NM_CONTROLLED=yes
ONBOOT=yes
BOOTPROTO=static
IPADDR=192.168.120.1
NETMASK=255.255.255.0
GATEWAY=192.168.120.1
DNS1=8.8.8.8

/etc/init.d/network restart

chkconfig dhcpd on
chkconfig --list dhcpd
/etc/init.d/dhcpd start


#####################################################
#####################################################
#####################################################
6. 检查
网络环境测试:
ifconfig

服务运行状态及端口监听情况:
/etc/init.d/dhcpd status
/etc/init.d/xinetd status
/etc/init.d/vsftpd status

netstat -anlput | grep dhcpd
netstat -anlput | grep xinetd
netstat -anlput | grep vsftpd
lsof -i :69

# yum -y install lsof
# rpm -ivh /mnt/Packages/lsof-4.82-5.el6.x86_64.rpm

服务开机启动状态:
chkconfig --list dhcpd
chkconfig --list tftp
chkconfig --list xinetd
chkconfig --list vsftpd

下一跳地址及文件名称:
cat /etc/dhcp/dhcpd.conf

启动文件状态:
ls -lR /tftpboot

检查启动文件启动信息
cat /tftpboot/pxelinux.cfg/default
line 1 和 line 22

安装文件及应答文件状态:
cat /etc/fstab
df -lhT | grep pub
ls -l /var/ftp

检查应答文件中ftp地址
cat /var/ftp/ks.cfg

尝试使用tftp连接获取文件
chmod 777 /tftpboot
#####################################################
#####################################################
#####################################################
7. 配置新的虚拟机,并设置网络环境vmnet6,设置网络启动
# 在真实环境中,使用快速启动菜单选择启动项,即可!!!
# 由于使用虚拟机,设置BIOS 网络启动,所以在安装完成后,要及时停止,修改启动项为硬盘启动不然会无休止的重装系统!!!

 

2-8 无人值守安装服务器搭建 日志