Ambari2.6(HDP2.6.5)安装记要

本文介绍在 CentOS 7 环境下使用 Ambari2.5 (HDP2.6) 搭建大数据环境。

推荐使用如下脚本将 Ambari/HDP 相关软件包下到本地后配置 yum 源安装,在线安装速度太慢会经常遇到包找不到情况。

1
2
3
4
5
6
7
8
9
10
11
nohup wget -c http://public-repo-1.hortonworks.com/ambari/centos7/2.x/updates/2.6.2.2/ambari.repo \
https://public-repo-1.hortonworks.com/ambari/centos7/2.x/updates/2.6.2.2/ambari-2.6.2.2-centos7.tar.gz.md5 \
http://public-repo-1.hortonworks.com/ambari/centos7/2.x/updates/2.6.2.2/ambari-2.6.2.2-centos7.tar.gz \
http://public-repo-1.hortonworks.com/HDP/centos7/2.x/updates/2.6.5.0/HDP-2.6.5.0-292.xml \
http://public-repo-1.hortonworks.com/HDP/centos7/2.x/updates/2.6.5.0/hdp.repo \
http://public-repo-1.hortonworks.com/HDP/centos7/2.x/updates/2.6.5.0/HDP-2.6.5.0-centos7-rpm.tar.gz \
https://public-repo-1.hortonworks.com/HDP/centos7/2.x/updates/2.6.5.0/HDP-2.6.5.0-centos7-rpm.tar.gz.md5 \
http://public-repo-1.hortonworks.com/HDP-UTILS-1.1.0.22/repos/centos7/HDP-UTILS-1.1.0.22-centos7.tar.gz \
https://public-repo-1.hortonworks.com/HDP-UTILS-1.1.0.22/repos/centos7/HDP-UTILS-1.1.0.22-centos7.tar.gz.md5 \
http://public-repo-1.hortonworks.com/HDP-GPL/centos7/2.x/updates/2.6.5.0/hdp.gpl.repo \
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 &

CentOS 准备

安装CentOS 7

  • 安装时设置静态IP
  • 关闭Kdump
  • 关闭Selinux
  • 使用基础服务进行安装

安装相关软件包

挂载系统镜像

1
2
mkdir /media/CentOS
mount /dev/sr0 /media/CentOS

编辑 /etc/yum.repos.d/CentOS-Media.repo 启用本地存储库,修改 enabled1

1
2

yum install vim ntp yum-utils createrepo yum-plugin-priorities scp curl unzip tar wget

安装前设置

调整系统资源限制

编辑 /etc/systemd/system.conf/etc/systemd/user.conf 文件,修改如下:

1
DefaultLimitNOFILE=65536

设置 NTP

1
2
3
yum install -y ntp
systemctl enable ntpd
systemctl start ntpd

关闭系统防火墙

1
2
systemctl disable firewalld
service firewalld stop

SELinux、PackageKit、umask

编辑 /etc/sysconfig/selinux ,设置SELINUX=disabled

1
echo umask 0022 >> /etc/profile

编辑 /etc/yum/pluginconf.d/refresh-packagekit.conf

1
enabled=0

设置网络(DNS和NSCD)

所有节点都要设置。ambari在安装时需要配置全域名,所以需要检查DNS。为了减轻DNS的负担, 建议在节点里用 Name Service Caching Daemon (NSCD)

1
hostnamectl set-hostname ambari001

vim /etc/hosts

1
2
3
192.168.124.151   ambari001
192.168.124.152 ambari002
192.168.124.153 ambari003

vim /etc/sysconfig/network

1
2
NETWORKING=yes
HOSTNAME=ambari001

设置静态IP地址

编辑文件:/etc/sysconfig/network-scripts/ifcfg-eth0

1
2
3
4
5
6
7
8
9
10
TYPE="Ethernet"
ONBOOT="yes"
DEVICE="eth0"
BOOTPROTO="static"
IPADDR=192.168.124.151
NETMASK=255.255.255.0
GATEWAY=192.168.124.1
DNS1=61.128.128.68
NM_CONTROLLED=no
UUID="006cd5ef-034f-41aa-803c-5891c2241774"

关闭 python 的https verify

在需要安装Ambari的所有节点编辑文件:/etc/python/cert-verification.cfg

1
2
[https]
verify=disable

若修改后还遇到问题,编辑/etc/ambari-agent/conf/ambari-agent.ini文件,设置如下值(添加或修改,其它不变)

1
2
3
[security]

force_https_protocol=PROTOCOL_TLSv1_2

然后重启 ambari-agentambari-agent restart

SSH免密码登录

使用root账号登录 Ambari Server 主机并生成SSH私钥:

1
ssh-keygen

添加`authorized_keys文件:

1
2
cd ~/.ssh
cat id_rsa.pub >> authorized_keys

修改 ~/.ssh 目录 和 ~/.ssh/authorized_keys 文件系统权限(注意:~/.ssh/authorized_keys文件权限必需为600,不然免密码登录将失效):

1
2
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys

authorized_keys 文件其复制到所有 Ambari Agent 主机(注意:有可能需要在Agent主机上创建 .ssh 目录)

1
scp ~/.ssh/authorized_keys root@<remote.target.host>:~/.ssh/

(请将 <remote.target.host> 替换为集群中每台 Ambari Agent 主机地址)

验证每台主机免密码登录是否成功

1
ssh root@<remote.target.host>

本地 ambari/hdp yum源设置(可选)

ambari.repo 文件入到 /etc/yum.repo.d/ 目录,并将 hdp.repos 地址替换成你实际的本地 yum 服务地址。

我们可以使用 Nginx 来搭建 yum 服务,只需要注意相映路径即可。

Nginx配置HDP YUM源

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
server {
listen 80;
server_name public-repo-1.hortonworks.com hdp.repos;

client_max_body_size 250m;

proxy_read_timeout 3600;
#proxy_connect_timeout 300;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

root /opt/Downloads/HDP/repos;

location / {
autoindex on;
}

}

ambari.repo

1
2
3
4
5
6
7
8
#VERSION_NUMBER=2.6.2.2-1
[ambari-2.6.2.2]
name=ambari Version - ambari-2.6.2.2
baseurl=http://hdp.repos/ambari/centos7/2.x/updates/2.6.2.2
gpgcheck=1
gpgkey=http://hdp.repos/ambari/centos7/2.x/updates/2.6.2.2/RPM-GPG-KEY/RPM-GPG-KEY-Jenkins
enabled=1
priority=1

安装独立PostgreSQL数据库(可选)

1
2
rpm -ivh https://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-7-x86_64/pgdg-centos96-9.6-3.noarch.rpm
sudo yum -y install postgresql96-server postgresql96-contrib

选择:Enter advanced database configuration ,并选择 [4] - PostgreSQL

创建ambari用户和数据库

创建用户和数据库psql -h localhost -U postgres -d postgres

1
2
3
4
create user ambari encrypted password 'bigdata';
create database ambari owner=ambari template=template1;
create database hive owner=ambari template=template1;
create database oozie owner=ambari template=template1;

设置默认schema,使用ambari用户登录到ambari数据库,psql -h localhost -U ambari -d ambari -W

1
set search_path to "$user",ambari;

初始化表

-h localhost -U ambari -d ambari -flink
1
2
3
4
5
6
7
8
9

## 安装/设置 **ambari-server**

*为了一些不必要的麻烦,推荐关闭 selinux*

**Install**

```sh
yum install ambari-server

配置 ambari-server

1
ambari-server setup --java-home=/usr/local/java --jdbc-db=postgres --jdbc-driver=/usr/share/java/postgresql-jdbc.jar --enable-lzo-under-gpl-license --database=postgres --databasehost=hdp2001 --databaseport=5432 --databasename=ambari --postgresschema=ambari --databaseusername=ambari --databasepassword=bigdata

使用 -j 选项指定 JAVA_HOME 目录,这里推荐使用 Oracle JDK 1.8,并配置 Java Cryptography Extension (JCE) 。若不指定 -j 选项,ambari-server 将自动下载配置了JCE的Oracle JDK 1.8版本。

一切使用默认配置即可,当看到以下输出就代表 Ambari Server 配置成功:

1
2
3
...........
Adjusting ambari-server permissions and ownership...
Ambari Server 'setup' completed successfully.

安装/配置/部署集群

启动Ambari-server

1
ambari-server start

打开浏览器登录网址:[http://ambari001:8080](http://ambari001:8080)(请使用你自己安装的 Ambari Server地址)。

使用默认用户名/密码 admin/admin 登录,之后你可以修改它。

登录后首先创建我们的第一个大数据集群,点击 Launch Install Wizard 按钮创建集群。

创建集群

首先我们将需要给集群取一个名字,接下来将选择 HDP 的版本,这里我们选择 2.6 版本。

我们将使用本地源来安装 HDP ,按图设置本地源地址:

  • HDP-2.6: http://hdp.repos/HDP/centos7/2.x/updates/2.6.5.0
  • HDP-UTILS-1.1.0.22: http://hdp.repos/HDP-UTILS-1.1.0.22/repos/centos7
  • HDP-GPL: http://hdp.repos/HDP-GPL/centos7/2.x/updates/2.6.5.0

选择版本并配置HDP

分享到