• 1、CDH集群搭建


    一、准备工作

    1、系统环境

    系统centos6.5
    节点三台:
        192.168.1.130
        192.168.1.131
        192.168.1.132
    
    1、所有节点关闭防火墙
        service iptables stop
        chkconfig iptables off    
    
    2、所有节点关闭selinux
    
    3、主机名和hosts文件
        127.0.0.1       localhost.localdomain    localhost 
        192.168.1.130    bigdata-cdh01.ibeifeng.com    bigdata-cdh01    
        192.168.1.131    bigdata-cdh02.ibeifeng.com      bigdata-cdh02
        192.168.1.132    bigdata-cdh03.ibeifeng.com      bigdata-cdh03
    
    4、创建一个普通用户,所有节点
        username:beifeng        passwd:beifeng
    
        [root@bigdata-cdh01 ~]# useradd beifeng
        [root@bigdata-cdh01 ~]# passwd beifeng
        
        [root@bigdata-cdh02 ~]# useradd beifeng
        [root@bigdata-cdh02 ~]# passwd beifeng
    
        [root@bigdata-cdh03 ~]# useradd beifeng
        [root@bigdata-cdh03 ~]# passwd beifeng
    
    5、配置beifneg用户的sudo权限
        vim /etc/sudoers                #所有节点执行
        beifeng ALL=(root)NOPASSWD:ALL        #写入此行    
        :wq!                    #保存退出
    
    6、切换到beifeng用户
        su - beifeng
    
    7、禁用ipv6
        sudo vim /etc/modprobe.d/dist.conf        #写入一下两行,所有节点
        alias net-pf-10 off
        alias ipv6 off
    
    8、所有及节点安装jdk
        sudo rpm -qa |grep java            #先查看系统是否自带jdk,如果有就卸载
        然后安装jdk,比较简单;    
    
    9、设置文件描述符
        vim /etc/security/limits.conf            #写入以下4行
        * hard nofile 65535
        * soft nofile 65535
        * hard nproc 65535
        * soft nproc 65535

    2、系统环境2

    1、时间同步
        在内网找一台作为时间服务器,所有的机器与这台机器时间进行定时的同步,比如每十分钟同步一次时间;
        这里用CDH1做时间服务器;
        
        ##检查是否安装
        [root@bigdata-cdh01 ~]# rpm -qa |grep ntp    
        ntp-4.2.6p5-15.el6.centos.x86_64
        fontpackages-filesystem-1.41-1.1.el6.noarch
        ntpdate-4.2.6p5-15.el6.centos.x86_64
        
        ##配置:
        vim /etc/ntp.conf
        #第一处
        restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap    #去掉此行的注释,并改为集群网段
    
        #第二处,注释掉下面几行
        #server 0.centos.pool.ntp.org iburst
        #server 1.centos.pool.ntp.org iburst
        #server 2.centos.pool.ntp.org iburst
        #server 3.centos.pool.ntp.org iburst
    
        #第三处,添加下面两行
        server  127.127.1.0     # local clock
        fudge   127.127.1.0 stratum 10
        
        ##设置同步更新本地hwclock
        [root@master hadoop-2.5.0]# vim /etc/sysconfig/ntpd
        # Drop root to id 'ntp:ntp' by default.
        SYNC_HWCLOCK=yes                #添加此行            
        OPTIONS="-u ntp:ntp -p /var/run/ntpd.pid -g"
        
        ##启动ntpd
        [root@master hadoop-2.5.0]# service ntpd status
        [root@master hadoop-2.5.0]# service ntpd start
        [root@master hadoop-2.5.0]#chkconfig ntpd on
    
        在CDH2、CDH3上设置同步时间脚本:
        #CDH2
        [root@slave1 hadoop-2.5.0]# crontab -l
        #去master同步时间,10分钟1次
        0-59/10 * * * * /usr/sbin/ntpdate bigdata-cdh01.ibeifeng.com
    
        #CDH3
        [root@slave2 hadoop-2.5.0]# crontab -l
        #去master同步时间,10分钟1次
        0-59/10 * * * * /usr/sbin/ntpdate bigdata-cdh01.ibeifeng.com
    
    2、配置ssh互信
    
    3、重启所有节点

    二、安装CDH

    离线rpm安装,CDH5.3.6版本;

    1、安装CM的准备

    网站:
        http://archive.cloudera.com/cm5/
    
    cm-5.3.6bin文件:
        http://archive.cloudera.com/cm5/installer/5.3.6/
    
    cm-5.3.6依赖rpm包:
        http://archive.cloudera.com/cm5/redhat/6/x86_64/cm/5.3.6/RPMS/x86_64/
    
    
    1、上传安装包
    [beifeng@bigdata-cdh01 softwares]$ ls
    cdh-5.3.6    cm-5.3.6    postgresq-libs    repo-libs
    
    [beifeng@bigdata-cdh01 softwares]$ tree ./
    ./
    ├── cdh-5.3.6
    │   ├── CDH-5.3.6-1.cdh5.3.6.p0.11-el6.parcel.parcel
    │   └── CDH-5.3.6-1.cdh5.3.6.p0.11-el6.parcel.sha1
    ├── cm-5.3.6
    │   ├── cloudera-manager-agent-5.3.6-1.cm536.p0.244.el6.x86_64.rpm
    │   ├── cloudera-manager-daemons-5.3.6-1.cm536.p0.244.el6.x86_64.rpm
    │   ├── cloudera-manager-installer.bin
    │   ├── cloudera-manager-server-5.3.6-1.cm536.p0.244.el6.x86_64.rpm
    │   ├── cloudera-manager-server-db-2-5.3.6-1.cm536.p0.244.el6.x86_64.rpm
    │   ├── enterprise-debuginfo-5.3.6-1.cm536.p0.244.el6.x86_64.rpm
    │   ├── jdk-6u31-linux-amd64.rpm
    │   └── oracle-j2sdk1.7-1.7.0+update67-1.x86_64.rpm
    ├── postgresq-libs
    │   ├── postgresql-8.4.18-1.el6_4.x86_64.rpm
    │   ├── postgresql-libs-8.4.18-1.el6_4.x86_64.rpm
    │   └── postgresql-server-8.4.18-1.el6_4.x86_64.rpm
    └── repo-libs
        ├── createrepo-0.9.9-18.el6.noarch.rpm
        ├── deltarpm-3.5-0.5.20090913git.el6.x86_64.rpm
        └── python-deltarpm-3.5-0.5.20090913git.el6.x86_64.rpm
    
    2、搭建yum本地源服务器
    说明:本地安装一个http服务器,将软件放进网站目录下去,安装的时候通过URL寻找;
    安装http:
    [beifeng@bigdata-cdh01 ~]$ sudo rpm -qa |grep http
    httpd-tools-2.2.15-29.el6.centos.x86_64
    httpd-2.2.15-29.el6.centos.x86_64
    
    [beifeng@bigdata-cdh01 ~]$ sudo service httpd start
    正在启动 httpd:                                           [确定]
    
    [beifeng@bigdata-cdh01 ~]$ sudo service httpd status
    httpd (pid  2634) 正在运行...
    
    [beifeng@bigdata-cdh01 ~]$ sudo chkconfig httpd on
    
    创建软件存放目录:
    [beifeng@bigdata-cdh01 ~]$ cd /var/www/html/
    
    [beifeng@bigdata-cdh01 html]$ sudo mkdir -p cm5/redhat/6/x86_64/cm/5/RPMS/x86_64/
    
    [beifeng@bigdata-cdh01 html]$ ls
    cm5
    
    [beifeng@bigdata-cdh01 html]$ tree
    .
    └── cm5
        └── redhat
            └── 6
                └── x86_64
                    └── cm
                        └── 5
                            └── RPMS
                                └── x86_64
    
    将cm软件包放进网站目录:
    ##
    [beifeng@bigdata-cdh01 cm-5.3.6]$ pwd
    /opt/softwares/cm-5.3.6
    
    [beifeng@bigdata-cdh01 cm-5.3.6]$ sudo mv ./cloudera-manager-installer.bin ../        #先把cm目录中的bin文件移出去
    
    ##
    [beifeng@bigdata-cdh01 x86_64]$ pwd
    /var/www/html/cm5/redhat/6/x86_64/cm/5/RPMS/x86_64
    
    [beifeng@bigdata-cdh01 x86_64]$ sudo mv /opt/softwares/cm-5.3.6/* ./
    
    3、修改hosts文件
    [beifeng@bigdata-cdh01 cm-5.3.6]$ sudo vim /etc/hosts
    192.168.1.130    archive.cloudera.com                #cdh1添加此行,我这里为了测试,本地hosts也添加了此行
    
    4、准备repo文件
    [beifeng@bigdata-cdh01 yum.repos.d]$ pwd
    /etc/yum.repos.d
    
    [beifeng@bigdata-cdh01 yum.repos.d]$ sudo rm -rf ./*
    
    [beifeng@bigdata-cdh01 yum.repos.d]$ sudo touch cloudera-manager.repo
    
    [beifeng@bigdata-cdh01 yum.repos.d]$ cat cloudera-manager.repo 
    [cloudera-manager]
    # Packages for Cloudera Manager, Version 5, on RedHat or CentOS 6 x86_64                 
    name=Cloudera Manager
    baseurl=http://archive.cloudera.com/cm5/redhat/6/x86_64/cm/5/
    gpgkey=http://archive.cloudera.com/cm5/redhat/6/x86_64/cm/RPM-GPG-KEY-cloudera    
    gpgcheck = 1
     
    RPM-GPG-KEY-cloudera    #这个文件手动生成一下
    https://archive.cloudera.com/cm5/redhat/6/x86_64/cm/RPM-GPG-KEY-cloudera  #在网上下载此文件,放到/var/www/html/cm5/redhat/6/x86_64/cm/下面

    2、安装CM

    ###
    [beifeng@bigdata-cdh01 postgresq-libs]$ pwd
    /opt/softwares/postgresq-libs
    
    [beifeng@bigdata-cdh01 postgresq-libs]$ sudo chmod u+x ./*
    
    [beifeng@bigdata-cdh01 postgresq-libs]$ sudo rpm -ivh *.rpm
    Preparing...                ########################################### [100%]
       1:postgresql-libs        ########################################### [ 33%]
       2:postgresql             ########################################### [ 67%]
       3:postgresql-server      ########################################### [100%]
    
    
    ###
    安装CM:
    [beifeng@bigdata-cdh01 repo-libs]$ pwd
    /opt/softwares/repo-libs
    [beifeng@bigdata-cdh01 repo-libs]$ ls
    createrepo-0.9.9-18.el6.noarch.rpm  deltarpm-3.5-0.5.20090913git.el6.x86_64.rpm  python-deltarpm-3.5-0.5.20090913git.el6.x86_64.rpm
    
    [beifeng@bigdata-cdh01 repo-libs]$ sudo rpm -ivh ./*.rpm
    Preparing...                ########################################### [100%]
       1:deltarpm               ########################################### [ 33%]
       2:python-deltarpm        ########################################### [ 67%]
       3:createrepo             ########################################### [100%]
    
    [beifeng@bigdata-cdh01 5]$ pwd
    /var/www/html/cm5/redhat/6/x86_64/cm/5
    
    [beifeng@bigdata-cdh01 5]$ sudo createrepo .        #当前目录下会生成一个文件夹:repodata
    
    
    
    [beifeng@bigdata-cdh01 postgresq-libs]$ cd /opt/softwares/
    [beifeng@bigdata-cdh01 softwares]$ sudo chmod +x cloudera-manager-installer.bin
    [beifeng@bigdata-cdh01 softwares]$ sudo ./cloudera-manager-installer.bin    #接着会出现一个界面
        Next-->Next-->Yes-->Next-->Yes ...
    
    如果报错了,日至都在/var/log/cloudera-manager-installer
     
    ###
    等待安装完成后:

    [beifeng@bigdata-cdh01 ~]$ netstat -ntlp |grep 7180
    (No info could be read for "-p": geteuid()=501 but you should be root.)
    tcp        0      0 0.0.0.0:7180                0.0.0.0:*                   LISTEN      -  

    浏览器打开:hostname(ip)+port

    账号/密码:admin

    3、安装CDH

    此时要准备CDH的包

    网站:http://archive.cloudera.com/cdh5/parcels/5.3.6/
    
    下载以下两个包:
        CDH-5.3.6-1.cdh5.3.6.p0.11-el6.parcel
        CDH-5.3.6-1.cdh5.3.6.p0.11-el6.parcel.sha1
    
    创建/opt/cloudera/parcel-repo  可能CM安装时已经自动创建过了;
    
    将上面两个包mv进/opt/cloudera/parcel-repo:
    [beifeng@bigdata-cdh01 parcel-repo]$ ls
    CDH-5.3.6-1.cdh5.3.6.p0.11-el6.parcel  CDH-5.3.6-1.cdh5.3.6.p0.11-el6.parcel.sha1
    
    [beifeng@bigdata-cdh01 parcel-repo]$ sudo mv CDH-5.3.6-1.cdh5.3.6.p0.11-el6.parcel.sha1 ./CDH-5.3.6-1.cdh5.3.6.p0.11-el6.parcel.sha    #去掉末尾的1
    
    
    ##
    查看cm的状态,
    [beifeng@bigdata-cdh01 ~]$ sudo service cloudera-scm-server status
    cloudera-scm-server (pid  3151) 正在运行...
    
    
    ##
    修改CDH01 yum文件,并分发:
    [beifeng@bigdata-cdh01 ~]$ sudo cat /etc/yum.repos.d/cloudera-manager.repo         #内容改为如下
    [cloudera-manager]
    name=Cloudera Manager
    baseurl=http://bigdata-cdh01.ibeifeng.com/cm5/redhat/6/x86_64/cm/5/
    gpgkey=http://bigdata-cdh01.ibeifeng.com/cm5/redhat/6/x86_64/cm/RPM-GPG-KEY-cloudera
    gpgcheck=1
    
    CDH02: sudo rm -rf /etc/yum.repos.d/*
    CDH03: sudo rm -rf /etc/yum.repos.d/*
    [beifeng@bigdata-cdh01 ~]$ sudo scp -r /etc/yum.repos.d/cloudera-manager.repo root@bigdata-cdh02:/etc/yum.repos.d/
    [beifeng@bigdata-cdh01 ~]$ sudo scp -r /etc/yum.repos.d/cloudera-manager.repo root@bigdata-cdh03:/etc/yum.repos.d/

    image

    image

    输入主机名,搜索主机:

    image

    image

    image

    image

    image

    然后,等待安装完成;

    image

    image

    等待分配:

    image

    image

    ###
    CDH01 的hosts文件中,注释掉下面一行:
    192.168.1.130    archive.cloudera.com
    
    
    ###
    所有节点关闭swap(可以切换到root执行):
        echo 0 > /proc/sys/vm/swappiness
        sysctl vm/swappiness
        echo 'vm.swappiness = 0' >> /etc/sysctl.conf
        sysctl -p
    
    
    ###
    所有节点执行:
        echo never > /sys/kernel/mm/transparent_hugepage/defrag
        echo 'echo never > /sys/kernel/mm/transparent_hugepage/defrag' >> /etc/rc.local

    继续:

    image

    点击左上角Logo先离开;

    4、安装CMS监控服务

    image

    image

    image

    image

    image

    CDH2、CDH3节点:

    sudo crontab -e
    0-59/10 * * * *  sh /home/crontab/ntp.sh


    ##
    /home/crontab/ntp.sh

    #!/bin/bash
    #
    /sbin/service ntpd stop
    /usr/sbin/ntpdate bigdata-cdh01.ibeifeng.com
    /sbin/service ntpd start

  • 相关阅读:
    mybatis
    mybatis
    hadoop完全分布式搭建
    用构造器确保初始化
    HashMap的内部结构与hash冲突
    方法重载 与 方法覆盖
    Django后台管理admin或者adminx中使用富文本编辑器
    Celery在Django中的使用介绍
    django.db.utils.InternalError: (1060, "Duplicate column name 'user_id'")迁移报错解决方法
    Django2.0版本以上与pymsql 不匹配问题以及解决方法
  • 原文地址:https://www.cnblogs.com/weiyiming007/p/10975487.html
Copyright © 2020-2023  润新知