大家好,我是binso,之前在【知乎】上发表这个文章,也是我,谢谢!!!


其他更多关于大数据的使用和交流,请加QQ群讨论:主要是spark kudu impala hbase hive kafka等



1.ambari安装准备

1.1 准备安装包

安装文件下载:

ambari地址:public-repo-1.hortonworks.com

HDP地址:public-repo-1.hortonworks.com

HDP-utils地址:public-repo-1.hortonworks.com


文件非常的大,所以不建议在线安装。(没有的,可以找binsoo拿,知乎号就是微号)

想了解最新版本信息,也下载地址.docs.hortonworks.com/


1.2 准备安装环境

1.2.1 设置无密码SSH: 在线文档查看

Red Hat Linux上安装使用SSH

配置root用户的ssh登录


1.2.2 添加DNS


编辑 /etc/hosts 文件

vi /etc/hosts


将做为安装集群的机器全部加入到hosts文件中


1.2.3 编辑网络配置文件

vi /etc/sysconfig/network


NETWORKING=yes

HOSTNAME=hu01


1.2.4 禁用防火墙

如果是CentOS 6

chkconfig iptables off 或 /etc/init.d/iptables stop

如果是CentOS 7

systemctl disable firewalld 或 service firewalld stop


1.2.5 安装jdk

略(下载,然后直接解压:tar -zvxf jdk-8u121-linux-x64.tar.gz -C /usr/java/)

安装完之后,配置一下profile

vi /etc/profile

在里面加如下:

##########java home##########

export JAVA_HOME=/usr/java/jdk-xxx

export PATH=$PATH:${JAVA_HOME}/bin


1.3 安装ambari

1.3.1 使用本地源安装时,先要安装httpd,来搭建源地址

yum install httpd

(没有网络怎么办,实际为下载对应的gz文件,解压到路径下.)

用命令,默认安装的路径为:

/var/www/下


1.3.2 配置本地源

上传下载文件到192.168.1.218的root目录下

准备以root用户来进行安装

(安装时,最好已经放到相邻服务器中,方便复制文件)

scp ambari-2.5.1.0-centos7.tar.gz 192.168.1.218:/root

scp HDP-2.6.1.0-centos7-rpm.tar.gz 192.168.1.218:/root

scp HDP-UTILS-1.1.0.21-centos7.tar.gz 192.168.1.218:/root


解压到 /var/www/html/ 目录下

命令:

tar -zvxf /root/ambari-2.5.1.0-centos7.tar.gz -C /var/www/html/

tar -zvxf /root/HDP-2.6.1.0-centos7-rpm.tar.gz -C /var/www/html/

tar -zvxf /root/HDP-UTILS-1.1.0.21-centos7.tar.gz -C /var/www/html/HDP-UTILS-1.1.0.21/centos7


配置ambari.repo,相当于制作repo

修改内容:vi /etc/yum.repos.d/ambari.repo


配置httpd的配置文件

修改命令:vi /etc/httpd/conf/httpd.conf


启动httpd服务

service httpd start



1.3.3 安装命令

第1步:yum install ambari-server


原因是本地源,相当快下载与安装的.


第2步:配置ambari

备注:提前安装好JDK的版本,配置的时候需要,(要不,就是在线安装).


命令:ambari-server setup



第3步:

输入:3 为自定义配置jdk


第4步:

接下来是配置mysql数据库:(要提前安装好mysql数据库,并提交准备好对应的mysql的访问jar包,如:mysql-connector-java-5.1.38.jar)

以上安装部署时,要根据提示,先执行/var/lib/ambari-server/resources/Ambari-DDL-MySQL-CREATE.sql文件,这个可以直接在数据库中执行。

(回到数据库处,先执行脚本,创建好表之后还可以进行)

配置完成


1.3.3 启动ambari-server


1.3.4 查看日志:


mysql的链接失败,是因为配置的driver没有设置正确.

修改如下:vi /etc/ambari-server/conf/ambari.properties

再次启动,成功.


1.3.4 打开网页:192.168.1.218:8080 直接到了安装界面


下一步,配置节点,制作安装源.


2.大数据组件可视化安装过程:举例zookeeper的安装

2.1


2.2


根据自定义的安装源,来修改内容如下:

2.3

主要填写:

1.每行填写一个host name,对应的是安装集群的节点

2.提交配置的ssh的私密

填写完成后


安装过程时,报错:

ERROR 2017-09-20 10:55:30,922 main.py:244 - Ambari agent machine hostname (localhost.localdomain) does not match expected ambari server hostname (fb01). Aborting registration. Please check hostname, hostname -f and /etc/hosts file to confirm your hostname is setup correctly


表示:你的hostname没有修改。

另外,记得关闭防火墙


2.4

安装ambari-agent 客户端

2.5

操作:选中要安装的版本组件。会涉及关联校验步骤。


2.6

在上一环节,只选中zookeeper提交后

这个环节,是选择master


2.7-2.10都直接下一步就可以了





3.大数据组件api接口安装过程

以zookeeper为例子:

3.1

使用post方式提交数据

url: 192.168.1.220:8080/api/

提交数据:{"ServiceInfo":{"service_name":"ZOOKEEPER"}}

目的:注册服务名字,方便监控


3.2

使用put方式提交数据

url: 192.168.1.220:8080/api/

提交数据:(实际内容可以通过json工具查看一下,主要提交的就是配置文件)

[{"Clusters":{"desired_config":[{"type":"zoo.cfg","tag":"version1506065925604","properties":{"autopurge.purgeInterval":"24","autopurge.snapRetainCount":"30","clientPort":"2181","dataDir":"/hadoop/zookeeper","initLimit":"10","syncLimit":"5","tickTime":"3000"},"service_config_version_note":"Initial configurations for ZooKeeper"},{"type":"zookeeper-env","tag":"version1506065925604","properties":{"content":"\nexport JAVA_HOME={{java64_home}}\nexport ZOOKEEPER_HOME={{zk_home}}\nexport ZOO_LOG_DIR={{zk_log_dir}}\nexport ZOOPIDFILE={{zk_pid_file}}\nexport SERVER_JVMFLAGS={{zk_server_heapsize}}\nexport JAVA=$JAVA_HOME/bin/java\nexport CLASSPATH=$CLASSPATH:/usr/share/zookeeper/*\n\n{% if security_enabled %}\nexport SERVER_JVMFLAGS=\"$SERVER_JVMFLAGS -Djava.security.auth.login.config={{zk_server_jaas_file}}\"\nexport CLIENT_JVMFLAGS=\"$CLIENT_JVMFLAGS -Djava.security.auth.login.config={{zk_client_jaas_file}}\"\n{% endif %}","zk_log_dir":"/var/log/zookeeper","zk_pid_dir":"/var/run/zookeeper","zk_server_heapsize":"1024m","zk_user":"zookeeper"},"service_config_version_note":"Initial configurations for ZooKeeper"},{"type":"zookeeper-log4j","tag":"version1506065925604","properties":{"content":"\n#\n#\n# Licensed to the Apache Software Foundation (ASF) under one\n# or more contributor license agreements. See the NOTICE file\n# distributed with this work for additional information\n# regarding copyright ownership. The ASF licenses this file\n# to you under the Apache License, Version 2.0 (the\n# \"License\"); you may not use this file except in compliance\n# with the License. You may obtain a copy of the License at\n#\n# http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing,\n# software distributed under the License is distributed on an\n# \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n# KIND, either express or implied. See the License for the\n# specific language governing permissions and limitations\n# under the License.\n#\n#\n#\n\n#\n# ZooKeeper Logging Configuration\n#\n\n# DEFAULT: console appender only\nlog4j.rootLogger=INFO, CONSOLE, ROLLINGFILE\n\n# Example with rolling log file\n#log4j.rootLogger=DEBUG, CONSOLE, ROLLINGFILE\n\n# Example with rolling log file and tracing\n#log4j.rootLogger=TRACE, CONSOLE, ROLLINGFILE, TRACEFILE\n\n#\n# Log INFO level and above messages to the console\n#\nlog4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender\nlog4j.appender.CONSOLE.Threshold=INFO\nlog4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout\nlog4j.appender.CONSOLE.layout.ConversionPattern=%d{ISO8601} - %-5p [%t:%C{1}@%L] - %m%n\n\n#\n# Add ROLLINGFILE to rootLogger to get log file output\n# Log DEBUG level and above messages to a log file\nlog4j.appender.ROLLINGFILE=org.apache.log4j.RollingFileAppender\nlog4j.appender.ROLLINGFILE.Threshold=DEBUG\nlog4j.appender.ROLLINGFILE.File={{zk_log_dir}}/zookeeper.log\n\n# Max log file size of 10MB\nlog4j.appender.ROLLINGFILE.MaxFileSize={{zookeeper_log_max_backup_size}}MB\n# uncomment the next line to limit number of backup files\n#log4j.appender.ROLLINGFILE.MaxBackupIndex={{zookeeper_log_number_of_backup_files}}\n\nlog4j.appender.ROLLINGFILE.layout=org.apache.log4j.PatternLayout\nlog4j.appender.ROLLINGFILE.layout.ConversionPattern=%d{ISO8601} - %-5p [%t:%C{1}@%L] - %m%n\n\n\n#\n# Add TRACEFILE to rootLogger to get log file output\n# Log DEBUG level and above messages to a log file\nlog4j.appender.TRACEFILE=org.apache.log4j.FileAppender\nlog4j.appender.TRACEFILE.Threshold=TRACE\nlog4j.appender.TRACEFILE.File=zookeeper_trace.log\n\nlog4j.appender.TRACEFILE.layout=org.apache.log4j.PatternLayout\n### Notice we are including log4j's NDC here (%x)\nlog4j.appender.TRACEFILE.layout.ConversionPattern=%d{ISO8601} - %-5p [%t:%C{1}@%L][%x] - %m%n","zookeeper_log_max_backup_size":"10","zookeeper_log_number_of_backup_files":"10"},"service_config_version_note":"Initial configurations for ZooKeeper"},{"type":"zookeeper-logsearch-conf","tag":"version1506065925604","properties":{"component_mappings":"ZOOKEEPER_SERVER:zookeeper","content":"\n{\n \"input\":[\n {\n \"type\":\"zookeeper\",\n \"rowtype\":\"service\",\n \"path\":\"{{default('/configurations/zookeeper-env/zk_log_dir', '/var/log/zookeeper')}}/zookeeper*.log\"\n }\n ],\n \"filter\":[\n {\n \"filter\":\"grok\",\n \"conditions\":{\n \"fields\":{\"type\":[\"zookeeper\"]}\n },\n \"log4j_format\":\"%d{ISO8601} - %-5p [%t:%C{1}@%L] - %m%n\",\n \"multiline_pattern\":\"^(%{TIMESTAMP_ISO8601:logtime})\",\n \"message_pattern\":\"(?m)^%{TIMESTAMP_ISO8601:logtime}%{SPACE}-%{SPACE}%{LOGLEVEL:level}%{SPACE}\\\\[%{DATA:thread_name}\\\\@%{INT:line_number}\\\\]%{SPACE}-%{SPACE}%{GREEDYDATA:log_message}\",\n \"post_map_values\": {\n \"logtime\": {\n \"map_date\":{\n \"target_date_pattern\":\"yyyy-MM-dd HH:mm:ss,SSS\"\n }\n }\n }\n }\n ]\n}","service_name":"Zookeeper"},"service_config_version_note":"Initial configurations for ZooKeeper"}]}}]

目的:将页面配置的参数内容做为了字段提交保存到数据库,形成配置版本,其中version1506065925604为版本号。


3.3

使用post方式提交数据

url: 192.168.1.220:8080/api/

提交数据:{"components":[{"ServiceComponentInfo":{"component_name":"ZOOKEEPER_CLIENT"}},{"ServiceComponentInfo":{"component_name":"ZOOKEEPER_SERVER"}}]}

目的:向组件注册名字,方便监控时名字对应


3.4

使用post方式提交数据

url: 192.168.1.220:8080/api/

提交数据:

2次数据提交如下:

第1次:

{"RequestInfo":{"query":"Hosts/host_name=fb02|Hosts/host_name=fb04|Hosts/host_name=fb03"},"Body":{"host_components":[{"HostRoles":{"component_name":"ZOOKEEPER_SERVER"}}]}}

第2次:

{"RequestInfo":{"query":"Hosts/host_name=fb04"},"Body":{"host_components":[{"HostRoles":{"component_name":"ZOOKEEPER_CLIENT"}}]}}

目的:指定需要安装的节点


3.5

使用put方式提交数据

url: 192.168.1.220:8080/api/

提交数据:

{"RequestInfo":{"context":"Install Services","operation_level":{"level":"CLUSTER","cluster_name":"amb"}},"Body":{"ServiceInfo":{"state":"INSTALLED"}}}

目的:发起安装


如要其它组件的安装api文档,请联作者。


4.ambari的api使用说明

安装api:

192.168.1.220:8080/api/


监控api:

192.168.1.220:8080/api/


1.内存

192.168.1.220:8080/api/


2.cpu

192.168.1.220:8080/api/


3.磁盘

192.168.1.220:8080/api/


This is a premium name

没有,只有cpu等待io 叫 wio,在cpu的api里有数据


5.网络

192.168.1.220:8080/api/


6.日志查看



7.应用状态

192.168.1.220:8080/api/

其中?后面为过滤条件,/后面是取的字段,多个字段用,分隔来取


http://192.168.1.220:8080/api/v1/clusters/amb/requests取的每个hosts中的


8.所有组件安装情况 与 当前情况

192.168.1.220:8080/api/



9.已经安装的组件安装配置情况

192.168.1.220:8080/api/


下面有:

1类:Clusters

对应:192.168.1.220:8080/api/


1.1 health_report

1.2 desired_configs

1.3 desired_service_config_versions


2类: alerts_summary

对应:192.168.1.220:8080/api/


3类: alerts_summary_hosts

对应:192.168.1.220:8080/api/


4类: config_groups

对应:192.168.1.220:8080/api/


5类:kerberos_descriptors

对应:192.168.1.220:8080/api/


6类:hosts

对应:192.168.1.220:8080/api/


7类:configurations

对应:192.168.1.220:8080/api/


8类:services

对应:192.168.1.220:8080/api/


9类:requests

对应:192.168.1.220:8080/api/


10类:alerts

对应:192.168.1.220:8080/api/


11类:stack_versions

对应:192.168.1.220:8080/api/


12类:service_config_versions

对应:192.168.1.220:8080/api/


13类:alert_definitions

对应:192.168.1.220:8080/api/


5.ambari的框架解析

待续!!!


6.ambari引入的开源包

待续!!!!!!


7.ambari的二次开发

待续!!!!!!!!!

Logo

Kafka开源项目指南提供详尽教程,助开发者掌握其架构、配置和使用,实现高效数据流管理和实时处理。它高性能、可扩展,适合日志收集和实时数据处理,通过持久化保障数据安全,是企业大数据生态系统的核心。

更多推荐