本文最后更新于 207 天前,其中的信息可能已经有所发展或是发生改变。

前期准备

1. 安装包准备

Ambari2.7.5. HDP3.1.5. libtirpc-devel:
链接:https://pan.baidu.com/s/1eteZ2jGkSq4Pz5YFfHyJgQ
提取码:6hq3

2.服务器配置

主机名cpu内存硬盘系统版本ip地址
node0014c10g50gisoft-serveros-4.2192.168.150.106
node0022c4g20gisoft-serveros-4.2192.168.150.107

3.修改系统版本文件(所有节点执行)

  1. sed -i 's/4/7/g' /etc/redhat-release
  2. sed -i 's/4/7/g' /etc/os-release

4.配置主机名(所有节点执行)

2台服务器的hosts都需要做如下修改

  • 修改主机名
  1. hostnamectl set-hostname node001
  2. bash
  • 修改hosts文件
  1. vim /etc/hosts
  2. 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
  3. ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
  4. 192.168.150.106 node001
  5. 192.168.150.107 node002

5.关闭防火墙及selinux(所有节点执行)

2台服务器上分别执行以下操作,关闭防火墙并配置开机不自动启动

  1. systemctl stop firewalld
  2. systemctl disable firewalld
  3. setenforce 0

为了重启后依然关闭,配置如下文件

  1. vim /etc/sysconfig/selinux
  2. 修改
  3. SELINUX=disabled

6.配置ssh互信(所有节点执行)

方法一

在每台服务器上执行如下操作,一直回车即可

  1. ssh-keygen -t rsa
  2. ssh-copy-id -i /root/.ssh/id_rsa.pub node001
  3. ssh-copy-id -i /root/.ssh/id_rsa.pub node002

方法二

在每台服务器上执行如下操作,一直回车即可

ssh-keygen -t rsa

在服务器1上将公钥(名为id_rsa.pub文件)追加到认证文件(名为authorized_keys文件)中:

cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys

去其他服务器节点将~/.ssh/id_rsa.pub中的内容拷贝到服务器1的~/.ssh/authorized_keys中,查看文件中的内容

  1. cat ~/.ssh/authorized_keys
  2. ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC/eA09X4s5RIYvuYNxVvtOo6unY1mgipsFyoz/hy/Gwk0onfZvBi/Sl3TVRZO5aqcHccAGlLF7OPTKH1qUuKVtnUOQik0TouL5VKsOBDMHHRT9D5UwqaIE8tYDC8V6uwieFgscZcBjhrsJ/Iramo9ce7N9RTO3otRMRQxOs+Wd1F/ZOmpRtMGU2N4RH4i2quRU6m2lt/eJKpNupSHKoztTQRsEanilHVASnikAXH8JpG70iO7RXR/hLz+/Of3ISUrOMSO4/ZIIu4xnYN3jvsXOdK/qIhP/PI2s+uF22IvVE6xZYVadQFa4zAuhQmCBWkE7vMyI1UJkxP7OQYj72LUH root@node001
  3. ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCnz8wHoytR2Xlnl04rQq4I2vgUVWbkKjv30pj+Toz4719ah4cY9pvZj0JsfhVzaaCsR14BLFVLkqKUhCWK3K6muT4iHb+N0WirpbwfJkztmQeco7Ha9xrPQ8v/I4xZujFoMVA0tkb/32zRTxOkPv9AUgB8V6Lin6LnB/AcnhnmoIs5PdbAdh/kBGpQGKIZkbyCUOYz9/PZuGJoJBblqfWiqzxYYLN9+cYMkmPnB1HdDewAepIsIC18U3ujE+1Su2UlmISPvvr1zG4XR4ZZoKQsOOJq3XRMGVkDvmFhl03JHZpd6BW0796CeYVZ41UomWXTOduQql+tYWUbegzGLmRZ root@node002
  4. ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC8AFoGJHp2M45xLYNzXUHLWzRwHsgRPHjeErStq0tEy9bQv4OkN41j0FrxVAYJiGHdHGturriVgUEtL59RjcrJH6bAvhP54nM5YiQlNnWnSUR27Zuaodz4nhYUFq/Co5eDN6lTfL8pgYiEdpBOvE5t1w3bisdblP7YGQ2lF1zzCEGfQ79QbntEbyGNoR9sGHm11x9fOH+fape8TjQJrEAO4d1tAhMqVygQKwqwAPKeqhEum6BaLli83TsXzd7gyz9H7AAc1m04NaLB26xfynW6MVuk1j94awXKlGXjrbNTC/Kg6M8bd5PT/k3DOkx4b+nEs8xZ5x1j4D2OaO1X6rZx root@node003

设置认证文件的权限:

chmod 600 ~/.ssh/authorized_keys

~/.ssh/authorized_keys同步到其他节点

scp ~/.ssh/authorized_keys node002:~/.ssh/authorized_keys
  • 注意:这里第一次使用同步还需要密码,之后就不需要了

验证免密是否配置成功

ssh到不同服务器

ssh node002

7. 配置ntp时钟同步

选择一台服务器作为NTP Server,这里选择node001

将如下配置vim /etc/ntp.conf

  1. # Use public servers from the pool.ntp.org project.
  2. # Please consider joining the pool (http://www.pool.ntp.org/join.html).
  3. server 0.centos.pool.ntp.org iburst
  4. server 1.centos.pool.ntp.org iburst
  5. server 2.centos.pool.ntp.org iburst
  6. server 3.centos.pool.ntp.org iburst

修改为

  1. # Use public servers from the pool.ntp.org project.
  2. # Please consider joining the pool (http://www.pool.ntp.org/join.html).
  3. #server 0.centos.pool.ntp.org iburst
  4. #server 1.centos.pool.ntp.org iburst
  5. #server 2.centos.pool.ntp.org iburst
  6. #server 3.centos.pool.ntp.org iburst
  7. server 127.127.1.0
  8. fudge 127.127.1.0 stratum 10

node002节点做如下配置

vim /etc/ntp.conf

  1. # Use public servers from the pool.ntp.org project.
  2. # Please consider joining the pool (http://www.pool.ntp.org/join.html).
  3. server 0.centos.pool.ntp.org iburst
  4. server 1.centos.pool.ntp.org iburst
  5. server 2.centos.pool.ntp.org iburst
  6. server 3.centos.pool.ntp.org iburst

修改为

  1. # Use public servers from the pool.ntp.org project.
  2. # Please consider joining the pool (http://www.pool.ntp.org/join.html).
  3. #server 0.centos.pool.ntp.org iburst
  4. #server 1.centos.pool.ntp.org iburst
  5. #server 2.centos.pool.ntp.org iburst
  6. #server 3.centos.pool.ntp.org iburst
  7. server 192.168.150.106

在每台服务器上启动ntpd服务,并配置服务开机自启动

  1. systemctl restart ntpd
  2. systemctl enable ntpd

9.设置swap(所有节点执行)

  1. echo vm.swappiness = 1 >> /etc/sysctl.conf
  2. sysctl vm.swappiness=1
  3. sysctl -p

10. 关闭透明大页面(所有节点执行)

由于透明超大页面已知会导致意外的节点重新启动并导致RAC出现性能问题,因此Oracle强烈建议禁用

  1. echo never > /sys/kernel/mm/transparent_hugepage/defrag
  2. echo never > /sys/kernel/mm/transparent_hugepage/enabled

11.安装http服务(node001节点执行)

安装apache的httpd服务主要用于搭建OS. Ambari和hdp的yum源。在集群服务器中选择一台服务器来安装httpd服务,命令如下:

  1. yum -y install httpd
  2. systemctl start httpd
  3. systemctl enable httpd.service

验证,在浏览器输入http://192.168.150.106看到如下截图则说明启动成功。

image-20211123141149628

13.安装Java(所有节点执行)

下载地址:https://www.oracle.com/java/technologies/javase/javase-jdk8-downloads.html

  1. tar -zxvf jdk-8u271-linux-x64.tar.gz
  2. mkdir /usr/local/java
  3. mv jdk1.8.0_271/* /usr/local/java

配置环境变量

vim /root/.bashrc

添加如下配置

  1. export JAVA_HOME=/usr/local/java
  2. export PATH=$PATH:$JAVA_HOME/bin
  3. export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
  4. export JRE_HOME=$JAVA_HOME/jre

激活配置

  1. source /root/.bashrc
  2. java -version

14. 安装maven3.6(node001节点执行)

下载解压

  1. tar -zxvf apache-maven-3.6.3-bin.tar.gz
  2. mkdir -p /opt/src/maven
  3. mv apache-maven-3.6.3/* /opt/src/maven

配置maven环境变量

  1. vim /root/.bashrc
  2. # set maven home
  3. export PATH=$PATH:/opt/src/maven/bin

激活

source /root/.bashrc

安装Ambari&HDP

1. 配置Ambari. HDP. libtirpc-devel本地源

解压

  1. tar -zxvf ambari-2.7.5.0-centos7.tar.gz -C /var/www/html/
  2. tar -zxvf HDP-3.1.5.0-centos7-rpm.tar.gz -C /var/www/html/
  3. tar -zxvf HDP-GPL-3.1.5.0-centos7-gpl.tar.gz -C /var/www/html/
  4. tar -zxvf HDP-UTILS-1.1.0.22-centos7.tar.gz -C /var/www/html/
  5. ll /var/www/html/
  6. 总用量 0
  7. drwxr-xr-x. 3 root root 21 11月 23 22:31 ambari
  8. drwxr-xr-x. 3 1001 users 21 12月 18 2019 HDP
  9. drwxr-xr-x. 3 1001 users 21 12月 18 2019 HDP-GPL
  10. drwxr-xr-x. 3 1001 users 21 8月 13 2018 HDP-UTILS

设置设置用户组和授权

  1. chown -R root:root /var/www/html/HDP
  2. chown -R root:root /var/www/html/HDP-GPL
  3. chown -R root:root /var/www/html/HDP-UTILS
  4. chmod -R 755 /var/www/html/HDP
  5. chmod -R 755 /var/www/html/HDP-GPL
  6. chmod -R 755 /var/www/html/HDP-UTILS

创建libtirpc-devel本地源

  1. mkdir /var/www/html/libtirpc
  2. mv /root/libtirpc-* /var/www/html/libtirpc/
  3. cd /var/www/html/libtirpc
  4. createrepo .

制作本地源

配置ambari.repo

  1. vim /etc/yum.repos.d/ambari.repo
  2. [Ambari-2.7.5.0]
  3. name=Ambari-2.7.5.0
  4. baseurl=http://192.168.150.106/ambari/centos7/2.7.5.0-72/
  5. gpgcheck=0
  6. enabled=1
  7. priority=1

配置HDP和HDP-TILS

  1. vim /etc/yum.repos.d/HDP.repo
  2. [HDP-3.1.5.0]
  3. name=HDP Version - HDP-3.1.5.0
  4. baseurl=http://192.168.150.106/HDP/centos7/3.1.5.0-152/
  5. gpgcheck=0
  6. enabled=1
  7. priority=1
  8. [HDP-UTILS-1.1.0.22]
  9. name=HDP-UTILS Version - HDP-UTILS-1.1.0.22
  10. baseurl=http://192.168.150.106/HDP-UTILS/centos7/1.1.0.22/
  11. gpgcheck=0
  12. enabled=1
  13. priority=1
  14. [HDP-GPL-3.1.5.0]
  15. name=HDP-GPL Version - HDP-GPL-3.1.5.0
  16. baseurl=http://192.168.150.106/HDP-GPL/centos7/3.1.5.0-152
  17. gpgcheck=0
  18. enabled=1
  19. priority=1

配置libtirpc.repo

  1. vim /etc/yum.repos.d/libtirpc.repo
  2. [libtirpc_repo]
  3. name=libtirpc-0.2.4-0.16
  4. baseurl=http://192.168.150.106/libtirpc/
  5. gpgcheck=0
  6. enabled=1
  7. priority=1

拷贝到其他节点

scp /etc/yum.repos.d/* node002:/etc/yum.repos.d/

查看源

  1. yum clean all
  2. yum repolist

2. 安装mariadb(node001节点执行)

安装MariaDB服务器

yum install mariadb-server -y

启动并设置开机启动

  1. systemctl enable mariadb
  2. systemctl start mariadb

初始化

  1. /usr/bin/mysql_secure_installation
  2. [...]
  3. Enter current password for root (enter for none):
  4. OK, successfully used password, moving on...
  5. [...]
  6. Set root password? [Y/n] Y
  7. New password:123456
  8. Re-enter new password:123456
  9. [...]
  10. Remove anonymous users? [Y/n] Y
  11. [...]
  12. Disallow root login remotely? [Y/n] N
  13. [...]
  14. Remove test database and access to it [Y/n] Y
  15. [...]
  16. Reload privilege tables now? [Y/n] Y
  17. [...]
  18. All done! If you've completed all of the above steps, your MariaDB 18 installation should now be secure.
  19. Thanks for using MariaDB!

为MariaDB安装MySQL JDBC驱动程序

  1. tar zxf mysql-connector-java-5.1.40.tar.gz
  2. mv mysql-connector-java-5.1.40/mysql-connector-java-5.1.40-bin.jar /usr/share/java/mysql-connector-java.jar

创建需要的数据库

如果需要ranger,编辑以下⽂件: vim /etc/my.cnf 并添加以下⾏:

log_bin_trust_function_creators = 1

重启数据库并登录

  1. systemctl restart mariadb
  2. mysql -u root -p123456

3. 安装和配置ambari-server(node001节点执行)

安装ambari-server

yum -y install ambari-server

复制mysql jdbc驱动到/var/lib/ambari-server/resources/

cp /usr/share/java/mysql-connector-java.jar /var/lib/ambari-server/resources/

配置/etc/ambari-server/conf/ambari.properties,添加如下行

  1. vim /etc/ambari-server/conf/ambari.properties
  2. server.jdbc.driver.path=/usr/share/java/mysql-connector-java.jar

执行

ambari-server setup --jdbc-db=mysql --jdbc-driver=/usr/share/java/mysql-connector-java.jar

初始化ambari-server

  1. ambari-server setup
  2. 1) 提示是否自定义设置。输入:y
  3. Customize user account for ambari-server daemon [y/n] (n)? y
  4. (2)ambari-server 账号。
  5. Enter user account for ambari-server daemon (root):
  6. 如果直接回车就是默认选择root用户
  7. 如果输入已经创建的用户就会显示:
  8. Enter user account for ambari-server daemon (root):ambari
  9. Adjusting ambari-server permissions and ownership...
  10. (3)设置JDK。输入:2
  11. Checking JDK...
  12. Do you want to change Oracle JDK [y/n] (n)? y
  13. [1] Oracle JDK 1.8 + Java Cryptography Extension (JCE) Policy Files 8
  14. [2] Custom JDK
  15. ==============================================================================
  16. Enter choice (1): 2
  17. 如果上面选择3自定义JDK,则需要设置JAVA_HOME。输入:/usr/local/java
  18. WARNING: JDK must be installed on all hosts and JAVA_HOME must be valid on all hosts.
  19. 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.
  20. Path to JAVA_HOME: /usr/local/java
  21. Validating JDK on Ambari Server...done.
  22. Completing setup...
  23. (4)安装GPL,选择:y
  24. Checking GPL software agreement...
  25. GPL License for LZO: https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html
  26. Enable Ambari Server to download and install GPL Licensed LZO packages [y/n] (n)? y
  27. (5)数据库配置。选择:y
  28. Configuring database...
  29. Enter advanced database configuration [y/n] (n)? y
  30. (6)选择数据库类型。输入:3
  31. Configuring database...
  32. ==============================================================================
  33. Choose one of the following options:
  34. [1] - PostgreSQL (Embedded)
  35. [2] - Oracle
  36. [3] - MySQL/ MariaDB
  37. [4] - PostgreSQL
  38. [5] - Microsoft SQL Server (Tech Preview)
  39. [6] - SQL Anywhere
  40. ==============================================================================
  41. Enter choice (3): 3
  42. (7)设置数据库的具体配置信息,根据实际情况输入,如果和括号内相同,则可以直接回车。如果想重命名,就输入。
  43. Hostname (localhost):node001
  44. Port (3306): 3306
  45. Database name (ambari): ambari
  46. Username (ambari): ambari
  47. Enter Database Password (bigdata):ambari123
  48. Re-Enter password: ambari123
  49. (8)将Ambari数据库脚本导入到数据库
  50. 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 这个sql后面会用到,导入数据库
  51. Proceed with configuring remote database connection properties [y/n] (y)? y

登录mariadb创建ambari安装所需要的库

设置的账号后面配置ambari-server的时候会用到

  1. mysql -uroot -p123456
  2. CREATE DATABASE ambari;
  3. use ambari;
  4. CREATE USER 'ambari'@'%' IDENTIFIED BY 'ambari123';
  5. GRANT ALL PRIVILEGES ON *.* TO 'ambari'@'%';
  6. CREATE USER 'ambari'@'localhost' IDENTIFIED BY 'ambari123';
  7. GRANT ALL PRIVILEGES ON *.* TO 'ambari'@'localhost';
  8. CREATE USER 'ambari'@'node001' IDENTIFIED BY 'ambari123';
  9. GRANT ALL PRIVILEGES ON *.* TO 'ambari'@'node001';
  10. source /var/lib/ambari-server/resources/Ambari-DDL-MySQL-CREATE.sql
  11. show tables;
  12. use mysql;
  13. select host,user from user where user='ambari';
  14. CREATE DATABASE hive;
  15. use hive;
  16. CREATE USER 'hive'@'%' IDENTIFIED BY 'hive';
  17. GRANT ALL PRIVILEGES ON *.* TO 'hive'@'%';
  18. CREATE USER 'hive'@'localhost' IDENTIFIED BY 'hive';
  19. GRANT ALL PRIVILEGES ON *.* TO 'hive'@'localhost';
  20. CREATE USER 'hive'@'node001' IDENTIFIED BY 'hive';
  21. GRANT ALL PRIVILEGES ON *.* TO 'hive'@'node001';
  22. CREATE DATABASE oozie;
  23. use oozie;
  24. CREATE USER 'oozie'@'%' IDENTIFIED BY 'oozie';
  25. GRANT ALL PRIVILEGES ON *.* TO 'oozie'@'%';
  26. CREATE USER 'oozie'@'localhost' IDENTIFIED BY 'oozie';
  27. GRANT ALL PRIVILEGES ON *.* TO 'oozie'@'localhost';
  28. CREATE USER 'oozie'@'node001' IDENTIFIED BY 'oozie';
  29. GRANT ALL PRIVILEGES ON *.* TO 'oozie'@'node001';
  30. FLUSH PRIVILEGES;

4. 安装ambari-agent(所有节点执行)

  1. pssh -h /node.list -i 'yum -y install ambari-agent'
  2. pssh -h /node.list -i 'systemctl start ambari-agent'

5. 安装libtirpc-devel(所有节点)

pssh -h /node.list -i 'yum -y install libtirpc-devel'

6. 启动ambari服务

ambari-server start

部署集群

1. 登录界面

http://192.168.150.106:8080

默认管理员账户登录, 账户:admin 密码:admin

image-20211123145726406

2. 选择版本,配置yum源

1)选择Launch Install Wizard
2)配置集群名称
3)选择版本并修改本地源地址

选HDP-3.1(Default Version Definition);
选Use Local Repository;
选redhat7:

HDP-3.1:http://node001/HDP/centos7/3.1.5.0-152/
HDP-3.1-GPL: http://node001/HDP-GPL/centos7/3.1.5.0-152/
HDP-UTILS-1.1.0.22: http://node001/HDP-UTILS/centos7/1.1.0.22/

image-20211123150120718

3. 配置节点和密钥

下载主节点的/root/.ssh/id_rsa,并上传!点击下一步,进入确认主机界面

也可直接cat /root/.ssh/id_rsa 粘贴即可

image-20211123150255012

验证通过

image-20211123150337730

4. 勾选需要安装的服务

由于资源有限,这里并没有选择所有服务

image-20211123151238695

5. 分配服务master

image-20211123151312856

6. 分配服务slaves

image-20211123151134172

设置相关服务的密码
Grafana Admin: 123456
Hive Database: hive
Activity Explorer’s Admin: admin

image-20211123151427030

7. 连接数据库

image-20211123151525068

8. 编辑配置,默认即可

image-20211123151547943

9. 开始部署

image-20211123151705941

10. 安装成功

右上角两个警告是磁盘使用率警告,虚机分配的磁盘较小

image-20211123163439475

其他问题(正常情况不需要修改)

1. 添加其他系统支持

HDP默认不支持安装到 isoft-serverosv4.2,需手动添加支持

vim /usr/lib/ambari-server/lib/ambari_commons/resources/os_family.json

添加如下两行,注意缩进和逗号

image-20211123145525458

2. YARN Registry DNS 服务启动失败

  1. lsof -i:53
  2. kill -9

3. 设置初始检测的系统版本

  1. vim /etc/ambari-server/conf/ambari.properties
  2. server.os_family=redhat7
  3. server.os_type=redhat7

参考

https://blog.csdn.net/qq_36048223/article/details/116113987