操作系统我用的是ubuntu 12.04,每台机子都配了ntp。 openstack安装是个很麻烦的工作,本文档是我自己安装的记录。在此感谢下liangbo.me的博主,他的安装文档给了我很大的帮助,我就是基于他的文档来的。
操作系统我用的是ubuntu 12.04,每台机子都配了ntp。
openstack安装是个很麻烦的工作,本文档是我自己安装的记录。在此感谢下liangbo.me的博主,他的安装文档给了我很大的帮助,我就是基于他的文档来的。博客地址:http://liangbo.me/index.php/2012/03/27/11/。
我使用了6台电脑来安装openstack,分配如下:
keystone
Host:keystone
ip:192.168.0.106
mysql, keystone
Swift
Host:swift1
ip:192.168.0.110
Proxy-server, account-server, container-server, object-server
Host:swift2
ip:192.168.0.111
account-server, container-server, object-server
Glance
Host:glance
ip:192.168.0.112
Glance-api, glance-registry
Compute
Host:compute1
ip: 192.168.0.114
rabbitmq-server bridge-utils compute-control相关组件
Host:compute2
ip: 192.168.0.109
Nova-compute
dashboard
Host:compute1
ip: 192.168.0.114
openstack-dashboard
原文链接:http://blog.csdn.net/nocturne1210/article/details/7877188
操作系统我用的是ubuntu 12.04,每台机子都配了ntp。 openstack安装是个很麻烦的工作,本文档是我自己安装的记录。在此感谢下liangbo.me的博主,他的安装文档给了我很大的帮助,我就是基于他的文档来的。博客地址:http://liangbo.me/index.php/2012/03/27/11/。 我使用了6台电脑来安装openstack,分配如下:
原文链接:http://blog.csdn.net/nocturne1210/article/details/7877188 |
openstack安装(2)——keystone
keystone是openstack中用于身份验证的项目,任何服务请求需要经过它的验证获得服务的endpoint。具体作用请看相关官方文档。这里我使用的是mysql来存储keystone的数据。
1、安装 1)安装数据库 sudoapt-get install mysql-server mysql-client python-mysqldb 进/etc/mysql/my.cnf里,将bind-address=127.0.0.1改成 0.0.0.0。这样远程主机就可以连接上这个mysql。 重启mysql服务。sudo service mysql restart 2)安装keystone Ø 安装软件 sudoapt-get install keystone 创建keystone数据库,并创建用户以及分配权限。 create database keystone; grant all on keystone.* to 'keystone'@'%' identified by 'keystonepwd';
Ø 配置keystone 配置keystone,修改/etc/keystone/keystone.conf文件: [sql] #connection = sqlite:var/lib/keystone/keystone.db connection = mysql://keystone:keystonepwd@192.168.0.106/keystone
这里注意一下该文件里的这部份信息,记住admin_token参数,以后会用的上,这个参数是用来访问keystone服务的。默认是ADMIN,也可以改成别的。 [DEFAULT] public_port = 5000 admin_port = 35357 admin_token = ADMIN compute_port = 8774 verbose = True debug = True log_config =/etc/keystone/logging.conf
重启keystone服务 sudoservice keystone restart 同步数据库, sudokeystone-manage db_sync 然后去数据库里看, mysql>show tables;
+------------------------+ |Tables_in_keystone | +------------------------+ |ec2_credential | |endpoint | |metadata | |migrate_version | |role | |service | |tenant | |token | |user | |user_tenant_membership | +------------------------+
2、使用keystone 导入环境变量,当然也可以在每次执行keystone命令时加上这方面的参数,keystone 命令格式参见它的help export SERVICE_TOKEN=ADMIN exportSERVICE_ENDPOINT=http://192.168.0.106:35357/v2.0
添加tenant: keystonetenant-create --name adminTenant --description "Admin Tenant"--enabled true keystone@keystone:~$keystone tenant-list +----------------------------------+-------------+---------+ | id | name | enabled | +----------------------------------+-------------+---------+ |72a95ab302cc42d59e6f414769dcfec7 | adminTenant | True | +----------------------------------+-------------+---------+
添加user: keystoneuser-create --tenant_id 72a95ab302cc42d59e6f414769dcfec7 --name admin --passopenstack --enabled true keystone@keystone:~$ keystone user-list +----------------------------------+---------+-------+-------+ | id | enabled | email | name | +----------------------------------+---------+-------+-------+ |4fd5ba059a6945c0a43ff63b0140b0a9 | True | None | admin | +----------------------------------+---------+-------+-------+
添加role keystonerole-create --name adminRole keystone@keystone:~$ keystone role-list +----------------------------------+-----------+ | id | name | +----------------------------------+-----------+ |675b96a12d834021b519ef50502a5e5e | adminRole | +----------------------------------+-----------+
将这三者关联 keystoneuser-role-add --user 4fd5ba059a6945c0a43ff63b0140b0a9 --tenant_id72a95ab302cc42d59e6f414769dcfec7 --role 675b96a12d834021b519ef50502a5e5e
这样就ok了。测试一下,用curl工具测试。 sudo apt-get install curl 我们先输入一个错误的密码试试 curl-d '{"auth": {"tenantName": "adminTenant","passwordCredentials":{"username": "admin","password": "wrong"}}}' -H"Content-type: application/json" http://192.168.0.106:35357/v2.0/tokens| python -mjson.tool 返回结果 { "error":{ "code":401, "message":"Invalid user / password", "title":"Not Authorized" } } 如果用户名/密码都正确的话 curl -d'{"auth": {"tenantName": "adminTenant","passwordCredentials":{"username": "admin","password": "openstack"}}}' -H "Content-type:application/json" http://192.168.0.106:35357/v2.0/tokens | python-mjson.tool 就会返回很多信息,如token、user等,内容太多了,这里我就不贴了。
原文链接:http://blog.csdn.net/nocturne1210/article/details/7877307 |
这篇文章介绍的是在Openstack nova开发过程中如何进行单元测试,在nova的开发环境搭建好之后,如果对源码进行了修改,就应该做单元测试,本篇文章基本上是对官方文档的翻译,仅对关键步骤稍作介绍,相关的资料后面列举。 1.执行测试 上一篇文章中已经介绍过单元测试的方法,执行测试脚本:
这样会对整个nova工程进行一次测试,会花不少时间。这个脚本里封装了nose测试框架的用法,关于nose可以自己搜索相关资源,也可以到这里了解。这个脚本支持许多不同的参数以获得相应的信息,具体参数如下:
想了解更多关于参数的信息,点击这里。 上面是对整个工程的测试,如果仅想对某个模块或功能做测试的话,可以运行相应的测试子集:
上面的代码是对nova调度器模块做的测试,也可以对模块中的具体类或方法做测试,如下:
2.控制输出 默认情况下,执行测试之后,会在控制台输出大量的测试信息,在这些输出中找到想要的结果还是比较困难的,即便是 重定向到文件中,依然不是很方便,这样就需要控制测试的输出结果。在执行测试的时候添加一个参数就可以:
|
This HOWTO will guide you though a multi-node Openstack Essex deployment with Puppet on Ubuntu 12.04.
PrerequisitesThis environment will include 3 hosts:
My overall design (for sure, just for internal development and testing):
Network setup example for /etc/network/interfaces (update with your dns-* accordingly): auto lo iface lo inet loopback auto eth0 iface eth0 inet static address 172.24.0.11 netmask 255.255.0.0 network 172.24.0.0 broadcast 172.24.255.255 gateway 172.24.0.1 dns-nameservers 202.130.97.65 202.130.97.66 dns-search hkstp.internal auto eth1 iface eth1 inet manual up ifconfig eth1 up You may also need to map above hostname statically by editing /etc/hosts as below: 127.0.0.1 localhost 172.24.0.11 vms1.hkstp.internal vms1 172.24.0.12 vms2.hkstp.internal vms2 172.24.0.13 vms3.hkstp.internal vms3 Every node that is configured to be a nova volume service must have a volume group called nova-volumes.
Install Puppet(All nodes) Install puppet agent: aptitude -y install puppet augeas-tools (Controller node only) Install puppetmaster by APT, and also install puppetlabs_spec_helper by Gem: aptitude -y install puppetmaster sqlite3 libsqlite3-ruby libactiverecord-ruby git rake gem install puppetlabs_spec_helper (All nodes) Enable pluginsync and configure the hostname of the puppetmaster: augtool << EOF set /files/etc/puppet/puppet.conf/agent/pluginsync true set /files/etc/puppet/puppet.conf/agent/server vms1.hkstp.internal save EOF (Controller node only) Enable storedconfig and configure database: augtool << EOF set /files/etc/puppet/puppet.conf/master/storeconfigs true set /files/etc/puppet/puppet.conf/master/dbadapter sqlite3 set /files/etc/puppet/puppet.conf/master/dblocation /var/lib/puppet/server_data/storeconfigs.sqlite save EOF (Controller node only) Create a dummy site manifest: cat > /etc/puppet/manifests/site.pp << EOF node default { notify { "Hey ! It works !": } } EOF (Controller node only) Restart puppetmaster /etc/init.d/puppetmaster restart Test the puppet agents(All nodes) Register each client with the puppetmaster: puppet agent -vt --waitforcert 60 (Controller node only) While the puppet agent is waiting, sign the client certificates: puppetca sign -a There should be no error and you should see similar message as below on client: info: Caching catalog for vms3.hkstp.internal info: Applying configuration version '1340077073' notice: Hey ! It works ! Install the Openstack modules for PuppetBefore keep on going it is strongly recommend to reboot your system: reboot (Controller node only) Install the latest revision of the modules from GIT: cd /etc/puppet/modules git clone git://github.com/puppetlabs/puppetlabs-openstack openstack cd openstack rake modules:clone Now your /etc/puppet/modules should looks like below: root@vms1:/etc/puppet/modules# ls -la /etc/puppet/modules/ total 80 drwxr-xr-x 20 root root 4096 Jun 19 11:55 . drwxr-xr-x 6 root root 4096 Jun 19 11:46 .. drwxr-xr-x 7 root root 4096 Jun 19 11:55 apt drwxr-xr-x 7 root root 4096 Jun 19 11:54 concat drwxr-xr-x 5 root root 4096 Jun 19 11:55 git drwxr-xr-x 9 root root 4096 Jun 19 11:55 glance drwxr-xr-x 6 root root 4096 Jun 19 11:55 horizon drwxr-xr-x 9 root root 4096 Jun 19 11:55 keystone drwxr-xr-x 7 root root 4096 Jun 19 11:54 memcached drwxr-xr-x 9 root root 4096 Jun 19 11:55 mysql drwxr-xr-x 11 root root 4096 Jun 19 11:55 nova drwxr-xr-x 7 root root 4096 Jun 19 11:54 openstack drwxr-xr-x 9 root root 4096 Jun 19 11:55 rabbitmq drwxr-xr-x 8 root root 4096 Jun 19 11:55 rsync drwxr-xr-x 7 root root 4096 Jun 19 11:55 ssh drwxr-xr-x 7 root root 4096 Jun 19 11:55 stdlib drwxr-xr-x 10 root root 4096 Jun 19 11:55 swift drwxr-xr-x 5 root root 4096 Jun 19 11:55 sysctl drwxr-xr-x 6 root root 4096 Jun 19 11:55 vcsrepo drwxr-xr-x 8 root root 4096 Jun 19 11:55 xinetd Deploy Openstack controller node on multi-node environment(Controller node only) Some patch to latest GIT so suit for my usecase (therefore you should futher more override them with your case): cat > /tmp/puppetlabs-openstack.patch << EOF diff --git examples/site.pp examples/site.pp index 879d8fa..fd38d4e 100644 --- examples/site.pp +++ examples/site.pp @@ -4,7 +4,9 @@ # # deploy a script that can be used to test nova -class { 'openstack::test_file': } +class { 'openstack::test_file': + image_type => 'ubuntu', +} ####### shared variables ################## @@ -21,17 +23,17 @@ \$public_interface = 'eth0' \$private_interface = 'eth1' # credentials \$admin_email = 'root@localhost' -\$admin_password = 'keystone_admin' -\$keystone_db_password = 'keystone_db_pass' -\$keystone_admin_token = 'keystone_admin_token' -\$nova_db_password = 'nova_pass' -\$nova_user_password = 'nova_pass' -\$glance_db_password = 'glance_pass' -\$glance_user_password = 'glance_pass' -\$rabbit_password = 'openstack_rabbit_password' -\$rabbit_user = 'openstack_rabbit_user' -\$fixed_network_range = '10.0.0.0/24' -\$floating_network_range = '192.168.101.64/28' +\$admin_password = 'openstack' +\$keystone_db_password = 'openstack' +\$keystone_admin_token = 'bdbb8df712625fa7d1e0ff1e049e8aab' +\$nova_db_password = 'openstack' +\$nova_user_password = 'openstack' +\$glance_db_password = 'openstack' +\$glance_user_password = 'openstack' +\$rabbit_password = 'openstack' +\$rabbit_user = 'openstack' +\$fixed_network_range = '10.1.0.0/16' +\$floating_network_range = '172.24.1.0/24' # switch this to true to have all service log at verbose \$verbose = false # by default it does not enable atomatically adding floating IPs @@ -75,7 +77,7 @@ node /openstack_all/ { # multi-node specific parameters -\$controller_node_address = '192.168.101.11' +\$controller_node_address = '172.24.0.11' \$controller_node_public = \$controller_node_address \$controller_node_internal = \$controller_node_address @@ -83,9 +85,9 @@ \$sql_connection = "mysql://nova:\${nova_db_password}@\${controller_node_in node /openstack_controller/ { -# class { 'nova::volume': enabled => true } + class { 'nova::volume': enabled => true } -# class { 'nova::volume::iscsi': } + class { 'nova::volume::iscsi': } class { 'openstack::controller': public_address => \$controller_node_public, @@ -142,7 +144,7 @@ node /openstack_compute/ { vncproxy_host => \$controller_node_public, vnc_enabled => true, verbose => \$verbose, - manage_volumes => true, + manage_volumes => false, nova_volume => 'nova-volumes' } EOF cd /etc/puppet/modules/openstack patch -p0 < /tmp/puppetlabs-openstack.patch Link the module's example site.pp on the controller for production (I do so therefore able to keep trace changes with GIT): rm -rf /etc/puppet/manifests/site.pp ln -s /etc/puppet/modules/openstack/examples/site.pp /etc/puppet/manifests/site.pp Once everything is configured on the controller, you can now configure the controller node by: puppet agent -vt --waitforcert 60 --certname openstack_controller While the puppet agent is waiting, sign the client certificates: puppetca sign -a Now wait and have a coffee break... Once ready, access http://172.24.0.11/ and should show Openstack Dashboard as below: Login with admin/openstack and should show screen as below: Deploy Openstack compute node on multi-node environmentOnce controller get ready, configure compute nodes by: puppet agent -vt --waitforcert 60 --certname openstack_compute_vms1 puppet agent -vt --waitforcert 60 --certname openstack_compute_vms2 puppet agent -vt --waitforcert 60 --certname openstack_compute_vms3 While the puppet agent is waiting, sign the client certificates: puppetca sign -a Now wait and have a coffee break... Verify your Openstack deploymentOnce you have installed Openstack with Puppet (and assuming you experience no errors), the next step is to verify the installation. Ensure that your authentication information is in the user's environment by: source /root/openrc For development I would like to release firewall rules for all conntection: nova secgroup-add-rule default tcp 1 65535 0.0.0.0/0 nova secgroup-add-rule default udp 1 65535 0.0.0.0/0 nova secgroup-add-rule default icmp -1 255 0.0.0.0/0 Verify that all of the services for nova are operational by (Ctrl + C to terminate): watch -n1 nova-manage service list Which should give you similar result as: Every 1.0s: nova-manage service list Tue Jun 19 15:52:12 2012 2012-06-19 15:52:12 DEBUG nova.utils [req-7eb90044-238e-4ff5-b60a-cbf7fc243b2e None None] backend <module ' nova.db.sqlalchemy.api' from '/usr/lib/python2.7/dist-packages/nova/db/sqlalchemy/api.pyc'> from (pid=3498) __get_backend /usr/lib/python2.7/dist-packages/nova/utils.py:658 Binary Host Zone Status State Updated_At nova-consoleauth vms1 nova enabled :-) 2012-06-19 07:52:05 nova-scheduler vms1 nova enabled :-) 2012-06-19 07:52:05 nova-cert vms1 nova enabled :-) 2012-06-19 07:52:05 nova-compute vms1 nova enabled :-) 2012-06-19 07:52:09 nova-volume vms1 nova enabled :-) 2012-06-19 07:52:05 nova-network vms1 nova enabled :-) 2012-06-19 07:52:07 nova-network vms3 nova enabled :-) 2012-06-19 07:52:05 nova-volume vms3 nova enabled :-) 2012-06-19 07:52:03 nova-compute vms3 nova enabled :-) 2012-06-19 07:52:11 Run the test script in order to import default images, add key, and start it: cp /etc/puppet/modules/openstack/files/nova_test.sh /tmp/nova_test.sh cd /tmp bash ./nova_test.sh Now access http://172.24.0.11/ and test as below:
Upgrading(Controller node only) First of all you should MANUALLY access all /etc/puppet/modules/* GIT clone and pull with latest update... That's too complicated! Let's download my lazy git-pull-all.sh script and get it done within seconds! wget http://edin.no-ip.com/files/git-pull-all_sh mv git-pull-all_sh /usr/local/bin/git-pull-all.sh chmod a+x /usr/local/bin/git-pull-all.sh git-pull-all.sh /etc/puppet/modules Go back to controller and redeploy with latest setup: puppet agent -vt --waitforcert 60 --certname openstack_controller And so for compute nodes too: puppet agent -vt --waitforcert 60 --certname openstack_compute_vms1 puppet agent -vt --waitforcert 60 --certname openstack_compute_vms2 puppet agent -vt --waitforcert 60 --certname openstack_compute_vms3 Don't forget to reboot all of your systems ;-) |