<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>服务器安全维护工作室 &#187; 基于Kickstart自动化安装CentOS教程</title>
	<atom:link href="https://www.fuwuqiok.com/tag/%e5%9f%ba%e4%ba%8ekickstart%e8%87%aa%e5%8a%a8%e5%8c%96%e5%ae%89%e8%a3%85centos%e6%95%99%e7%a8%8b/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.fuwuqiok.com</link>
	<description></description>
	<lastBuildDate>Sun, 01 Mar 2020 07:28:40 +0000</lastBuildDate>
	<language>zh-CN</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=4.2.26</generator>
	<item>
		<title>基于Kickstart自动化安装CentOS教程</title>
		<link>https://www.fuwuqiok.com/%e5%9f%ba%e4%ba%8ekickstart%e8%87%aa%e5%8a%a8%e5%8c%96%e5%ae%89%e8%a3%85centos%e6%95%99%e7%a8%8b/</link>
		<comments>https://www.fuwuqiok.com/%e5%9f%ba%e4%ba%8ekickstart%e8%87%aa%e5%8a%a8%e5%8c%96%e5%ae%89%e8%a3%85centos%e6%95%99%e7%a8%8b/#comments</comments>
		<pubDate>Sun, 23 Aug 2015 09:59:42 +0000</pubDate>
		<dc:creator><![CDATA[admin]]></dc:creator>
				<category><![CDATA[服务器迁移]]></category>
		<category><![CDATA[网站代维]]></category>
		<category><![CDATA[基于Kickstart自动化安装CentOS教程]]></category>

		<guid isPermaLink="false">https://www.fuwuqiok.com/?p=2682</guid>
		<description><![CDATA[<p>前言 因为一客户手上有60多台服务器，需要在浪潮的x86服务器中集中部署CentOS搭建基于Hadoop的大数 [&#8230;]</p>
<p><a rel="nofollow" href="https://www.fuwuqiok.com/%e5%9f%ba%e4%ba%8ekickstart%e8%87%aa%e5%8a%a8%e5%8c%96%e5%ae%89%e8%a3%85centos%e6%95%99%e7%a8%8b/">基于Kickstart自动化安装CentOS教程</a>，首发于<a rel="nofollow" href="https://www.fuwuqiok.com">服务器安全维护工作室</a>。</p>
]]></description>
				<content:encoded><![CDATA[<p>前言</p>
<p>因为一客户手上有60多台服务器，需要在浪潮的x86服务器中集中部署CentOS搭建基于Hadoop的大数据平台，这次主要通过 Kisckstart实现最简单的光盘方式自动化安装CentOS，而网上的大多数教程并不完全适用于自身的环境，本文将不再赘述Kickstart相关 概念，细节可参考扩展阅读。</p>
<blockquote><p>Kickstart是最为通用的Linux自动化安装方法之一</p></blockquote>
<h2 id="环境准备">环境准备</h2>
<h3 id="定制系统">定制系统</h3>
<blockquote><p>CentOS-6.4-x86_64</p></blockquote>
<p>官方下载地址 &#8211; <a href="http://wiki.centos.org/Download" target="_blank" rel="external">http://wiki.centos.org/Download</a></p>
<h3 id="安装软件包">安装软件包</h3>
<blockquote><p>代理上网小技巧，export http_proxy=ip:port</p>
<pre><span class="line">yum -y install createrepo mkisofs

</span></pre>
<h2 id="制作流程">制作流程</h2>
<h3>目录结构</h3>
<h3>拷贝CentOS原始镜像内容，不做任何精简</h3>
<pre><span class="line">mkdir /mnt/centos</span>
<span class="line">mount /dev/sr0 /mnt/centos</span>
<span class="line">mkdir /tmp/iso</span>
<span class="line">cp -r /mnt/centos/* /tmp/iso

</span></pre>
<h3 id="增加Kickstart配置文件">增加Kickstart配置文件</h3>
<blockquote><p>文件路径和安装方式可自由定义</p>
<pre><span class="line"><span class="built_in">cd</span> /tmp/iso/isolinux</span>
<span class="line"><span class="comment">#修改引导，注意ks=部分</span></span>
<span class="line">vi isolinux.cfg</span>

<span class="line">label linux</span>
<span class="line">  menu label ^Install or upgrade an existing system</span>
<span class="line">  menu default</span>
<span class="line">  kernel vmlinuz</span>
<span class="line">  append initrd=initrd.img ks=cdrom:/isolinux/ks.cfg</span>

<span class="line"><span class="comment">#手动增加Kickstart配置文件</span></span>
<span class="line">vi ks.cfg</span>


</pre>
<pre><span class="line"><span class="comment">#基于Kickstart自动化安装CentOS实践</span></span>
<span class="line"><span class="comment">#Kickstart file automatically generated by anaconda.</span></span>
<span class="line"><span class="comment">#version=DEVEL</span></span>

<span class="line"><span class="comment">#Install OS instead of upgrade</span></span>
<span class="line"><span class="comment">#表示是安装，而不是升级</span></span>
<span class="line">install</span>

<span class="line"><span class="comment">#Use text mode install</span></span>
<span class="line"><span class="comment">#文本方式安装 </span></span>
<span class="line">text</span>

<span class="line"><span class="comment">#Use network installation</span></span>
<span class="line"><span class="comment">#使用网络安装</span></span>
<span class="line"><span class="comment">#url --url=ftp://ip/centos</span></span>
<span class="line"><span class="comment">#Local installation Use CDROM installation media</span></span>
<span class="line"><span class="comment">#使用光盘安装 </span></span>
<span class="line">cdrom</span>

<span class="line"><span class="comment">#Installation Number configuration</span></span>
<span class="line"><span class="comment">#如果是RedHat的系统，会要求输入key，这里配置为跳过，如果不配置安装时会停在那里要求用户输入key</span></span>
<span class="line"><span class="comment">#key –skip</span></span>

<span class="line"><span class="comment">#System language</span></span>
<span class="line"><span class="comment">#语言环境</span></span>
<span class="line"><span class="comment">#lang en_US.UTF-8</span></span>
<span class="line">lang zh_CN.UTF-<span class="number">8</span></span>

<span class="line"><span class="comment">#System keyboard</span></span>
<span class="line"><span class="comment">#键盘类型</span></span>
<span class="line">keyboard us</span>

<span class="line"><span class="comment">#Network information</span></span>
<span class="line"><span class="comment">#网络配置</span></span>
<span class="line"><span class="comment">#network --device eth0 --bootproto dhcp --onboot yes</span></span>

<span class="line"><span class="comment">#Root password </span></span>
<span class="line"><span class="comment">#root密码</span></span>
<span class="line">rootpw chinaums</span>

<span class="line"><span class="comment">#Firewall configuration</span></span>
<span class="line"><span class="comment">#禁用防火墙</span></span>
<span class="line">firewall --disabled</span>

<span class="line"><span class="comment">#SELinux configuration </span></span>
<span class="line"><span class="comment">#禁用selinux</span></span>
<span class="line">selinux --disabled</span>

<span class="line"><span class="comment">#Run the Setup Agent on first boot</span></span>
<span class="line"><span class="comment">#禁用第一次启动时设置系统的向导</span></span>
<span class="line">firstboot --disable</span>

<span class="line"><span class="comment">#System authorization information</span></span>
<span class="line"><span class="comment">#用户认证配置，useshadow表示使用本地认证，--passalgo表示密码加密算法</span></span>
<span class="line">authconfig --enableshadow --passalgo=sha512</span>

<span class="line"><span class="comment">#System timezone </span></span>
<span class="line"><span class="comment">#设置时区为上海</span></span>
<span class="line">timezone --isUtc Asia/Shanghai</span>

<span class="line"><span class="comment">#System bootloader configuration</span></span>
<span class="line"><span class="comment">#指明bootloader的安装位置，指明驱动器的排序，指明操作系统安装完成之后，向内核传递的参数</span></span>
<span class="line">bootloader --location=mbr --driveorder=sda --append=<span class="string">"crashkernel=auto rhgb quiet"</span></span>

<span class="line"><span class="comment">#Clear the Master Boot Record</span></span>
<span class="line"><span class="comment">#清除MBR引导记录</span></span>
<span class="line">zerombr yes</span>

<span class="line"><span class="comment">#Partition clearing information</span></span>
<span class="line"><span class="comment">#清除硬盘上的所有数据</span></span>
<span class="line">clearpart --all --initlabel</span>

<span class="line"><span class="comment">#Disk partitioning information </span></span>
<span class="line"><span class="comment">#自定义分区</span></span>

<span class="line"><span class="comment">#创建一个200M大小的分区挂载/boot类型为ext4</span></span>
<span class="line">part /boot --fstype=ext4  --size=<span class="number">200</span> --ondisk=sda</span>

<span class="line"><span class="comment">#创建一个20000M大小的SWAP分区</span></span>
<span class="line">part swap --size=<span class="number">20000</span> --ondisk=sda</span>

<span class="line"><span class="comment">#创建/目录</span></span>
<span class="line">part / --fstype=ext4 --grow --size=<span class="number">1</span> --ondisk=sda</span>

<span class="line"><span class="comment">#Reboot after installation</span></span>
<span class="line"><span class="comment">#设置完成之后重启</span></span>
<span class="line">reboot --eject</span>

<span class="line"><span class="comment">#This packages is for CentOS 6.4</span></span>
<span class="line"><span class="comment">#为CentOS 6.4定制的软件包</span></span>
<span class="line">%packages</span>
<span class="line">@base</span>
<span class="line">@core</span>
<span class="line">@chinese-support</span>
<span class="line">@server-policy</span>
<span class="line">telnet</span>

<span class="line"><span class="comment">#增加安装后运行脚本  </span></span>
<span class="line">%post</span>
<span class="line"><span class="comment">#config service  </span></span>
<span class="line"><span class="comment">#自定义服务</span></span>
<span class="line">service NetworkManager stop</span>
<span class="line">chkconfig NetworkManager off</span>
<span class="line">service network restart</span>

<span class="line"><span class="comment">#eject cdrom</span></span>
<span class="line"><span class="comment">#安装完成弹出光碟  </span></span>
<span class="line"><span class="comment">#eject</span></span>

<span class="line"><span class="comment">#reboot</span></span>
<span class="line"><span class="comment">#执行完毕后重启  </span></span>
<span class="line"><span class="comment">#reboot -f  </span></span>

<span class="line"><span class="comment">#结束自动化部署</span></span>
<span class="line">%end</span></pre>
</blockquote>
<pre></pre>
<h3 id="生成依赖关系和ISO文件">生成依赖关系和ISO文件</h3>
<blockquote><p>注意路径和命令的准确性</p>
<figure class="highlight bash">
<table>
<tbody>
<tr>
<td class="code">
<pre><span class="line"><span class="built_in">cd</span> /tmp/iso</span>
<span class="line">createrepo -g repodata/*comps.xml . </span>
<span class="line">mkisofs -o /tmp/CentOS-<span class="number">6.4</span>_64_auto.iso -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size <span class="number">4</span> -boot-info-table  -joliet-long  -R -J -v -T /tmp/iso/</span></pre>
</td>
</tr>
</tbody>
</table>
</figure>
<h3 id="测试和建议">测试和建议</h3>
<blockquote><p>推荐两篇参考文献，建议先在虚拟机上反复测试验证再到物理机部署</p></blockquote>
<p>Linux Kickstart 自动安装 &#8211; <a href="http://liaoph.com/linux-kickstart/" target="_blank" rel="external">http://liaoph.com/linux-kickstart/</a><br />
Centos6.4定制自动化安装盘 &#8211; <a href="http://www.wpython.com/444.html" target="_blank" rel="external">http://www.wpython.com/444.html</a></p></blockquote>
</blockquote>
<p><a rel="nofollow" href="https://www.fuwuqiok.com/%e5%9f%ba%e4%ba%8ekickstart%e8%87%aa%e5%8a%a8%e5%8c%96%e5%ae%89%e8%a3%85centos%e6%95%99%e7%a8%8b/">基于Kickstart自动化安装CentOS教程</a>，首发于<a rel="nofollow" href="https://www.fuwuqiok.com">服务器安全维护工作室</a>。</p>
]]></content:encoded>
			<wfw:commentRss>https://www.fuwuqiok.com/%e5%9f%ba%e4%ba%8ekickstart%e8%87%aa%e5%8a%a8%e5%8c%96%e5%ae%89%e8%a3%85centos%e6%95%99%e7%a8%8b/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
