CentOS7下搭建yum仓库
服务端配置:
1、开启yum缓存
sed -i 's#keepcache=0#keepcache=1#g' /etc/yum.conf [root@control /]# cat /etc/yum.conf|grep "keepcache" keepcache=1 [root@control /]#
2、创建仓库
mkdir -p /application/yum/centos7/x86_64
cd /application/yum/centos7/x86_64
3、安装createrepo软件 用于生成yum仓库数据库的软件
yum -y install createrepo
4、初始化repodata索引文件
[root@control x86_64]# createrepo -pdo /application/yum/centos7/x86_64/ /application/yum/centos7/x86_64/ Saving Primary metadata Saving file lists metadata Saving other metadata Generating sqlite DBs Sqlite DBs complete [root@control x86_64]#
5、提供Web服务(Nginx、Python、Tomcat等都可以)
查看端口占用:
[root@control x86_64]# lsof -i:80 [root@control x86_64]#
端口没有被占用,使用Python SimpleHTTPServer模块提供80端口服务:
[root@control x86_64]# python -m SimpleHTTPServer 80 &>/dev/null & [1] 19350 [root@control x86_64]# lsof -i:80 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME python 19350 root 3u IPv4 56003 0t0 TCP *:http (LISTEN) [root@control x86_64]#
6、把已下载的rpm包移动到yum仓库
find /var/cache/ -type f -name "*rpm"|xargs -i cp {} /application/yum/centos6/x86_64/
7、每次新增一个rpm包就要更新一下
createrepo --update /application/yum/centos7/x86_64
8、如果客户端yum 安装时提示找不到自己定制的rpm包可以:
[root@control x86_64]# pwd /application/yum/centos7/x86_64 [root@control x86_64]# createrepo -g /application/repodata/repomd.xml ./
客户端配置:
1、客户端配置
cd /etc/yum.repos.d/ mv * /tmp/bak/ vim localyum.repo [localyum] name=Server baseurl=http://10.0.0.5 #这里就是配置服务端的ip,如果不是80端口还需要加上端口 enable=1 gpgcheck=0
2、清yum缓存
yum clean all
3、列表显示yum仓库
yum list
4、自己定制定制的rpm包也可以放到自己搭建的yum仓库,这样就可以用内网直接yum安装了
镜像同步公网yum源:
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
上游yum源必须要支持rsync协议,否则不能使用rsync进行同步。
http://mirrors.ustc.edu.cn/status/
CentOS官方标准源:rsync://mirrors.ustc.edu.cn/centos/
epel源:rsync://mirrors.ustc.edu.cn/epel/
同步命令:
# 同步base源,小技巧,我们安装系统的光盘镜像含有部分rpm包,大概3G,这些就不用重新下载。
/usr/bin/rsync -av rsync://rsync.mirrors.ustc.edu.cn/centos/7/os/x86_64/ /data/yum_data/centos/7/os/x86_64/
/usr/bin/rsync -av rsync://rsync.mirrors.ustc.edu.cn/centos/7/extras/x86_64/ /data/yum_data/centos/7/extras/x86_64/
/usr/bin/rsync -av rsync://rsync.mirrors.ustc.edu.cn/centos/7/updates/x86_64/ /data/yum_data/centos/7/updates/x86_64/
# epel源
/usr/bin/rsync -av --exclude=debug rsync://rsync.mirrors.ustc.edu.cn/epel/7/x86_64/ /data/yum_data/epel/7/x86_64/
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
搭建Zabbix源。
第一种方法:
Zabbix官网 http://repo.zabbix.com/
可以完全镜像,也可以最小化镜像。
wget -r -p -np -k http://repo.zabbix.com/zabbix/2.4/rhel/6/x86_64/
wget -r -p -np -k http://repo.zabbix.com/non-supported/rhel/6/x86_64/
wget http://repo.zabbix.com/RPM-GPG-KEY-ZABBIX
wget http://repo.zabbix.com/zabbix-official-repo.key
第二种方法:
rpm -ivh http://repo.zabbix.com/zabbix/2.4/rhel/6/x86_64/zabbix-release-2.4-1.el6.noarch.rpm
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo
yum -y install zabbix-server-mysql zabbix-web-mysql mysql-server mysql wqy-microhei-fonts zabbix-get zabbix-agent