+VMware从头完全部署

1.环境及软件准备

Virtual Machine Software

VMware 17

OS

Windows 11

VM OS

CentOS 7.9

Ambari

2.7.4.0

HDP

3.1.4.0

HDP-UTILS

1.1.0.22

Java

JDK8

SQL

Mysql 5.7

你可以在这里查询软件之间的版本支持度

Ambari、HDP、HDP-UTILS安装包下载链接如下

提取码:3rwq

用VMware直接创建一个虚拟机,centos79的。

2.准备工作

2.1关闭防火墙

sudo systemctl status firewalld # 通过此命令查看防火墙状态
sudo systemctl stop firewalld # 关闭防火墙
sudo systemctl disable firewalld # 关闭防火墙开机自启

2.2安装JDK

sudo yum install java-1.8.0-openjdk.x86_64 java-1.8.0-openjdk-devel.x86_64 java-1.8.0-openjdk-headless.x86_64

readlink -f /usr/bin/java #查看java安装位置

sudo vim /etc/profile
export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.372.b07-1.el7_9.x86_64
export PATH=$PATH:$JAVA_HOME/bin

2.3关闭SELinux

# 临时性关闭(立即生效,但是重启服务器后失效)
setenforce 0 #设置selinux为permissive模式(即关闭)
setenforce 1 #设置selinux为enforcing模式(即开启)
# 永久性关闭(这样需要重启服务器后生效)
sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config

然后reboot重启,sestatus查看SELinux状态

2.4安装额外软件包

  • sshpass:用明文方式自动输入ssh密码,快速免密脚本需要。

  • pssh:同时对多个机器使用shh执行命令,方便管理后续集群。

2.5克隆额外从节点服务器

使用VMware克隆功能,选择完全克隆。

2.6安装MySQL(主节点)

sudo yum install -y https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm #添加mysql到yum的安装列表中
sudo rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022 #添加对mysql安装的密钥
sudo yum install -y mysql-community-server #安装mysql-server
sudo systemctl start mysqld
sudo systemctl enable mysqld

重置初始密码和免输密码登录

MySQL

修改/etc/my.cnf添加以下配置

[mysqld]
port=3306
bind-address=0.0.0.0
systemctl restart mysqld #开启服务
netstat -nltp | grep 3306 # 查看mysql默认的3306端口号是否存在
systemctl enable mysqld # 将mysql服务加入到开机自启

2.7配置域名映射(主节点)

同时开启三台虚拟机,输入ifconfig查看各个的ip地址

vim /etc/hosts写入映射规则,根据ip追加以下内容

192.168.137.132 hdp1
192.168.137.133 hdp2
192.168.137.134 hdp3

使用脚本[0]将hosts文件传到所有其它主机

脚本

2.8配置免密

用脚本[1]快速配置所以主机互相免密

脚本

2.9时间同步

2.9.1主服务器时间配置(主节点)

选一台服务器作时间服务器,这里以hdp1作为时间服务器,其他服务器以时间服务器时间为准

sudo yum install ntp
sudo vim /etc/ntp.conf

授权192.168.137.0-192.168.137.255网段上的所有机器可以从这台机器上查询和同步时间

#修改
#restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap
#为
restrict 192.168.137.0 mask 255.255.255.0 nomodify notrap #我这里使用的网段为137,具体网段根据服务器的ip而定

#注释
#server 0.centos.pool.ntp.org iburst
#server 1.centos.pool.ntp.org iburst
#server 2.centos.pool.ntp.org iburst
#server 3.centos.pool.ntp.org iburst
# 添加如下,使用阿里云服务器时间
server ntp1.aliyun.com iburst
server ntp2.aliyun.com iburst
server ntp3.aliyun.com iburst
server ntp4.aliyun.com iburst
server ntp5.aliyun.com iburst
server ntp6.aliyun.com iburst
server ntp7.aliyun.com iburst

#追加,当该节点丢失网络连接,依然可以采用本地时间作为时间服务器为集群中的其他节点提供时间同步
server 127.127.1.0
fudge 127.127.1.0 stratum 10
sudo systemctl start ntpd # 启动ntpd服务
sudo systemctl enable ntpd # 配置ntpd服务开机自启

2.9.2其它服务器时间配置(主节点)

创建一个host.txt文件,写入所有从节点

hdp1
hdp2
hdp3
hdp4
pssh -h host.txt -i yum install -y ntpdate #安装时间同步包
pssh -h host.txt ntpdate hdp0 #同步时间

创建tmp.txt文件,写入以下内容,表示每小时的第29分和59分同步一次时间

29,59 * * * * /usr/sbin/ntpdate hdp0

然后使用pssh将这个内容写入所有从节点的crontab

pssh -h host.txt -t 10 -I < tmp.txt 'crontab -'

3.安装Ambari

3.1配置ambari和hdp的yum源(主节点)

# 安装httpd
sudo yum install -y httpd
# 启动http
sudo systemctl start httpd
# 将httpd加入到开机自启
sudo systemctl enable httpd

上传安装包并解压那三个压缩包

# 先在/var/www/html目录下创建ambari、hdp、hdp-utils文件夹
mkdir /var/www/html/ambari
mkdir /var/www/html/hdp
mkdir /var/www/html/hdp-utils
# 这里的-C是指定解压目录
tar -zxf /opt/ambari-2.7.4.0-centos7.tar.gz -C /var/www/html/ambari 
tar -zxf /opt/HDP-3.1.4.0-centos7-rpm.tar.gz -C /var/www/html/hdp
tar -zxf /opt/HDP-UTILS-1.1.0.22-centos7.tar.gz -C /var/www/html/hdp-utils/

配置yum源,ip记得改

# 配置ambari源
vim /etc/yum.repos.d/ambari.repo

#内容如下
[ambari]
name=ambari
baseurl=http://192.168.80.xxx/ambari/ambari/centos7/2.7.4.0-118
gpgcheck=0
# 配置hdp和hdp-utils源
vim /etc/yum.repos.d/hdp.repo

# 内容如下
[HDP]
name=HDP
baseurl=http://192.168.80.xxx/hdp/HDP/centos7/3.1.4.0-315
gpgcheck=0
[HDP-UTILS]
name=HDP_UTILS
baseurl=http://192.168.80.xxx/hdp-utils/HDP-UTILS/centos7/1.1.0.22/
gpgcheck=0
# yum创建缓存
yum clean all
yum makecache

# 通过yum repolist命令验证即可
yum repolist

配置好yum源后使用scp命令将ambari.repo和hdp.repo文件发送到其他节点的/etc/yum.repos.d/目录下

3.2配置和安装ambari-server(主节点)

yum install -y ambari-server #安装ambari-server

配置数据库

# 登录已经安装好的mysql
mysql -u root

mysql>  CREATE USER 'ambari'@'%' IDENTIFIED BY 'MKLmkl11@@'; -- 创建ambari用户
Query OK, 0 rows affected (0.00 sec)

mysql> create database ambari;
Query OK, 1 row affected (0.00 sec) -- 创建ambari数据库

mysql> grant all on ambari.* to ambari@'%';
Query OK, 0 rows affected, 1 warning (0.00 sec) -- 授权

mysql> use ambari; -- 使用已经创建好的ambari数据库
Database changed

mysql> source /var/lib/ambari-server/resources/Ambari-DDL-MySQL-CREATE.sql; -- 使用ambari-server提供的sql脚本创建相关表

下载jdbc驱动

下载驱动

这里我使用最新版jdbc8.0.33之后可以运行ambari-server,但是和mysql5.7适配的jdbc5.1.44会一直遇到已耗尽最大连接次数和flush的问题,看了很多解决办法没解决掉。不过用8.0.33也没什么不好的。

将jdbc驱动包放到指定目录

#查看安装位置和内容
rpm -qpl mysql-connector-j-8.0.33-1.el7.noarch.rpm
#安装
sudo rpm -ivh mysql-connector-j-8.0.33-1.el7.noarch.rpm
#查看是否安装
rpm -qa | grep mysql-connector-j
# 创建目录
mkdir -p /usr/share/java
# 如果mysql-connector-java.jar不在/usr/share/java/下则复制一份过去

配置ambari-server

[root@hdp1 Downloads]# 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 (mumu): 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] Custom JDK
==============================================================================
Enter choice (1): 2
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/lib/jvm/java-1.8.0-openjdk-1.8.0.372.b07-1.el7_9.x86_64/jre
Validating JDK on Ambari Server...done.
Check JDK version for Ambari Server...
JDK version found: 8
Minimum JDK version is 8 for Ambari. Skipping to setup different JDK for Ambari Server.
Checking GPL software agreement...
GPL License for LZO: https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html
Enable Ambari Server to download and install GPL Licensed LZO packages [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 / MariaDB
[4] - PostgreSQL
[5] - Microsoft SQL Server (Tech Preview)
[6] - SQL Anywhere
[7] - BDB
==============================================================================
Enter choice (1): 3
Hostname (localhost): hdp1
Port (3306): 
Database name (ambari): 
Username (ambari): 
Enter Database Password (bigdata): 
Invalid characters in password. Use only alphanumeric or _ or - characters
Enter Database Password (bigdata): 
Invalid characters in password. Use only alphanumeric or _ or - characters
Enter Database Password (bigdata): 
Configuring ambari database...
Should ambari use existing default jdbc /usr/share/java/mysql-connector-java.jar [y/n] (y)? 
Configuring remote database connection properties...
WARNING: Before starting Ambari Server, you must run the following DDL directly from the database shell to create the schema: /var/lib/ambari-server/resources/Ambari-DDL-MySQL-CREATE.sql
Proceed with configuring remote database connection properties [y/n] (y)? 
Extracting system views...
ambari-admin-2.7.4.0.118.jar
....
Ambari repo file doesn't contain latest json url, skipping repoinfos modification
Adjusting ambari-server permissions and ownership...
Ambari Server 'setup' completed successfully.
[root@hdp1 Downloads]# 

启动ambari

ambari-server start

3.3 安装、配置ambari-agent节点(所有节点Optional)

你也可以在下一步的2-Install Options中选择Provide your SSH and autoconf就可以跳过这一步

yum install -y ambari-agent #安装ambari-agent
sudo vim /etc/ambari-agent/conf/ambari-agent.ini
# 将hostname=localhost修改为hdp1
# [server]
# hostname=hdp1
ambari-agent start #启动服务

4. 部署HDP

通过ip:8080就可以访问Web UI了,登录ambari,默认用户名和密码都是admin。

点击ClusterInformation --> LAUNCH INSTALL WIZARD开始安装向导

填集群名字

5. Enjoy

:-)

Last updated