构建 Openstack yum 源

对于企业的 Openstack 私有云,出于安全和某些因素的考虑,有些服务器无法访问公网,导致服务器无法更新某些 RPM 包,同时内部常有 Openstack
新特性开发需求、版本的维护与升级,因此非常有必要构建企业私有的 openstack yum 源。 构建 openstack yum 源有两个步骤:1.同步(下载)官方的源至企业 yum 服务器中;2. 重新创建 repo 并通过 nginx(apache)发布。

Overview

以 Redhat Openstack 官网安装手册为例,安装 Openstack 需要用到两类共计 8 个 repo,

1). Centos 源

CentOS-Base.repo  CentOS-Debuginfo.repo  CentOS-Media.repo  CentOS-Vault.repo

2). openstack 源及相关依赖源(epel, foreman, puppet):

epel.repo  foreman.repo  puppetlabs.repo  rdo-release.repo

构建本地源步骤

1.yum源文件下载

(1).下载必要工具:

[[email protected] ~]# yum -y install wget

[[email protected] ~]# yum -y install createrepo

(2).下载yum源到本地:

[[email protected] ~]# mkdir -p /wget-yum

[[email protected] ~]# cd /wget-yum

下载Centos 源:

[[email protected] wget-yum]# wget -S -c -r -np -L http://mirrors.sohu.com/centos/6.5/

下载foreman源:

[[email protected] wget-yum]# wget -S -c -r -np -L http://yum.theforeman.org/plugins/1.5/el6/

[[email protected] wget-yum]# wget -S -c -r -np -L http://yum.theforeman.org/releases/1.5/el6/

下载epel源:

[[email protected] wget-yum]# wget -S -c -r -np -L http://mirrors.yun-idc.com/epel/6/

下载puppetlabs源:

[[email protected] wget-yum]# wget -S -c -r -np -L https://yum.puppetlabs.com/el/6/

下载openstack源:

[[email protected] wget-yum]# wget -S -c -r -np -L https://repos.fedorapeople.org/repos/openstack/openstack-havana/

[[email protected] wget-yum]# wget -S -c -r -np -L https://repos.fedorapeople.org/repos/openstack/openstack-icehouse/

(3).删除不需要的软件包和文件:

[[email protected] wget-yum]# find ./ -name index.html* | xarge rm -rf

[[email protected] wget-yum]# find ./ -name fedora-20 | xarge rm -rf

[[email protected] wget-yum]# find ./ -name fedora-19 | xarge rm -rf

[[email protected] wget-yum]# find ./ -name i386 | xarge rm -rf

(4).调整目录结构:

[[email protected] wget-yum]# mkdir foreman

[[email protected] wget-yum]# mv yum.theforeman.org/plugins foreman/

[[email protected] wget-yum]# mv yum.theforeman.org/releases foreman/

[[email protected] wget-yum]# rm -rf yum.theforeman.org

[[email protected] wget-yum]# mv mirrors.yun-idc.com/epel ./

[[email protected] wget-yum]# rm -rf mirrors.yun-idc.com

[[email protected] wget-yum]# mkdir puppetlabs

[[email protected] wget-yum]# mv yum.puppetlabs.com/el /puppetlabs/

[[email protected] wget-yum]# rm -rf yum.puppetlabs.com

[[email protected] wget-yum]# mv repos.fedorapeople.org/repos/openstack ./

[[email protected] wget-yum]# rm -rf repos.fedorapeople.org

[[email protected] wget-yum]# ls

centos  epel  foreman  openstack  puppetlabs

2.nginx配置:

[[email protected] wget-yum]# rpm -ivh http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm

[[email protected] wget-yum]# yum -y install nginx

[[email protected] wget-yum]# vi /etc/nginx/nginx.conf

<span style="color: rgb(69, 69, 69); font-family: Arial, sans-serif; font-size: 14px; line-height: 20px;">[[email protected] wget-yum]# vi /etc/nginx/nginx.conf</span>
user  nginx;
worker_processes  8;
error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;
events {
    worker_connections  8192;
}
http {
    autoindex on;
    autoindex_exact_size off;
    autoindex_localtime on;
    charset utf-8,gbk;
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';
    access_log  /var/log/nginx/access.log  main;
    sendfile        on;
    keepalive_timeout  65;
    include /etc/nginx/conf.d/*.conf;
}
[[email protected] wget-yum]# vi /etc/nginx/conf.d/default.conf

server {
    listen       80;
    server_name  openstack-yum-server.cn;
    location / {
        #root   html;
        root /wget-yum;
        autoindex on;
        index  index.html index.htm;
    }
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }
}

[[email protected] wget-yum]# /etc/init.d/nginx restart

3. release.rpm制作:

(1).下载icehouse源码包:

[[email protected] ~]# wget https://repos.fedorapeople.org/repos/openstack/openstack-icehouse/rdo-release-icehouse-4.src.rpm

(2).创建padraig用户和组:

[[email protected] ~]# groupadd -g 2000 padraig

[[email protected] ~]# useradd -u 2000 -g padraig -m padraig -d /home -s /bin/bash

(3).解压rpm,并修改各个 .repo 文件的 url:

[[email protected] ~]# rpm -i rdo-release-icehouse-4.src.rpm

修改 .repo 文件,以 rdo-release.repo 为例

[openstack-havana]
name=OpenStack Havana Repository
baseurl=http://openstack-yum-server.cn/openstack/openstack-havana/epel-6/
enabled=1
skip_if_unavailable=0
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-RDO-Havana
priority=98

(4).修改 .spec 文件内容:

[[email protected] ~]# cd rpmbuild/

[[email protected] rpmbuild]#

SOURCES  SPECS

[[email protected] ~]# cd SPECS

[[email protected] SPECS]# vi rdo-release.spec

URL:            https://github.com/redhat-openstack/rdo-release

Source0:        rdo-release.repo

Source1:        RPM-GPG-KEY-RDO-Icehouse

Source2:        foreman.repo

Source3:        RPM-GPG-KEY-foreman

Source4:        puppetlabs.repo

Source5:        RPM-GPG-KEY-puppetlabs

Source6:        epel.repo

Source7:        RPM-GPG-KEY-EPEL-6

%install

install -p -D -m 644 %{SOURCE0} %{buildroot}%{_sysconfdir}/yum.repos.d/rdo-release.repo

install -p -D -m 644 %{SOURCE2} %{buildroot}%{_sysconfdir}/yum.repos.d/foreman.repo

install -p -D -m 644 %{SOURCE4} %{buildroot}%{_sysconfdir}/yum.repos.d/puppetlabs.repo

install -p -D -m 644 %{SOURCE6} %{buildroot}%{_sysconfdir}/yum.repos.d/epel.repo

#GPG Keys

install -Dpm 644 %{SOURCE1} %{buildroot}%{_sysconfdir}/pki/rpm-gpg/RPM-GPG-KEY-RDO-Icehouse

install -Dpm 644 %{SOURCE3} %{buildroot}%{_sysconfdir}/pki/rpm-gpg/RPM-GPG-KEY-foreman

install -Dpm 644 %{SOURCE5} %{buildroot}%{_sysconfdir}/pki/rpm-gpg/RPM-GPG-KEY-puppetlabs

install -Dpm 644 %{SOURCE7} %{buildroot}%{_sysconfdir}/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6

for repo in rdo-release foreman puppetlabs epel ; do

(5).修改SOURCES文件内容,并增加相应文件:

[[email protected] SPECS]# cd ../SOURCES

[[email protected] SOURCES]# ls

epel.repo  foreman.repo  puppetlabs.repo  rdo-release.repo  RPM-GPG-KEY-EPEL-6  RPM-GPG-KEY-foreman  RPM-GPG-KEY-puppetlabs  RPM-GPG-KEY-RDO-Icehouse

(6).重新打包rpm:

[[email protected] SPECS]# yum -y install rpm-build

[[email protected] SPECS]# pwd

/root/rpmbuild/SPECS

[[email protected] SPECS]# rpmbuild -ba rdo-release.spec

4. 解决依赖关系,创建仓库:

[[email protected] updates]# ls

repodata  x86_64

[[email protected] updates]# pwd

yum-repo/openstack/openstack-icehouse/updates

[[email protected] updates]# createrepo x86_64

5. repo 更新 RPM 包:

createrepo x86_64 --update

**********************************************************************************************************************************

编译后的rpm源码包示例:

new-rdo-release-havana-8.0.src.rpm

new-rdo-release-icehouse-4.0.src.rpm

troubleshooting:

  1. yum repolist 出现

    [[email protected] yum.repos.d]# yum repolist

    Loaded plugins: axelget, fastestmirror, security

    Loading mirror speeds from cached hostfile

    http://openstack-yum-server/ceph/el6/x86_64/repodata/repomd.xml:
    [Errno 14] PYCURL ERROR 22 - "The requested URL returned error: 403 Forbidden"

    Trying other mirror.

    http://openstack-yum-server/ceph/el6/noarch/repodata/repomd.xml:
    [Errno 14] PYCURL ERROR 22 - "The requested URL returned error: 403 Forbidden"

    Trying other mirror.

    .....

    解决方案:

    1)

    每个 repo 配置新增 proxy=None

    [openstack-havana-updates]

    .....

    _proxy_=None

    2)

    关闭防火墙, service iptables stop

注:此博文由陈尚华和本人所作。

时间: 2024-10-24 20:10:59

构建 Openstack yum 源的相关文章

构建本地yum源之rpmbuild

组内准备搭建内部yum源,在这之前需要规范软件的安装目录,并把现有的应用打包. 目前接触两种rpm打包工具,rpmbuild和fpm. - rpmbuild rpmbuild关键是spec文件编写. 环境搭建 yum -y install rpm-build rpmdevtools useradd rpm; su rpm 注: rpm打包需要特定目录下,在近期版本下rpmbuild可以在非root账号家目录下创建打包目录: rpmdev-setuptree [[email protected]

同步Openstack yum源

我们搭建Openstack时不可能是直接利用 外网的源因为外网的源有种种不确定性.所以要自己搭建内网的源来部署. 1.进行同步 yum install yum-utils createrepo yum-plugin-priorities vim /etc/yum.repos.d/openstack.repo [openstack-mitaka] name=OpenStack Icehouse Repository baseurl=http://mirrors.163.com/centos/7.3

构建本地Yum源

1.将CentOS-7-x86_64-Everything-1708.iso 文件加载虚拟机光驱 2./mnt 目录创建目录repos,存放之后挂载的光驱文件信息[[email protected] mnt]# mkdir repos[[email protected] mnt]# lsrepos[[email protected] mnt]# pwd/mnt 3.临时挂载光驱到/mnt/repos/目录,并查看挂载后生成的文件目录信息,Packages包含许多RPM软件安装包[[email p

openstack 离线YUM源搭建

服务器IP地址:192.168.0.213Openstack yum源的安装和部署说明书对于企业的openstack私有云,出于安全和某些因素的考虑,有些服务器无法访问公网,导致服务器无法更新某些RPM包,同时内部常有openstack新特性开发需求,版本的维护与升级,因此非常有必要构建企业私有的openstack yum源,构建openstack yum源有两个步骤:1.同步(下载)官方的源至企业yum服务器中:2.重新创建repo并通过(apache)发布.我们这里采用这2中方法,根据ope

制作openstack本地yum源

由于openstack的官网的yum源下载比较慢,现在我们把openstack.epel.ceph.redhat自带的安装包下载下来,自己制作一个本地的更新.安装yum源 一.把openstack.epel.ceph.redhat自带的安装包下载统一放到一个目录/yum.os.repo目录 [[email protected] ~]# mkdir /yum.os.repo 二.要确定yum源的配置路径 [[email protected] ~]#  ls /etc/yum.repos.d/ 为o

本地yum源构建以及Docker离线安装

Docker离线安装以及本地yum源构建 在docker的使用过程中有时候会遇到一些私有化部署的问题,就是在一些无法上网的机器上面安装使用dokcer,这就引出了docker的离线安装的问题,docker要如何进行离线安装呢?让我们接下来一步步阐述. 环境: centos 7.0 内核版本3.10.0-229.el7.x86_64 docker 1.12.6版本 基本思路: 在可以连接外网的机器(未安装过docker,同时跟局域网要安装docker的机器系统版本一致)通过yum命令将rpm以及相

搭建本地 yum 源 离线安装 Docker 1.12.6

使用 yum 安装 docker ,需要访问互联网.有时内网环境的机器也需要安装docker.直接使用rpm 包安装需要解决各种各样的依赖,搭建本地yum 源是一个很好解决问题的方法. centos yum 命令 提供了一种只下载不安装的命令 . yum  --downloadonly   ,  --downloaddir=DLDIR  ,下面是构建的详细步骤 环境准备 选择一台可以连接外网的服务器.保证可以相应的软件安装包 下载docker 软件 mkdir -p /opt/docker/do

OpenStack 部署总结之:通过本地yum源安装单节点openstack

通过外部网络的方式安装openstack可能会需要花费大量的事件在rpm包下载上,而且也有可能在某些客户现场不能访问外部网络环境,为了方便以及快速的安装,可以自己搭建一个yum源.本文从yum源的创建,到openstack单节点的安装,以及在安装的过程中出现的问题,做了一个完整的总结. 下载各安装源到本地 创建/root/centos目录,并进入该目录,执行以下命令 下载 CentOS 源 安装是在 CentOS发行版下进行,所以首先将 CentOS 最新版 6.5 版本的源拿到本地.定位到放置

从零开始构建集群前期准备之---yum源

工作中大多数使用centos系统,当我们安装完centos系统的时候其实yum已经配置好了.我们直接执行yum install 软件包名称 就可以安装好一个软件包.他默认使用配置好的centos的源.但好多人习惯都使用下面的这二个源 1.这是中科大的源 cd /etc/yum.repos.dmv CentOS-Base.repo CentOS-Base.repo.save   //先重命名Centos自带的yum源.wget http://mirrors.ustc.edu.cn/centos/C