Skip to content

openstack_local_repo

遇见王斌 edited this page Feb 13, 2018 · 1 revision

OpenStack 本地源

1 简介

考虑到以下问题,所以需要本地源

  • (1) 在正式环境中部署的 OpenStack Ocata 版本,但是过了几年后,CentOS 的 yum 源中去掉了 Ocata 的源,如果想要测试 Ocata 版本时
  • (2) 部署的正式环境没有外网

2 生成本地源

2.1 获取 OpenStack 安装程序并创建本地源的目录

  • 【下载安装程序】git clone https://github.com/BillWang139967/openstack_install.git
  • 【进入安装目录】cd openstack_install
  • 【创建本地目录】mkdir -p /tmp/centos-openstack-ocata
  • 【生成执行脚本】echo '#!/bin/bash' > create_yum.sh
  • 【安装 OpenStack 网络源】yum -y install centos-release-openstack-ocata

2.2 生成 OpenStack 需要安装的包列表

在 openstack_install 目录下执行

[root@meetbill openstack_install]# grep yum -R  | grep openstack | grep -v main-installer | grep -v centos-release-openstack-ocata |  awk '{ $1="";$2="";$3=""; $4="";print "yum install --downloadonly --downloaddir=/tmp/centos-openstack-ocata" $0 }' 
yum install --downloadonly --downloaddir=/tmp/centos-openstack-ocata    python-openstackclient openstack-selinux crudini
yum install --downloadonly --downloaddir=/tmp/centos-openstack-ocata    openstack-neutron-linuxbridge ebtables ipset
yum install --downloadonly --downloaddir=/tmp/centos-openstack-ocata    openstack-neutron-openvswitch ebtables ipset
yum install --downloadonly --downloaddir=/tmp/centos-openstack-ocata    openstack-nova-compute
yum install --downloadonly --downloaddir=/tmp/centos-openstack-ocata    python-openstackclient openstack-selinux crudini
yum install --downloadonly --downloaddir=/tmp/centos-openstack-ocata    openstack-cinder targetcli
yum install --downloadonly --downloaddir=/tmp/centos-openstack-ocata    openstack-glance
yum install --downloadonly --downloaddir=/tmp/centos-openstack-ocata    openstack-dashboard
yum install --downloadonly --downloaddir=/tmp/centos-openstack-ocata    openstack-keystone httpd mod_wsgi openstack-utils
yum install --downloadonly --downloaddir=/tmp/centos-openstack-ocata    openstack-neutron openstack-neutron-ml2 openstack-neutron-linuxbridge ebtables python-neutron python-neutronclient
yum install --downloadonly --downloaddir=/tmp/centos-openstack-ocata    openstack-neutron openstack-neutron-openvswitch openstack-neutron-ml2 python-neutron python-neutronclient ebtables
yum install --downloadonly --downloaddir=/tmp/centos-openstack-ocata    openstack-nova-api openstack-nova-conductor openstack-nova-console openstack-nova-novncproxy openstack-nova-scheduler openstack-nova-placement-api
yum install --downloadonly --downloaddir=/tmp/centos-openstack-ocata    python-openstackclient openstack-selinux crudini
yum install --downloadonly --downloaddir=/tmp/centos-openstack-ocata    openstack-neutron-linuxbridge ebtables ipset
yum install --downloadonly --downloaddir=/tmp/centos-openstack-ocata    openstack-neutron-openvswitch ebtables ipset
yum install --downloadonly --downloaddir=/tmp/centos-openstack-ocata    openstack-nova-compute
yum install --downloadonly --downloaddir=/tmp/centos-openstack-ocata    python-openstackclient openstack-selinux crudini
yum install --downloadonly --downloaddir=/tmp/centos-openstack-ocata    openstack-cinder targetcli
yum install --downloadonly --downloaddir=/tmp/centos-openstack-ocata    openstack-glance
yum install --downloadonly --downloaddir=/tmp/centos-openstack-ocata    openstack-dashboard
yum install --downloadonly --downloaddir=/tmp/centos-openstack-ocata    openstack-keystone httpd mod_wsgi openstack-utils
yum install --downloadonly --downloaddir=/tmp/centos-openstack-ocata    openstack-neutron openstack-neutron-ml2 openstack-neutron-linuxbridge ebtables python-neutron python-neutronclient
yum install --downloadonly --downloaddir=/tmp/centos-openstack-ocata    openstack-neutron openstack-neutron-openvswitch openstack-neutron-ml2 python-neutron python-neutronclient ebtables
yum install --downloadonly --downloaddir=/tmp/centos-openstack-ocata    openstack-nova-api openstack-nova-conductor openstack-nova-console openstack-nova-novncproxy openstack-nova-scheduler openstack-nova-placement-api

将上面内容输出到脚本中

grep yum -R | grep openstack | grep -v main-installer | grep -v centos-release-openstack-ocata | awk '{ $1="";$2="";$3=""; $4="";print "yum install --downloadonly --downloaddir=/tmp/centos-openstack-ocata" $0 }' >> create_yum.sh

2.3 将包下载到固定的目录中

bash create_yum.sh

2.4 生成本地源

  • yum -y install createrepo
  • cd /tmp
  • createrepo centos-openstack-ocata/
  • tar -zcvf centos-openstack-ocata.xxxx.tar.gz centos-openstack-ocata

3 使用本地源

3.1 解压本地源包到固定目录

#tar -zxvf centos-openstack-ocata* -C /opt

如:链接:https://pan.baidu.com/s/1sndYi09 密码:8ro5

3.2 将 repo 文件放到 Linux 目录

如将下面内容写入 /etc/yum.repos.d/ocata.repo 文件中

# ocata.repo
# including software: 
# ocata
[localyum]
name=ocata
baseurl=file:///opt/centos-openstack-ocata
gpgcheck=0
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7