---
title: "centos6下安装ambari 1.7.0"
author: "highill"
date: "2015-04-12T17:56:21Z"
tags: []
categories: ["开源软件"]
slug: "centos6-ambari-1-7-0"
draft: false
lastmod: "2015-04-12T19:06:01Z"
id: 2201688
url: "https://highill.iteye.com/blog/2201688"
---

apache ambari是一款大数据管理平台, 可以管理hadoop, hive, hbase, storm等hadoop相关软件.

编译安装有点麻烦, 使用yum安装1.7.0, 貌似2.0.0暂时不在yum支持范围内, 官网没有提供yum公网地址.
记录一下使用yum安装ambari过程, 把踩过的坑记一下.

官网教程 
<https://cwiki.apache.org/confluence/display/AMBARI/Install+Ambari+1.7.0+from+Public+Repositories>

**
1. 添加新的yum repo
**

```shell

# cd /etc/yum.repos.d/
# wget http://public-repo-1.hortonworks.com/ambari/centos6/1.x/updates/1.7.0/ambari.repo

```


如果重命名ambari.repo的话

```shell

# mv ambari.repo ambari_1.7.repo

```

会导致错误

```error

Command start time 2015-04-12 14:35:43
/etc/yum.repos.d/ambari.repo: No such file or directory
scp /etc/yum.repos.d/ambari.repo
host=192.168.1.152, exitcode=1
Command end time 2015-04-12 14:35:43

```



**
2. 安装ambari-server
最好先关闭防火墙.
**

```shell

# yum -y install ambari-server
Dependency Installed:
  postgresql.x86_64 0:8.4.20-2.el6_6
  postgresql-libs.x86_64 0:8.4.20-2.el6_6
  postgresql-server.x86_64 0:8.4.20-2.el6_6


```



**
3. 设置ambari
**


```shell

# ambari-server setup
REASON: Before starting Ambari Server, you must copy the MySQL JDBC driver JAR file to /usr/share/java.

```

如果使用mysql, 需要拷贝mysql-jdbc驱动到 /usr/share/java.
/var/lib/ambari-server/resources/mysql-connector-java-commercial-5.1.25-bin.jar 就有一个合适的.

这里面坑最多.如果使用mysql需要先准备数据库,用户名,密码.此外, sql有的表字段很长,会导致创建表失败,启动ambari后找不到相关表,或者没数据.



```error

mysql脚本在/var/lib/ambari-server/resources/Ambari-DDL-MySQL-CREATE.sql
导入mysql会提示这个错误
MySQL ERROR: Specified key was too long; max key length is 1000bytes.

```


解决办法,全局使用InnoDB引擎

```mysql


# cd /var/lib/ambari-server/resources/
mysql> show engines;
# vim /etc/my.cnf
default-storage-engine=INNODB

# service mysqld restart

```

导入mysql数据

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

```


设置ambari-server使用oracle jdk 和mysql数据库

```shell

# ambari-server setup
REASON: Before starting Ambari Server, you must copy the MySQL JDBC driver JAR file to /usr/share/java.

```

按步骤操作就行了

**
4.启动ambari-server并安装软件
**


```shell

# ambari-server start

访问
http://192.168.1.152:8080/
用户名/密码 admin/admin

```


如果启动错误

```error

Using python  /usr/bin/python2.6
Starting ambari-server
Traceback (most recent call last):
  File "/usr/sbin/ambari-server.py", line 4766, in <module>    main()
  File "/usr/sbin/ambari-server.py", line 4561, in main    start(options)
  File "/usr/sbin/ambari-server.py", line 2513, in start     if not check_reverse_lookup():
  File "/usr/sbin/ambari-server.py", line 760, in check_reverse_lookup    host_ip = socket.gethostbyname(host_name) socket.gaierror: [errno -2] 

Name or service not known

```

 需要在hosts配置主机名和IP映射


```shell

# vim /etc/hosts
192.168.1.152 haier.p7450.centos


```


添加Cluster时,需要ssh免登录, 最好使用主机名,使用IP也不能成功安装.

SSH免登录依然报错

```error

ERROR: Bootstrap of host 192.168.1.152 fails because previous action finished with non-zero exit code (255)
ERROR MESSAGE: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).

STDOUT: 
Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).


```

选择 SSH生成的私钥解决此问题

安装组件使用mysql, 比如hive,oozie等需要设置

```shell

ambari-server setup --jdbc-db=mysql --jdbc-driver=/var/lib/ambari-server/resources/mysql-connector-java-commercial-5.1.25-bin.jar

```


一台电脑没办烦安装hadoop真实分布式环境, 就选择安装zookeeper和kafka, 可以正常安装, 启动. 剩下的慢慢整理.