liuming794 发表于 2015-11-11 15:03:20

通过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:



view
plaincopy


[*]
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:





view
plaincopy


[*]
sahara image-register --id a00f66cd-81ee-4bb8-af9a-5cb50e3602a7 --username cloud-user   



      vanilla的镜像注册后,需要添加两个标签:vanilla和hadoop的版本





view
plaincopy


[*]
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










备注:在创建集群的时候,vanilla的centos镜像,执行_configure_instance的sudo
hostname报错,需要输入密码,所以后面换了ubuntu的镜像。这个应该跟我注册镜像的时候,传入的username原来是sahara有关,后面改成对应的cloud-user。







2. 创建网络



      创建内部网络



view
plaincopy


[*]
neutron net-create vlan-70   
[*]
neutron subnet-create vlan-70 70.0.0.0/24




   另外,为了让单板和虚拟机进行通信,需要在虚拟机对应的网桥上配一个同网段的IP:

view
plaincopy


[*]
<pre name=&quot;code&quot; class=&quot;plain&quot;>root@openstack:~# virsh dumpxml 6 | grep bridge
[*]
    <interface type='bridge'>
[*]
      <source bridge='qbrdcd0f1de-e1'/>
[*]
root@openstack:~# ifconfig qbrdcd0f1de-e1 70.0.0.203/24



注:qbrdcd0f1de-e1表示虚拟机的网桥,可以通过virsh dumpxml 6 | grep bridge来查看。当然也可以在br-int上开一个对应vlan子接口,并配上同一个网段的IP:



view
plaincopy


[*]
vconfig add br-int 110
[*]
ifconfig br-int.110 70.0.0.5/24



110表示网口对应的tag,可以通过ovs-vsctl show查看对应网口(看port id的前几位)的tag标签,通过下面的命令可以设置tag标签。



view
plaincopy


[*]
ovs-vsctl set port qvo2fb1f645-05 tag=110




3. 虚拟机套餐:



view
plaincopy


[*]
nova flavor-create sahara_flavor2 111 1024 11 2

注:vanilla的官方镜像是10G,disk的大小设置成大于10G。





4. 创建节点模板:

node-group-templates.json

view
plaincopy


[*]
{
[*]
    &quot;plugin_name&quot;: &quot;vanilla&quot;,
[*]
    &quot;hadoop_version&quot;: &quot;1.2.1&quot;,
[*]
    &quot;node_processes&quot;: [
[*]
      &quot;namenode&quot;,
[*]
      &quot;oozie&quot;,
[*]
      &quot;jobtracker&quot;,
[*]
      &quot;datanode&quot;,
[*]
      &quot;tasktracker&quot;,
[*]
      &quot;secondarynamenode&quot;
[*]
    ],
[*]
    &quot;name&quot;: &quot;master&quot;,
[*]
    &quot;flavor_id&quot;: &quot;111&quot;
[*]
}



      创建命令:



view
plaincopy


[*]
saharanode-group-template-create --json node-group-templates.json








5. 创建集群:

      先注入key,不然vanilla的镜像因为不知道密码无法登陆。


      第一步,生成公钥



view
plaincopy


[*]
ssh-keygen -t rsa -P ''



      第二步,通过nova注册公钥





view
plaincopy


[*]
nova keypair-add sahara --pub-key ~/.ssh/id_rsa.pub



      编辑集群模板:



cluster-template.json



view
plaincopy


[*]
{
[*]
    &quot;plugin_name&quot;: &quot;vanilla&quot;,
[*]
    &quot;hadoop_version&quot;: &quot;1.2.1&quot;,
[*]
    &quot;node_groups&quot;: [
[*]
      {
[*]
            &quot;name&quot;: &quot;master&quot;,
[*]
            &quot;count&quot;: 1,
[*]
            &quot;node_group_template_id&quot;: &quot;56d00dcd-1909-4508-8ea5-65174722fe39&quot;
[*]
      }
[*]
    ],
[*]
    &quot;name&quot;: &quot;cluster-template2&quot;,
[*]
    &quot;neutron_management_network&quot;: &quot;6779575a-9eca-4bd9-885a-b9389d3b21dc&quot;,
[*]
    &quot;cluster_configs&quot;:   
[*]
    {
[*]
      &quot;HDFS&quot;: {
[*]
            &quot;dfs.replication&quot;: 1
[*]
      }
[*]
    },
[*]
    &quot;user_keypair_id&quot;:&quot;sahara&quot;,
[*]
    &quot;default_image_id&quot;: &quot;a00f66cd-81ee-4bb8-af9a-5cb50e3602a7&quot;
[*]
}



      创建集群:



view
plaincopy


[*]
sahara cluster-create --json cluster-template.json










      在部署的Hadoop集群的时候,碰到了很多问题,下面做个大概的说明:

问题1:创建集群的时候,报了下面的错误



view
plaincopy


[*]
Traceback (most recent call last):
[*]
File &quot;/usr/lib/python2.7/dist-packages/saharaclient/shell.py&quot;, line 762, in main
[*]
    OpenStackSaharaShell().main(map(strutils.safe_decode, sys.argv))
[*]
File &quot;/usr/lib/python2.7/dist-packages/saharaclient/shell.py&quot;, line 698, in main
[*]
    args.func(self.cs, args)
[*]
File &quot;/usr/lib/python2.7/dist-packages/saharaclient/api/shell.py&quot;, line 327, in do_cluster_create
[*]
    _show_cluster(cs.clusters.create(**template))
[*]
File &quot;/usr/lib/python2.7/dist-packages/saharaclient/api/clusters.py&quot;, line 49, in create
[*]
    node_groups=node_groups)
[*]
File &quot;/usr/lib/python2.7/dist-packages/saharaclient/api/clusters.py&quot;, line 32, in _assert_variables
[*]
    var_name)
[*]
APIException: None



      通过在方法_assert_variables这个方法出打断点,发现是因为集群的模板中,没有设置default_image_id这个参数导致,但是官网的rest文档给的例子没有这个参数。



问题2:一开始设置了多个节点目标,而多个节点目标中部署了多个的namenode、jobtracker、oozie,导致报了下面的错误:



view
plaincopy


[*]
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



      所以,在Hadoop集群中,namenode、jobtracker、oozie最多只能有一个。



问题3:Floatingip pool not found

      一开始只是简单创建一个网络,导致配置浮动IP的时候错误,用我前面的那种创建网络的方法创建ok。

问题4:虚拟机获取metadata失败

      为了让虚拟机获取metadata,需要在nova-api和neutron metadata的配置文件进行相关的配置:

      nova-api的配置中需要配置以下参数:



view
plaincopy


[*]
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中,需要配置:



view
plaincopy


[*]
nova_metadata_ip = 192.168.206.190
[*]
nova_metadata_port = 8775
[*]
nova_metadata_protocol = http
[*]
nova_client_cert = openstack
[*]
nova_client_priv_key = openstack






问题5:浮动IP问题

      虚拟机拉起来后,浮动IP不通,因为我这边用的neutron的网络,所以把sahara的配置中浮动IP关闭了(use_floating_ips=false)。





问题6:vanilla的centos镜像,虚拟机起来后,sahara在部署hadoop业务的时候报错:

      Error duringcommand execution: &quot;sudo hostnamecluster-template2-master-001.novalocal&quot;

      所以后面换了vanilla的Ubuntu系统镜像就可以了。



【参考资料】

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


[*]上一篇Sahara的基本概念和架构
[*]下一篇用ironic安装openstack的原理



版权声明:欢迎大家转载,转载请注明出处blog.iyunv.com/tantexian。
页: [1]
查看完整版本: 通过Sahara部署Hadoop集群分类