标签:云计算 openstack sahara hadoop
声明:
本博客欢迎转载,但请保留原作者信息,并请注明出处!
作者:郭德清
团队:华为杭州OpenStack团队
在前一篇文章对Sahara的安装配置做了下总结,今天主要对如何在Sahara环境上部署Hadoop集群做一个总结,也把自己部署的时候填过的坑总结下,避免其他人在同一个坑掉下。
1. 上传镜像
这边选择的是vanilla的镜像,下载地址:http://docs.openstack.org/developer/sahara/userdoc/vanilla_plugin.html ,我选择的是sahara-icehouse-vanilla-1.2.1-centos-6.5.qcow2。通过下面的命令上传镜像到glance:
glance image-create --name sahara-icehouse-vanilla-1.2.1-centos --file ./sahara-icehouse-vanilla-1.2.1-centos-6.5.qcow2 --disk-format qcow2 --container-format bare
sahara image-register --id a00f66cd-81ee-4bb8-af9a-5cb50e3602a7 --username sahara
sahara image-add-tag --id a00f66cd-81ee-4bb8-af9a-5cb50e3602a7 --tag vanilla sahara image-add-tag --id a00f66cd-81ee-4bb8-af9a-5cb50e3602a7 --tag 1.2.1
2. 创建网络
创建路由neutron router-create router1
创建外部网络
neutron net-create ext_net --router:external=True neutron subnet-create ext_net --allocation-pool start=172.28.12.10,end=172.28.12.50 --gateway 172.28.12.1 172.28.12.0/24 --enable_dhcp=False
创建内部网络
neutron net-create vlan-70 neutron subnet-create vlan-70 70.0.0.0/24
绑定内外网到router1
neutron router-gateway-set 8dab3833-2616-4713-90c2-ab85f7d1a226 2dd5901d-3292-4edf-9c14-5999b4e6ed0d neutron router-interface-add 8dab3833-2616-4713-90c2-ab85f7d1a226 a92654b6-09a5-4adc-a301-6a405d5c924d
另外,为了让单板和虚拟机进行通信,需要在br-int上开一个对应vlan子接口,并配上同一个网段的IP:
vconfig add br-int 2 ifconfig br-int.2 70.0.0.5/24
注:2表示网络的segmentation_id,可以通过neutron net-show来查看对应网络的segmentation_id。
3. 虚拟机套餐:
nova flavor-create sahara_flavor2 111 1024 11 1注:vanilla的官方镜像是10G,disk的大小设置成大于10G。
4. 创建节点模板:
node-group-templates.json
{ "plugin_name": "vanilla", "hadoop_version": "1.2.1", "node_processes": [ "namenode", "oozie", "jobtracker", "datanode", "tasktracker", "secondarynamenode" ], "name": "master", "floating_ip_pool": "2dd5901d-3292-4edf-9c14-5999b4e6ed0d", "auto_security_group": true, "flavor_id": "111" }
sahara node-group-template-create --json node-group-templates.json
5. 创建集群:
先注入key,不然vanilla的镜像因为不知道密码无法登陆。第一步,生成公钥
ssh-keygen -t rsa -P ''
nova keypair-add sahara --pub-key ~/.ssh/id_rsa.pub
cluster-template.json
{ "plugin_name": "vanilla", "hadoop_version": "1.2.1", "node_groups": [ { "name": "master", "count": 1, "node_group_template_id": "56d00dcd-1909-4508-8ea5-65174722fe39" } ], "name": "cluster-template", "neutron_management_network": "6779575a-9eca-4bd9-885a-b9389d3b21dc", "cluster_configs": { "HDFS": { "dfs.replication": 1 } }, "user_keypair_id":"sahara", "default_image_id": "a00f66cd-81ee-4bb8-af9a-5cb50e3602a7" }
sahara cluster-create --json cluster-template.json
在部署的Hadoop集群的时候,碰到了很多问题,下面做个大概的说明:
问题1:创建集群的时候,报了下面的错误
Traceback (most recent call last): File "/usr/lib/python2.7/dist-packages/saharaclient/shell.py", line 762, in main OpenStackSaharaShell().main(map(strutils.safe_decode, sys.argv[1:])) File "/usr/lib/python2.7/dist-packages/saharaclient/shell.py", line 698, in main args.func(self.cs, args) File "/usr/lib/python2.7/dist-packages/saharaclient/api/shell.py", line 327, in do_cluster_create _show_cluster(cs.clusters.create(**template)) File "/usr/lib/python2.7/dist-packages/saharaclient/api/clusters.py", line 49, in create node_groups=node_groups) File "/usr/lib/python2.7/dist-packages/saharaclient/api/clusters.py", line 32, in _assert_variables var_name) APIException: None
问题2:一开始设置了多个节点目标,而多个节点目标中部署了多个的namenode、jobtracker、oozie,导致报了下面的错误:
ERROR: Hadoop cluster should contain 1 namenode component(s). Actual namenode count is 2 ERROR: Hadoop cluster should contain 0 or 1 jobtracker component(s). Actual jobtracker count is 2 ERROR: Hadoop cluster should contain 0 or 1 oozie component(s). Actual oozie count is 2
问题3:Floatingip pool not found
一开始只是简单创建一个网络,导致配置浮动IP的时候错误,用我前面的那种创建网络的方法创建ok。
问题4:虚拟机获取metadata失败
为了让虚拟机获取metadata,需要在nova-api和neutron metadata的配置文件进行相关的配置:
nova-api的配置中需要配置以下参数:
enabled_apis=ec2,osapi_compute,metadata metadata_workers = 1 service_neutron_metadata_proxy = true metadata_listen = 192.168.206.190 metadata_port = 8775
neutron metadata的配置文件metadata_agent.ini中,需要配置:
nova_metadata_ip = 192.168.206.190 nova_metadata_port = 8775 nova_metadata_protocol = http nova_client_cert = openstack nova_client_priv_key = openstack
【参考资料】
http://docs.openstack.org/developer/sahara/devref/quickstart.html
http://docs.openstack.org/developer/sahara/restapi/rest_api_v1.0.html
http://docs.openstack.org/developer/sahara/userdoc/vanilla_plugin.html#cluster-validation
http://www.server110.com/openstack/201402/6817.html
标签:云计算 openstack sahara hadoop
原文地址:http://blog.csdn.net/canxinghen/article/details/41864399