本地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 ...
随机推荐
- 5 月 35 日临近,Google 无法访问,可以使用 Google IP 来解决。
每年都会有几天那啥,你懂的. 直接使用 Google 的域名访问经常会打不开,而使用 Google 的 IP 就会很顺畅. 使用 Chrome 浏览器我们经常都会在地址栏直接搜索,所以我们只要添加一个 ...
- C++获取二维数组的元素个数
C/C++获取二维数组的大小/长度/元素个数 ][]; ]) /
- sublime Text 3 使用插件追踪函数
一.下载工具 https://pan.baidu.com/s/1R0bZMMGQeKTTajIA-9DU3w 或者 https://pan.baidu.com/s/1R0bZMMGQeKTTajIA- ...
- PHP递归实现无限级分类
在一些复杂的系统中,要求对信息栏目进行无限级的分类,以增强系统的灵活性.那么PHP是如何实现无限级分类的呢?我们在本文中使用递归算法并结合mysql数据表实现无限级分类. 在一些复杂的系统中,要求对信 ...
- 我买网B轮融资成功,五周年豪掷千万回馈会员
对中粮我买网而言,近期的B轮融资应该算是最大的好消息了------8月1日,中粮我买网在京宣布完毕B轮融资.金额高达1亿美元.被称为"食品电商史上最大融资".据悉,本次融资 ...
- 微信 oauth4
4.最后 4. 使用access_token获取用户信息 请求方法: https://api.weixin.qq.com/sns/userinfo?access_token=ACCESS_TOKEN& ...
- Android无线测试之—UiAutomator UiObject API介绍二
点击与长按 一.组件区域位置关系 Rect 对象代表一个矩形区域 [Left,Top] [Right,Bottom] 二.点击与长按API 返回值 API 描述 boolean click() 点击对 ...
- Sublime Text 3如何快速生成HTML5的头部信息和常用的快捷键
一.快速生成HTML5的头部信息的步骤: 1.Ctrl + N,新建一个文档: 2.Ctrl + Shift + P,打开命令模式,再输入 sshtml 进行模糊匹配,将语法切换到html模式: 3. ...
- react-native 中使用redux 优化 Connect 使用装饰器简化代码报错
报错信息 error: bundling failed: Error: The 'decorators' plugin requires a 'decoratorsBeforeExport' opti ...
- RabbitMQ_消息队列基本使用_1
什么叫消息队列 消息(Message)是指在应用间传送的数据.消息可以非常简单,比如只包含文本字符串,也可以更复杂,可能包含嵌入对象. 消息队列(Message Queue)是一种应用间的通信方式,消 ...