简单的,暂时没时间整理
服务端配置:
开启本地缓存 ** ######****可有可无**
[root@hosue ~]# vim /etc/yum.conf
[root@m01 ~]# sed -i 's#keepcache=0#keepcache=1#g' /etc/yum.conf
[root@m01 ~]# sed -i '3c keepcache=1' /etc/yum.conf ç======三种方法取一即可
[main]
cachedir=/var/cache/yum/releasever
keepcache=1 ç****==========****本地缓存,1为开启,0为不开启,咱们这里选择打开
debuglevel=2
logfile=/var/log/yum.log
exactarch=1
obsoletes=1
gpgcheck=1
plugins=1
installonly_limit=5
bugtracker_url=http://bugs.centos.org/set_project.php?project_id=23&ref=http://bugs.
centos.org/bug_report_page.php?category=yum
distroverpkg=centos-release
本地缓存路径为****/****var/cache/yum/x86_64/7
只下载不安装的命令 ↓
yum install --downloadonly --downloaddir=/local_basic/ nfs-utils
--downloadonly 只下载不安装
--downloaddir 指定rpm包的下载路径
安装createrepo
yum install createrepo -y
参数
-u --baseurl <url> 指定Base URL的地址
-o --outputdir <url> 指定元数据的输出位置
-x --excludes <packages> 指定在形成元数据时需要排除的包
-i --pkglist <filename> 指定一个文件,该文件内的包信息将被包含在即将生成的元数据中,格式为每个包信息独占一行,不含通配符、正则,以及范围表达式。
-n --includepkg 通过命令行指定要纳入本地库中的包信息,需要提供URL或本地路径。
-q --quiet 安静模式执行操作,不输出任何信息。
-g --groupfile <groupfile> 指定本地软件仓库的组划分,范例如下:
createrepo -g comps.xml /path/to/rpms注意:组文件需要和rpm包放置于同一路径下。
-v --verbose 输出详细信息。
-c --cachedir <path>指定一个目录,用作存放软件仓库中软件包的校验和信息。当createrepo在未发生明显改变的相同仓库文件上持续多次运行时,指定cachedir会明显提高其性能。
--update 如果元数据已经存在,且软件仓库中只有部分软件发生了改变或增减,则可用update参数直接对原有元数据进行升级,效率比重新分析rpm包依赖并生成新的元数据要高很多。
-p --pretty 以整洁的格式输出xml文件。
-d --database 该选项指定使用SQLite来存储生成的元数据,默认项。
给服务端缓存文件生成索引
[root@hosue /]# createrepo /local_basic/ 生成索引文件
Saving Primary metadata
Saving file lists metadata
Saving other metadata
Generating sqlite DBs
Sqlite DBs complete
每次加入rpm包需要执行下面命令
createrepo --update /local-basic/
通过http协议访问
[root@yumcangku /]# yum install nginx -y
[root@yumcangku /]# cd /etc/nginx/conf.d/
[root@yumcangku /]# vim local_basic.conf
server {
listen 12345;
server_name 10.0.0.68; ç================本机IP
root /local_basic;
index index.html;
location / {
root /local_basic;
autoindex on;
autoindex_localtime on;
autoindex_exact_size off;
}
}
写完记着启动nginx
效果图如下:
[图片上传失败...(image-9423f8-1557890526710)]
客户端配置:
1.首先打包/erc/yum.repo.d/下面的原有源也可以通过优先级设置,稍后说优先级
2.创建一个本地源local_basic.repo
[local-base]
name=Server
baseurl=http://10.0.0.68:12345
enable=1
gpgcheck=0 检查0关闭就可以
清除yum缓存
yum clean all
执行此命令检查是否是从本地源找的包
yum provides nfs-utils
正确返回如下↓
[root@web03_64 /etc/yum.repos.d]# yum provides nfs-utils
Loaded plugins: fastestmirror
Determining fastest mirrors
local-base | 2.9 kB 00:00:00
local-base/primary_db | 14 kB 00:00:00
1:nfs-utils-1.3.0-0.61.el7.x86_64 : NFS utilities and supporting clients and daemons for the kernel NFS server
Repo : local-base
关于优先级设置
1.下载第三方插件
yum install yum-plugin-priorities.noarch
2.检查是否启动服务(默认是开启的)
cat /etc/yum/pluginconf.d/priorities.conf
[main]
enabled = 1
3.修改已有源的优先级
priority=1
local_basic.repo的修改
[local-base]
name=Server
baseurl=http://10.0.0.68:12345/
enable=1
gpgcheck=0
priority=1 1则为优先级最高
~
CentOS-Base.repo的修改
CentOS-Base.repo
The mirror system uses the connecting IP address of the client and the
update status of each mirror to pick mirrors that are updated to and
geographically close to the client. You should use this for CentOS updates
unless you are manually picking other mirrors.
If the mirrorlist= does not work for you, as a fall back you can try the
remarked out baseurl= line instead.
[base]
name=CentOS-$releasever - Base - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/basearch/
http://mirrors.aliyuncs.com/centos/$releasever/os/$basearch/
http://mirrors.cloud.aliyuncs.com/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
priority=2 <ç================
released updates
[updates]
name=CentOS-$releasever - Updates - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/basearch/
http://mirrors.aliyuncs.com/centos/$releasever/updates/$basearch/
http://mirrors.cloud.aliyuncs.com/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
priority=2 <ç================
additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/basearch/
http://mirrors.aliyuncs.com/centos/$releasever/extras/$basearch/
http://mirrors.cloud.aliyuncs.com/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
priority=2 <ç================
additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/basearch/
http://mirrors.aliyuncs.com/centos/$releasever/centosplus/$basearch/
http://mirrors.cloud.aliyuncs.com/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
priority=2 <ç================
contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/basearch/
http://mirrors.aliyuncs.com/centos/$releasever/contrib/$basearch/
http://mirrors.cloud.aliyuncs.com/centos/$releasever/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
priority=2 <ç================