CDH6.0.1详细安装步骤及问题解决

时间:2024-05-20 07:39:46

CDH6.0.1详细安装步骤及常见问题解决

Cloudera Manager能够大大减轻配置hadoop集群的工作量,安装好以后能够快速熟悉Hadoop生态系统常用的一些组件,如HBase, Hive, Spark, Oozie, Impala, Hue等等。笔者在安装Cloudera Manager过程中遇到了很多麻烦,最终在折腾了一个星期以后终于配置成功。现在将配置步骤和过程中遇到的一些问题的解决办法拿出来与大家一起分享。

系统环境

• 操作系统:3台 CentOS 7 x64
• Cloudera Manager:6.0.1
• CDH: 6.0.1

VM IP Adress Centos_HostName Disk Space Physical Memory Role
192.168.1.101 hadoop01 40GB 16GB Cloudera Manager Server + Cloudera Manager Agent
192.168.1.102 hadoop02 40GB 4GB Cloudera Manager Agent
192.168.1.106 hadoop06 40GB 8GB Cloudera Manager Agent
  1. 最初是想搭建一个5个节点的Hadoop集群的,后来发现Cloudera Manager占用内存特别多,无奈一台PC只能安装一个CentOS;
  2. 安装CentOS系统时磁盘空间最好选成40GB,默认的20GB不够用。以后扩展很麻烦;
  3. 默认2GB的swap空间不够用,需要扩展成4GB;

一、配置网络环境

安装完CentOS后第一步就是配置网络。

  1. 编辑/etc/sysconfig/network-scripts/ifcfg-eth0配置文件,修改其中以下粗体标示的项目:
    vi /etc/sysconfig/network-scripts/ifcfg-eth0
    TYPE=Ethernet
    BOOTPROTO=static
    DEFROUTE=yes
    PEERDNS=yes
    PEERROUTES=yes
    IPV4_FAILURE_FATAL=no
    IPV6INIT=yes
    IPV6_AUTOCONF=yes
    IPV6_DEFROUTE=yes
    IPV6_PEERDNS=yes
    IPV6_PEERROUTES=yes
    IPV6_FAILURE_FATAL=no
    NAME=eth0
    UUID=3719cf03-5d05-454b-903f-e1e26ad34fd6
    DEVICE=eth0
    ONBOOT=yes
    IPADDR=192.168.1.101
    NETWORK=192.168.1.1
    NETSTAT=255.255.255.0
    GATEWAY=192.168.1.1
    DNS1=222.186.160.70
    DNS2=114.114.114.114

    其它主机的IP地址做相应的更改。

  2. 编辑/etc/default/grub文件,在GRUB_CMD_LINE_LINUX="“项中,插入"net.ifnames=0 biosdevname=0”(与原有项之间用空格隔开),保存退出。

  3. 调用命令grub2-mkconfig -o /boot/grub2/grub.cfg更新配置,然后直接reboot重启。
    这样之后再用ifconfig -a命令查看时,就有eth0网卡存在了。

  4. 更改hostname
    hostnamectl set-hostname hadoop01

  5. 修改hosts文件
    vi /etc/hosts

    192.168.1.101 hadoop01
    192.168.1.102 hadoop02
    192.168.1.106 hadoop06

  6. 关闭防火墙
    sed -i ‘s/SELINUX=enforcing/SELINUX=disabled/g’ /etc/selinux/config
    setenforce 0
    systemctl stop firewalld.service
    systemctl disable firewalld.service

  7. 配置免密登录:
    在每台主机上生成rsa公钥和私钥
    ssh-****** -t rsa
    cd .ssh
    cat id_rsa.pub >> authorized_keys
    登录其他主机,将其他主机的公钥文件内容都拷贝到hadoop01主机上的authorized_keys文件中,命令如下:
    [[email protected] .ssh]# ssh-copy-id -i hadoop01
    /usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
    /usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed – if you are prompted now it is to install the new keys
    [email protected]’s password:

Number of key(s) added: 1

Now try logging into the machine, with: “ssh ‘hadoop01’”
and check to make sure that only the key(s) you wanted were added.
在每台主机上重复以上步骤,使任意两台主机间都能相互连通。

至此,免密码登录已经设定完成。

  1. 更改系统时间:
    进入home目录,修改.bash_profile
    #setup time region
    TZ=‘Asia/Shanghai’
    export TZ
    或者: tzselect

    将当前时间和日期写入BIOS,避免重启后失效
    hwclock –w

    另外还要进入CentOS的菜单System Tools–> Settings --> Date & Time中,将时区修改为Asia/Shanghai。
    CDH6.0.1详细安装步骤及问题解决

  2. 配置NTP同步各台服务器的时间
    9.1主节点配置

    在配置之前,先使用ntpdate手动同步一下时间,免得本机与对时中心时间差距太大,使得ntpd不能正常同步。这里选用65.55.56.206作为对时中心,ntpdate -u ntp1.aliyun.com
    vi /etc/ntp.conf
    #Hosts on local network are less restricted.
    取消下面一行的注释,并将其中IP和掩码修改为真实环境IP和掩码,此行配置为允许ntp客户端连接的配置
    restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap
    找到server 0.centos.pool.ntp.org iburst,并将所有server配置进行注释
    添加下面两行内容
    server 127.127.1.0 # local clock
    fudge 127.127.1.0 stratum 10

    启动NTP服务
    设置后,重启ntpd服务,用ntpstat来检查效果【大概几秒钟就可以看到效果】
    #systemctl restart ntpd
    #ntpstat

    vi /etc/sysconfig/ntpdate
    #Set to ‘yes’ to sync hw clock after successful ntpdate
    SYNC_HWCLOCK=yes

    9.2 Agent节点配置
    修改/etc/ntp.conf
    对该文件进行以下内容的修改:
    1、注释所有restrict和server配置
    2、添加下面一行,需要修改以下的IP为NTP服务器的IP(在本案例中就是server主机的IP)
    server 192.168.1.101

    将所有主机的ntp服务设置为开机自动启动
    chkconfig ntpd on
    systemctl enable ntpd.service

二、 配置163 yum源

  1. 下载repo文件
    cd /etc/yum.repos.d/
    wget http://mirrors.163.com/.help/CentOS7-Base-163.repo

  2. 备份并替换系统的repo文件
    mv CentOS-Base.repo CentOS-Base.repo.bak
    cp CentOS7-Base-163.repo CentOS-Base.repo

  3. 执行yum源更新命令
    yum clean all
    yum makecache
    yum update

    yum install chkconfig python bind-utils psmisc libxslt zlib sqlite cyrus-sasl-plain cyrus-sasl-gssapi fuse fuse-libs redhat-lsb –y

    yum install httpd mod_ssl openssl-devel python-psycopg2 –y
    yum install MySQL-python
    yum install perl
    yum install autoconf

三、安装MySQL

  1. 查看并卸载CentOS系统自带的MySQL和Mariadb
    rpm -qa | grep MySQL
    rpm -qa | grep mariadb
    rpm -e --nodeps MySQL-python-1.2.5-1.el7.x86_64
    rpm -e --nodeps mariadb-libs-5.5.60-1.el7_5.x86_64

  2. 下载并上传以下rpm包到主节点
    MySQL-client-5.6.42-1.el7.x86_64.rpm
    MySQL-devel-5.6.42-1.el7.x86_64.rpm
    MySQL-server-5.6.42-1.el7.x86_64.rpm

  3. 在主节点上执行以下命令安装MySQL
    rpm -ivh MySQL*

  4. 安装完成后启动MySQL:
    service mysql start
    systemctl start mysql.service

  5. 修改MySQL的配置文件
    vi /etc/my.cnf

    [mysqld]
    datadir=/var/lib/mysql
    socket=/var/lib/mysql/mysql.sock
    transaction-isolation = READ-COMMITTED
    #Disabling symbolic-links is recommended to prevent assorted security risks;
    #to do so, uncomment this line:
    symbolic-links = 0
    key_buffer_size = 32M
    max_allowed_packet = 32M
    thread_stack = 256K
    thread_cache_size = 64
    query_cache_limit = 8M
    query_cache_size = 64M
    query_cache_type = 1
    max_connections = 550
    #expire_logs_days = 10
    #max_binlog_size = 100M
    #log_bin should be on a disk with enough free space.
    #Replace ‘/var/lib/mysql/mysql_binary_log’ with an appropriate path for your
    #system and chown the specified folder to the mysql user.
    log_bin=/var/lib/mysql/mysql_binary_log
    #In later versions of MySQL, if you enable the binary log and do not set
    #a server_id, MySQL will not start. The server_id must be unique within
    #the replicating group.
    server_id=1
    binlog_format = mixed
    read_buffer_size = 2M
    read_rnd_buffer_size = 16M
    sort_buffer_size = 8M
    join_buffer_size = 8M
    #InnoDB settings
    innodb_file_per_table = 1
    innodb_flush_log_at_trx_commit = 2
    innodb_log_buffer_size = 64M
    innodb_buffer_pool_size = 4G
    innodb_thread_concurrency = 8
    innodb_flush_method = O_DIRECT
    innodb_log_file_size = 512M
    [mysqld_safe]
    log-error=/var/log/mysqld.log
    pid-file=/var/run/mysqld/mysqld.pid
    sql_mode=STRICT_ALL_TABLES

  6. 获取系统初始密码:
    [[email protected] ~]# cat /root/.mysql_secret
    #The random password set for the root user at Tue Dec 18 20:37:59 2018 (local time): pP4xR06U9nPyWrhA

    登录MySQL:

    [[email protected] ~]# mysql -uroot -ppP4xR06U9nPyWrhA
    Warning: Using a password on the command line interface can be insecure.
    Welcome to the MySQL monitor. Commands end with ; or \g.
    Your MySQL connection id is 2
    Server version: 5.6.42

    SET PASSWORD FOR ‘root’@‘localhost’ = PASSWORD(‘xxxxxxx’)

    grant all on . to [email protected]"%" identified by " xxxxxxx "

    设置MySQL开机自启动

    systemctl enable mysql.service

    初始化MySQL

    /usr/bin/mysql_secure_installation

    下载mysql-connector-java-5.1.46.tar.gz并解压
    在解压目录下找到mysql-connector-java.jar, 复制到所有主机的/usr/share/java目录下

    cd mysql-connector-java-5.1.46
    cp mysql-connector-java-5.1.46.jar /usr/share/java/mysql-connector-java.jar

    [[email protected] usr]# ls -l /usr/share/java/mysql-connector-java.jar
    -rw-r–r-- 1 root root 1004838 Dec 19 20:45 /usr/share/java/mysql-connector-java.jar

    下载Oracle JDK包oracle-j2sdk1.8-1.8.0+update141-1.x86_64.rpm上传到所有主机并安装
    下载地址:https://archive.cloudera.com/cm6/6.0.1/redhat7/yum/RPMS/x86_64/

    rpm -ivh oracle-j2sdk1.8-1.8.0+update141-1.x86_64.rpm

  7. Creating Databases for Cloudera Software
    需要建的库有
    scm、amon、rman、hue、metastore、sentry、nav、navms、oozie
    CREATE DATABASE scm DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
    GRANT ALL ON scm.* TO ‘scm’@’%’ IDENTIFIED BY ‘[email protected]’;
    CREATE DATABASE rman DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
    GRANT ALL ON rman.* TO ‘rman’@’%’ IDENTIFIED BY ‘[email protected]’;
    CREATE DATABASE hue DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
    GRANT ALL ON hue.* TO ‘hue’@’%’ IDENTIFIED BY ‘[email protected]’;
    CREATE DATABASE metastore DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
    GRANT ALL ON metastore.* TO ‘metastore’@’%’ IDENTIFIED BY ‘[email protected]’;
    CREATE DATABASE sentry DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
    GRANT ALL ON sentry.* TO ‘sentry’@’%’ IDENTIFIED BY ‘[email protected]’;
    CREATE DATABASE nav DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
    GRANT ALL ON nav.* TO ‘nav’@’%’ IDENTIFIED BY ‘[email protected]’;
    CREATE DATABASE navms DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
    GRANT ALL ON navms.* TO ‘navms’@’%’ IDENTIFIED BY ‘[email protected]’;
    CREATE DATABASE oozie DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
    GRANT ALL ON oozie.* TO ‘oozie’@’%’ IDENTIFIED BY ‘[email protected]’;
    CDH6.0.1详细安装步骤及问题解决

  8. 初始化cloudera manager数据库

/opt/cloudera/cm/schema/scm_prepare_database.sh mysql scm scm

四、下载并安装Cloudera Manager

  1. 下载地址: https://archive.cloudera.com/cm6/6.0.1/redhat7/yum/RPMS/x86_64/
    1.1. cloudera-manager-daemons-6.0.1-610811.el7.x86_64.rpm
    1.2. cloudera-manager-server-6.0.1-610811.el7.x86_64.rpm
    1.3. cloudera-manager-agent-6.0.1-610811.el7.x86_64.rpm

    在主节点hadoop01服务器上安装1,2,3;
    在Agent服务器上安装1,3;

  2. 在主节点hadoop01上执行:
    systemctl start cloudera-scm-server

    查看日志:
    tail -f /var/log/cloudera-scm-server/cloudera-scm-server.log
    显示如下表示服务已经正常起来
    INFO WebServerImpl:com.cloudera.server.cmf.WebServerImpl: Started Jetty server.
    CDH6.0.1详细安装步骤及问题解决

  3. 在所有Agent节点hadoop01, hadoop02, hadoop06上执行:

    配置Agent的Server指向
    vi /etc/cloudera-scm-agent/config.ini

    [General]
    #Hostname of the CM server.
    server_host=hadoop01

    [Security]
    #Use TLS and certificate validation when connecting to the CM server.
    use_tls=1

    启动cloudera-scm-agent服务:
    systemctl status cloudera-scm-agent
    systemctl start cloudera-scm-agent

    Agent Log文件位置:/var/log/cloudera-scm-agent
    cloudera-scm-agent.log

    tail -f /var/log/cloudera-scm-agent/cloudera-scm-agent.log

五、配置CDH

Cloudera Manager Server启动起来以后就可以登录Web界面进行CDH的安装配置工作了。
在浏览器中输入 http://192.168.1.101:7180
就可以看到如下的登录界面
CDH6.0.1详细安装步骤及问题解决

用户名和密码默认都为admin

点击登录按钮后就会看到选择TLS认证方式的界面,在此我们采用第1种方式,让cloudera manager自动配置TLS认证。
在主节点hadoop01机器上执行:

JAVA_HOME=/usr/java/jdk1.8.0_181-amd64 /opt/cloudera/cm-agent/bin/certmanager --location /opt/cloudera/CMCA setup --configure-services

重启cloudera manager server,然后重新登录,就会看到如下界面

CDH6.0.1详细安装步骤及问题解决

点击继续,就会看到选择主机的界面
CDH6.0.1详细安装步骤及问题解决

输入要安装CDH的主机IP地址,点击搜索
CDH6.0.1详细安装步骤及问题解决

选中搜索到的主机,点击继续
CDH6.0.1详细安装步骤及问题解决

在此我们不做任何改动,直接点击继续
CDH6.0.1详细安装步骤及问题解决

我们前面已经手动安装了Oracle-j2sdk,所以这里不用再做勾选,直接点击继续
CDH6.0.1详细安装步骤及问题解决

输入root用户的密码,点击继续
CDH6.0.1详细安装步骤及问题解决

运行一段时间以后又遇到了如下的错误:主机运行状况不良。
CDH6.0.1详细安装步骤及问题解决
在网上搜索到如下解决办法,应用后问题得到解决:
Cloudera 安装Parcel提示主机运行状况不良
解决方法
删除agent目录下面的cm_guid文件,并重启失败节点的agent服务。

[[email protected] ~]# cd /var/lib/cloudera-scm-agent/
[[email protected] cloudera-scm-agent]# ll
total 32
-rw------- 1 root root 2 Dec 28 14:27 active_parcels.json
drwxr-xr-x 2 cloudera-scm cloudera-scm 4096 Dec 28 23:01 agent-cert
-rw-r–r-- 1 root root 36 Dec 28 14:25 cm_guid
-rw------- 1 root root 13813 Dec 29 07:10 response.avro
-rw-r–r-- 1 root root 36 Dec 28 14:25 uuid
[[email protected] cloudera-scm-agent]# rm -rf cm_guid
[[email protected] cloudera-scm-agent]# systemctl restart cloudera-scm-agent
CDH6.0.1详细安装步骤及问题解决

在两台报错的主机上将cm_guid删除后,返回安装界面,发现已经自动进行到如下界面开始继续安装

CDH6.0.1详细安装步骤及问题解决

等待一段时间后CDH parcel已经在所有主机上**
CDH6.0.1详细安装步骤及问题解决

点击继续,进入检查主机正确性的界面
CDH6.0.1详细安装步骤及问题解决

出现3个黄色警告,我们一 一解决。

  1. Cloudera 建议将 /proc/sys/vm/swappiness 设置为最大值 10。当前设置为 30。

Cloudera 建议将 /proc/sys/vm/swappiness 设置为最大值 10。当前设置为 30。使用 sysctl 命令在运行时更改该设置并编辑 /etc/sysctl.conf,以在重启后保存该设置。您可以继续进行安装,但 Cloudera Manager 可能会报告您的主机由于交换而运行状况不良。以下主机将受到影响:
查看详细信息
hadoop[01-02, 06]

解决办法:
临时调整: sysctl vm.swappiness=10
永久调整: vi /etc/sysctl.conf
增加下面一行
vm.swappiness=10
CDH6.0.1详细安装步骤及问题解决

  1. 已启用透明大页面压缩,可能会导致重大性能问题。

已启用透明大页面压缩,可能会导致重大性能问题。请运行“echo never > /sys/kernel/mm/transparent_hugepage/defrag”和“echo never > /sys/kernel/mm/transparent_hugepage/enabled”以禁用此设置,然后将同一命令添加到 /etc/rc.local 等初始化脚本中,以便在系统重启时予以设置。以下主机将受到影响:
查看详细信息
hadoop[01-02, 06]

解决办法:
echo never > /sys/kernel/mm/transparent_hugepage/defrag
echo never > /sys/kernel/mm/transparent_hugepage/enabled
修改/etc/rc.local将上面两行添加进去
vi /etc/rc.local

  1. Psycopg2版本太低的问题
    安装pip
    yum -y install epel-release
    yum -y install python-pip
    pip install --upgrade pip
    yum install postgresql-devel

安装psycopg2
下载psycopg2-2.7.6.1.tar.gz并解压
[[email protected] psycopg2-2.7.6.1]# python setup.py build
[[email protected] psycopg2-2.7.6.1]# python setup.py install

重新运行检查主机,所有项目检查通过
CDH6.0.1详细安装步骤及问题解决

CDH6.0.1详细安装步骤及问题解决

点击继续
CDH6.0.1详细安装步骤及问题解决

我们选择所有服务,点击继续
CDH6.0.1详细安装步骤及问题解决

CDH6.0.1详细安装步骤及问题解决

点击按主机查看按钮,可以清楚的看到每台主机上安装的组件

CDH6.0.1详细安装步骤及问题解决

我们采用默认设置,直接点击继续
CDH6.0.1详细安装步骤及问题解决

输入先前创建的数据库的名称,用户名和密码,测试连接,全部通过,点击继续

CDH6.0.1详细安装步骤及问题解决
CDH6.0.1详细安装步骤及问题解决

CDH6.0.1详细安装步骤及问题解决

直接点击继续开始安装
CDH6.0.1详细安装步骤及问题解决
CDH6.0.1详细安装步骤及问题解决
等待一段时间后安装完成
CDH6.0.1详细安装步骤及问题解决

点击继续,进入Summary界面
CDH6.0.1详细安装步骤及问题解决

至此,CDH安装顺利完成,Cheers!

接下来让我们一起看看安装完成后的主界面
CDH6.0.1详细安装步骤及问题解决