Ambari搭建HDP集群


概述

Ambari是Hortonworks开源的Hadoop平台的管理软件,具备Hadoop组件的安装、管理、运维等基本功能,提供Web UI进行可视化的集群管理,简化了大数据平台的安装、使用难度。

功能列表

操作级别:

  • Host Level Action(机器级别的操作)
  • Component Level Action(模块级别的操作)

基于角色的用户管理,角色分为:

  • Cluster User。 查看集群和Service的信息,如配置、service状态、健康状态等。Read-only
  • Service Operator。 能够操作Service的生命周期,如启动,停止,也可以进行一些如Rebalance DataNode和YARN refresh的操作
  • Service Administrator。 在Service Operator的基础上增加了配置service,移动NameNode,启用HA等操作
  • Cluster Operator。 在Service Administrator的基础上增加了对hosts和components的操作,如增加,删除等
  • Cluster Administrator。集群的超级管理员,拥有无上的权利,可以操作任何组件。

Dashboard 监控 :

  • Roll Start功能。根据Service的依赖关系,按照一定的顺序启动每个Service。比如HBase依赖HDFS和Zookeeper,Ambari会先启动HDFS和Zookeeper,之后启动HBase。

  • 关键的运维指标(metrics)–metrics 是“度量,指标”的意思

  • 在左侧的 Service 列表,中间部分是 Service 的模块(Component)信息,也就是该 Service 有哪些模块及其数目。右上角有个 Service Action 的按钮,包括service的启动、停止、删除等操作。

  • Quick links(导向组件原生管理界面)

    • NameNode UI、ResourceManage UI、HBase Master UI
    • HDFS的NameNode的logs
    • YARN的ResourceManage 的logs
    • Hbase的logs

Alert介绍:

  • Alert 告警级别 Status:
    OK 、Warning、Critical、Unknown、None
  • Alert 告警类型:
    WEB、Port、Metric、Aggregate 和 Script
  • Ambari 中的 Alert 类型对比
类型 用途 告警级别 阀值是否可配置 单位
PORT 用来监测机器上的一个端口是否可用 OK, WARN, CRIT
METRIC 用来监测 Metric 相关的配置属性 OK, WARN, CRIT 变量
AGGREGATE 用于收集其他某些 Alert 的状态 OK, WARN, CRIT 百分比
WEB 用于监测一个 WEB UI(URL)地址是否可用 OK, WARN, CRIT
SCRIPT Alert 的监测逻辑由一个自定义的 python 脚本执行 OK, CRIT

一、环境准备

1.版本介绍

Centos7
JDK1.8.0_212
Mysql5.7.25
Ambari2.6.2.2
HDP-2.6.5.0-292
HDP-GPL-2.6.5.0
HDP-UTILS-1.1.0.22

2.配置hosts

修改/etc/hosts文件,将hosts文件拷贝至其他节点

xxx1 ambari
xxx2 nname1
xxx3 nname2
xxx4 dnode1
xxx5 dnode2
xxx6 dnode3
xxx7 dnode4
xxx8 dnode5
xxx9 dnode6

3.配置SSH

执行ssh_auto.sh脚本,自动创建秘钥,发送秘钥到其他节点

#!/bin/bash
set -e

#所需变量
#取得集群的所有主机名,这里需要注意:/etc/hosts配置的IP和主机名只能用一个空格分割
hostList=$(cat /etc/hosts | tail -n +2 | cut -d ' ' -f 2)
pingCount=5
logPre=TDP

#服务器密码
passwd=xxxx

set timeout 60

#秘钥生成函数
ssh-keygen(){
    echo "======>$host ssh-keygen... \n"
    /usr/bin/expect <<EOF
    spawn ssh-keygen
    expect {
        "Enter file in which to save the*" { send "\r"; exp_continue}
        "Overwrite*" { send "n\r" ; exp_continue}
        "Enter passphrase*" { send "\r"; exp_continue} 
        "Enter same passphrase again:" { send "\r" ; exp_continue}
    }
EOF
}

#拷贝公钥函数
ssh-copy-id(){
    echo "======>$host ssh-copy-id... \n"
    /usr/bin/expect <<EOF
    spawn ssh-copy-id $host
    expect {
        "*yes/no*" {send "yes\r" ; exp_continue}
        "*password*" {send "$passwd\r" ; exp_continue}
    }

EOF
}

ssh-keygen

for host in $hostList
do

    echo "----------------$host-----------------"
    #检测主机的连通性
    unPing=$(ping $host -c $pingCount | grep 'Unreachable' | wc -l)
    if [ "$unPing" == "$pingCount" ]; then
        echo -e "$logPre======>$host is Unreachable,please check '/etc/hosts' file"
        continue
    fi

    echo "$logPre======>$host  "
   
    ssh-copy-id $host

    echo "$logPre======>$host is done! "

done

wait

echo "------hosts done--------"

4.配置firewall&selinux

配置防火墙需要开放的端口

firewall-cmd --zone=public --add-port=80/tcp --permanent
firewall-cmd --zone=public --add-port=1024-65535/tcp --permanent
firewall-cmd --reload
firewall-cmd --list-all

修改/etc/selinux/config配置文件,永久关闭selinux

sed -i "s/^SELINUX=.*$/SELINUX=disabled/" /etc/selinux/config

修改完后重启系统,查看selinux

sestatus

5.配置时间同步

安装ntp服务

yum install -y ntp

开启ntp服务

systemctl start ntpd

开启开机自启ntp服务

systemctl enable ntpd

修改时区

timedatectl set-timezone Asia/Shanghai

6.安装JDK

解压安装

tar -xvf jdk-8u112-linux-x64.tar.gz -C /opt/

连接软连接

ln -s jdk1.8.0_112/ jdk

配置环境变量

sed -i '$a \export JAVA_HOME=/opt/jdk\nexport JAVA_BIN=$JAVA_HOME/bin\nexport CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/tools.jar\nexport PATH=.:$JAVA_BIN:$PATH' /etc/profile

重载环境变量

source /etc/profile

查看java版本

java -version

7.安装mysql

解压到指定目录

tar -xzvf mysql-5.7.25-linux-glibc2.12-x86_64.tar.gz -C /opt/server/

移动并修改文件名

mv /opt/server/mysql-5.7.25-linux-glibc2.12-x86_64 /usr/local/mysql

创建数据仓库目录

mkdir -p /opt/server/mysql/data

新建mysql用户组

groupadd mysql

新建msyql用户禁止登录shell

useradd -r -s /sbin/nologin -g mysql mysql -d /usr/local/mysql

改变目录属有者

chown -R mysql:mysql /usr/local/mysql
chown -R mysql:mysql /opt/server/mysql

进入/usr/local/mysql目录,配置mysql参数

bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/opt/server/mysql/data

上边命令执行完成后,会生成mysql的临时密码,要注意!!!

bin/mysql_ssl_rsa_setup  --datadir=/opt/server/mysql/data

修改系统配置文件

cd /usr/local/mysql/support-files
cp mysql.server /etc/init.d/mysql

sed -i "s/^basedir=.*$/basedir=/usr/local/mysql/" /etc/init.d/mysql
sed -i "s/^datadir=.*$/datadir=/opt/server/mysql/data/"  /etc/init.d/mysql

建立软连接

ln -s /usr/local/mysql/bin/mysql /usr/bin/mysql

启动mysql

/etc/init.d/mysql start

登录mysql

mysql -hlocalhost -uroot -p

修改用户密码并授权

mysql> set password=password('root');
mysql> grant all privileges on *.* to 'root'@'%' identified by 'root';
mysql> flush privileges;
mysql> exit;

配置mysql开机自启

chmod 755 /etc/init.d/mysql
chkconfig --add mysql
chkconfig --level 345 mysql on

8.配置本地yum源

8.1安装httpd服务

安装httpd

yum -y install httpd

启动服务

systemctl start httpd

开机自启

systemctl enable httpd

8.2制作本地仓库

下载ambri&hdp包

wget -O /var/www/html/ambari-2.6.2.2-centos7.tar.gz http://public-repo-1.hortonworks.com/ambari/centos7/2.x/updates/2.6.2.2/ambari-2.6.2.2-centos7.tar.gz

wget -O /var/www/html/HDP-2.6.5.0-centos7-rpm.tar.gz http://public-repo-1.hortonworks.com/HDP/centos7/2.x/updates/2.6.5.0/HDP-2.6.5.0-centos7-rpm.tar.gz

wget -O /var/www/html/HDP-UTILS-1.1.0.22-centos7.tar.gz http://public-repo-1.hortonworks.com/HDP-UTILS-1.1.0.22/repos/centos7/HDP-UTILS-1.1.0.22-centos7.tar.gz

wget -O /var/www/html/HDP-GPL-2.6.5.0-centos7-gpl.tar.gz http://public-repo-1.hortonworks.com/HDP-GPL/centos7/2.x/updates/2.6.5.0/HDP-GPL-2.6.5.0-centos7-gpl.tar.gz

将包进行解压

tar xvf ambari-2.6.2.2-centos7.tar.gz 
tar xvf HDP-2.6.5.0-centos7-rpm.tar.gz
tar xvf HDP-UTILS-1.1.0.22-centos7.tar.gz
tar xvf HDP-GPL-2.6.5.0-centos7-gpl.tar.gz

修改文件,将下图中的5个文件中yum源文件地址都改为本地搭建的yum源地址

8.3配置本机yum源

下载本地ambari&hdp的yum源文件

wget -O /etc/yum.repos.d/ambari.repo http://host/ambari/centos7/2.6.2.2-1/ambari.repo

wget -O /etc/yum.repos.d/hdp.repo http://host/HDP/centos7/2.6.5.0-292/hdp.repo

wget -O /etc/yum.repos.d/hdp.gpl.repo http://host/HDP-GPL/centos7/2.6.5.0-292/hdp.gpl.repo

8.4附加

下载官方ambari&hdp的yum源文件

wget -O /etc/yum.repos.d/ambari.repo http://public-repo-1.hortonworks.com/ambari/centos7/2.x/updates/2.6.2.2/ambari.repo

wget -O /etc/yum.repos.d/hdp.repo http://public-repo-1.hortonworks.com/HDP/centos7/2.x/updates/2.6.5.0/hdp.repo

wget -O /etc/yum.repos.d/hdp.gpl.repo http://public-repo-1.hortonworks.com/HDP-GPL/centos7/2.x/updates/2.6.5.0/hdp.gpl.repo

清除yum缓存

yum clean all

重新建立缓存

yum makecache

9.安装ambari

安装ambari-server

yum install ambari-server -y

配置ambari数据库

mysql> create database ambari default charset='utf8';
mysql> grant all privileges on ambari.* to 'ambari'@'%' identified by 'ambari';
mysql> flush privileges;
mysql> use ambari;
mysql> source /var/lib/ambari-server/resources/Ambari-DDL-MySQL-CREATE.sql;

配置ambari-server

ambari-server setup
##ambari-server配置项
Customize user account for ambari-server daemon [y/n] :n 是表示选择root用户
 
=============================================================================
Checking JDK...
[1] Oracle JDK 1.8 + Java Cryptography Extension (JCE) Policy Files 8
[2] Oracle JDK 1.7 + Java Cryptography Extension (JCE) Policy Files 7
[3] Custom JDK
=============================================================================
Enter choice :3  #是自己安装的jdk,输入/opt/jdk
 
Enable Ambari Server to download and install GPL Licensed LZO packages [y/n] :y

#y是代表用自己安装的数据库(n是代表ambari自带的PostgreSQL,不建议)
Enter advanced database configuration [y/n]:y 
 
==============================================================================
Choose one of the following options:
[1] - PostgreSQL (Embedded)
[2] - Oracle
[3] - MySQL / MariaDB
[4] - PostgreSQL
[5] - Microsoft SQL Server (Tech Preview)
[6] - SQL Anywhere
[7] - BDB
==============================================================================
Enter Choice:3 #是自己安装的mysql
Hostname:localhost
Port:3306
Database name:ambari
Username:ambari
Enter Database Password:ambari
Re-enter Password:ambari
 
#"Ambari Server 'setup' completed successfully" 看到这句话就说明配置完成了

添加jdbc驱动

sed -i '$a \server.jdbc.driver.path=/usr/share/java/mysql-connector-java-5.1.37.jar' /etc/ambari-server/conf/ambari.properties

启动ambari-server

ambari-server start

关闭ambari-server

ambari-server stop

查看ambari-server运行状态

ambari-server status

登录ambari web界面(admin/admin)

http://host:8080

附加:修改默认端口

client.api.port=


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM