软件包及yum仓库建设

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/weixin_43551152/article/details/83513467

软件包管理

程序包的来源
获取程序包的途径:
(1) 系统发版的光盘或官方的服务器
CentOS镜像:
https://www.centos.org/download/
http://mirrors.aliyun.com
http://mirrors.sohu.com
http://mirrors.163.com
(2) 项目官方站点
(3) 第三方组织:
Fedora-EPEL:
Extra Packages for Enterprise Linux
Rpmforge:RHEL推荐,包很全
搜索引擎:
http://pkgs.org
http://rpmfind.net
http://rpm.pbone.net
https://sourceforge.net/
(4) 自己制作
注意:第三方包建议要检查其合法性
来源合法性,程序包的完整性

[install-options]
--test: 测试安装,但不真正执行安装,即dry run模式
--nodeps:忽略依赖关系
--replacepkgs| replacefiles
--nosignature: 不检查来源合法性
--nodigest:不检查包完整性
--noscripts:不执行程序包脚本
%pre: 安装前脚本--nopre
%post: 安装后脚本--nopost
%preun: 卸载前脚本--nopreun
%postun: 卸载后脚本--nopostun

救援模式进入

getent +命令或者文件或者用户 看是否存在
例子 getent f1.txt 看f1是否存在

rpm -qpi 查询还未安装的包内的文件
rpm -qi  查询包的说信息
rpm -q +命令名字 查询命令版本号    
rpm -ql +tree  查询tree包里有什么文件
rpm -q tree &> /dev/null ||rpm -ivh /cdrom/Package/tree-1.6.0-10.el7.x86_64.rpm  查询tree软件是否安装,如果没有安装则安装文件 
rpm -e +软件名  卸载该软件
rpm -upgrade 升级,一般情况下不用升级,直接卸载老版本安装新版本
rpm --oldpackage 降级
rpm -ivh +软件 + --force  强制安装 
rpm -qa | wc -l  查询有多少个包

包校验

包来源合法性验正及完整性验证
完整性验证:SHA256
来源合法性验证:RSA
公钥加密
对称加密:加密、解密使用同一密钥
非对称加密:密钥是成对儿的
public key: 公钥,公开所有人
secret key: 私钥, 不能公开
导入所需要公钥

rpm -K|checksigrpmfile检查包的完整性和签名
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
CentOS 7发行版光盘提供:RPM-GPG-KEY-CentOS-7
rpm -qa“gpg-pubkey*”

查询CentOS-7的完整性和签名

cat /misc/cd/RPM-GPG-KEY-CentOS-7  获取centos7公钥
rpm --import /misc/cd/RPM-GPG-KEY-CentOS-7  导入公钥到系统
rpm -K +软件包 显示出pgp md5 ok 查询完整性和签名

YUM

常用命令

yum install remove list info search groupinstall grouplist groupremove  history 
yum clean all 

yum server
yum repo 仓库
包含*.rpm 包和 matadata 源数据(.rpm包需要的数据)
安装文件 yum install +包的名字,不用补全

yum仓库建设************基于httpd服务的客户端仓库

新建一台虚拟机作为仓库
进入虚拟机输入

cd /etc/yum.repo.d/
df      #查询光盘挂载位置
ls /misc/
ls /misc/cd  #触发光盘挂载到/misc/cd(神奇目录)
df 
mkdir bak   
mv *.repo bak/      备份原来的repo
ls      然后看文件夹repodata在哪个目录,就将其所在的目录作为repo的路径
ls /misc/cd 看到repodata在这个路径,就将/misc/cd作为repo的路径
vim base.repo
写入
[base]
name=aliyun  或者bendiyuan  名字随便
baseurl=file:///misc/cd/  (http://  https://  ftp://  file://)网络源用http,(如阿里 https://mirrors.aliyun.com/centos/7/os/x86_64/)(6.7通用版本阿里源https://mirrors.aliyun.com/centos/$releasever/$basearch )本地源用file  (******$releasever/$basearch***********$代表系统版本和架构)
gpgcheck=0                     忽略完整性检查
wq保存
repo本地包

yum仓库建设***********基于httpd服务的服务器仓库

yum install httpd
cd /var/www/html
yum -ql httpd|grep service
systemctl start httpd    #浏览器输入虚拟机IP地址测试服务器是否运行 http://192.168.221.129/
pwd 查询是否在/var/www/html
echo 浩哥在此! > index.html # http://192.168.221.129/ https://mirrors.tuna.tsinghua.edu.cn/centos/7/os/x86_64/ #使用清华源镜像
/var/www/html
/var/www/html/centos/7/os/x86_64/
/var/www/html/centos/6/os/x86_64/
mkdir -pv centos/{6,7}/os/x86_64/  #创建目录
 #在浏览器输入http://192.168.221.129/centos/  即可看到和清华源镜像一样的目录结构
mount /dev/sr0 /var/www/html/centos/7/os/x86_64/
进入http://192.168.221.129/centos/7/os/x86_64/  #可看到光盘镜像已上传
vim /etc/yum.repos.d/base.repo
写入
[base]
name=centos
baseurl=file:///misc/cd/
#baseurl=http://192.168.221.129/centos/7/os/x86_6    IP地址非固定
gpgcheck=0
[epel]
name=EPEL
baseurl=https://mirrors.aliyun.com/centos/$releasever/$basearchl
gpgcheck=0
enabled=0
输入wq保存
yum repolist
yum clean all
systemctl start httpd 启动服务

yum remove + 安装包的名称 卸载包
yum repolist 列出仓库列表
yum grouplist 查询包组
常用包组Development tools
yum groupinstall "Development tools"安装包组
卸载多余网卡

猜你喜欢

转载自blog.csdn.net/weixin_43551152/article/details/83513467
今日推荐