首页 > 其他 > 详细

第二十章 搭建本地yum仓库,仓库共享给其他主机

时间:2020-08-01 21:46:17      阅读:116      评论:0      收藏:0      [点我收藏+]


搭建本地仓库

?
1. yum仓库, mount /dev/cdrom   将镜像光盘进行挂载, /mnt
?
[root@lxy ~]# mount /dev/cdrom   /mnt
mount: /dev/sr0 is write-protected, mounting read-only
[root@lxy ~]# df -h
Filesystem     Size Used Avail Use% Mounted on
/dev/sda3       48G  2.0G   46G   5% /
devtmpfs       980M     0 980M   0% /dev
tmpfs           991M     0 991M   0% /dev/shm
tmpfs           991M  9.6M 981M   1% /run
tmpfs           991M     0 991M   0% /sys/fs/cgroup
/dev/sda1       497M 120M 378M  25% /boot
tmpfs           199M     0 199M   0% /run/user/0
/dev/sr0        4.3G  4.3G     0 100% /mnt
[root@lxy ~]# ll /mnt/Packages/*.rpm |wc -l
4021
?
2.禁用其它yum源仓库(连接外网的yum仓库)
?
[root@lxy ~]# gzip /etc/yum.repos.d/*
[root@lxy ~]# ll /etc/yum.repos.d/
total 8
-rw-r--r--. 1 root root 601 Dec 25 11:22 CentOS-Base.repo.gz
-rw-r--r--. 1 root root 254 Dec 25 11:48 epel.repo.gz
[root@lxy ~]# yum repolist
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
repolist: 0
?
3.书写yum仓库的配置文件
?
file://     #本地的地址
?
ftp://   #网络文件传输
?
http://   https:// #网路协议
?
?
[root@lxy ~]# cat /etc/yum.repos.d/local.repo
[lxy]#名称
name = this is local repo #备注信息
baseurl = file:///mnt #路径在哪里
enabled = 1   #启用仓库
gpgcheck = 0    #是否检查合法性
?
4.清空缓存
?
[root@lxy ~]# yum clean all
?
5.检查仓库是否可用
[root@lxy ~]# yum repolist
Loaded plugins: fastestmirror
Determining fastest mirrors
lxy                                                                                                           | 3.6 kB  00:00:00    
(1/2): lxy/group_gz                                                                                           | 166 kB  00:00:00    
(2/2): lxy/primary_db                                                                                         | 3.1 MB  00:00:00    
repo id                                                 repo name                                                             status
lxy                                                     this is local repo                                                   4,021
repolist: 4,021
?
?
?

将本地仓库共享给其它主机

1.安装vsftpd服务

[root@lxy ~]# yum  install  -y  vsftpd

#启动服务
[root@lxy ~]# systemctl   start  vsftpd
#查看服务状态
[root@lxy ~]# systemctl   status  vsftpd

2.关闭防火墙

[root@lxy ~]# systemctl  stop  firewalld
[root@lxy ~]# systemctl  disable  firewalld

3.关闭selinux安全防护用

[root@lxy ~]# getenforce 
Enforcing
[root@lxy ~]# setenforce 
usage:  setenforce [ Enforcing | Permissive | 1 | 0 ]
[root@lxy ~]# setenforce 0
[root@lxy ~]# getenforce 
Permissive
#永久关闭
[root@lxy ~]# sed  -i  ‘7s#enforcing#disabled#g‘  /etc/selinux/config


4.浏览器访问测试

ftp://10.0.0.90/
#客户端测试
[root@client ~]# curl  ftp://10.0.0.90
drwxr-xr-x    2 0        0               6 Oct 30  2018 pub

5. 创建一个yum源仓库  

[root@lxy ~]# mkdir  /var/ftp/local
[root@lxy ~]# ll  /var/ftp/
total 0
drwxr-xr-x. 2 root root 6 Dec 26 10:46 local

6. 将rpm包拷贝到仓库目录中

[root@lxy ~]# cp  -rp  /mnt/Packages/*  /var/ftp/local/

7.让这个目录变成yum仓库
[root@lxy ~]# yum  install  -y  createrepo

[root@lxy ~]# createrepo   /var/ftp/local/
Spawning worker 0 with 4021 pkgs
Workers Finished
Saving Primary metadata
Saving file lists metadata
Saving other metadata
Generating sqlite DBs
Sqlite DBs complete

8.书写配置文件

[root@lxy ~]# cat /etc/yum.repos.d/local.repo
[lxy]
name = this is local  repo
baseurl = ftp://10.0.0.90/local
enabled = 1
gpgcheck = 0

9. 下载测试  

[root@lxy ~]#  yum  clean  all

[root@lxy ~]# yum repolist
Loaded plugins: fastestmirror
Determining fastest mirrors
lxy                                                                                                           | 2.9 kB  00:00:00     
lxy/primary_db                                                                                                | 3.2 MB  00:00:00     
repo id                                                  repo name                                                             status
lxy                                                      this is local  repo                                                   4,021
repolist: 4,021

10.让其它的主机也使用这个仓库


[root@client ~]# gzip  /etc/yum.repos.d/*
[root@client ~]# vi  /etc/yum.repos.d/local.repo
[root@client ~]# cat /etc/yum.repos.d/local.repo
[lxy]
name = this is local  repo
baseurl = ftp://10.0.0.90/local
enabled = 1
gpgcheck = 0
[root@client ~]# yum  clean  all
Loaded plugins: fastestmirror
Cleaning repos: lxy
Cleaning up list of fastest mirrors
Other repos take up 105 M of disk space (use --verbose for details)
[root@client ~]# yum  repolist
Loaded plugins: fastestmirror
Determining fastest mirrors
lxy                                                                                                           | 2.9 kB  00:00:00     
lxy/primary_db                                                                                                | 3.2 MB  00:00:00     
repo id                                                  repo name                                                             status
lxy                                                      this is local  repo                                                   4,021
repolist: 4,021

编译安装

?
Nginx
?
准备环境
?
[root@client ~]# rm -rf /etc/yum.repos.d/*
?
[root@client ~]# curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
% Total   % Received % Xferd Average Speed   Time   Time     Time Current
                                Dload Upload   Total   Spent   Left Speed
100  2523  100  2523    0     0  77411      0 --:--:-- --:--:-- --:--:-- 78843
[root@client ~]# curl -o   /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
% Total   % Received % Xferd Average Speed   Time   Time     Time Current
                                Dload Upload   Total   Spent   Left Speed
100   664  100   664    0     0  23762      0 --:--:-- --:--:-- --:--:-- 24592
[root@client ~]# ll /etc/yum.repos.d/
total 8
-rw-r--r--. 1 root root 2523 Dec 26 19:41 CentOS-Base.repo
-rw-r--r--. 1 root root  664 Dec 26 19:41 epel.repo
?
?
1. 下载Nginx的源码包
[root@client ~]# yum install -y wget
[root@client ~]# wget http://nginx.org/download/nginx-1.16.1.tar.gz
?
2.解压
?
[root@client ~]# tar xf nginx-1.16.1.tar.gz
[root@client ~]# ll
total 1016
-rw-------. 1 root root    1429 Nov 26 20:28 anaconda-ks.cfg
drwxr-xr-x. 8 1001 1001     158 Aug 13 20:51 nginx-1.16.1
?
3.进入目录,开始预编译,生成makefile文件  
?
[root@client nginx-1.16.1]# ./configure   --prefix=/application/nginx-1.16.1 --with-http_ssl_module
?
#第一步报错
[root@client nginx-1.16.1]# ./configure   --prefix=/application/nginx-1.16.1 --with-http_ssl_module
checking for OS
+ Linux 3.10.0-957.el7.x86_64 x86_64
checking for C compiler ... not found
?
./configure: error: C compiler cc is not found
?
[root@client nginx-1.16.1]# yum install -y gcc #按照报错进行安装gcc软件
?
#重新进行预编译
[root@client nginx-1.16.1]# ./configure   --prefix=/application/nginx-1.16.1 --with-http_ssl_module
?
./configure: error: SSL modules require the OpenSSL library.
You can either do not enable the modules, or install the OpenSSL library
into the system, or build the OpenSSL library statically from the source
with nginx by using --with-openssl=<path> option.
?
解决这个报错:
?
[root@client nginx-1.16.1]# yum install -y openssl openssl-devel
?
?
?
#重新进行预编译
[root@client nginx-1.16.1]# ./configure   --prefix=/application/nginx-1.16.1 --with-http_ssl_module
?
./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre=<path> option.
?
#解决报错
?
[root@client nginx-1.16.1]# yum install -y pcre pcre-devel
?
[root@client nginx-1.16.1]# echo $?
0
?
[root@client nginx-1.16.1]# ll
total 756
drwxr-xr-x. 6 1001 1001   4096 Dec 26 19:48 auto
-rw-r--r--. 1 1001 1001 296463 Aug 13 20:51 CHANGES
-rw-r--r--. 1 1001 1001 452171 Aug 13 20:51 CHANGES.ru
drwxr-xr-x. 2 1001 1001    168 Dec 26 19:48 conf
-rwxr-xr-x. 1 1001 1001   2502 Aug 13 20:51 configure
drwxr-xr-x. 4 1001 1001     72 Dec 26 19:48 contrib
drwxr-xr-x. 2 1001 1001     40 Dec 26 19:48 html
-rw-r--r--. 1 1001 1001   1397 Aug 13 20:51 LICENSE
-rw-r--r--. 1 root root    412 Dec 26 20:01 Makefile
?
4.进行编译,根据makefile文件进行编译
?
[root@client nginx-1.16.1]# make
?
5.将编译的结果拷贝到预编译的指定的程序目录
?
[root@client nginx-1.16.1]# make install
?
[root@client nginx-1.16.1]# ll /application/nginx-1.16.1/
total 4
drwxr-xr-x. 2 root root 4096 Dec 26 20:10 conf
drwxr-xr-x. 2 root root   40 Dec 26 20:10 html
drwxr-xr-x. 2 root root    6 Dec 26 20:10 logs
drwxr-xr-x. 2 root root   19 Dec 26 20:10 sbin
?
6. 做个软连接  
?
[root@client nginx-1.16.1]# ln -s /application/nginx-1.16.1/ /application/nginx
?
7.启动nginx
?
[root@client nginx-1.16.1]# /application/nginx/sbin/nginx
[root@client nginx-1.16.1]# netstat -lntp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      12139/nginx: master
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      6871/sshd          
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      6996/master        
tcp6       0      0 :::22                   :::*                   LISTEN      6871/sshd          
tcp6       0      0 ::1:25                 :::*                   LISTEN      6996/master
?
8.浏览器访问测试
?
[root@client nginx-1.16.1]# systemctl stop firewalld
[root@client nginx-1.16.1]# setenforce 0
?
http://10.0.0.80/
?

 

第二十章 搭建本地yum仓库,仓库共享给其他主机

原文:https://www.cnblogs.com/smyjs172lxy/p/13415774.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!