分享

基于DevStack的Openstack folsom版开发环境搭建(1-2)

xioaxu790 发表于 2014-6-6 08:51:15 [显示全部楼层] 回帖奖励 阅读模式 关闭右栏 0 21509
本帖最后由 xioaxu790 于 2014-6-6 08:55 编辑
问题导读:
1、什么是 DevStack,如何使用?

2、Openstack下如何手动开启各个服务?
3、如何导入环境变量?





一.使用DevStack搭建框架
   DevStack是一个开源脚本,用于搭建单节点的openstack开发环境。但是,如果不在localrc脚本里修改相应配置,其搭建出来的openstack不包含quantum模块(如何配置使其包含quantum模块openstack官网有说明),并且这个是使用screen技术集成的各个模块,重启之后需要手动开启各个服务,并导入环境变量。


开启各服务命令:
1.keystone
  1. keystone-all --config-file=/etc/keystone/keystone.conf &(&的意思是keystone在后台运行,可不加)
复制代码

2.glance
  1.   glance-api --config-file=/etc/glance/glance-api.conf &
  2.      glance-registry --config-file=/etc/glance/glance-registry.conf &
复制代码

3.cinder
  1. cinder-all --config-file=/etc/cinder/cinder.conf &
复制代码

4.nova
  1.   nova-api-os-compute --config-file=/etc/nova/nova.conf &
  2.      nova-api-metadata --config-file=/etc/nova/nova.conf &
  3.      nova-compute --config-file=/etc/nova/nova.conf &
  4.      nova-cert --config-file=/etc/nova/nova.conf &
  5.      nova-scheduler --config-file=/etc/nova/nova.conf &
  6.      nova-volume --config-file=/etc/nova/nova.conf &
  7.      nova-network --config-file=/etc/nova/nova.conf &
  8.      nova-consoleauth --config-file=/etc/nova/nova.conf &
  9.      nova-novncproxy --config-file=/etc/nova/nova.conf &
  10.      #nova-xvpvncproxy --config-file=/etc/nova/nova.conf &
  11.      #nova-consoleauth --config-file=/etc/nova/nova.conf &
  12.      nova-objectstore --config-file=/etc/nova/nova.conf &
  13.       -----或者直接nova-all --config-file=/etc/nova/nova.conf &
复制代码

导入环境变量:
导入环境变量主要是通过keystone认证的需要
  1.   export OS_SERVICE_TOKEN=123456
  2.      export OS_USERNAME=admin
  3.      export OS_PASSWORD=123456
  4.      export OS_TENANT_NAME=admin
  5.      export OS_AUTH_URL=http://localhost:5000/v2.0/
  6.      export OS_SERVICE_ENDPOINT=http://localhost:35357/v2.0/
复制代码

导入成功后可用env命令查看
使用glance创建镜像文件的命令
  1. glance add name="ubuntu-test" container_format=bare disk_format=raw is_public=true</home/zg/下载/ubuntu.img
复制代码

二.安装quantum模块

    首先,需要保证quantum的版本和其他模块的版本匹配(我安装的是quantum-2012.2版本),否则会出如下错误:
Python代码
  1. Traceback (most recent call last):  
  2.   File "/usr/local/lib/python2.7/dist-packages/cliff/app.py", line 249, in run_subcommand  
  3.     result = cmd.run(parsed_args)  
  4.   File "/usr/local/lib/python2.7/dist-packages/python_quantumclient-0.0.0-py2.7.egg/quantumclient/common/command.py", line 35, in run  
  5.     return super(OpenStackCommand, self).run(parsed_args)  
  6.   File "/usr/local/lib/python2.7/dist-packages/cliff/display.py", line 84, in run  
  7.     column_names, data = self.take_action(parsed_args)  
  8.   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  
  9.     return self.get_data(parsed_args)  
  10.   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  
  11.     data = obj_creator(body)  
  12.   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  
  13.     ret = self.function(instance, *args, **kwargs)  
  14.   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  
  15.     return self.post(self.networks_path, body=body)  
  16.   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  
  17.     headers=headers, params=params)  
  18.   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  
  19.     self._handle_fault_response(status_code, replybody)  
  20.   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  
  21.     exception_handler_v20(status_code, des_error_body)  
  22.   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  
  23.     message=message)  
  24. QuantumClientException: 404 Not Found  
  25.   
  26. The resource could not be found.  
复制代码


启动quantum:
quantum一共有四部分,他们的启动顺序有一定要求
Python代码
  1. 1.sudo quantum-openvswitch-agent --config-file=/etc/quantum/plugins/openvswitch/ovs_quantum_plugin.ini  
  2. 2.sudo quantum-server --config-file=/etc/quantum/quantum.conf --config-file=/etc/quantum/plugins/openvswitch/ovs_quantum_plugin.ini  
  3. 3.sudo quantum-dhcp-agent --config-file=/etc/quantum/quantum.conf --config-file=/etc/quantum/dhcp_agent.ini  
  4. 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的内容
  1. [default]
  2. rabbit_password = 123456
  3. rabbit_host = localhost
复制代码

2.endpoint错误解决方法
需要在keystone里为每个服务配置endpoint

3.启动nova-compute的ImportError: No module named quantum.manager问题
  注释掉nova.conf中的network_manager即可

4.修复启动quantum-l3-agent时导入模块错误
  1. 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
  1. 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启动问题
报错:
  1. 2012-12-11 14:47:12     INFO [quantum.openstack.common.rpc.common] Connected to AMQP server on localhost:5672  
  2. 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出错
报错:
  1. 2012-12-12 14:20:52    ERROR [quantum.openstack.common.policy] Failed to understand rule u'l'  
  2. Traceback (most recent call last):  
  3.   File "/usr/local/lib/python2.7/dist-packages/quantum-2012.2-py2.7.egg/quantum/openstack/common/policy.py", line 161, in _check  
  4. ValueError: need more than 1 value to unpack  
  5. /etc/quantum/policy.py
复制代码
用/opt/stack/quantum/etc/policy.py覆盖etc/quantum下的同名文件即可

9.虚拟机分配不到ip地址问题
需要先用quantum创建net subnet router等等
  1. tenant_id=`keystone tenant-list |awk '/ admin/ {print $2}'`  
  2. net_id=`quantum net-create --tenant-id $tenant_id net_one --provider:network_type flat --provider:physical_network physnet1 |awk '/ id/ {print $4}'`  
  3. 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}'`  
  4. router_id=`quantum router-create --tenant-id $tenant_id router1 |awk '/ id/ {print $4}'`  
  5. quantum router-interface-add $router_id $subnet_id  
复制代码

quantum.conf的相关配置进行调整
  1. sed -i 's/sql_connection = sqlite:\/\//sql_connection = mysql:\/\/root:123456@localhost\/ovs_quantum/g' /etc/quantum/quantum/plugins/openvswitch/ovs_quantum_plugin.ini  
  2.     sed -i '24a tenant_network_type = none' /etc/quantum/quantum/plugins/openvswitch/ovs_quantum_plugin.ini  
  3.     sed -i '36a network_vlan_ranges = physnet1' /etc/quantum/quantum/plugins/openvswitch/ovs_quantum_plugin.ini  
  4.     sed -i '43a enable_tunneling = False' /etc/quantum/quantum/plugins/openvswitch/ovs_quantum_plugin.ini  
  5.     sed -i '60a integration_bridge = br-int' /etc/quantum/quantum/plugins/openvswitch/ovs_quantum_plugin.ini  
  6.     sed -i '81a bridge_mappings = physnet1:br-int' /etc/quantum/quantum/plugins/openvswitch/ovs_quantum_plugin.ini  
复制代码



                 本文,未完待续:基于DevStack的Openstack folsom版开发环境搭建(3-4),敬请期待!!






没找到任何评论,期待你打破沉寂

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关闭

推荐上一条 /2 下一条