? ? yum是rpm的软件包管理工具,可以自动解决rpm软件依赖关系,虽然是通过yum安装的但是最后执行的还是rpm,也就是说没有rpm命令yum也就不能用了。
分类:本地yum和远程yum
本地yum:
file://
远程yum:
http://
ftp://
清理yum缓存:
?? ?yum clean all缓存软件包信息: ? ?
? ? 提高搜索/安装软件的速度
? ? yum makecache? ??
查询yum源信息: ??
? ?yum repolist ? ??? ??
查看命令属于哪个软件
? ??yum provides rz ? ?查看系统已经安装好的软件和没有安装的软件(源里存在即可查到):
?? ?yum list?? ?查看已安装的软件包
? ?yum list | grep @
查找软件包
? ?yum search telnet
安装本地rpm包
? ?yum localinstall
安装远程rpm包
? yum -y install 地址(http:)
安装软件:
? ? yum install 软件名称
?? ?yum install mysql mysql-server -y?? ??? ??? ?#-y跳过确认提示直接安装升级软件
? ? yum update 软件包
重装:
? ? yum -y reinstall 软件名 ? ? ? ?
卸载软件: 会把有关软件包的依赖包也卸载掉
?? ?yum erase ?mysql-server?
?? ?yum remove mysql-server?
?? ?yum -y remove mysql-server回滚
? ?yum history undo ID
? ? ?Linux安装完成后默认的是国外的yum源,下载速度缓慢,可以更换为国内的yum源,提高安装速度。=
阿里巴巴开源镜像站-OPSX镜像站-阿里云开发者社区 (aliyun.com)
1.进入/etc/yum.repos.d,转移备份原有内容
[root@localhost ~]# cd /etc/yum.repos.d
[root@localhost yum.repos.d]# mv CentOS-Base.repo CentOS-Base.repo.backup
[root@localhost yum.repos.d]# mv epel.repo epel.repo.backup
[root@localhost yum.repos.d]# mv epel-testing.repo epel-testing.repo.backup
2.下载新的 CentOS-Base.repo 到 /etc/yum.repos.d/
[root@localhost ~]# curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
3.下载新epel.repo 到/etc/yum.repos.d/
[root@localhost yum.repos.d]# wget -O /etc/yum.repos.d/epel.repo https://mirrors.aliyun.com/repo/epel-7.repo
4.清除yum缓存? ?yum clean all? ?yum makecache fast? 生成本地缓存
[root@shiyan yum.repos.d]# yum clean all
已加载插件:fastestmirror
正在清理软件源: base epel extras updates
Cleaning up list of fastest mirrors
5.查看yum源信息? ?
[root@shiyan yum.repos.d]# yum repolist
已加载插件:fastestmirror
Determining fastest mirrors
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
源标识 源名称 状态
base/7/x86_64 CentOS-7 - Base - mirrors.aliyun.co 10,072
epel/x86_64 Extra Packages for Enterprise Linux 13,770
extras/7/x86_64 CentOS-7 - Extras - mirrors.aliyun. 518
updates/7/x86_64 CentOS-7 - Updates - mirrors.aliyun 5,176
repolist: 29,536
? ? (1)切换映像文件
? ? ?(2)挂载光盘
[root@shiyan yum.repos.d]# mount /dev/cdrom /mnt
mount: /dev/sr0 写保护,将以只读方式挂载
? ? ?(3)编辑本地存储库的相关配置信息
[root@shiyan yum.repos.d]# vim jx.repo
[jx]
name=jx repo
baseurl=file:///mnt 挂载点
enabled=1 启用这个源
gpgcheck=0 不检查不校验
? ? ? (4)清除yum缓存
[root@shiyan yum.repos.d]# yum clean all
已加载插件:fastestmirror
正在清理软件源: base epel extras jx updates
Cleaning up list of fastest mirrors
? ? (5)重新生成缓存
[root@shiyan yum.repos.d]# yum makecache
已加载插件:fastestmirror
Determining fastest mirrors
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
base | 3.6 kB 00:00:00
epel | 4.7 kB 00:00:00
extras | 2.9 kB 00:00:00
jx | 3.6 kB 00:00:00
updates
元数据缓存已建立
? ? ?(6)查看yum源信息
[root@shiyan yum.repos.d]# yum repolist
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
源标识 源名称 状态
base/7/x86_64 CentOS-7 - Base - mirrors.aliyun.com 10,072
epel/x86_64 Extra Packages for Enterprise Linux 7 - x86_64 13,770
extras/7/x86_64 CentOS-7 - Extras - mirrors.aliyun.com 518
jx jx repo 4,070
updates/7/x86_64 CentOS-7 - Updates - mirrors.aliyun.com 5,176
repolist: 33,606
(1)关闭防火墙和selinux
systemctl stop firewalld
setenforce 0
(2)下载并开启vsftpd
vsftpd : ftp服务器软件
[root@shiyan yum.repos.d]# yum -y install vsftpd
[root@shiyan yum.repos.d]# systemctl start vsftpd
(3)进入/var/ftp 创建目录
[root@shiyan yum.repos.d]# cd /var/ftp
[root@shiyan ftp]# ls
pub
[root@shiyan ftp]# mkdir yum
(4)将/mnt/Package/* 下的软件包拷贝到/var/ftp/yum
[root@shiyan mnt]# cp /mnt/Packages/* /var/ftp/yum
[root@shiyan mnt]# cd /var/ftp/yum
[root@shiyan yum]# ll |wc -l
268
(5)安装createrepo
[root@shiyan yum.repos.d]# yum -y install createrepo
[root@shiyan yum.repos.d]# createrepo /var/ftp/yum
Spawning worker 0 with 267 pkgs
Workers Finished
Saving Primary metadata
Saving file lists metadata
Saving other metadata
Generating sqlite DBs
Sqlite DBs complete
主机:
编辑存储库信息
[root@shiyan yum.repos.d]# vim ftp.repo
[ftprepo]
name=ftprepo
baseurl=file:///var/ftp/yum
enabled=1
gpgcheck=0
[root@shiyan yum]# yum clean all
已加载插件:fastestmirror
正在清理软件源: base epel extras ftprepo jx updates
Cleaning up list of fastest mirrors
[root@shiyan yum.repos.d]# yum repolist
源标识 源名称 状态
base/7/x86_64 CentOS-7 - Base - mirrors.aliyun.com 10,072
epel/x86_64 Extra Packages for Enterprise Linux 7 - x86_64 13,770
extras/7/x86_64 CentOS-7 - Extras - mirrors.aliyun.com 518
ftprepo ftprepo 267
jx jx repo 4,070
updates/7/x86_64 CentOS-7 - Updates - mirrors.aliyun.com 5,176
repolist: 33,873
客户端:
编辑存储库相关信息
[root@zhangxiao yum.repos.d]# vim ftp.repo
[ftprepo]
name=ftprepoe
baseurl=ftp://192.168.142.138/yum
enabled=1
gpgcheck=0
[root@zhangxiao yum.repos.d]# yum clean all
已加载插件:fastestmirror, langpacks
正在清理软件源: ftprepo
Cleaning up list of fastest mirrors
Other repos take up 1.0 G of disk space (use --verbose for details)
[root@zhangxiao yum.repos.d]# yum repolist
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
源标识 源名称 状态
ftprepo ftprepoe 267
repolist: 267
#制作自己的yum源
安装完软件之后,软件不会被删除(默认安装完之后,不会保留安装包)
#打开yum缓存功能
进入vim /etc/yum.conf 修改下面keepcache的值为1,软件会被保存到cachedir指定的目录下
[root@shiyan ~]# vim /etc/yum.conf
[main]
cachedir=/var/cache/yum/$basearch/$releasever
keepcache=1 修改为1
debuglevel=2
logfile=/var/log/yum.log
exactarch=1
[root@shiyan packages]# yum -y install httpd
===========================================================
Package 架构 版本 源 大小
===========================================================
正在安装:
httpd x86_64 2.4.6-99.el7.centos.1 updates 2.7 M
事务概要
===========================================================
注意这里的源,安装后的软件包在这个源里
[root@shiyan packages]# cd /var/cache/yum/x86_64/7/updates/packages/ ##yum缓存仓库
[root@shiyan packages]# ls
httpd-2.4.6-99.el7.centos.1.x86_64.rpm
httpd-tools-2.4.6-99.el7.centos.1.x86_64.rpm
自己制作yum源
[root@shiyan ~]# mkdir /myyum (把rpm安装包放到此目录里面)
[root@shiyan ~]#cp /var/cache/yum/x86_64/7/base/packages/* /myyum/ #把用yum安装的软件包拷贝到目录下
[root@shiyan ~]# createrepo /myyum //此目录就可以作为yum源了。
[root@shiyan ~]# vim /etc/yum.repos.d/myyum.repo
[myyum]
name=myyum
baseurl=file:///myyum
enabled=1
gpgcheck=0
[root@shiyan ~]# yum repolist
服务机
vim /etc/yum.repos.d/local.repo
[base]
name=base
baseurl=http://package.qf.com/base
enabled=1
gpgcheck=0
[epel]
name=epel
baseurl=http://package.qf.com/epel
enabled=1
gpgcheck=0
[updates]
name=updates
baseurl=http://package.qf.com/updates
enabled=1
gpgcheck=0
[extras]
name=extras
baseurl=http://package.qf.com/extras
enabled=1
gpgcheck=0
yum clean all
yum repolist
yum -y install yum-utils nginx createrepo
cd /usr/share/nginx/html
rm -rf *
reposync -r base -r epel -r extras -r updates 克隆
createrepo base
createrepo epel
createrepo extras
createrepo updates
修改nginx的配置文件:
vim /etc/nginx/nginx.conf
location / {
root /usr/share/nginx/html;
index index.html index.htm index.php;
autoindex on;
}
nginx -t
systemctl restart nginx 重启nginx
客户机:
vim /etc/yum.repos.d/http.repo
[base]
name=base
baseurl=http://192.168.100.138/base
enabled=1
gpgcheck=0
[epel]
name=epel
baseurl=http://package.qf.com/epel
enabled=1
gpgcheck=0
[updates]
name=updates
baseurl=http://package.qf.com/updates
enabled=1
gpgcheck=0
[extras]
name=extras
baseurl=http://package.qf.com/extras
enabled=1
gpgcheck=0
yum clean all
yum repolist