《LINUX教程:搭建CnetOS6.5 x64最小化系统及在线yum源的配置》要点:
本文介绍了LINUX教程:搭建CnetOS6.5 x64最小化系统及在线yum源的配置,希望对您有用。如果有疑问,可以联系我们。
CentOS系统作为红帽系列的一款linux系统,因为其免费、开源,在中小企业中得到了广泛应用,生产上为了更好的利用资源,都采用最小系统安装,因为一个图形界面都会占去系统资源的30%到40%,生产上一般都是最经济原则,不装图形界面,软件也是必要什么装什么,一般通过ssh连接或者xshell连接即可.本文从以下四个方面给出了CentOS系统的最小化安装及在线yum源的配置.
大纲:
一、搭建CnetOS6.5x64最小化系统.
二、ip,主机名等的相关配置.
三、当地和在线yum源的配置.
四、快照及克隆.
看图,一步一步来即可
硬盘年夜小20G 足够用了, 即使后续不够可,可以再添加硬盘,做成磁盘阵列也是可以的.
单个磁盘文件比多个文件好些,如果禁绝备移动,那么就用单个磁盘文件.
2. 启动虚拟机:安装最小体系.
这个地方简单说明一下:如果你在安装的时候,忘记选择某些soft repositories ,好比说:“Develop tools” 这个repository忘记安装了,
或者你后续还想安装别的的repositories,那么可以用yum group list 看一下:
[root@xiaolyu ~]# yum grouplist Loaded plugins: fastestmirror, security Setting up Group Process Loading mirror speeds from cached hostfile * base: mirrors.aliyun.com * epel: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com Installed Groups: Base E-mail server Graphical Administration Tools Hardware monitoring utilities Legacy UNIX compatibility Networking Tools Performance Tools Perl Support Security Tools System administration tools Available Groups: Additional Development Backup Client Backup Server CIFS file server Client management tools Compatibility libraries Console internet tools Debugging Tools Desktop Desktop Debugging and Performance Tools Desktop Platform Desktop Platform Development Development tools Dial-up Networking Support Directory Client Directory Server Eclipse Emacs FCoE Storage Client FTP server Fonts General Purpose Desktop Graphics Creation Tools Guest Agents High Availability High Availability Management Identity Management Server Infiniband Support Input Methods Internet Applications Internet Browser Java Platform KDE Desktop Large Systems Performance Legacy X Window System compatibility Load Balancer Mainframe Access Messaging Client Support MySQL Database client MySQL Database server NFS file server Network Infrastructure Server Network Storage Server Network file system client Office Suite and Productivity PHP Support PostgreSQL Database client PostgreSQL Database server Print Server Printing client Remote Desktop Clients Resilient Storage Ruby Support SNMP Support Scalable Filesystems Scientific support Server Platform Server Platform Development Smart card support Storage Availability Tools System Management TeX support Technical Writing TurboGears application framework Virtualization Virtualization Client Virtualization Platform Virtualization Tools Web Server Web Servlet Engine Web-Based Enterprise Management X Window System iSCSI Storage Client Available Language Groups: Afrikaans Support [af] Albanian Support [sq] Amazigh Support [ber] Arabic Support [ar] Armenian Support [hy] Assamese Support [as] Azerbaijani Support [az] Basque Support [eu] Belarusian Support [be] Bengali Support [bn] Bhutanese Support [dz] Brazilian Portuguese Support [pt_BR] Breton Support [br] Bulgarian Support [bg] Catalan Support [ca] Chhattisgarhi Support [hne] Chichewa Support [ny] Chinese Support [zh] Coptic Support [cop] Croatian Support [hr] Czech Support [cs] Danish Support [da] Dutch Support [nl] English (UK) Support [en_GB] Esperanto Support [eo] Estonian Support [et] Ethiopic Support [am] Faroese Support [fo] Fijian Support [fj] Filipino Support [fil] Finnish Support [fi] French Support [fr] Frisian Support [fy] Friulian Support [fur] Gaelic Support [gd] Galician Support [gl] Georgian Support [ka] German Support [de] Greek Support [el] Gujarati Support [gu] Hebrew Support [he] Hiligaynon Support [hil] Hindi Support [hi] Hungarian Support [hu] Icelandic Support [is] Indonesian Support [id] Interlingua Support [ia] Inuktitut Support [iu] Irish Support [ga] Italian Support [it] Japanese Support [ja] Kannada Support [kn] Kashmiri Support [ks] Kashubian Support [csb] Kazakh Support [kk] Khmer Support [km] Kinyarwanda Support [rw] Konkani Support [kok] Korean Support [ko] Kurdish Support [ku] Lao Support [lo] Latin Support [la] Latvian Support [lv] Lithuanian Support [lt] Low Saxon Support [nds] Luxembourgish Support [lb] Macedonian Support [mk] Maithili Support [mai] Malagasy Support [mg] Malay Support [ms] Malayalam Support [ml] Maltese Support [mt] Manx Support [gv] Maori Support [mi] Marathi Support [mr] Mongolian Support [mn] Myanmar (Burmese) Support [my] Nepali Support [ne] Northern Sotho Support [nso] Norwegian Support [nb] Occitan Support [oc] Oriya Support [or] Persian Support [fa] Polish Support [pl] Portuguese Support [pt] Punjabi Support [pa] Romanian Support [ro] Russian Support [ru] Sanskrit Support [sa] Sardinian Support [sc] Serbian Support [sr] Sindhi Support [sd] Sinhala Support [si] Slovak Support [sk] Slovenian Support [sl] Somali Support [so] Southern Ndebele Support [nr] Southern Sotho Support [st] Spanish Support [es] Swahili Support [sw] Swati Support [ss] Swedish Support [sv] Tagalog Support [tl] Tajik Support [tg] Tamil Support [ta] Telugu Support [te] Tetum Support [tet] Thai Support [th] Tibetan Support [bo] Tsonga Support [ts] Tswana Support [tn] Turkish Support [tr] Turkmen Support [tk] Ukrainian Support [uk] Upper Sorbian Support [hsb] Urdu Support [ur] Uzbek Support [uz] Venda Support [ve] Vietnamese Support [vi] Walloon Support [wa] Welsh Support [cy] Xhosa Support [xh] Zulu Support [zu] Done
找到你希望装的软件组,好比:“Develop tools”, yum groupinstall "Develop tools".
假如不想用这个软件组了,可以yum groupremove "Develop tools";
当然了,如果yum源都没有,那么一切都白费,所以后续会讲到yum源的配置.
正在安装:
第二步、ip,主机名等的相关设置装备摆设.
1. 先设置ip,便利进行xshell的连接和后续的在线yum源的安装.
这里采纳桥接模式:
在vmware上【edit】-> 【virtual network edit】按下图设置即可.
在我新装的虚拟机上右键【setting】按下图设置即可.
改动ip地址的配置文件. vi /etc/sysconfig/network-scripts/ifcfg-eth0
然后重启服务: service network restart
看一下本机地址:ifconfig
看一下:宿主机的ip地址:
然后ping 一下宿主机的ip地址和百度的网址测试一下表里网是否相通:
ping 192.168.31.160
ping www.baidu.com
因为表里网已经通了,可以连接xshell了,后续的操作便在xshell中进行:
2. 清空iptables
1)iptables -F 清空iptables的相关配置,然后保留该配置文件.我们可以man iptables查看iptales的相关命令.这里不展开.
2)直接封闭iptables 的开机自启动.
我们知道rhel6只要是服务,都可以通过chkconfig service-name off 来封闭开机自启动.
iptables作为可执行文件,在/etc/init.d的目录下,当然可以啦.一般在该目录下都是服务,而不是一般的应用法式.
chkconfig iptables off
2. 封闭selinux服务.
1)查看selinux服务:
2)封闭selinux.修改配置文件.
vi /etc/sysconfig/selinux
检验是selinux是否被关闭,必要重启系统:reboot.
如果只是临时封闭selinux ,可以执行命令setenforce 0.
reboot 之后是这个样子:
3. 主机名的修改以及与ip之间映射配置文件阐明
#hostname xxx 命令可以临时修改机器名,但机器重新启动之后就会恢复本来的值.
#hostname 查看主机名
#hostname -i 查看本机械名对应的ip地址
vim /etc/hosts 这个文件,便是我们通常配置主机名,和主机名与ip之间映射的地方.
一般情况下hosts的内容关于主机名(hostname)的界说,每行为一个主机,每行由三部份组成,每个部份由空格隔开.
下面是我的配置文件:
把这上面这个配置文件的内容分别写入每台机器的/etc/hosts内容中,这样这两台局域网的机器就可以通过hostname来拜访了.后面的服务ssh 远程登录就用到了主机名和ip地址的映射.
hostname -i 查看本机主机名和ip地址的对应关系.
当然每行也可以是两部份,便是主机IP地址和主机名;例如 192.168.31.76 xiaolyu76
127.0.0.1 是回环地址,好比我们不想让局域网的其它机器看到我们测试的网络程序,就可以用回环地址来测试.
为什么必要定义ip与主机名的映射呢?
其实理解也简单,好比我们有三台主机,每台做不同的事,一台做MAIL服务器,一台做FTP服务器,一台做SMB服务器,所以我们就可以这样来设计hostname;
改动主机名,改动成你喜欢的主机名.
vi /etc/sysconfig/network
如果想临时改动一下主机名,可以这样:hostname host-name
RedHat系列的linux,包括Fedora和CentOS,安装软件,最常用的无外乎:yum安装和rpm安装.
yum软件安装,因为不必要依赖包,以及不必指出具体的软件版本,安装起来极为方便,因此得到了广泛的应用.
1. 当地yum源的配置:
因为当地的yum源,就是我们的iso镜像系统中的软件包,因此,需要先挂在ISO镜像文件,也即:/dev/sr0.
配置当地yum源:
阐明:yum源的文件名以repo为后缀,这是linux中为数不多的区分后缀名的例子.
配置当地yum源后,需要先清空yun 缓存: yum clean all
然后天生yum列表: yum list
来我们来试试,用yum安装一下vim : yum install -y vim // -y 取消交互式安装,不消提示.
2. 在线yum源的设置装备摆设:
centos是不需要注册的,所以可以获取在线yum源,当然了,rhel6也可以通过获取centos的在线yun源来配置本身的yum源.
为了便于资料保存,这里给出了CentOS5,6,7的在线yum源的配置办法.
设置装备摆设网络yum源
阿里云镜像源站点(http://mirrors.aliyun.com/).
centos镜像参考:http://mirrors.aliyun.com/help/centos
网易163开源镜像网站:(http://mirrors.163.com/)
CentOS镜像参考:http://mirrors.163.com/.help/centos.html
中科年夜开源镜像网站:http://centos.ustc.edu.cn/
搜狐的Linux安装镜像源:http://mirrors.sohu.com/
北京都城在线科技:http://mirrors.yun-idc.com/
上面的几个国内的开源镜像网站,一般前两个就可以了,当然了,最好的办法是不同的linux虚拟机配置不同的在线yum源,通过比较最终选择自己最满意的yum源.
操作完全一样.
1)、备份
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
2)、下载新的CentOS-Base.repo 到/etc/yum.repos.d/
CentOS 5
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-5.repo
CentOS 6
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
CentOS 7
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
3)、之后运行yum makecache天生缓存.
rhel 网络yum源的设置装备摆设:
RHEL系统设置装备摆设:
yum clean all
yum list
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
sed -i 's/$releasever/6.7/g' /etc/yum.repos.d/CentOS-Base.repo
yum clean all
yum list
3. 扩大yum源:epel源的配置:
设置装备摆设epel源:
设置装备摆设参考:http://mirrors.aliyun.com/help/epel
Epel
1、备份(如有设置装备摆设其他epel源)
mv /etc/yum.repos.d/epel.repo /etc/yum.repos.d/epel.repo.backup
mv /etc/yum.repos.d/epel-testing.repo /etc/yum.repos.d/epel-testing.repo.backup
2、下载新repo 到/etc/yum.repos.d/
epel(RHEL 7)
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
epel(RHEL 6)
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo
epel(RHEL 5)
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-5.repo
更多详情见请继续阅读下一页的出色内容:
_baidu_page_break_tag_当配置在线yum源成功后,进行yum clean all之后,用yum makecache生成yum缓存时,报如下差错:
[root@xiaolyu11 network-scripts]# yum makecache Loaded plugins: fastestmirror, security Determining fastest mirrors * base: mirrors.aliyun.com * epel: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com http://mirrors.aliyun.com/CentOS/6/os/x86_64/repodata/repomd.xml: [Errno 12] Timeout on http://mirrors.aliyun.com/centos/6/os/x86_64/repodata/repomd.xml: (28, 'Connection time-out') Trying other mirror. http://mirrors.aliyuncs.com/centos/6/os/x86_64/repodata/repomd.xml: [Errno 12] Timeout on http://mirrors.aliyuncs.com/centos/6/os/x86_64/repodata/repomd.xml: (28, 'connect() timed out!') Trying other mirror. Error: Cannot retrieve repository metadata (repomd.xml) for repository: base. Please verify its path and try again [root@xiaolyu11 network-scripts]#
解决办法:
1. 改动DNS.添加辅助dns.
也就是ifcfg-eth0末尾添加两行DNS配置,如果本来有8.8.8.8,那么也一定要加上8.8.4.4,这两个地址是google提供的免费DNS服务器的IP地址.
2. 重启network 服务
[root@xiaolyu11 network-scripts]# vim /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
TYPE=Ethernet
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=static
IPADDR=192.168.31.11
NETMASK=255.255.255.0
GETWAY=192.168.31.1
DNS1=8.8.8.8
DNS2=8.8.4.4
ARPCHECK=no
网卡配置文件末端添加:ARPCHECK=no
再次重启收集服务:
3. yum makecache,胜利:
[root@xiaolyu11 network-scripts]# yum makecache Loaded plugins: fastestmirror, security Loading mirror speeds from cached hostfile * base: mirrors.aliyun.com * epel: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com base | 3.7 kB 00:00 base/group_gz | 226 kB 00:00 base/filelists_db | 6.4 MB 00:06 base/primary_db | 4.7 MB 00:04
如果在配置在线yum源的过程中,也呈现关于镜像地址问题,尤其是宿主机和虚拟机可以通信,虚拟机又可以ping www.baidu.com通常的情况下,
请依照上面的方面进行解决.
说明快照和克隆,必需在虚拟机中,不能在xshell中进行.
1. 快照:
快照比拟简单,这里不详细描述.
2. 克隆:
首先说明:要克隆一个虚拟机,必需是在虚拟机关机的情况下才可以克隆,所以克隆一个虚拟机之前,应该先将该虚拟机关机.
在VMware中选择->【VM】->【Manage】->【clone】:
进入如下界面:
克隆完成后,必要做的相关工作:
1)开机运行虚拟机,vim /etc/sysconfig/network-scripts/ifcfg-eth0
删掉mac地址和uuid,不然的话和我本来的机器一模一样,这个克隆机还是不能用.下次重启的时候会自动生成新的mac地址和uuid.
如果有ip地址,ip地址也要改动.
我这里暂时还没有做集群,所以主机名,这里就不修改了.修改办法见上面.
原设置装备摆设文件:
改动后的配置文件:
2)删失落网卡.
rm-rf /etc/udev/rules.d/70-persistent-net.rules
重启体系:reboot
有一点:我也很奇怪:便是为什么配置文件中没有mac地址和uuid呢?
vim /etc/sysconfig/network-scripts/ifcfg-eth0
本文永远更新链接地址:
更多LINUX教程,尽在维易PHP学院专栏。欢迎交流《LINUX教程:搭建CnetOS6.5 x64最小化系统及在线yum源的配置》!