【OpenStack】OpenStack笔记

本文详细介绍了OpenStack中的高可用性设置,包括基于Corosync和Pacemaker的集群、DRBD存储解决方案以及Ceph对象存储集群。此外,还探讨了数据库的备份与恢复策略。内容涵盖了OpenStack的多个组件,如Nova、Cinder、Quantum、Keystone和Glance的使用和配置,以及测试、调试和日志管理等关键方面。
摘要由CSDN通过智能技术生成

声明:

本博客欢迎转发,但请保留原作者信息!

新浪微博:@孔令贤HW

博客地址:http://blog.csdn.net/lynn_kong

内容系本人学习、研究和总结,如有雷同,实属荣幸!


1. 通用

binary = os.path.basename(inspect.stack()[-1][1]) 这是因为python可以查看堆栈的内容。所以可以得到压入栈中的脚本的名字。比如binary="nova-compute"

根据类名动态导入类:
mod_str, _sep, class_str = import_str.rpartition('.')
try:
	__import__(mod_str)
	return getattr(sys.modules[mod_str], class_str)
except (ImportError, ValueError, AttributeError), exc:

相关组件/项目
yagi:从AMQP队列中获取通知,提供API,通过PubSubHubbub提供订阅信息
计费: Dough https://github.com/lzyeval/dough
            trystack.org billing https://github.com/trystack/dash_billing
            nova-billing https://github.com/griddynamics/nova-billing
主机监控: Nagios, Zabbix and Munin
Climate(component towards resource reservations, capacity leasing project), https://launchpad.net/climate
XCloud: HPC on cloud,http://xlcloud.org/bin/view/Main/
Savanna: this project is to enable users to easily provision and manage Hadoop clusters on OpenStack, https://wiki.openstack.org/wiki/Savanna
Ironic:there will be a driver in Nova that talks to the Ironic API for Bare Metal. 关于Bare Metal的BP和wiki:
        https://blueprints.launchpad.net/nova/+spec/baremetal-force-node(for havana)
        https://wiki.openstack.org/wiki/GeneralBareMetalProvisioningFramework
        http://www.mirantis.com/blog/bare-metal-provisioning-with-openstack-cloud/(from mirantis)

国际化:
/nova/openstack/common/gettextutils.py

可以使用request和response的gzip 压缩提高性能
Header    Type             Name                      Value
HTTP/1.1 Request     Accept-Encoding   gzip
HTTP/1.1 Response Content-Encoding gzip

可以使用分页:


指定版本号,两种方式:
1. GET /tenants HTTP/1.1
Host: identity.api.openstack.org
Accept: application/vnd.openstack.identity+xml; version=1.1
X-Auth-Token: eaaafd18-0fed-4b3a-81b4-663c99ec1cbb
2. GET / v1.1/tenants HTTP/1.1
Host: identity.api.openstack.org
Accept: application/xml
X-Auth-Token: eaaafd18-0fed-4b3a-81b4-663c99ec1cbb
直接Get http://IP:PORT可以查看支持的版本号
Get extension是需要版本号的,这就意味着extension在版本之间可能并不通用。

1.1 HA

1.      Build OpenStack on top of Corosync and use Pacemaker cluster resource manager to replicate cluster OpenStack services over multiple redundant nodes.

2.      For clustering of storage a DRBD block storage solution can be used. DRBD is a software that replicates block storage(hard disks etc.) over multiple nodes.

3.      Object storage services can be clustered via Ceph. Ceph is a clustered storage solution which is able to cluster not only block devices but also data objects and filesystems. Obviously Swift Object Store could be made highly available by using Ceph.

4.      OpenStack has MySQL as an underlying database system which is used to manage the different OpenStack Services. Instead of using a MySQL standalone database server one could use a MySQL Galera clustered database servers to make MySQL highly available too.



1.2 数据库的备份和恢复

备份所有数据库:mysqldump --opt --all-databases > openstack.sql
备份nova数据库:mysqldump --opt nova > nova.sql
可以很容易新建一个crontab任务:
#!/bin/bash
backup_dir="/var/lib/backups/mysql"
filename="${backup_dir}/mysql-`hostname`-`eval date +%Y%m%d`.sql.gz"
# Dump the entire MySQL database
/usr/bin/mysqldump --opt --all-databases | gzip > $filename 
# Delete backups older than 7 days
find $backup_dir -ctime +7 -type f -delete

恢复:
先停止服务(包括mysql),运行mysql nova < nova.sql,然后启动所有服务即可。

2. 测试

To investigate risk probabilities and impacts, we must have a test on what happens to the OpenStack cloud if some components fail. One such test is the “Chaos Monkey” test developed by Netflix. A “Chaos Monkey” is a service which identifies groups of systems in an IT architecture environment and randomly terminates some of the systems. The random termination of some components serves as a test on what happens if some systems in a complex  IT environment randomly fail. The risk of component failures in anOpenStack implementation could be tested by using such Chaos Monkey services.By running multiple tests on multiple OpenStack configurations one can easily learn if  the current architecture is able to reach the required availabilitylevel or not.


3. 调试

使用PDB调试quantum

1. 插入代码:

import pdb; pdb.set_trace()

2. 停止服务

3. 手动启动服务:/usr/bin/quantum-server --config-file /etc/quantum/quantum.conf --log-file /var/log/quantum/server.log

如果是nova,需要修改osapi_compute_workers=1,以防止并发


4. 日志

Nova(Folsom)(nova/openstack/common/log.py)中定义了:
'%(asctime)s %(levelname)s %(name)s [%(request_id)s] %(instance)s %(message)s'
我一般在配置文件中如下配置:
logging_default_format_string = '%(asctime)s %(levelname)s [%(name)s %(lineno)d] [%(process)d] %(message)s'
logging_context_format_string= '%(asctime)s %(levelname)s [%(name)s %(lineno)d] [%(process)d] %(me

评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值