目录
rpm与yum详解
rpm
1.rpm介绍
rpm软件包名称: 软件名称 版本号(主版本、次版本、修订号) 操作系统 -----90%的规律 #有依赖关系,不能自动解决依赖关系。 举例:openssh-6.6.1p1-31.el7.x86_64.rpm 数字前面的是名称 数字是版本号:第一位主版本号,第二位次版本号,带横杠的是修订号, el几---操作系统的版本。 noarch : 32位64位都支持 x86_64 : 64位 AMD64 ARM 苹果 鸿蒙 i4-686的包 :32位 devel:表示这个RPM包是软件的开发包; ====== #用rpm安装需要考虑如下信息: 1.需要考虑系统的版本需要与rpm对应 2.系统的架构:如32位还是64位 3.需要考虑依赖关系
2.rpm安装
语法 # rpm -ivh 软件包名称 -i install -vh verbose human -U upgrade 升级 查找rpm包的网站:http://rpmfind.net/ http://pkgs.org 1.通过rpm安装 可以先下载下来 [root@linux-server ~]# wget http://download-ib01.fedoraproject.org/pub/epel/7/x86_64/Packages/n/ntfs-3g-2017.3.23-11.el7.x86_64.rpm #wget下载命令 #wget -O 指定存放路径 [root@linux-server ~]# rpm -ivh ntfs-3g-2017.3.23-11.el7.x86_64.rpm #本地安装rpm包 2.直接通过连接安装rpm包 [root@linux-server ~]# rpm -ivh http://download-ib01.fedoraproject.org/pub/epel/7/x86_64/Packages/n/ntfs-3g-2017.3.23-11.el7.x86_64.rpm
3.选项及其用法
[root@localhost ~]#rpm -qa 查看系统中已安装的软件包 [root@localhost ~]#rpm -ql 查看软件包在系统中生成的所有文件 [root@localhost ~]#rpm -qc 查看软件包在系统中的配置文件 [root@localhost ~]#rpm -qf 查看系统中的某一文件是由哪一软件包生成的 [root@localhost ~]#rpm -ivh 安装软件包 [root@localhost ~]#rpm -ivh IP地址 远程安装软件包 [root@localhost ~]#rpm -Uvh 更新软件包 [root@localhost ~]#rpm -e 卸载软件包 选项详解 -q query -l list -f file -a all -c config -e erase
rpm工具管理软件包总结: 1. 很难解决包依赖关系 2. 如果某个文件没有,很难知道它由哪个rpm包提供
yum管理
yum介绍
#可以自动解决rpm软件依赖关系,虽然是通过yum安装的但是最后执行的还是rpm,也就是说没有rpm命令yum也就不能用了。 分类:本地yum和远程yum 本地yum: file:// 远程yum: http:// ftp://
yum操作
yum -y install 软件名 安装软件包 yum -y reinstall 软件名 重新安装 yum -y localinstall 本地安装 yum clean all 清除以前缓存源 yum makecache fast 生成自己的缓存源 yum repolist 列出yum仓库 yum provides 查看某条命令属于哪个软件 yum update 更新软件包 所有软件包已安装和未安装都更新 yum upgrade 更新软件包 只更新已安装的软件包 yum serach 关键字 yum history 查看历史操作 yum history undo ID 删除 yum -remove 软件包 yum -erase 软件包
配置阿里云yum源
1.cd /etc/yum.reops.d 2.删除以前的yum源 rm -rf * 3.配置阿里云yum源 curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo(普通源) curl -o /etc/yum.repos.d/epel.repo https://mirrors.aliyun.com/repo/epel-7.repo(加强源) 4.清除yum源缓存 yum clean all 5.生成自己的yum源 yum makecacher fsat 6.列出yum源 yum repolist
通过镜像制作本地yum源
1.将镜像挂载到/mnt [root@localhost ~]#mount /dev/cdrom /mnt 2.制作yum源 [root@localhost ~]#cd /etc/yum.repos.d [root@localhost ~]#vim jingxiang.repo [jingxiang] name=jingxiang baseurl=file:///mnt enable=1 gpgcheck=0 3.清除yum缓存 [root@localhost ~]#yum clean all 4.生成自己的缓存 [root@localhost ~]#yum makecache fast 5.列出yum仓库 [root@localhost ~]#yum repolist
制作局域网yum源
#服务端配置 1.安装vsftpd [root@localhost ~]#yum -y install vsftpd 2.配置网络源 [root@localhost ~]#cd /etc/htp/pub [root@localhost ~]#curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo (基础源) [root@localhost ~]#curl -o /etc/yum.repos.d/epel.repo https://mirrors.aliyun.com/repo/epel-7.repo (扩展源) 3.重启vsftpd [root@localhost ~]#systemctl restart vsftpd 4.清除yum缓存 [root@localhost ~]#yum clean all 5.生成自己的yum缓存 [root@localhost ~]#yum makecache fast 6.列出yum仓库 [root@localhost ~]#yum repolist #客户端配置 1.[root@localhost ~]#cd /etc/yum.repos.d 2.配置服务端yum源 [root@localhost ~]#vim ftp.repo [ftp.repo] name=ftp.repo baseurl=ftp://服务端IP/pub enable=1 gpgcheck=0 3.清除yum缓存 [root@localhost ~]#yum clean all 4.生成自己的yum缓存 [root@localhost ~]#yum makecache fast 5.列出yum仓库 [root@localhost ~]#yum repolist
克隆yum源
在公司内网中,可能无法连接外部网络,这时需要我们将外部yum源中的包克隆到本地
在yum源服务器上
[root@linux-server ~]# curl -o /etc/yum.repos.d/myrepo.repo https://download.beyourself.org.cn/repo/centos7-repo && echo -e "10.36.172.9 package.qf.com package2.qf.com" >> /etc/hosts
[root@linux-server ~]# yum install -y yum-utils epel-release
[root@linux-server ~]# yum install -y nginx
[root@linux-server ~]# cd /usr/share/nginx/html
[root@linux-server ~]# rm -rf *
[root@linux-server ~]# reposync -r base -r epel -r extras -r updates 同步一部分
[root@linux-server ~]# createrepo base/
[root@linux-server ~]# createrepo epel/
[root@linux-server ~]# createrepo extras/
[root@linux-server ~]# createrepo updates/
[root@linux-server ~]# vim /etc/nginx/nginx.conf +43
location / {
root /usr/share/nginx/html;
autoindex on;
}
[root@linux-server ~]# systemctl restart nginx
在客户端
[root@linux-client ~]# vim /etc/yum.repos.d/myrepo.repo
[http-base-yum]
name=http-yum
baseurl=http://192.168.137.142/base
enabled=1
gpgcheck=0