yum仓库配置与内网源部署记录
使用yum的好处主要就是在于能够自动解决软件包之间的依赖、这使得维护更加容易、这篇文章主要就是记录部署内网源的操作过程以及yum工具如何使用
因为需要、数据库要从Oracle迁移至MySQL、在部署MySQL的时候也是内网、所以这里就需要解决源码编译MySQL时安装依赖包的工作、下面为操作过程
在yum中软件仓库的发布方式有多种、其中包括:
FTP服务 :ftp://...... HTTP服务:http://...... 本地目录 :file://......
一、服务端配置
1)准备软件仓库目录
提示:第一个目录为使用HTTP形式发布、第二个目录为使用FTP形式发布
[root@vpn ~]# mkdir /opt/yum/ [root@vpn ~]# mkdir -p /opt/yum/http/7 [root@vpn ~]# mkdir -p /opt/yum/ftp/7
2)将软件包复制到对应的发布目录
注意:因为VPN服务器带宽有限、所以这里我没有下载镜像、而是使用上传到VPN服务器的软件包进行制作
[root@vpn ~]# cp /data/soft/*.rpm /opt/yum/http/7/ [root@vpn ~]# ls -lh /opt/yum/http/7/ | wc -l 3972 [root@vpn ~]# cp /data/soft/*.rpm /opt/yum/ftp/7/ [root@vpn ~]# ls -lh /opt/yum/ftp/7/ | wc -l 3972
3)使用createrepo工具创建仓库
[root@vpn ~]# yum -y install createrepo | tail -7 正在安装 : createrepo-0.9.9-28.el7.noarch 1/1 验证中 : createrepo-0.9.9-28.el7.noarch 1/1 已安装: createrepo.noarch 0:0.9.9-28.el7 完毕! [root@vpn ~]# createrepo /opt/yum/http/7/ Spawning worker 0 with 3971 pkgs Workers Finished Saving Primary metadata Saving file lists metadata Saving other metadata Generating sqlite DBs Sqlite DBs complete [root@vpn ~]# createrepo /opt/yum/ftp/7/ Spawning worker 0 with 3971 pkgs Workers Finished Saving Primary metadata Saving file lists metadata Saving other metadata Generating sqlite DBs Sqlite DBs complete [root@vpn ~]# ls -lh /opt/yum/http/7/ | grep repodata drwxr-xr-x 2 root root 4.0K 12月 19 17:00 repodata [root@vpn ~]# ls -lh /opt/yum/ftp/7/ | grep repodata drwxr-xr-x 2 root root 4.0K 12月 19 17:06 repodata
4)部署Nginx、使用HTTP形式进行发布
1、下载并安装Nginx
[root@vpn ~]# useradd -M -s /sbin/nologin nginx [root@vpn ~]# yum -y install pcre pcre-devel zlib zlib-devel ncurses ncurses-devel gcc gcc-c++ [root@vpn ~]# wget -c www.nginx.org/download/nginx-1.16.1.tar.gz [root@vpn ~]# tar xf nginx-1.16.1.tar.gz -C /usr/src/ [root@vpn ~]# cd /usr/src/nginx-1.16.1/ [root@vpn nginx-1.16.1]# ./configure --prefix=/etc/nginx --user=nginx --group=nginx && make -j 8 && make install -j 8 && cd ~
2、添加Nginx至环境变量、并将其添加为系统服务
[root@vpn ~]# echo 'export PATH=/etc/nginx/sbin:$PATH' >> /etc/profile [root@vpn ~]# source /etc/profile && nginx [root@vpn ~]# cat > /usr/lib/systemd/system/nginx.service << EOF [Unit] Description=nginx After=network.target [Service] Type=forking PIDFile=/etc/nginx/logs/nginx.pid ExecStart=/etc/nginx/sbin/nginx ExecReload=killall -s HUP $(cat /etc/nginx/logs/nginx.pid) ExecStop=killall -s QUIT $(cat /etc/nginx/logs/nginx.pid) PrivateTmp=Flase [Install] WantedBy=multi-user.target EOF [root@vpn ~]# systemctl daemon-reload && pkill -9 nginx [root@vpn ~]# systemctl restart nginx && systemctl enable nginx [root@vpn ~]# cp /etc/nginx/conf/nginx.conf /etc/nginx/conf/nginx.conf.bak
3、编辑Nginx的配置文件、指定yum仓库目录的位置、最后重启Nginx服务即可
[root@vpn ~]# vim /etc/nginx/conf/nginx.conf user nginx; worker_processes 4; worker_cpu_affinity 00000001 00000010 00000100 00001000; pid /etc/nginx/logs/nginx.pid; error_log /etc/nginx/logserror.log info; events { use epoll; worker_connections 1024; } http { include mime.types; default_type application/octet-stream; log_format mds '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log logs/access.log mds; sendfile on; tcp_nopush on; tcp_nodelay on; send_timeout 10; keepalive_timeout 60; server_tokens off; client_max_body_size 1024m; fastcgi_buffers 64 4K; client_header_buffer_size 15k; large_client_header_buffers 4 128k; open_file_cache_valid 30s; open_file_cache_min_uses 2; open_file_cache max=65535 inactive=20s; server { listen 80; charset utf-8; index index.html; server_name localhost; location / { root /opt/yum/http; autoindex on; autoindex_localtime on; autoindex_exact_size off; } } } [root@vpn ~]# nginx -t nginx: the configuration file /etc/nginx/conf/nginx.conf syntax is ok nginx: configuration file /etc/nginx/conf/nginx.conf test is successful [root@vpn ~]# systemctl restart nginx [root@vpn ~]# systemctl | grep nginx nginx.service loaded active running nginx
5)部署FTP、使用FTP形式进行发布
注意:vsftpd是服务端程序、ftp是客户端程序
(1)安装vsftpd服务
[root@vpn ~]# yum -y install vsftpd ftp | tail -9 正在安装 : ftp-0.17-67.el7.x86_64 1/2 正在安装 : vsftpd-3.0.2-25.el7.x86_64 2/2 验证中 : vsftpd-3.0.2-25.el7.x86_64 1/2 验证中 : ftp-0.17-67.el7.x86_64 2/2 已安装: ftp.x86_64 0:0.17-67.el7 vsftpd.x86_64 0:3.0.2-25.el7 完毕! [root@vpn ~]# systemctl enable vsftpd Created symlink from /etc/systemd/system/multi-user.target.wants/vsftpd.service to /usr/lib/systemd/system/vsftpd.service.
安装完成以后、匿名用户的默认访问目录为:/var/ftp/pub
(2)对创建的软件仓库目录进行授权、并编辑配置文件允许匿名用户访问
注意:给匿名用户使用的根目录一定不能有写入权限、否则将报500错误、如下所示:
响应: 331 Please specify the password. 命令: PASS 响应: 500 OOPS: vsftpd: refusing to run with writable root inside chroot() 错误: 严重错误: 无法连接到服务器
因为仓库目录我们在上个环节已经创建了、所以这里只需对其进行授权并编辑配置文件即可
[root@vpn ~]# grep ftp /etc/passwd ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin [root@vpn ~]# chown -R ftp:ftp /opt/yum/ftp/7/ [root@vpn ~]# cp /etc/vsftpd/vsftpd.conf /etc/vsftpd/vsftpd.conf.bak [root@vpn ~]# vim /etc/vsftpd/vsftpd.conf anonymous_enable=YES anon_root=/opt/yum/ftp anon_umask=022 [root@vpn ~]# systemctl start vsftpd [root@vpn ~]# systemctl | grep vsftpd vsftpd.service loaded active running Vsftpd ftp daemon
(3)使用客户端登录FTP服务器测试
注意:这里因为是匿名模式、所以访问的时候用户名输入ftp、密码直接回车即可
[root@master ~]# ftp 10.2.3.11 Connected to 10.2.3.11 (10.2.3.11). 220 (vsFTPd 3.0.2) Name (10.2.3.11:root): ftp 331 Please specify the password. Password: 230 Login successful. Remote system type is UNIX. Using binary mode to transfer files. ftp> ftp> ls 227 Entering Passive Mode (10,2,3,11,182,48). 150 Here comes the directory listing. drwxr-xr-x 3 14 50 221184 Dec 19 09:06 7 226 Directory send OK.
二、客户端使用
yum工具是比较常用的yum客户端、它由默认安装的 yum-3.4.3-158.el7.centos.noarch 所提供
1)yum工具使用说明
提示:这里我整理了一下yum工具的命令、比较靠前的是比较常用的
yum install 软件包名称 #安装软件包 yum remove 软件包名称 #移除软件包 yum update 软件包名称 #升级软件包 yum clean all #清空仓库所有缓存 yum makecache #将信息缓存到本地、提高搜索与安装速度 yum repolist all #列出所有仓库 yum search all 软件包名称 #查询指定软件包 all为所有 yum list all #列出软件仓库中所有的软件包 yum info 软件包名称 #查询软件包的描述信息 yum list installed #列出系统中已经安装的软件包 yum list available #列出可用但尚未安装的软件包 yum list updates #列出可以升级版本的软件包 yum reinstall 软件包名称 #重新安装软件包 yum check-update #检查可更新的软件包 yum grouplist #查看系统中已经安装的软件包组 yum groupinstall 软件包组 #安装指定的软件包组 yum groupremove 软件包组 #移除指定的软件包组 yum groupinfo 软件包组 #查询指定的软件包组信息
提示1:在安装软件包的时候、如果提示说RPM数据库损坏、则执行:rpm -initdb 修复数据库即可
提示2:在安装某个软件包的时候、如果要省去交互过程、则可使用 -y 选项、比如:yum -y install httpd
2)指定服务端仓库位置
注意:yum工具使用的软件仓库信息存放于 /etc/yum.repos.d 目录中、其扩展名为 .repo、.repo文件可有多个
(1)对HTTP发布的进行配置
[root@master ~]# vim /etc/yum.repos.d/server-http.repo [base] name=http-server baseurl=http://10.2.3.11/7 enabled=1 gpgcheck=0 [root@master ~]# yum makecache 已加载插件:fastestmirror Loading mirror speeds from cached hostfile base | 2.9 kB 00:00:00 (1/3): base/primary_db | 3.1 MB 00:00:00 (2/3): base/filelists_db | 3.1 MB 00:00:00 (3/3): base/other_db | 1.3 MB 00:00:00 元数据缓存已建立 [root@master ~]# yum repolist all 已加载插件:fastestmirror Loading mirror speeds from cached hostfile 源标识 源名称 状态 base http-server 启用: 3,971 repolist: 3,971
(2)对FTP发布的进行配置
[root@master ~]# vim /etc/yum.repos.d/server-ftp.repo [extend] name=ftp-server baseurl=ftp://10.2.3.11/7 enabled=1 gpgcheck=0 [root@master ~]# yum makecache 已加载插件:fastestmirror Determining fastest mirrors extend | 2.9 kB 00:00:00 (1/3): extend/primary_db | 3.1 MB 00:00:00 (2/3): extend/filelists_db | 3.1 MB 00:00:00 (3/3): extend/other_db | 1.3 MB 00:00:00 元数据缓存已建立 [root@master ~]# yum repolist all 已加载插件:fastestmirror Loading mirror speeds from cached hostfile 源标识 源名称 状态 extend ftp-server 启用: 3,971 repolist: 3,971
(3)使用createrepo更新RPM信息
配置完成以后可以进行使用了、如果后期再把软件包放进仓库目录、那就需要使用createrepo工具对其进行更新、否则在客户端安装的时候还是会提示没有这个软件包
如下所示、我在客户端查找是否有openvpn这个客户端软件包、可以看见没有
[root@master ~]# yum search all openvpn 已加载插件:fastestmirror Loading mirror speeds from cached hostfile 警告:没有匹配 openvpn 的软件包 No matches found
上传软件包到服务端的目录仓库、并使用createrepo更新RPM信息
注意:这里我是使用rz命令上传到发布目录的、所以没有截图
[root@vpn ~]# ls -lh /opt/yum/http/7/ | grep openvpn -rw-r--r-- 1 root root 522K 12月 19 18:22 openvpn-2.4.7-1.el7.x86_64.rpm [root@vpn ~]# [root@vpn ~]# createrepo /opt/yum/http/7/ Spawning worker 0 with 3974 pkgs Workers Finished Saving Primary metadata Saving file lists metadata Saving other metadata Generating sqlite DBs Sqlite DBs complete
这个时候再来客户端查找openvpn软件包、可以看见已有、并且可以正常安装
注意:服务端更新完成以后、客户端如果要安装新放进来的软件包、则需要先执行 yum makecache 再次更新缓存
[root@master ~]# yum makecache 已加载插件:fastestmirror Loading mirror speeds from cached hostfile local | 2.9 kB 00:00:00 (1/3): local/primary_db | 3.1 MB 00:00:00 (2/3): local/filelists_db | 3.1 MB 00:00:00 (3/3): local/other_db | 1.3 MB 00:00:00 元数据缓存已建立 [root@master ~]# yum search all openvpn 已加载插件:fastestmirror Loading mirror speeds from cached hostfile =================================================================== 匹配:openvpn =================================================================== openvpn.x86_64 : A full-featured SSL VPN solution [root@master ~]# yum -y install openvpn | tail -8 Running transaction 正在安装 : openvpn-2.4.7-1.el7.x86_64 1/1 验证中 : openvpn-2.4.7-1.el7.x86_64 1/1 已安装: openvpn.x86_64 0:2.4.7-1.el7 完毕!
【只是为了打发时间】
yum仓库配置与内网源部署记录的更多相关文章
- YUM仓库配置
YUM的前身是YUP(Yellow dog Updater,Yellow dog Linux的软件更新器),最初由TSS公司(Terra Soft Solutions,INC.)使用Python语言开 ...
- centos7内网源站建设
centos7内网源站建设 1.部署环境: 系统:Centos7 x86_64 应用服务:nginx.createrepo.reposync 镜像源:https://mirrors.aliyun.co ...
- 【转】CentOS5.6下配置rsync内网同步数据到外网
[转]CentOS5.6下配置rsync内网同步数据到外网 本文转自:http://www.linuxidc.com/Linux/2012-06/64070.htm 一.需求 卫士那边有一个需求,就是 ...
- Linux yum仓库配置
yum仓库配置 10.1 概述 YUM(全称为 Yellow dog Updater, Modified)是一个在Fedora和RedHat以及CentOS中的Shell前端软件包管理器.基于RPM包 ...
- CentOS7之yum仓库配置
操作系统版本:CentOS Linux release 7.2.1511 (Core) Yum软件版本:yum-3.4.3-132.el7.centos.0.1.noarch Yum主配置文件:/ ...
- Ubuntu16.04双网卡配置,内网外网同时访问
Ubuntu16.04双网卡配置,内网外网同时访问 配置:vim/etc/network/interface auto lo iface lo inet loopback auto eno1 ifac ...
- Hyper-V 配置虚拟机内网及外网环境
一.为Hyper-V虚拟机准备内外网环境 1.内网环境——虚拟机与虚拟机及主机可以互通
- k8s内网安装部署(二)
续上篇 https://www.cnblogs.com/wangql/p/13397034.html 一.kubeadm安装 1.kube-proxy开启ipvs的前置条件 modprobe br_n ...
- kubernetes 内网节点部署笔记(一)
在Centos7上部署kubernetes时,碰到很多坑,特别在摸拟在内网部署时,有来自GFW的障碍,有来自Firewalld的阻塞,反正是各种不服,终于慢慢理顺了思路,自己记录一下,防止遗忘. 环境 ...
随机推荐
- Android Gradle脚本从Groovy迁移到Kotlin DSL
Android Gradle从Groovy迁移到Kotlin Android项目用Gradle构建, 其脚本语言之前是Groovy, 目前也提供了Kotlin的支持, 所以可以迁移到Kotlin. 官 ...
- vnpy源码阅读学习(4):自己写一个类似vnpy的UI框架
自己写一个类似vnpy的界面框架 概述 通过之前3次对vnpy的界面代码的研究,我们去模仿做一个vn.py的大框架.巩固一下PyQt5的学习. 这部分的代码相对来说没有难度和深度,基本上就是把PyQt ...
- 基于Java+HttpClient+TestNG的接口自动化测试框架(四)-------参数存取处理
在真正开始接口测试之前,我们需要对参数的处理进行梳理.这里所说的“参数”,既包含之前在xml中的配置(我们称之为全局参数),也包含在每一条用例中书写的param.全局参数为固定不变的,而根据接口相应获 ...
- 高通量计算框架HTCondor(三)——使用命令
目录 1. 目录 2. 进程 3. 命令 3.1. condor_q 3.2. condor_status 3.3. conodr_submit 3.4. conodr_rm 4. 相关 1. 目录 ...
- 基于javaSwing的贪食蛇游戏
这个项目时,是我好几年前写的了.但对刚入门,或者想瞧瞧java的图形的界面swing的同学,还是有点用处的. 在这推荐给你. 涉及技术点 swing,多线程,文件读写,多媒体文件播放等 游戏简介 该游 ...
- List自定义排序 (例子省份排序)
//待排序集合 List<String> list=new ArrayList<String>(); list.add("辽宁"); list.add(&q ...
- printf 函数笔记
函数声明 int printf (const char*, ...); 说明 <返回值> printf ("<格式化字符串>", <参数表>); ...
- http--->http缓存机制系统梳理
http缓存 HTTP请求的过程 从在浏览器地址栏敲入域名-DNS解析-实际IP-(中间可能多个代理服务器分发)- 源服务器,请求抵达源服务器后,在服务器上找到请求的资源,再通过代理服务器一层层的返回 ...
- Windows10 企业版激活
今天同大家分享一个Windows自带的激活方法(注:适用于win10 企业版 2019长期服务版,其他版本自行测试) 1.首先确保电脑网络通畅(不需要梯子) 2.以管理员方式运行cmd输入: slmg ...
- IDEA debug下取消后续操作
有时进行测试时,不想后面的代码执行 具体应该怎么请看下文: 测试代码 public class demo { public static void main(String[] args) { Syst ...