本地yum源建立
一、openstack(ocata)本地yum源的建立:
1、配置yum缓存:
vi /etc/yum.conf
把yum.conf配置改为:
[main]
cachedir=/var/cache/yum/$basearch/$releasever
keepcache=1
2、指定Ocata镜像源
yum install -y epel-release
yum list all|grep openstack
yum install centos-release-openstack-ocata.noarch -y
3、安装所有ocata版的软件包(下面有用python3脚本将源的文件全下载下来):
vi openstack_yum.sh
#!/bin/bash
yum installl -y createrepo yum-plugin-priorities
yum install ntp rabbitmq-server memcached python-memcached -y
yum install python-openstackclient openstack-selinux mariadb mariadb-server python2-PyMySQL -y
yum install openstack-keystone httpd mod_wsgi -y
yum -y install openstack-glance python-glanceclient -y
yum install -y openstack-nova-api openstack-nova-placement-api openstack-novaconductor \
openstack-nova-console openstack-nova-novncproxy openstack-novascheduler \
python-novaclient
yum install -y openstack-nova-compute sysfsutils
yum install -y openstack-neutron openstack-neutron-ml2 python-neutronclient
yum install -y ebtables openstack-neutron-openvswitch ipset
yum install -y openstack-dashboard
yum install -y openstack-cinder targetcli python-oslo-db MySQL-python lvm2 python-keystone
yum install -y openstack-swift-proxy python-swiftclient python-keystoneauth-token \
python-keystonemiddleware memcached
yum install -y xfsprogs rsync
yum install -y openstack-swift-account openstack-swift-container \
openstack-swift-object
yum install -y openstack-heat-api openstack-heat-api-cfn openstack-heatengine \
python-heatclient
yum install -y mongodb-server mongodb
yum install -y openstack-ceilometer-api openstack-ceilometer-collector \
openstack-ceilometer-notification openstack-ceilometer-central \
openstack-ceilometer-alarm \
python-ceilometerclient
yum install -y openstack-ceilometer-compute python-ceilometerclient pythonpecan
yum install -y openstack-trove python-troveclient
yum install -y openstack-sahara python-saharaclient
./openstack_yum.sh
3、复制下载过来的软件包:
mkdir /opt/ocata_yum
cp -R /var/cache/yum/x86_64/7/ /opt/ocata_yum/
yum install createrepo
createrepo /opt/ocata_yum/
4、安装nginx:
1、安装依赖包:
yum install -y pcre pcre-devel openssl openssl-devel gcc wget
groupadd -r nginx
useradd -r -g nginx -s /bin/false -M nginx
2、安装nginx:
cd /usr/loca/src
wget http://nginx.org/download/nginx-1.8.0.tar.gz
tar -zxvf nginx-1.8.0.tar.gz
cd nginx-1.8.0
./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_ssl_module --with-http_flv_module --with-http_stub_status_module --with-http_gzip_static_module --with-pcre
make && make install
3、配置nginx.conf
user nginx;
worker_processes 1;
events {
worker_connections 1024;
} http {
include mime.types;
default_type application/octet-stream;
charset utf-8; log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
sendfile on;
gzip on;
include vhosts/*.conf;
}
nginx.conf
mkdir /usr/local/nginx/conf/vhosts/
vi /usr/local/nginx/conf/vhosts/ocata.conf
server {
listen 80;
server_name localhost;
index index.html index.php index.htm;
access_log /var/log/nginx/access.log main;
error_log /var/log/nginx/error.log;
location /{
root /opt/;
autoindex on;
autoindex_exact_size off;
autoindex_localtime on;
}
}
ocata.conf
4、启动nginx
/usr/local/nginx/sbin/nginx -t
/usr/local/nginx/sbin/nginx
echo "/usr/local/nginx/sbin/nginx" >> /etc/rc.local
5、配置使用yum源的机器:
配置yum源:
vi /etc/yum.repos.d/openstack_ocata.repo
[ocata]
name=ocata_rpm
baseurl=http://192.168.71.21/ocata_yum/
enabled=1
gpgcheck=0
[updates]
name=kevin update
baseurl=http://192.168.71.21/ocata_yum/
gpgcheck=0
enabled=1
mv CentOS-Base.repo CentOS-Base.repo.bak
yum clean all
yum makecache
python3下载网易源的软件包:
from html.parser import HTMLParser
from urllib import request
import urllib
import os,sys
import socket
class myparser(HTMLParser):
'''找到a标签并把属性的值放到列表里'''
def __init__(self):
HTMLParser.__init__(self)
self.links = []
def handle_starttag(self, tag, attrs):
if tag == 'a':
if len(attrs) == 0:
pass
else:
for (variable,value) in attrs:
# print(value)
if variable == 'href':
self.links.append(value)
def callbackfunc(blocknum, blocksize, totalsize):
'''回调函数,打印下载进度
@blocknum: 已经下载的数据块
@blocksize: 数据块的大小
@totalsize: 远程文件的大小
'''
percent = int(100.0 * blocknum * blocksize / totalsize)
if totalsize > 505528:
pass
else:
percent = 100
sys.stdout.write('\r')
sys.stdout.write(file_name + percent * '>' + str(percent) + '%')
sys.stdout.flush()
def create_dir(root_tree,catalog):
'''根据url的目录结构在本地穿件文件夹'''
os.chdir(root_tree)
try:
os.makedirs(catalog)
except FileExistsError as e:
pass def download_file(url,down_path):
'''下载文件保存到相应的目录,并把下载失败的放在一个字典里'''
global file_name
global error_download
file_name = url.split('/')[-1]
error_download = {}
socket.setdefaulttimeout(30)
try:
request.urlretrieve(url,down_path,callbackfunc)
except socket.gaierror as e:
error_download[url] = down_path
print('socket.gaierror' , url)
except urllib.error.URLError as e:
error_download[url] = down_path
print('urllib.error.URLError',url)
sys.stdout.write('\n') def get_url_tree(url_tree):
'''获取一个字典,链接:目录,并把文件夹创建及把文件下载'''
url_tree_dict = {}
level = 0
for url in url_tree:
response = request.urlopen(url)
page = response.read().decode('utf-8')
hp = myparser()
hp.feed(page)
hp.close()
try:
hp.links.remove("../")
except ValueError as e:
pass
for file in hp.links:
if '/' in file:
create_dir(url_tree[url], file)
url_tree_dict[url+file] = url_tree[url]+file
else:
download_file(url+file,url_tree[url]+file)
if file.find('/') > 0:
level += 1
return url_tree_dict , level
url_tree = {"http://mirrors.163.com/centos/7/cloud/x86_64/openstack-ocata/":'/centos/7/cloud/x86_64/openstack-ocata/'}
try:
os.makedirs('/centos/7/cloud/x86_64/openstack-ocata/')
except FileExistsError as e:
pass while True:
url_tree,level = get_url_tree(url_tree)
if level == 0:
break
print(url_tree,level)
for key in error_download:
download_file(key,error_download[key])
本地yum源建立的更多相关文章
- Centos6.5建立本地YUM源
很多情况下公司的服务器是不允许连外网的,那么安装软件的时候就很不方便了,这里就需要建立一个本地YUM源了. 文件位置:/etc/yum.repos.d/ 后缀一定是.repo结束. 下面我们搭建 ...
- createrepo 建立本地yum源
linux使用createrepo制作本地yum源 目录 linux使用createrepo制作本地yum源 安装createrepo软件包 进入本地rpm包目录 执行完后可以看到生成的repod ...
- Centos6.4 本地yum源配置
由于单位的服务器均使用的是内网,而安装一些软件如Git,需要很多的依赖包,使用yum安装相对简单,由于不能联网故配置本地yum源配置. 1.首先将需要rpm库添加到系统中: 1).虚拟机中安装的lin ...
- Linux虚拟机配置本地yum源
刚开始使用Linux,自己构建了一个Linux虚拟机之后,在使用yum install的时候,经常是出错,提示连接不上. 一直以为是自己构建的虚拟机的问题,后来在网上查找了一些资料,才发现:需要配置本 ...
- Linux 配置本地yum源
Linux 配置无网络状态利用yum安装软件 在有网络的情况下安装软件只需一条yum install xxx命令,例如安装gcc只需一条指令:yum install gcc 那么在没有网络的情况下该 ...
- 详解centos7配置本地yum源的方法
近在使用虚拟机时遇到一些麻烦,因为公司内部有网络管理,所以vm连接不上外网,yum无法安装软件,怎么解决呢?–使用iso做本地yum源,可以解决大部份的包安装. vm安装的是centos7. 1.挂载 ...
- Redhat/CentOS 制作本地yum源
一.制作本地yum源的场景有: (1) 操作系统ISO文件是通过光驱读取的 (2) 操作系统ISO文件是通过USB设备挂载的 (3) 操作系统ISO文件是被上传到本地文件夹的形式 二. 这3种配置方式 ...
- L03-Linux RHEL6.5系统中配置本地yum源
1.将iso镜像文件上传到linux系统.注意要将文件放在合适的目录下,因为后面机器重启时还要自动挂载,所以此次挂载成功之后该文件也不要删除. 2.将iso光盘挂载到/mnt/iso目录下. (1)先 ...
- RHEL7 本地yum源配置
配置yum 源 1.挂载DVD光盘到/mnt 因为配置时候路径名里面不能有空格,否则不能识别 [root@ mnt]# mount /dev/cdrom /mnt 2.在目录/etc/yum.r ...
随机推荐
- PHP 7安装使用体验,升级PHP要谨慎
一.发挥PHP 7高性能的几个要点 PHP 7相对于之前的PHP版本来说可以说性能有了质的飞跃,但是所谓“好马配好鞍,好车配风帆”,想要发挥PHP 7的性能优势,还需要从以下几个方面做准备:(此部分引 ...
- unity mac 破解教程
1.安装好软件,我们解压破解包,有下面两个文件,Unity 和Unity_v5.x.ulf,放桌面. 2.打开终端. 3.输入文件地址,注意,我这上边的用户名,记得改成自己的用户名 ...
- h264 ES流文件通过计算first_mb_in_slice区分帧边界
本人因为近期在读取h264文件的时候,遇到怎样读取完整一帧数据的问题.通过使用elecard stream analyzer工具,以及结合<新一代视频压缩编码标准--H264/AVC>(第 ...
- ServletContext与Web应用以及Spring容器启动
一.ServletContext对象获取Demo Servlet容器在启动时会加载Web应用,并为每个Web应用创建唯一的ServletContext对象. 可以把ServletContext看作一个 ...
- TPM Key相关概念
1. Storage Keys:存储密钥,用来加密数据和其它密钥的通用非对称密钥,这里的其它密钥可以是另外一个存储密钥,也可以是绑定密钥或签名密钥.它本身是长度2048bit的RSA私钥:它既可以是可 ...
- Alluxio部署(local模式)
下载(pre-build for Hadoop 2.7) http://www.alluxio.org/download` 解压 tar -xvf alluxio-1.3.0-hadoop2.7-bi ...
- [浪风分享] -- 系列百度云管家 V2.1.0 单文件版-分享必用的神器
废话不多说,神器送上 百度云管家 V2.1.0 更新时间:2013年05月22日更新内容:1.支持云端文件管理:删除.重命名.新建文件夹.移动2.支持缩略图浏览模式3.支持三种文件排序方式:按修改时间 ...
- java后台如何根据表单中input的顺序获取value值
如果java后台准备用Servlet来实现,可以直接在doPost( )或者doGet( )中使用如下语句:request.setCharacterEndoding("UTF-8" ...
- Struts2上传文件(1)
使用Struts框架后, Struts2框架不会处理multipart/form-data的请求,它需要调用其他的上传文件框架来解析二进制数据.但是Struts在原有的上传解析器基础上做了很多的封装, ...
- Laravel5.1 Migration数据库迁移文件
Migration方便于团队开发,它就像数据库的版本控制一样,它的功能就是可以和别人共享你的数据库结构.这么说可能不太好理解,你跟着敲敲就明白了. 0 前提工作-配置数据库 找到你根目录的 .env ...