day17 搭建yum仓库 编译安装

搭建网络yum仓库

服务端操作

准备软件包( 1.光盘 2.缓存 3.联网下载 4.同步 )

1.挂载光盘或下载软件包

mount /dev/cdrom /mnt

[root@zhaoshuang ~/zhaoshuang]#mount /dev/cdrom /mnt
mount: /dev/sr0 is write-protected, mounting read-only
[root@zhaoshuang ~/zhaoshuang]#df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda3        18G  6.7G   12G  38% /
devtmpfs        476M     0  476M   0% /dev
tmpfs           487M     0  487M   0% /dev/shm
tmpfs           487M  7.6M  479M   2% /run
tmpfs           487M     0  487M   0% /sys/fs/cgroup
/dev/sda1       197M  105M   93M  54% /boot
tmpfs            98M     0   98M   0% /run/user/0
/dev/sr0        4.3G  4.3G     0 100% /mnt
[root@zhaoshuang ~/zhaoshuang]#

2.通过ftp共享软件包存放的目录

安装ftp 服务

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

开启vsf服务

[root@oldboy ~]# systemctl start vsftpd

关闭防火墙

[root@oldboy ~]# systemctl stop firewalld

关闭selinux

[root@oldboy ~]# setenforce 0

3.将光盘的rpm包拷到ftp共享目录下

[root@oldboy ~]# mkdir /var/ftp/centos7/
[root@oldboy ~]# find /mnt/ -type f -name "*.rpm" -exec cp {} /var/ftp/centos7/ \;

5.将共享的目录设置成yum仓库

安装createrepo 命令
[root@oldboy ~]# yum install createrepo -y
创建索引
[root@oldboy ~]# createrepo /var/ftp/centos7/

客户端操作

1. 关闭所有的公网yum仓库(因为光盘软件包版本低)

[root@oldboy-199 yum.repos.d]# gzip /etc/yum.repos.d/*

### 新建一个repo文件,文件中的baseurl指向服务端
[root@oldboy-199 ~]# cat /etc/yum.repos.d/ftpcentos7.repo
[ftp-centos7]
name = This is Base Repo
baseurl = ftp://10.0.0.200/centos7/
enable = 1
gpgcheck = 0

3. 测试是否能正常安装软件

[root@oldboy-199 ~]# yum install httpd -y


\

增加一个zabbix 仓库

服务端操作

服务端需要提供zabbix软件相关的仓库

1.获取安装包

image.png

4.1.1 curl 需要的网站 把参数追加到文件
curl https://mirrors.aliyun.com/zabbix/zabbix/4.0/rhel/7/x86_64/ > zabbix_1.txt

2. 利用awk 过滤有用的信息下载

zabbix-web-pgsql-4.0.6-1.el7.noarch.rpm            28-Mar-2019 14:00                8356
zabbix-web-pgsql-4.0.7-1.el7.noarch.rpm            18-Apr-2019 09:03                8424
zabbix-web-pgsql-4.0.8-1.el7.noarch.rpm            28-May-2019 10:30                8488
zabbix-web-pgsql-4.0.9-2.el7.noarch.rpm            05-Jun-2019 18:14                8624
zabbix-web-pgsql-4.0.9-3.el7.noarch.rpm            07-Jun-2019 10:09                8692

[root@zhaoshuang ~]#awk -F '["<]+' '{print "wget https://mirrors.aliyun.com/zabbix/zabbix/4.0/rhel/7/x86_64/"$3}' zabbix_1.txt wget https://mirrors.aliyun.com/zabbix/zabbix/4.0/rhel/7/x86_64/ wget https://mirrors.aliyun.com/zabbix/zabbix/4.0/rhel/7/x86_64/title>Index of /zabbix/zabbix/4.0/rhel/7/x86_64/ wget https://mirrors.aliyun.com/zabbix/zabbix/4.0/rhel/7/x86_64/white wget https://mirrors.aliyun.com/zabbix/zabbix/4.0/rhel/7/x86_64//h1> wget https://mirrors.aliyun.com/zabbix/zabbix/4.0/rhel/7/x86_64/debuginfo/ wget https://mirrors.aliyun.com/zabbix/zabbix/4.0/rhel/7/x86_64/repodata/ wget https://mirrors.aliyun.com/zabbix/zabbix/4.0/rhel/7/x86_64/zabbix-agent-4.0.0-2.el7.x86_64.rpm wget https://mirrors.aliyun.com/zabbix/zabbix/4.0/rhel/7/x86_64/zabbix-agent-4.0.1-1.el7.x86_64.rpm wget https://mirrors.aliyun.com/zabbix/zabbix/4.0/rhel/7/x86_64/zabbix-agent-4.0.10-1.el7.x86_64.rpm wget https://mirrors.aliyun.com/zabbix/zabbix/4.0/rhel/7/x86_64/zabbix-agent-4.0.11-1.el7.x86_64.rpm wget https://mirrors.aliyun.com/zabbix/zabbix/4.0/rhel/7/x86_64/zabbix-agent-4.0.2-1.el7.x86_64.rpm

执行脚本下载rpm包

root@zhaoshuang ~/11]#sh zabbix_1.txt
--2019-08-18 22:45:02--  https://mirrors.aliyun.com/zabbix/zabbix/4.0/rhel/7/x86_64/zabbix-agent-4.0.0-2.el7.x86_64.rpm
Resolving mirrors.aliyun.com (mirrors.aliyun.com)... 103.15.99.91, 103.15.99.95, 103.15.99.92, ...
Connecting to mirrors.aliyun.com (mirrors.aliyun.com)|103.15.99.91|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 388552 (379K) [application/x-redhat-package-manager]
Saving to: ‘zabbix-agent-4.0.0-2.el7.x86_64.rpm’

100%[============================================================================================>] 388,552      475KB/s  

2019-08-18 22:45:03 (475 KB/s) - ‘zabbix-agent-4.0.0-2.el7.x86_64.rpm’ saved [388552/388552]

--2019-08-18 22:45:03--  https://mirrors.aliyun.com/zabbix/zabbix/4.0/rhel/7/x86_64/zabbix-agent-4.0.1-1.el7.x86_64.rpm
Resolving mirrors.aliyun.com (mirrors.aliyun.com)... 36.99.142.199, 219.147.83.250, 219.147.83.252, ...
Connecting to mirrors.aliyun.com (mirrors.aliyun.com)|36.99.142.199|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 390368 (381K) [application/x-redhat-package-manager]
Saving to: ‘zabbix-agent-4.0.1-1.el7.x86_64.rpm.1’

100%[============================================================================================>] 390,368      239KB/s  

3. zabbix 还需要下载4个软件包

同上操作curl网站 .追加文件 .awk过滤 .下载

curl http://repo.zabbix.com/non-supported/rhel/7/x86_64/ >1.txt

4.将zabbix目录生成为一个yum仓库

[root@zhaoshuang ~]# createrepo /var/ftp/zabbix

\

客户端操作

1.客户端新建一个repo文件指向服务端提供的zabbix仓库 10.0.0.199
[root@oldboy-199 ~]# cat /etc/yum.repos.d/ftpzabbix.repo
[ftp-zabbix]
name = ftp share zabbix repo
baseurl = ftp://10.0.0.200/zabbix/
enable = 1
gpgcheck = 0
2. 客户端测试zabbix仓库是否可用
[root@oldboy-199 ~]# yum clean all
[root@oldboy-199 ~]# yum install zabbix-agent
[root@oldboy-199 ~]# yum install zabbix-get
[root@oldboy-199 ~]# yum install zabbix-server




\

编译安装

源代码包(c 语言包)不可以直接运行 需要编译 编辑后生成一个可执行的程序

image.png
1.解压 tar 包

[root@zhaoshuang ~/99]#tar xf nginx-1.17.3.tar.gz

2.congiure,生成makefile文件

-p --pretty
以整洁的格式输出xml文件(指定安装软件位置)
--with-http_mp4_module
模块

[root@oldboy nginx-1.16.1]# ./configure --prefix=/usr/local/nginx-1.16 --with-http_mp4_module

报错

checking for PCRE library in /usr/include/pcre/ ... not found
checking for PCRE library in /usr/pkg/ ... not found
checking for PCRE library in /opt/local/ ... not found
#/configure:error:HTTP重写模块需要PCRE库。
./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= option.
[root@zhaoshuang ~/99/nginx-1.17.3]#

报错解决方法

复制error: the HTTP rewrite module requires the PCRE library. 到百度查看解决方法

image.png

安装依赖包
#yum install pcre openssl pcredevel -y
安装依赖包后继续执行上述命令
[root@oldboy nginx-1.16.1]# ./configure --prefix=/usr/local/nginx-1.16 --with-http_mp4_module
生成makefile文件完成后查看Makefile文件是否存在

image.png

2.开始编译

make

[root@oldboy nginx-1.16.1]#make

3.安装
make install

[root@oldboy nginx-1.16.1]#make install

4.创建软连接

#ln -s /usr/local/nginx-1.16/ /usr/local/nginx

5.开启nginx

#/usr/local/nginx/sbin/nginx

6.查看是否开启

[root@zhaoshuang /usr/local/nginx]#ps -ef |grep nginx
root      17904      1  0 21:39 ?        00:00:00 nginx: master process /usr/local/nginx/sbin/nginx
nobody    17905  17904  0 21:39 ?        00:00:00 nginx: worker process
root      17913  10398  0 21:55 pts/2    00:00:00 grep --color=auto nginx
[root@zhaoshuang /usr/local/nginx]#

你可能感兴趣的:(day17 搭建yum仓库 编译安装)