xywuyiba8 发表于 2015-4-12 13:45:48

Openstack 本地yum源配置

  主机配置:
  主机名             IP(Static)                        系统                                           配置                        角色

  yumserver   192.168.20.21       CentOS-6.5-x86_64-minimal         2CPU,4G,200G,1网卡      yumserver
  

  1.yum源文件下载

  (1).下载必要工具:
  # yum -y install wget
  (2).下载yum源到本地:
  # mkdir -p /wget-yum
  # cd /wget-yum
  下载centos6.5源:
  # wget -S -c -r -np -L http://mirrors.sohu.com/centos/6.5/
  下载foreman源:
  # wget -S -c -r -np -L http://yum.theforeman.org/plugins/1.5/el6/
# wget -S -c -r -np -L http://yum.theforeman.org/releases/1.5/el6/
下载epel源:
# wget -S -c -r -np -L http://mirrors.yun-idc.com/epel/6/
下载puppetlabs源:
# wget -S -c -r -np -L https://yum.puppetlabs.com/el/6/
下载openstack源:
# wget -S -c -r -np -L https://repos.fedorapeople.org/repos/openstack/openstack-havana/
# wget -S -c -r -np -L https://repos.fedorapeople.org/repos/openstack/openstack-icehouse/
(3).删除不需要的软件包和文件:
# find ./ -name index.html* | xarge rm -rf
# find ./ -name fedora-20 | xarge rm -rf
# find ./ -name fedora-19 | xarge rm -rf
# find ./ -name isos | xarge rm -rf
# find ./ -name i386 | xarge rm -rf
(4).调整目录结构:
# mv mirrors.sohu.com/centos ./
# rm -rf mirrors.sohu.com
# mkdir foreman
# mv yum.theforeman.org/plugins foreman/
# mv yum.theforeman.org/releases foreman/
# rm -rf yum.theforeman.org
# mv mirrors.yun-idc.com/epel ./
# rm -rf mirrors.yun-idc.com
# mkdir puppetlabs
# mv yum.puppetlabs.com/el /puppetlabs/
# rm -rf yum.puppetlabs.com
# mv repos.fedorapeople.org/repos/openstack ./
# rm -rf repos.fedorapeople.org
# ls
centosepelforemanopenstackpuppetlabs
2.nginx配置:
# rpm -ivh http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm
# yum -y install nginx
# vi /etc/nginx/nginx.conf

usernginx;
worker_processes8;
error_log/var/log/nginx/error.log warn;
pid      /var/run/nginx.pid;
events {
    worker_connections8192;
}
http {
    autoindex on;
    autoindex_exact_size off;
    autoindex_localtime on;
    charset utf-8,gbk;
    include       /etc/nginx/mime.types;
    default_typeapplication/octet-stream;
    log_formatmain'$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.logmain;
    sendfile      on;
    #tcp_nopush   on;
    keepalive_timeout65;
    #gzipon;
    include /etc/nginx/conf.d/*.conf;
}
# vi /etc/nginx/conf.d/default.conf


server {
    listen       80;
    server_nameopenstack.chensh.net;
    #charset koi8-r;
    #access_log/var/log/nginx/log/host.access.logmain;
#   location / {
#       root   /usr/share/nginx/html;
#       indexindex.html index.htm;
#   }
    location / {
      #root   html;
      root /wget-yum;
      autoindex on;
      indexindex.html index.htm;
    }
    #error_page404            /404.html;
    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504/50x.html;
    location = /50x.html {
      root   /usr/share/nginx/html;
    }
    # proxy the PHP scripts to Apache listening on 127.0.0.1:80
    #
    #location ~ \.php$ {
    #    proxy_pass   http://127.0.0.1;
    #}
    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    #location ~ \.php$ {
    #    root         html;
    #    fastcgi_pass   127.0.0.1:9000;
    #    fastcgi_indexindex.php;
    #    fastcgi_paramSCRIPT_FILENAME/scripts$fastcgi_script_name;
    #    include      fastcgi_params;
    #}
    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    #location ~ /\.ht {
    #    denyall;
    #}
}
# /etc/init.d/nginx restart
**********************************************************************************************************************************
3.release.rpm制作:
(1).下载icehouse源码包:
# wget https://repos.fedorapeople.org/repos/openstack/openstack-icehouse/rdo-release-icehouse-4.src.rpm
  (2).创建padraig用户和组:
  # groupadd -g 1000 padraig
  # useradd -u 1000 -g padraig -m padraig -d /home -s /bin/bash
  
(3).解压rpm:
# rpm -i rdo-release-icehouse-4.src.rpm
  (4).修改文件内容,指向本地yum源:
  # cd rpmbuild/
  #
  SOURCESSPECS
  # cd 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
  Source8:      CentOS-Openstack.repo
  Source9:      RPM-GPG-KEY-CentOS-openstack
  
  %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
  install -p -D -m 644 %{SOURCE8} %{buildroot}%{_sysconfdir}/yum.repos.d/CentOS-Openstack.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
  install -Dpm 644 %{SOURCE9} %{buildroot}%{_sysconfdir}/pki/rpm-gpg/RPM-GPG-KEY-CentOS-openstack
  

  for repo in rdo-release foreman puppetlabs epel CentOS-Openstack; do
  (5).修改SOURCES文件内容,并增加相应文件:
  # cd ../SOURCES
  # ls
  CentOS-Openstack.repoepel.repoforeman.repopuppetlabs.repordo-release.repoRPM-GPG-KEY-CentOS-openstackRPM-GPG-KEY-EPEL-6RPM-GPG-KEY-foremanRPM-GPG-KEY-puppetlabsRPM-GPG-KEY-RDO-Icehouse
  (6).重新打包rpm:
  # yum -y install rpm-build

  
# pwd
/root/rpmbuild/SPECS
  # rpmbuild -ba rdo-release.spec
  4.解决依赖关系,创建仓库:
  
  
  # ls
  repodatax86_64
  # pwd
  /letv/yum-repo/openstack/openstack-icehouse/updates
  # createrepo x86_64
  **********************************************************************************************************************************

  
页: [1]
查看完整版本: Openstack 本地yum源配置