openstack日志信息的国际化(i18n)

目前 OpenStack 的日志信息,是采用国际化语言提示的,这样会有一些问题。我在邮件列表发了一个信息,建议采用英文提示信息,原因如下:

1、英文日志信息,更加便于用户共享和查找问题。我们可以方便地在搜索引擎检索错误信息,可以将日志信息发送到邮件列表供讨论。如果采用国际化的日志信息,不便于大家交流和共享。

2、如果采用国际化的提示信息,对于开发人员来说,维护会困难得多,修改一个提示信息,需要修改很多版本的语言资源文件,这个对于开源项目来说是一个不小的负担。

3、日志信息不像界面提示,对于管理员才可见,出了问题才会去查日志,所以英文不是障碍。更重要的是用日志来检索和共享。

Andrew Hutchings回了一个邮件,提到:

1、开发峰会已经涉及这个议题

http://etherpad.openstack.org/FolsomI18N

谈到邮件列表里曾经提到不要采用国际化日志信息,但是会议上说要(特别是中国的系统管理员)。是否需要一个投票?相比较apache的项目

> The information in there says “mailing list says no, feedback from
> session says yes (especially requested by operators in china) – need a
> vote? compare to apache projects…”

我们有500多人的OpenStack社区,可以发起一个讨论或者投票。

2、Oracle处理日志信息,采用的是问题编号,比如 ORA-01000,这样也便于共享或者检索。
但是这种方式,还是要维护国际化资源文件,对于开源项目,维护困难。

> I do also remember a suggestion of translated error messages and a
> common error code (such as NOV1234 I guess?) to use in places such as a
> Google search (such as MySQL does). You could then search for the
> translated error message or the code if you feel your language skills
> are good enough to get multi-lingual results.

发表在 OpenStack | 留下评论

ubuntu 下修改 mysql 库文件目录不能启动

/var的目录过小,按照公司的安装习惯,将mysql 的 datadir切换到 /home/mysql,发现无法启动,日志中出现:

Apr 30 21:56:03 n1 kernel: [41411.680225] init: mysql post-start process (31902) terminated with status 1
Apr 30 21:56:03 n1 kernel: [41411.691791] type=1400 audit(1335794163.366:298): apparmor="STATUS" operation="profile_replace" name="/usr/sbin/mysqld" pid=31935 comm="apparmor_parser"
Apr 30 21:56:03 n1 kernel: [41411.707244] type=1400 audit(1335794163.382:299): apparmor="DENIED" operation="mknod" parent=1 profile="/usr/sbin/mysqld" name="/home/mysql/n1.lower-test" pid=31939 comm="mysqld" requested_mask="c" denied_mask="c" fsuid=0 ouid=0
Apr 30 21:56:03 n1 kernel: [41411.707381] type=1400 audit(1335794163.382:300): apparmor="DENIED" operation="mknod" parent=1 profile="/usr/sbin/mysqld" name="/home/mysql/n1.lower-test" pid=31939 comm="mysqld" requested_mask="c" denied_mask="c" fsuid=0 ouid=0
Apr 30 21:56:03 n1 kernel: [41411.711149] type=1400 audit(1335794163.386:301): apparmor="DENIED" operation="open" parent=1 profile="/usr/sbin/mysqld" name="/home/mysql/mysql/plugin.frm" pid=31939 comm="mysqld" requested_mask="r" denied_mask="r" fsuid=107 ouid=107
Apr 30 21:56:03 n1 kernel: [41411.736333] type=1400 audit(1335794163.410:302): apparmor="DENIED" operation="open" parent=1 profile="/usr/sbin/mysqld" name="/home/mysql/ibdata1" pid=31939 comm="mysqld" requested_mask="rw" denied_mask="rw" fsuid=107 ouid=107

原来是 apparmor 做了限制。AppArmor 是内核的一个安全增强模块,对程序存取资源进行限制。解决方法:

vi /etc/apparmor.d/usr.sbin.mysqld

/home/mysql/ r,
/home/mysql/** rwk,

重新启动mysql,正常。

发表在 DEVOPS | 留下评论

本地ssh非标准端口时,连接github.com

针对公网上的服务器的检查,在日志中会发现大量针对22端口(ssh)的非法扫描。为了增强安全性,减少这些扫描,我们将服务器的ssh端口改成了一个非标准的端口。

这时,连接github时,会出现错误,无法连接:

#git pull
ssh: connect to host github.com port xxxxx: Connection refused
fatal: The remote end hung up unexpectedly

解决方法,编辑一个 ssh 的config文件:

$vim ~/.ssh/config
Host github.com
HostName github.com
Port 22

测试一下:

$ssh  -T git@github.com
Hi pubyun! You've successfully authenticated, but GitHub does not provide shell access.
$git pull
Current branch master is up to date.
发表在 DEVOPS | 留下评论

RHEL 6.3 的一些重要改进

Red Hat Enterprise Linux 6.3 Beta已经发布了,一些重要的改进:

1、虚拟化

  • 提供一个 Virt-P2V工具,可以将windows和RedHat Linux的物理机转换成虚拟机,使用KVM进行部署。
  • 可以进行文件卷的在线resizing,提高了虚拟机的可用性
  • 增强qcow2磁盘镜像的存储性能,存取更加异步,从而降低vCPU占用和提高整体性能
  • 对虚拟机进行性能监控,采用vPMU,可以在主机上诊断虚拟机的性能。
  • 动态的vCPUs分配,不再需要重启,这个对计算资源伸缩有利(什么时候对内存可以在线伸缩?)
  • 虚拟机的休眠状态,支持S3、S4(休眠到磁盘、休眠到内存)

2、伸缩性

  • 最多支持的虚拟CPU数(vCPUs),从64提高到了160
  • 虚拟机支持的最多内存从512MB提高到2TB
以上两条,觉得是RedHat摆的噱头,没有太多实际意义,不断挤牙膏

3、存储

  • 全面支持FCoE,该特性还是预览测试阶段
  • LVM支持 raid4, 5, 6(以前这些raid是依靠MD来支持的),这样将存储管理的常见功能(创建卷、增缩卷大小、创建Raid、创建快照等)集成在一个界面里,简化了存储管理。该特性还是预览测试阶段
  • LVM支持 thin provisioned logical volumes(按需分配逻辑卷)。之前存储空间都是在创建的时候分配的,需要监控文件系统使用情况,手工增加卷空间。现在可以自动按需分配,自动扩展,不再需要人工干预。该特性还是预览测试阶段

4、支持 OpenJDK 7

5、Mysql InnoDB 的插件支持

这个插件,比内置的InnoDB引擎提供更多功能和更好的性能

 

发表在 DEVOPS | 留下评论

什么是openstack的 metadata

metadata字面上是元数据,是一个不容易理解的概念。在除了openstack的其他场合也经常会碰到。openstack里的metadata,是提供一个机制给用户,可以设定每一个instance 的参数。

具体可以参见openstack的相关api和以下的蓝图:

https://blueprints.launchpad.net/nova/+spec/openstack-api-metadata

比如你想给instance设置某个属性,比如主机名。metadata的一个重要应用,是设置每个instance的ssh公钥。公钥的设置有两种方式:

1、创建instance时注入文件镜像

2、启动instance后,通过metadata获取,然后用脚本写入

第二种方式更加灵活,可以给非root用户注入公钥。以下是获取ssh key的代码片段:

# Fetch public key using HTTP
ATTEMPTS=10
while [ ! -f /root/.ssh/authorized_keys ]; do
    curl -f http://169.254.169.254/latest/meta-data/public-keys/0/openssh-key > /tmp/aws-key 2>/dev/null
    if [ \$? -eq 0 ]; then
        cat /tmp/aws-key >> /root/.ssh/authorized_keys
        chmod 0600 /root/.ssh/authorized_keys
        restorecon /root/.ssh/authorized_keys
        rm -f /tmp/aws-key
        echo "Successfully retrieved AWS public key from instance metadata"
    else
        FAILED=\$((\$FAILED + 1))
        if [ \$FAILED -ge \$ATTEMPTS ]; then
            echo "Failed to retrieve AWS public key after \$FAILED attempts, quitting"
            break
        fi
        echo "Could not retrieve AWS public key (attempt #\$FAILED/\$ATTEMPTS), retrying in 5 seconds..."
        sleep 5
    fi
done

可以看到,获取metadata的api接口是:

http://169.254.169.254/latest/meta-data/public-keys/0/openssh-key

可是,这个IP地址,在我们 openstack 是不存在的。为什么可以获取到metadata呢?

这是由于Amazon的原因,最早metadata是亚马逊提出来的,参见:

http://docs.amazonwebservices.com/AWSEC2/latest/UserGuide/AESDG-chapter-instancedata.html

后来很多人给亚马逊定制了一些操作系统的镜像,比如 ubuntu, fedora, centos 等等,而且将里面获取 metadta 的api地址也写死了。所以opentack为了兼容,保留了这个地址 169.254.169.254。然后通过iptables nat映射到真实的api上:

iptables -A nova-network-PREROUTING -d 169.254.169.254/32 -p tcp -m tcp --dport 80 -j DNAT --to-destination 10.0.0.4:8775

使用metadata会带来便利,但是经常碰到的一个问题是,metadata获取不成功,导致instance启动很慢,并且获取失败会导致ssh key等功能设置失效,刚才获取ssh的代码片段中,就是尝试10次。需要注意的是:

1、在 network 上,正确设置相关参数,在 /etc/nova/nova.conf 里配置:

metadata_host=10.0.0.4

这里的 10.0.0.4 是api所在的内网地址

2、network上,要能够连接这个api地址 10.0.0.4

3、由于 api 判断instance是通过fix ip 来判断的,所以instance的fix ip地址段,一定要能够正确连接 api 所在 ip, 并且没有经过 nat 地址转换。否则不能正确获取instance 的metadata

openstack 的 metadata获取,我修正了一个bug:
https://review.openstack.org/#/c/5961/
https://code.launchpad.net/bugs/968453

但是,在某些场合,管理地址分开的情况下,还有bug, 需要继续改进:

https://bugs.launchpad.net/nova/+bug/982356

发表在 OpenStack | 留下评论

阿里云分享摘要

昨天阿里云弹性计算平台的郑永升,做了《阿里云弹性计算产品》的分享,主要介绍了阿里云弹性计算产品,并重点介绍自己在弹性计算产品运维中积累的安全防护以及集群管理方面的经验。下面是一些摘要:

http://vdisk.weibo.com/s/4tTcO

  • 阿里云使用的是自己开发的分布式操作系统飞天(Apsara),底层的分布式文件系统,解决了不同主机上虚拟机的迁移问题
  • 目前主要的销售渠道,在万网和阿里、淘宝的一些客户。万网相当于阿里云的一个销售。这是一个不错的组合。
  • 目前,阿里云的用户数,大概在一万
  • DDOS攻击现在是一个常态,阿里每天现在遭受数十次DDOS攻击,采用流量清洗和黑洞来解决。自动检测异常流量,然后触发清洗和黑洞。
  • 云计算环境下,安全是一个大问题。阿里每天现在除了DDOS,还每天新增100+以上的被挂马,windows RDP高危漏洞
  • 目前,用户中,windows操作系统占50%以上,但是Linux的增长迅速
  • 云计算下,硬件故障成为常态,每个月迁移100+次,硬盘年故障率1.62%
  • 30%的服务请求(工单)是由于用户的误操作导致的(比如修改fstab)
发表在 DEVOPS | 标签为 | 留下评论

淘宝子团关于kvm 调优的分享

今天在杭州参加淘宝嘉年华技术沙龙,主题是虚拟化和云计算,三个讲演:

  • 淘宝网子团分享淘宝kvm技术的使用
  • 华为的杨晓伟介绍虚拟化技术
  • 阿里云郑永升介绍弹性云计算技术

其中KVM 调优,三点值得关注的:

1、Kernel SamePage Merging(KSM)

在CentOS下KSM是打开的,Debian下KSM是关闭的。KSM的原理,是多个进程中,Linux将内核相似的内存页合并成一个内存页。这个特性,被KVM用来减少多个相似的虚拟机的内存占用,提高内存的使用效率。由于内存是共享的,所以多个虚拟机使用的内存减少了。这个特性,对于虚拟机使用相同镜像和操作系统时,效果更加明显。

但是,事情总是有代价的,使用这个特性,都要增加内核开销,用时间换空间。所以为了提高效率,可以将这个特性关闭。方法是:

两种关闭方式:

echo 0 > /sys/kernel/mm/ksm/run

或者

chkconfig ksm off
chkconfig ksmtuned off

另外,如果要使用KSM特性,也可以对参数进行调优。

具体参见:

http://www.linuxtopia.org/online_books/rhel6/rhel_6_virtualization/rhel_6_virtualization_chap-KSM.html

2、KVM Huge Page Backed Memory

intel 的X86 CPU通常使用4Kb内存页,当是经过配置,也能够使用巨页(huge page):

(4MB on x86_32, 2MB on x86_64 and x86_32 PAE)

使用巨页,KVM的虚拟机的页表将使用更少的内存,并且将提高CPU的效率。最高情况下,可以提高20%的效率!

使用方法,需要三部:

mount -t hugetlbfs hugetlbfs /dev/hugepages
#保留一些内存给巨页
sysctl vm.nr_hugepages=516
#给 kvm 传递参数 hugepages
qemu-kvm - qemu-kvm -mem-path /dev/hugepages

其中第三步,也可以在配置文件里加入:

<memoryBacking>
<hugepages/>
</memoryBacking>

验证方式,当虚拟机正常启动以后,在虚拟机里查看:

cat /proc/meminfo |grep -i HugePages_Free

3、sheepdog 存储的使用

taobao有已经在sheepdog上做了很多工作,代码贡献量已经排在最前面。

有几个重要的feature改进和很多bug fix。

taobao已经在95个物理机和950个虚拟机的环境下,做了测试。

具体可以参见:

http://sheepdog.taobao.org/

这是一个令人兴奋的改进。

 

发表在 OpenStack | 标签为 | 留下评论

openstack 的 vnc 支持的浏览器

https://github.com/kanaka/noVNC/wiki/Browser-support

Windows 7 (64-bit)

Browser Status Performance Notes
Chrome 14.0.835.186 Perfect Fast 32-bit. Native WebSockets
Firefox 7.0 Perfect Fast 32-bit. Native WebSockets
Opera 11.51 Perfect Fast 32-bit. WebSocket emulation with web-socket-js
Safari 5.1 Excellent Fast 32-bit. Native WebSockets. Disconnect issues
IE 9.0.8112.16421 Good Fast 32-bit. WebSocket emulation with web-socket-js. Styling issues
Firefox 6.0.2 Fair Slow (note 3) 32-bit. Native WebSockets

发表在 OpenStack | 留下评论

openstack下VNC的配置

由于云主机instance所在的compute一般在内网运行,而instance的VNC端口,是绑定在compute的IP地址上。外网的客户,需要访问instance的VNC,就需要使用Proxy代理。客户访问VNC,一般有两种方式的客户端,分别对应两种Proxy:

1、支持web socket的浏览器,比如 Chrome, FireFox等,使用 NoVNC
2、java客户端代理,使用xvpvncproxy

为了客户方便,一般使用第一种方式,这里就讲讲第一种方式下的VNC配置。

1、安装软件
1)在控制节点 controller上,需要安装:
nova-consoleauth
novnc
python-novnc

注:
也可以将控制节点放在内网,专门设置一个api节点,这时,nova-consoleauth就需要安装在控制节点上,另外两个软件包安装在api节点上。

2)计算节点compute上,不需要特别安装什么软件,只要正确设置

2、配置

假定网络接入如下:

控制节点或者api节点: 公网地址 192.168.28.4 管理口内网地址:10.0.0.4
计算节点: 管理口内网地址: 10.0.0.6
实例VM的IP地址段:10.9.0.0/24

1)控制节点或 api 节点配置

vncserver_proxyclient_address=10.0.0.6
novncproxy_base_url=http://192.168.28.4:6080/vnc_auto.html
xvpvncproxy_base_url=http://192.168.28.4:6081/console

2)计算节点配置

vncserver_proxyclient_address=10.0.0.6
novncproxy_base_url=http://192.168.28.4:6080/vnc_auto.html
xvpvncproxy_base_url=http://192.168.28.4:6081/console

#设定 compute上,vnc绑定的IP
vncserver_listen=10.0.0.6

3、测试

1) 在控制节点上,要能够连接计算节点的 vnc,比如第一个vnc端口是5900

# telnet 10.0.0.6 5900
Trying 10.0.0.6...
Connected to 10.0.0.6.
Escape character is '^]'.
RFB 003.008

2) 外网用户,要能够连接控制节点的6800端口

3)使用浏览器测试

注意,请使用 chrome 和 firefox 等支持 HTML5 和 websocket 的浏览器测试。IE至少需要 IE9 ,而且还可能有问题。

# nova get-vnc-console t1 novnc

+-------+-----------------------------------------------------------------------------------+
| Type | Url |
+-------+-----------------------------------------------------------------------------------+
| novnc | http://192.168.28.4:6080/vnc_auto.html?token=f5abd84d-708f-4486-af61-40c6e5a876c0 |
+-------+-----------------------------------------------------------------------------------+

注意:
1、vncserver_listen 参数的修改,对于已经启动的实例无效,这些实例必须重新启动
2、注意浏览器的版本
3、浏览器不能使用代理,否则出现无法连接错误

发表在 OpenStack | 留下评论

openstack的官方文档到底包括哪些?

说实话,openstack的文档有点乱,分散在几个地方。

这次会议上,有几个议题就是谈文档的,这里给出了一个官方文档列表:

http://etherpad.openstack.org/folsomdocsplanning

Session: http://summit.openstack.org/sessions/view/151

Blueprint:

Presenter: Anne Gentle, OpenStack Content Stacker at Rackspace, anne@openstack.org

zSession Goals:

Discuss criteria for priorities – audience? Reach based on web views? Others?

Describe the top three priorities for the timeframe of April 2012 to October 2012. Vote on these listed priorities:

1. Configuration information and reference architectures/scenarios for deployments, point out what

2. CLI documentation

3. Add Quantum to Compute guides

4. Move narrative docs from rst to main manuals

5. Redesign landing page based on personas

6. Genericize install docs for distros
Make it easy to report bug

Make it easy to find

Real deployment – config options

examples of different configurations!

keeping in mind the hardware arch and switch config required by those OpenStack configs

see “best practices” below

point out things that will change “at scale”

identify “deployers” as a key audience for the docs, differentiated from “admin”

Examples of how to interact with the API (go beyond JSON blobs)

Explain policy.json and how the defaults control which parts of the API are admin and which are not

Add Quantum to the compute guide

python clients (CLI)

best practices at virtualization layer and choices in images

“if you don’t know what you’re doing, do this”

make the installation docs more generic to include distros other than Ubuntu

need to identify key distros

persona-based landing page redesign

–how to find a source of truth

move narrative docs from rst to main manuals

 

Understand the breadth and depth of the sites used for documentation.

Should documentation keep up with milestone release points?
Description of all the sites used for various documentation processes:
Site Visitors per month (March-April 2012)

www 113,103

docs 95,907

wiki 58,367

swift 14,313

nova 13,885

api 2,666
__Admin guides__

Where: http://github.com/openstack/openstack-manuals

What:

– docs.openstack.org

– Compute Admin manual

– Object Storage Admin manual

– Supporting projects such as identity and image management are shared chapters inserted into each.

– Network connectivity (Quantum) Admin manual

Who:

Day-to-day administrators of OpenStack clouds (public and private)

How: Updated through the git/Gerrit review process.
__Install guides__

Where: http://github.com/openstack/openstack-manuals

What: docs.openstack.org Compute Install/Deploy guide with identity, image management, dashboard as chapters.

How: Updated through the git/Gerrit review process.

Where: http://launchpad.net/openstackbook

What: docs.openstack.org Ubuntu release-based OpenStack Starter Guide for Natty (Cactus), Oneiric (Diablo), Precise (Essex) soon to be completed

How: Updated through bzr/Launchpad merge processes.

Where: http://www.hastexo.com/resources/docs/installing-openstack-essex-4-ubuntu-1204-precise-pangolin

What: 12.04 Quick Start from Hastexo. It’s a great doc, but I think it could receive even more attention and updates if it were in the OpenStack docs umbrella, so I’m talking to the authors about submitting it.

Who:

Deployers of OpenStack clouds (public and private), proof-of-concept creators
__API info__

Where:

http://github.com/openstack/openstack-manuals

http://github.com/openstack/object-api

http://github.com/openstack/compute-api

http://github.com/openstack/netconn-api

http://github.com/openstack/identity-api

http://github.com/openstack/image-api

What:

openstack-manuals contains:

– docs.openstack.org

– API Quick Start

– Compute API Programmer’s Guide

– api.openstack.org

– OpenStack Compute extensions

Separate repos contain:

(pointed to from docs.openstack.org/api)

– OpenStack Compute API Dev Guide

– OpenStack Object Storage API Dev Guide

– OpenStack Image API Dev Guide

– OpenStack Identity API Dev Guide

– OpenStack Quantum API Dev Guide

Note: In making this listing I realized that Melange has an API spec at https://github.com/openstack/melange/blob/master/doc/source/apidoc.rst. Their latest commit says they make it so it builds to rtfd.org but I can’t find it on that site. Note sent to Dan and Troy.

Who: API programmers, Python developers

How: Updated through the git/Gerrit review process.
__Wiki__

Where: http://wiki.openstack.org

What: Release notes, project status and process information, very little how-to

Who: Contributors to the OpenStack projects
__Developer info__

Where: http://github.com/openstack/nova/

http://github.com/openstack/swift/

http://github.com/openstack/keystone/

http://github.com/openstack/glance/

http://github.com/openstack/horizon/

http://github.com/openstack/openstack-ci/
What:

http://nova.openstack.org

http://swift.openstack.org

http://keystone.openstack.org

http://glance.openstack.org

http://horizon.openstack.org

http://ci.openstack.org
__Main website__

Where: Silverstripe CMS with a few people with logins

What: openstack.org and all pages in it

Who: People who want to learn about OpenStack, community members, company members
__Related websites__

Where: http://github.com/openstack-dev/devstack

What: http://devstack.org
Where: not sure, probably Silverstripe CMS with a few people with logins

What: http://trystack.org

Who: People who want to learn about OpenStack, community members, company members
__Third party blogs and websites__

Where: The Internet

What: How-to and conceptual information about OpenStack

Who: Bloggers

How: I tend to link to good how-to information from bloggers at http://wiki.openstack.org/BloggersTips. Better curation methods would be great. I also contact bloggers directly and work with them to bring in CC licensed content to openstack-manuals.
__Planet Feeds__

Where: http://planet.openstack.org

What: Misc. blogs

Who: Bloggers

How: http://wiki.openstack.org/AddingYourBlog
__OpenStack directory / Satellite__

Where: TBD (asked for satellite.openstack.org)

What: List of projects related to OpenStack

Who: developers, deployers

How: TBD

发表在 OpenStack | 标签为 | 留下评论