本帖最后由 xioaxu790 于 2014-6-6 08:55 编辑
问题导读:
1、什么是 DevStack,如何使用?
2、Openstack下如何手动开启各个服务?
3、如何导入环境变量?
一.使用DevStack搭建框架
DevStack是一个开源脚本,用于搭建单节点的openstack开发环境。但是,如果不在localrc脚本里修改相应配置,其搭建出来的openstack不包含quantum模块(如何配置使其包含quantum模块openstack官网有说明),并且这个是使用screen技术集成的各个模块,重启之后需要手动开启各个服务,并导入环境变量。
开启各服务命令:
1.keystone
- keystone-all --config-file=/etc/keystone/keystone.conf &(&的意思是keystone在后台运行,可不加)
复制代码
2.glance
- glance-api --config-file=/etc/glance/glance-api.conf &
- glance-registry --config-file=/etc/glance/glance-registry.conf &
复制代码
3.cinder
- cinder-all --config-file=/etc/cinder/cinder.conf &
复制代码
4.nova
- nova-api-os-compute --config-file=/etc/nova/nova.conf &
- nova-api-metadata --config-file=/etc/nova/nova.conf &
- nova-compute --config-file=/etc/nova/nova.conf &
- nova-cert --config-file=/etc/nova/nova.conf &
- nova-scheduler --config-file=/etc/nova/nova.conf &
- nova-volume --config-file=/etc/nova/nova.conf &
- nova-network --config-file=/etc/nova/nova.conf &
- nova-consoleauth --config-file=/etc/nova/nova.conf &
- nova-novncproxy --config-file=/etc/nova/nova.conf &
- #nova-xvpvncproxy --config-file=/etc/nova/nova.conf &
- #nova-consoleauth --config-file=/etc/nova/nova.conf &
- nova-objectstore --config-file=/etc/nova/nova.conf &
- -----或者直接nova-all --config-file=/etc/nova/nova.conf &
-
复制代码
导入环境变量:
导入环境变量主要是通过keystone认证的需要
- export OS_SERVICE_TOKEN=123456
- export OS_USERNAME=admin
- export OS_PASSWORD=123456
- export OS_TENANT_NAME=admin
- export OS_AUTH_URL=http://localhost:5000/v2.0/
- export OS_SERVICE_ENDPOINT=http://localhost:35357/v2.0/
复制代码
导入成功后可用env命令查看
使用glance创建镜像文件的命令
- glance add name="ubuntu-test" container_format=bare disk_format=raw is_public=true</home/zg/下载/ubuntu.img
复制代码
二.安装quantum模块
首先,需要保证quantum的版本和其他模块的版本匹配(我安装的是quantum-2012.2版本),否则会出如下错误:
Python代码
- Traceback (most recent call last):
- File "/usr/local/lib/python2.7/dist-packages/cliff/app.py", line 249, in run_subcommand
- result = cmd.run(parsed_args)
- File "/usr/local/lib/python2.7/dist-packages/python_quantumclient-0.0.0-py2.7.egg/quantumclient/common/command.py", line 35, in run
- return super(OpenStackCommand, self).run(parsed_args)
- File "/usr/local/lib/python2.7/dist-packages/cliff/display.py", line 84, in run
- column_names, data = self.take_action(parsed_args)
- File "/usr/local/lib/python2.7/dist-packages/python_quantumclient-0.0.0-py2.7.egg/quantumclient/common/command.py", line 41, in take_action
- return self.get_data(parsed_args)
- File "/usr/local/lib/python2.7/dist-packages/python_quantumclient-0.0.0-py2.7.egg/quantumclient/quantum/v2_0/__init__.py", line 255, in get_data
- data = obj_creator(body)
- File "/usr/local/lib/python2.7/dist-packages/python_quantumclient-0.0.0-py2.7.egg/quantumclient/v2_0/client.py", line 102, in with_params
- ret = self.function(instance, *args, **kwargs)
- File "/usr/local/lib/python2.7/dist-packages/python_quantumclient-0.0.0-py2.7.egg/quantumclient/v2_0/client.py", line 262, in create_network
- return self.post(self.networks_path, body=body)
- File "/usr/local/lib/python2.7/dist-packages/python_quantumclient-0.0.0-py2.7.egg/quantumclient/v2_0/client.py", line 593, in post
- headers=headers, params=params)
- File "/usr/local/lib/python2.7/dist-packages/python_quantumclient-0.0.0-py2.7.egg/quantumclient/v2_0/client.py", line 518, in do_request
- self._handle_fault_response(status_code, replybody)
- File "/usr/local/lib/python2.7/dist-packages/python_quantumclient-0.0.0-py2.7.egg/quantumclient/v2_0/client.py", line 499, in _handle_fault_response
- exception_handler_v20(status_code, des_error_body)
- File "/usr/local/lib/python2.7/dist-packages/python_quantumclient-0.0.0-py2.7.egg/quantumclient/v2_0/client.py", line 82, in exception_handler_v20
- message=message)
- QuantumClientException: 404 Not Found
-
- The resource could not be found.
复制代码
启动quantum:
quantum一共有四部分,他们的启动顺序有一定要求
Python代码
- 1.sudo quantum-openvswitch-agent --config-file=/etc/quantum/plugins/openvswitch/ovs_quantum_plugin.ini
- 2.sudo quantum-server --config-file=/etc/quantum/quantum.conf --config-file=/etc/quantum/plugins/openvswitch/ovs_quantum_plugin.ini
- 3.sudo quantum-dhcp-agent --config-file=/etc/quantum/quantum.conf --config-file=/etc/quantum/dhcp_agent.ini
- 4.sudo quantum-l3-agent --config-file=/etc/quantum/l3_agent.ini
复制代码
调试quantum过程中遇到的各种小错误:
1.日志输出AMQP server on localhost:5672 is unreachable问题的解决方法
/etc/quantum/quantum.conf配置文件中 配置rabbit的内容
- [default]
- rabbit_password = 123456
- rabbit_host = localhost
复制代码
2.endpoint错误解决方法
需要在keystone里为每个服务配置endpoint
3.启动nova-compute的ImportError: No module named quantum.manager问题
注释掉nova.conf中的network_manager即可
4.修复启动quantum-l3-agent时导入模块错误
- sed -i 's/quantum-l3-agent = quantum.agent.l3_nat_agent:main/quantum-l3-agent = quantum.agent.l3_agent:main/g' setup.py
复制代码
5.修复eventlet一个bug
- sed -i 's/def wait(self, check_interval=0.01):/def wait(self, check_interval=0.01,timeout=None):/g' /usr/lib/python2.6/site-packages/eventlet/green/subprocess.py
复制代码
6.quantum-dhcp启动问题
报错:
- 2012-12-11 14:47:12 INFO [quantum.openstack.common.rpc.common] Connected to AMQP server on localhost:5672
- 2012-12-11 14:48:12 ERROR [quantum.openstack.common.rpc.common] Timed out waiting for RPC response: timed out
复制代码
需要在quantum-dhcp 的启动命令里加quantum.conf配置文件
7.启动quantum-server时Cannot operate on a closed database的问题:
quantum-server启动要加ovs插件的配置文件
8.quantum-server net-list出错
报错:
- 2012-12-12 14:20:52 ERROR [quantum.openstack.common.policy] Failed to understand rule u'l'
- Traceback (most recent call last):
- File "/usr/local/lib/python2.7/dist-packages/quantum-2012.2-py2.7.egg/quantum/openstack/common/policy.py", line 161, in _check
- ValueError: need more than 1 value to unpack
- /etc/quantum/policy.py
复制代码
用/opt/stack/quantum/etc/policy.py覆盖etc/quantum下的同名文件即可
9.虚拟机分配不到ip地址问题
需要先用quantum创建net subnet router等等
- tenant_id=`keystone tenant-list |awk '/ admin/ {print $2}'`
- net_id=`quantum net-create --tenant-id $tenant_id net_one --provider:network_type flat --provider:physical_network physnet1 |awk '/ id/ {print $4}'`
- subnet_id=`quantum subnet-create --tenant-id $tenant_id --ip_version 4 --gateway 10.0.0.1 $net_id 10.0.0.0/24 -- --enable_dhcp=True |awk '/ id/ {print $4}'`
- router_id=`quantum router-create --tenant-id $tenant_id router1 |awk '/ id/ {print $4}'`
- quantum router-interface-add $router_id $subnet_id
复制代码
quantum.conf的相关配置进行调整
- sed -i 's/sql_connection = sqlite:\/\//sql_connection = mysql:\/\/root:123456@localhost\/ovs_quantum/g' /etc/quantum/quantum/plugins/openvswitch/ovs_quantum_plugin.ini
- sed -i '24a tenant_network_type = none' /etc/quantum/quantum/plugins/openvswitch/ovs_quantum_plugin.ini
- sed -i '36a network_vlan_ranges = physnet1' /etc/quantum/quantum/plugins/openvswitch/ovs_quantum_plugin.ini
- sed -i '43a enable_tunneling = False' /etc/quantum/quantum/plugins/openvswitch/ovs_quantum_plugin.ini
- sed -i '60a integration_bridge = br-int' /etc/quantum/quantum/plugins/openvswitch/ovs_quantum_plugin.ini
- sed -i '81a bridge_mappings = physnet1:br-int' /etc/quantum/quantum/plugins/openvswitch/ovs_quantum_plugin.ini
复制代码
本文,未完待续:基于DevStack的Openstack folsom版开发环境搭建(3-4),敬请期待!!
|