搭建HDP

image-20180901150744204

安装时间同步服务

1
2
3
4
5
6
7
8
9
# 首先安装阿里云 yum 源
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
yum makecache

# 安装时间同步服务器
yum install -y ntp
service ntpd start #开启服务
chkconfig ntpd on #配置开机启动

关闭 THP

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# 关闭 selinux
## 查看是否开启
sestatus
vi /etc/sysconfig/selinux
SELINUX=disabled


# 如果出现下述结果说明启动了 THP
$ cat /sys/kernel/mm/transparent_hugepage/enabled
[always] madvise never

$ cat /sys/kernel/mm/transparent_hugepage/defrag
[always] madvise never

# 永久关闭THP
$ vi /etc/rc.d/rc.local
#添加
if test -f /sys/kernel/mm/transparent_hugepage/enabled; then
echo never > /sys/kernel/mm/transparent_hugepage/enabled
fi
if test -f /sys/kernel/mm/transparent_hugepage/defrag; then
echo never > /sys/kernel/mm/transparent_hugepage/defrag
fi


#重启
reboot
# 再检查, 发现 never 上加了 []
$ cat /sys/kernel/mm/transparent_hugepage/enabled
always madvise [never]

$ cat /sys/kernel/mm/transparent_hugepage/defrag
always madvise [never]

克隆机器

1
2
# 克隆前删一个文件
$ rm /etc/udev/rules.d/70-persistent-net.rules

在 00 上安装 mysql

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
[root@nd-00 ~]# yum list mysql-server  ## 如果有一项
[root@nd-00 ~]# yum install -y mysql-server
[root@nd-00 ~]# service mysqld start ## 启动 mysql, 根据提示设置密码
[root@nd-00 ~]# /usr/bin/mysqladmin -u root password 'root123' ## 注意:一定不要把密码设置成纯数字,会有 bug
[root@nd-00 ~]# chkconfig mysqld on ##设置 mysql 开机启动
# 修改Mysql配置文件
[root@nd-00 ~]# vi /etc/my.cnf
------------------->>>括号内是添加的
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
{------------------------------|
# 设置数据库默认编码
collation_server=utf8_general_ci
character_set_server=utf8
# 设置默认存储引擎
default-storage-engine=INNODB
------------------------------|}

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

{------------------------------|
[client]
# 设置客户端默认编码集
default-character-set=utf8
-------------------------------|}

# 重启 mysql 服务
[root@nd-00 ~]# service mysqld restart
# 登录
[root@nd-00 ~]# mysql -uroot -proot123
# 查看字符集
mysql> show variables like 'character_set_%';
+--------------------------+----------------------------+
| Variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | utf8 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | utf8 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0.00 sec)

# 在数据库创建相应的用户和 DB

######创建 ambari数据库及数据库的用户名和密码
mysql> create database ambari character set utf8; #创建库
mysql> CREATE USER 'ambari'@'%'IDENTIFIED BY 'Ambari123'; #创建用户
mysql> GRANT ALL PRIVILEGES ON ambari.* TO 'ambari'@'%'; #授权
mysql> FLUSH PRIVILEGES; #刷新权限

######创建 hive数据库及数据库的用户名和密码
mysql> create database hive character set utf8; #创建库
mysql> CREATE USER 'hive'@'%'IDENTIFIED BY 'Hive123'; #创建用户
mysql> GRANT ALL PRIVILEGES ON hive.* TO 'hive'@'%'; #授权
mysql> FLUSH PRIVILEGES; #刷新权限

#######下载 mysql-connection-java
[root@nd-00 ~]# yum install -y mysql-connector-java
# 查看是否有mysql-connection-java
[root@nd-00 ~]# ls /usr/share/java

配置免密登录

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# 所有机器都安装一个openssh 工具
$ yum install -y openssh-clients

[[[nd-00.hdp -> 00.01.02.03.04]]]
--------------
[root@nd-00 ~]# ssh-keygen -t rsa #然后一路回车
[root@nd-00 ~]# ssh-copy-id nd-00.hdp
[root@nd-00 ~]# ssh-copy-id nd-01.hdp
[root@nd-00 ~]# ssh-copy-id nd-02.hdp
[root@nd-00 ~]# ssh-copy-id nd-03.hdp
[root@nd-00 ~]# ssh-copy-id nd-04.hdp


[[[nd-01.hdp -> 01.02.03.04]]]
---------------

在 yum.hdp 上安装 yum 相关工具

1
2
3
yum install yum-utils -y
yum repolist
yum install createrepo -y

2.5 安装 Apache httpd

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
### 1>安装 apache 的 httpd 服务
[root@yum html]# yum install httpd -y

安装完 httpd 后,会生成 /var/www/html 目录 (相当于 tomcat 的 webapp 目录).
进入到 /var/www/html 目录下, 创建 ambari 和 hdp 目录, 用来存放安装文件.

[root@yum ~]# cd /var/www/html/
[root@yum html]# ls
[root@yum html]# mkdir /var/www/html/ambari
[root@yum html]# mkdir /var/www/html/hdp
[root@yum html]# mkdir /var/www/html/hdp/HDP-UTILS-1.1.0.21
<sub></sub><sub></sub><sub></sub><sub></sub><sub></sub><sub></sub>
#上传ambari 和 hdp..
<sub></sub><sub></sub><sub></sub><sub></sub><sub></sub><sub></sub>
# 解压到对应目录
[root@yum ~]# tar -zxvf ambari-2.4.1.0-centos6.tar.gz -C /var/www/html/ambari/
[root@yum ~]# tar -zxvf HDP-2.5.0.0-centos6-rpm.tar.gz -C /var/www/html/hdp/
[root@yum ~]# tar -zxvf HDP-UTILS-1.1.0.21-centos6.tar.gz -C /var/www/html/hdp/HDP-UTILS-1.1.0.21/


### 2>启动 httpd 服务: service httpd start
httpd 默认的端口为80, 启动后再浏览器中输入: http://192.168.170.77

### 3>设置 httpd 开机自启
$> chkconfig httpd on

2.6 配置本地 Repo

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
1>. 配置 Ambari
====================================================================================
[root@yum hdp]# yum install -y wget
[root@yum hdp]# wget -O /etc/yum.repos.d/ambari.repo http://public-repo-1.hortonworks.com/ambari/centos6/2.x/updates/2.4.1.0/ambari.repo

# 把 repo 库修改为 yum.hdp 上的地址
[root@yum yum.repos.d]# vi ambari.repo.bak
-----
#VERSION_NUMBER=2.4.1.0-22
[Updates-ambari-2.4.1.0]
name=ambari-2.4.1.0 - Updates
baseurl=http://192.168.170.77/ambari/AMBARI-2.4.1.0/centos6/2.4.1.0-22/
gpgcheck=1
gpgkey=http://192.168.170.77/ambari/AMBARI-2.4.1.0/centos6/2.4.1.0-22/RPM-GPG-KEY/RPM-GPG-KEY-Jenkins
enabled=1
priority=1

2>. 配置 HDP
====================================================================================
[root@yum yum.repos.d]# vi HDP.repo
------
#VERSION_NUMBER=2.5.0.0-1245
[HDP-2.5.0.0]
name=HDP VERSION - HDP-2.5.0.0
baseurl=http://192.168.170.77/hdp/HDP/centos6/
gpgcheck=1
gpgkey=http://192.168.170.77/hdp/HDP/centos6/RPM-GPG-KEY/RPM-GPG-KEY-Jenkins
enabled=1
priority=1

[HDP-UTILS-1.1.0.21]
name=HDP-UTILS VERSION - HDP-UTILS-1.1.0.21
baseurl=http://192.168.170.77/hdp/HDP-UTILS-1.1.0.21/
gpgcheck=1
gpgkey=http://192.168.170.77/hdp/HDP-UTILS-1.1.0.21/RPM-GPG-KEY/RPM-GPG-KEY-Jenkins
enabled=1
priority=1


3>. 分发 Ambari.repo & HDP.repo
====================================================================================
[root@yum yum.repos.d]# scp ambari.repo HDP.repo nd-00.hdp:$PWD
[root@nd-00 yum.repos.d]# scp ambari.repo HDP.repo nd-01.hdp:$PWD
[root@nd-00 yum.repos.d]# scp ambari.repo HDP.repo nd-02.hdp:$PWD
[root@nd-00 yum.repos.d]# scp ambari.repo HDP.repo nd-03.hdp:$PWD
[root@nd-00 yum.repos.d]# scp ambari.repo HDP.repo nd-04.hdp:$PWD



4>. 生成本地源
====================================================================================
使用 createrepo 命令, 生成本地源
(createrepo 用以创建 yum 源(软件仓库), 即为存放于本地特定位置的众多 rpm 包建立索引,描述各个包所需依赖信息, 并形成元数据)

[root@yum yum.repos.d]# createrepo /var/www/html/hdp/HDP/centos6/
[root@yum yum.repos.d]# createrepo /var/www/html/hdp/HDP-UTILS-1.1.0.21/

3. 安装 Ambari-Server

3.1. nd-00.hdp 节点安装

1
2
3
4
$> yum install ambari-server			
$> ambari-server setup # 设置初始化参数

​````````````````````````````````````````````````````````````

[root@nd-00 yum.repos.d]# ambari-server setup
Using python /usr/bin/python
Setup ambari-server
Checking SELinux…
SELinux status is ‘disabled’
Customize user account for ambari-server daemon [y/n] (n)? y
Enter user account for ambari-server daemon (root):root
Adjusting ambari-server permissions and ownership…
Checking firewall status…
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 (1): 3
WARNING: JDK must be installed on all hosts and JAVA_HOME must be valid on all hosts.
WARNING: JCE Policy files are required for configuring Kerberos security. If you plan to use Kerberos,please make sure JCE Unlimited Strength Jurisdiction Policy Files are valid on all hosts.
Path to JAVA_HOME: /usr/java/jdk1.8.0_181/
Validating JDK on Ambari Server…done.
Completing setup…
Configuring database…
Enter advanced database configuration [y/n] (n)? YHyHHH^H
input not recognized, please try again:
Enter advanced database configuration [y/n] (n)? y

Configuring database…

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 (1): 3
Hostname (localhost): nd-00
Port (3306):
Database name (ambari):
Username (ambari):
Enter Database Password (bigdata):
Re-enter password:
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
Proceed with configuring remote database connection properties [y/n] (y)? y
Extracting system views…
…..ambari-admin-2.4.1.0.22.jar
……
Adjusting ambari-server permissions and ownership…
Ambari Server ‘setup’ completed successfully.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20


# 记得要执行这个脚本: /var/lib/ambari-server/resources/Ambari-DDL-MySQL-CREATE.sql

## 首先允许远程登录mysql
mysql> mysql -uroot -proot123
mysql> GRANT ALL PRIVILEGES ON ambari.* TO 'ambari'@'localhost' IDENTIFIED BY 'Ambari123';
mysql> GRANT ALL PRIVILEGES ON ambari.* TO 'ambari'@'%' IDENTIFIED BY 'Ambari123';
mysql> FLUSH PRIVILEGES; #刷新权限

## 使用 ambari 用户登录 mysql
[root@nd-00 yum.repos.d]# mysql -u ambari -hnd-00 -pAmbari123
mysql> use ambari
mysql> source /var/lib/ambari-server/resources/Ambari-DDL-MySQL-CREATE.sql
mysql> exit

## 重启 mysql
[root@nd-00 yum.repos.d]# service mysqld restart


启动ambari-server

$ ambari-server start

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19



#### 3.2 安装 Agent

**nd-00~04.hdp 所有节点安装 ambari-agent**

```bash
[all]# yum install -y ambari-agent #安装
[all]# service ambari-agent start #启动


# 安装后可以直接访问:
http://192.168.170.100:8080
username:admin
password:admin

# nd0-4 开启 ntpd 服务
service ntpd start

3.3 登录 ambari-server 之后的相关设置

image-20180902135132283

image-20180902135328906

image-20180902140728441

3.5 超级大 bug: ssl 问题

1
2
3
4
5
6
7
('WARNING 2018-09-02 04:17:52,413 NetUtil.py:116 - Server at https://nd-00:8440 is not reachable, sleeping for 10 seconds...

ERROR 2018-09-02 04:17:53,793 NetUtil.py:88 - [Errno 8] _ssl.c:492: EOF occurred in violation of protocol
ERROR 2018-09-02 04:17:53,794 NetUtil.py:89 - SSLError: Failed to connect. Please check openssl library versions.
Refer to: https://bugzilla.redhat.com/show_bug.cgi?id=1022468 for more details.
WARNING 2018-09-02 04:17:53,794 NetUtil.py:116 - Server at https://nd-00:8440 is not reachable, sleeping for 10 seconds...
', None)

参考: https://my.oschina.net/haha256/blog/1836261 (感谢 浪费了一下午…..)

解决办法: 将服务器中, jdk 的安全机制改了

vim /usr/java/jdk1.8.0_171-amd64/jre/lib/security/java.security

image-20180902201242973

去掉3DES_EDE_CBC。重启ambari。

其它要注意的:

  • JAVA_HOME的 path 要写在最前面
  • 所有 agent 开启 ntpd 服务
  • 所有主机升级 ssl 为最新的: yum -y update openssl
  • 貌似开启了server> ambari-server start, 就会自动开启各个节点的 agent

总结搜索问题的思路:

  • 可以直接搜索报出来的错
  • 搜索关键词, 比如本错搜索如下2个关键词, google 第一页就可以找到解决办法!!!!
    • amabri openssl

安装备注

1
2
3
4
5
6
7
8
nd-00.hdp
nd-01.hdp
nd-02.hdp
nd-03.hdp
nd-04.hdp

http://yum/hdp/HDP/centos6/
http://yum/hdp/HDP-UTILS-1.1.0.21/

image-20180903113532918

image-20180903113954359

image-20180903114010177

解决这些问题

1
[root@nd-00 ~]# ambari-server setup --jdbc-db=mysql --jdbc-driver=/usr/share/java/mysql-connector-java.jar

image-20180903115035724

image-20180903115849862

image-20180903120025912

image-20180903120230116

Review

Admin Name : admin

Cluster Name : mycluster

Total Hosts : 5 (5 new)

Repositories:

Services:

  • HDFS
    • DataNode : 4 hosts
    • NameNode : nd-00.hdp
    • NFSGateway : 0 host
    • SNameNode : nd-01.hdp
  • YARN + MapReduce2
    • App Timeline Server : nd-01.hdp
    • NodeManager : 4 hosts
    • ResourceManager : nd-01.hdp
  • Tez
    • Clients : 3 hosts
  • Hive
    • Metastore : nd-01.hdp
    • HiveServer2 : nd-01.hdp
    • WebHCat Server : nd-01.hdp
    • Database : Existing MySQL / MariaDB Database
  • HBase
    • Master : nd-00.hdp
    • RegionServer : 4 hosts
    • Phoenix Query Server : 0 host
  • Pig
    • Clients : 3 hosts
  • ZooKeeper
    • Server : 3 hosts
  • Flume
    • Flume : 4 hosts
  • Ambari Infra
    • Infra Solr Instance : nd-00.hdp
  • Ambari Metrics
    • Metrics Collector : nd-02.hdp
    • Grafana : nd-00.hdp
  • Kafka
    • Broker : nd-00.hdp
  • SmartSense
    • Activity Analyzer : nd-00.hdp
    • Activity Explorer : nd-00.hdp
    • HST Server : nd-00.hdp
  • Spark
    • Livy Server : 0 host
    • History Server : nd-00.hdp
    • Thrift Server : 0 host
  • Slider
    • Clients : 3 hosts

image-20180903120705901

如果帮到你, 可以给我赞助杯咖啡☕️
0%