ambari

Posted clown_x

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ambari相关的知识,希望对你有一定的参考价值。

参考博客: https://www.unixhot.com/article/46

使用ambari 快速部署hadoop 集群

Ambari是 Apache Software Foundation 中的一个顶级项目。Ambari可以创建、管理、监控 Hadoop 的集群。包括整个Hadoop生态圈(例如 Hive,Hbase,Sqoop,Zookeeper 等)。无论是初学者像快速部署一套Hadoop环境,还是用于生产的自动化部署,Ambari都可以满足。
 你可以在官网http://ambari.apache.org/获取最新的Ambari的内容,目前Ambari还支持流行的 Spark,Storm 等计算框架,Kafka消息队列、以及资源调度平台 YARN 等。
Ambari 自身也是一个分布式架构的软件,主要由两部分组成:Ambari Server 和 Ambari Agent。我们可以通过 Ambari Server 通知 Ambari Agent 安装对应的软件;甚至连Ambari Agent我们都可以在Web界面上来进行安装和部署。
Ambari Agent 会定时地发送各个机器每个项目组件的当前状态给 Ambari Server,并在Web界面上进行展示汇总,方面我们及时掌握集群状态

基础环境准备

[[email protected] ~]# ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
6b:74:cc:37:a0:79:a7:66:48:c4:3e:b0:17:bc:d3:87 [email protected]
The key‘s randomart image is:
+--[ RSA 2048]----+
| |
| o |
| . = . |
| = O o |
| . S E = |
| + B = . |
| + + |
| . o |
| |
+-----------------+
[[email protected] ~]# cat .ssh/id_rsa.pub >.ssh/authorized_keys
[[email protected] ~]# ls -l .ssh/authorized_keys
-rw-r--r-- 1 root root 398 May 17 21:34 .ssh/authorized_keys
[[email protected] ~]# chmod 600 .ssh/authorized_keys
[[email protected] ~]# ls -l .ssh/authorized_keys
-rw------- 1 root root 398 May 17 21:34 .ssh/authorized_keys
[[email protected] ~]# scp .ssh/id_rsa.pub 192.168.56.13:/root/.ssh/authorized_keys
[email protected]‘s password:
id_rsa.pub 100% 398 0.4KB/s 00:00
[[email protected] ~]# ssh [email protected]
Last failed login: Fri May 18 09:57:41 CST 2018 from slave-1 on ssh:notty
There were 3 failed login attempts since the last successful login.
Last login: Fri May 18 09:48:42 2018 from 192.168.56.1
[[email protected] ~]# exit

安装jdk

[[email protected] ~]# yum install -y java-1.8.0 mysql-connector-java

部署ambari-server

[[email protected] ~]# cd /etc/yum.repos.d/

wget http://public-repo-1.hortonworks.com/ambari/centos7/2.x/updates/2.2.0.0/ambari.repo

yum install -y ambari-server

数据库配置

[[email protected] ~]# mysql -uroot -psalt
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 3
Server version: 5.5.56-MariaDB MariaDB Server

Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.

Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.

MariaDB [(none)]> create database ambari character set utf8; #创建ambari数据库及用户
Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> create user ‘ambari‘@‘%‘ identified by ‘ambari‘;
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> grant all privileges on . to ‘ambari‘@‘%‘;
Query OK, 0 rows affected (0.01 sec)

MariaDB [(none)]>

MariaDB [(none)]> create database hive character set utf8; #创建hvie库及用户
Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> create user ‘hive‘@‘%‘ identified by ‘hive‘;
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> grant all privileges on . to ‘hive‘@‘%‘;
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)

设置ambari-server

[[email protected] ~]# ambari-server setup
Using python /usr/bin/python2
Setup ambari-server
Checking SELinux...
SELinux status is ‘disabled‘
Customize user account for ambari-server daemon [y/n] (n)?
Adjusting ambari-server permissions and ownership...
Checking firewall status...
Redirecting to /bin/systemctl status iptables.service
Unit iptables.service could not be found.

Checking JDK...
Do you want to change Oracle JDK [y/n] (n)?
Completing setup...
Configuring database...
Enter advanced database configuration [y/n] (n)? y
Configuring database...
==============================================================================
Choose one of the following options:
[1] - PostgreSQL (Embedded)
[2] - Oracle
[3] - MySQL
[4] - PostgreSQL
[5] - Microsoft SQL Server (Tech Preview)
[6] - SQL Anywhere
==============================================================================
Enter choice (3): 3
Hostname (localhost):
Port (3306):
Database name (ambari):
Username (ambari):
Enter Database Password (ambari):
Configuring ambari database...
Copying JDBC drivers to server resources...
Configuring remote database connection properties...
WARNING: Before starting Ambari Server, you must run the following DDL against the database to create the schema: /var/lib/ambari-server/resources/Ambari-DDL-MySQL-CREATE.sql
Extracting system views...
.......
Adjusting ambari-server permissions and ownership...
Ambari Server ‘setup‘ completed successfully.
[[email protected] ~]#
[[email protected] ~]# ambari-server start
Using python /usr/bin/python2
Starting ambari-server
Ambari Server running with administrator privileges.
Organizing resource files at /var/lib/ambari-server/resources...
WARNING: setpgid(2444, 0) failed - [Errno 13] Permission denied
Server PID at: /var/run/ambari-server/ambari-server.pid
Server out at: /var/log/ambari-server/ambari-server.out
Server log at: /var/log/ambari-server/ambari-server.log
Waiting for server start....................
Ambari Server ‘start‘ completed successfully.
[[email protected] ~]#

报错:

参考地址:https://docs.hortonworks.com/HDPDocuments/Ambari-2.6.0.0/bk_ambari-administration/content/using_ambari_with_mysql.html

1、18 May 2018 13:47:43,118 ERROR [main] DBAccessorImpl:102 - Error while creating database accessor
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver

解决:
[[email protected] ~]# ambari-server setup --jdbc-db=mysql --jdbc-driver=/usr/share/java/mysql-connector-java.jar
Using python /usr/bin/python2
Setup ambari-server
Copying /usr/share/java/mysql-connector-java.jar to /var/lib/ambari-server/resources
JDBC driver was successfully initialized.
Ambari Server ‘setup‘ completed successfully.

2、Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table ‘ambari.metainfo‘ doesn‘t exist
解决:
[[email protected] ambari-server]# mysql -uroot -psalt

MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| ambari |
| hive |
| mysql |
| performance_schema |
| salt |
+--------------------+
6 rows in set (0.00 sec)

MariaDB [(none)]> use ambari;
Database changed
MariaDB [ambari]> show tables;
Empty set (0.00 sec)

MariaDB [ambari]> source /var/lib/ambari-server/resources/Ambari-DDL-MySQL-CREATE.sql

以上是关于ambari的主要内容,如果未能解决你的问题,请参考以下文章

Ambari源代码分析之Resource.Type与ResourceProvider相应关系

Ambari源代码分析之Resource.Type与PropertyProvider相应关系

Ambari ambari安装

ambari 搭建hadoop大数据平台系列4-配置ambari-server

原创大数据基础之Ambari通过Ambari部署Airflow

自定义 Ambari 服务的 Ambari 用户和组管理