1.创建yum软件保存目录
[root@localhost ~]# mkdir -p /www/share/yum
2. 修改yum配置文件
先备份yum配置文件,修改yum配置文件中yum软件包保存目录并开启rmp包缓存功能
[root@localhost ~]# cp /etc/yum.conf /etc/yum.conf.bak [root@localhost ~]# vim
/etc/yum.conf [main] #cachedir=/var/cache/yum/$basearch/$releasever cachedir=
/www/share/yum/$basearch/$releasever keepcache=1
3.安装createrepo和http
createrepo 命令用于创建yum源(软件仓库),即为存放于本地特定位置的众多rpm包建立索引,描述各包所需依赖信息,并形成元数据。
[root@localhost ~]# yum install createrepo httpd -y
4.创建http共享目录
[root@yumrepo www]# vim /etc/httpd/conf.d/share.conf #http share Alias /share
/www/share <Directory"/www/share"> Options Indexes FollowSymLinks IndexOptions
NameWidth=* DescriptionWidth=* FoldersFirst IndexOptions SuppressIcon HTMLTable
Charset=UTF-8 SuppressHTMLPreamble Order allow,deny Allow from all Require all
granted </Directory>
5. 修改http配置文件
备份httpd配置并修改配置文件
[root@localhost ~]# cp /etc/httpd/conf/httpd.conf{,.bak} [root@localhost ~]#
echo " ServerName localhost #关闭版本号显示 ServerSignature Off ServerTokens Prod
">>/etc/httpd/conf/httpd.conf
6.启动http服务
[root@localhost ~]# systemctl enable httpd.service && systemctl restart
httpd.service [root@localhost ~]# netstat -antp|grep 'httpd'
浏览器访问192.168.92.60/share ,能访问即正常
7.创建YUM软件仓库
[root@localhost ~]# mkdir -p /www/share/centos7_rpm [root@localhost ~]#
createrepo -p /www/share/centos7_rpm/ Saving Primary metadata Saving file lists
metadataSaving other metadata Generating sqlite DBs Sqlite DBs complete [root
@localhost ~]# ll /www/share/centos7_rpm/ total 4 drwxr-xr-x 2 root root 4096
Jun 19 09:40 repodata
8.创建源文件
[root@localhost ~]# echo " [My_share] name=My_Souce baseurl
=http://192.168.92.60/share/centos7_rpm/gpgcheck=0 enabled=1 cost=88 gpgkey
=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 ">/www/share/Lan7.repo
9.下载软件包
1.将yum缓存的rpm包拷贝到/www/share/centos7_rpm/
[root@localhost ~]# find /www/share/yum -name *.rpm |sed -r 's#.*#mv &
/www/share/centos7_rpm/\n#'|bash
2.下载没有安装过的包
[root@localhost ~]# yum install --downloadonly --
downloaddir=/www/share/centos7_rpm/ -y 包名称
3.重新下载已经安装过的包
[root@localhost ~]# yum reinstall --downloadonly --
downloaddir=/www/share/centos7_rpm/ -y 包名称
4.更新源
[root@localhost ~]# createrepo --update -p /www/share/centos7_rpm/ ############
##############################
5.创建rpm下载、yum更新shell
[root@localhost ~]# echo '#!/bin/sh [ $# = 0 ] && { echo "更新源"
/usr/bin/createrepo--update -p /www/share/centos7_rpm/ } || { echo "yum下载" yum
install--downloadonly --downloaddir=/www/share/centos7_rpm/ -y $* echo "更新源"
/usr/bin/createrepo--update -p /www/share/centos7_rpm/ } '>yumd.sh
[root@localhost ~]# ln -s $(pwd)/yumd.sh /usr/bin/yumd [root@localhost ~]#
chmod +x yumd.sh
执行 yumd 更新源,执行 yumd 软件1 软件2 ,就会下载相关软件并更新源
10.下载OpenStack安装包
1.仅作为参考,根据需求添加其它组件
[root@localhost ~]# yum install centos-release-openstack-queens -y
#安装OpenStack官方源 [root@localhost ~]# yum install --downloadonly
--downloaddir=/www/share/centos7_rpm/ -y \ python-openstackclient
openstack-selinux python-openstackclient python2-PyMySQL \ openstack-utils \
mariadb mariadb-server mariadb-galera-server python2-PyMySQL \ erlang socat
rabbitmq-server \ openstack-keystone httpd mod_wsgi memcached python-memcached
\ apr apr-util \ openstack-glance python-glance \ openstack-nova-api
openstack-nova-conductor \ openstack-nova-console openstack-nova-novncproxy \
openstack-nova-scheduler openstack-nova-placement-api \ openstack-nova-compute
python-openstackclient openstack-selinux \ openstack-neutron
openstack-neutron-ml2 \ openstack-neutron-linuxbridge python-neutronclient
ebtables ipset \ openstack-neutron-linuxbridge ebtables ipset \
openstack-dashboard \ openstack-cinder targetcli python-keystone lvm2 \
corosync pacemaker pcs fence-agents resource-agents \
openstack-neutron-linuxbridge
2.更新源
createrepo --update -p /www/share/centos7_rpm/
11.客户端使用源
1.下载服务端源文件到本地
wget -O /etc/yum.repos.d/Lan7.repo http://192.168.92.60/share/Lan7.repo
2.客户端测试,查看源名称为myshare说明正常
yum install httpd
参考来源:http://www.cnblogs.com/elvi/p/7657770.html
<http://www.cnblogs.com/elvi/p/7657770.html>
热门工具 换一换