二 yum的使用

pingrpm软件包的管理方式:
rpm命令管理:针对依赖包,rpm命令选择忽略(不安装);
使用步骤:
1.连接光盘,在系统中挂载光盘;
mount /dev/cdrom /mnt
2.使用rpm命令安装或者卸载;
安装: rpm -ivh /mnt/Packages/*.rpm --nodeps
卸载: rpm -e * --nodeps
yum命令管理:针对依赖包,yum命令采取与你所安装的安装的软件包一同安装;
使用步骤:
1.连接光盘,在系统中挂载光盘;
mount /dev/cdrom /mnt
2.将系统原有的yum配置文件删除(系统自带的yum源需要联网);
rm -rf /etc/yum.repos.d/*
3.手动编写yum的源配置文件(将源配置为镜像文件);
vi /etc/yum.repos.d/centos.repo
[local]
name=local
baseurl=file:///mnt
enable=1
gpgcheck=0
:wq
4.使用yum命令管理软件包;
安装:yum -y install 软件包名(Complete!出现此提示表示完成)
卸载:yum -y erase 软件包名

1.配置本地yum源;
2.为虚拟机添加桥接模式网卡;
3.ip a 虚拟机中查看;
4.编写eth1的网卡配置文件;
vi /etc/sysconfig/network-scripts/ifcfg-eth1
DEVICE=eth1
TYPE=Ethernet
ONBOOT=yes
NM_CONTROLLED=no
BOOTPROTO=dhcp
5.重启网络服务:
/etc/init.d/network restart
6.验证是否可以正常上网;
ping www.baidu.com
7.配置阿里的yum源;
[root@lwh ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
8.配置epel的yum源:
yum -y install epel-release
9.验证yum元是否配置完成;
ls /etc/yum.repos.d/
10.开启yum的缓存;
11.安装ntop软件包;yum clean all
yum -y install ntop


缓存后使用find /var/cache/yum -name "*.rpm"命令查看缓存下的软件包
若无缓存,使用ftp下载ntop软件包并上传到虚拟机的/ntop目录下;
挂载光盘,写yum配置配置文件,安装软件包creeterepo;
mount /dev/cdrom /mnt
rm -rf /etc/yum.repos.d/*
vi /etc/yum.repos.d/centos.repo
[local]
name=local
baseurl=file:///mnt
enable=1
gpgcheck=0
yum -y install createrepo
生成软件包的数据文件:createrepo -g /mnt/repodata/repomd.xml /ntop
验证数据文件的生成: ls /ntop
删除所有yum源文件:rm -rf /etc/yum.repos.d/*
编写yum配置文件,将软件包源位置设置为ntop;
vi /etc/yum.repos.d/centos.repo
[local]
name=local
baseurl=file:///ntop
enable=1
gpgcheck=0
安装ntop测试:yum -y install ntop
aready installed
搭建本地yum源仓库完成

原文地址:https://www.cnblogs.com/vilenx/p/12532684.html