1.1 版本说明
1.2 linux版本
- HDP 安装 linux 版本 centos7.5 mini的英文版, 中文版会有一系列的安装问题
1.3 端口
检查端口命令:
# netstat -anp | grep 5432
HDP 默认使用 8080 端口 注意: 因为HDP版是使用ambari来管理hadoop 集群组件的,ambari
默认安装使用postgreSql保存元数据,然而postgreSQL默认端口也是:5432 , 所以安装ambari时候可以先安装Mysql
,把ambari元数据保存到Mysql中,后续Hive也可以将元数据保存到 Mysql
1.4 安装完成后展示
1.5 linux设置
1.5.1 关闭防火墙
修改配置
systemctl stop firewalld
systemctl disable firewalld
检查配置
systemctl status firewalld
1.5.2 配置域名
查看:
#cat /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=localhost
编辑:
#vi /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=node1 (注意不用将机器名改成node-1,node_1之类的不符合linux机器名规范的形式,否则就会报错)
1.5.3 配置域名解析(每个节点都要)
修改 hosts 配置
# vi /etc/hosts
192.168.38.146 node1
192.168.38.147 node2
192.168.38.148 node3
修改本机 hostname,要永久修改主机名,你可以修改静态主机名:
hostnamectl --static set-hostname [主机名]
#hostnamectl --static set-hostname node1
#hostnamectl --static set-hostname node2
#hostnamectl --static set-hostname node3
1.6 禁用IPV6
# vi /etc/sysctl.conf
增加以下内容
# add
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
使配置生效
[root@node1 /]# sysctl -p
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
1.7 禁用 Selinux
修改/etc/selinux/config文件中设置SELINUX=disabled ,然后重启服务器
修改内容:
SELINUX=disabled
重启机器才生效
检查 selinux 状态
1.8 JDK 卸载与安装
卸载系统自带 jdk
# rpm -qa|grep java
# rpm -e --nodeps xxx yyy zzz
1.9. 解压jdk
# chmod 755 jdk-8u112-linux-x64.tar.gz --修改权限
# tar -zxf jdk-8u112-linux-x64.tar.gz -C /opt/modules/ --解压JDK到/opt/modules/
# ln -s /opt/modules/jdk1.8.0_112 /opt/modules/jdk --建立JDK的软连接,方便将来更换版本
# vi /etc/profile --编辑环境变量配置文件
export JAVA_HOME=/opt/modules/jdk
export PATH=$JAVA_HOME/bin:$PATH
1.10 使环境变量生效
# source /etc/profile
# java -version
1.11 设置文件打开数目和用户最大进程数
文件打开数目
#ulimit -a
用户最大进程数
# ulimit -u
设置 # vi /etc/security/limits.conf 增加内容:
* soft nofile 128000
* hard nofile 128000
* soft nproc 128000
* hard nproc 128000
设置# /etc/security/limits.d/20-nproc.conf 修改内容:将* soft nproc 的数值改为 128000
* soft nproc 128000
root soft nproc unlimited
1.12 ssh 无密码登录(root)
node1 ip:192.168.38.146
node2 ip:192.168.38.147
node3 ip:192.168..38.148
在node1上:
rm -rf /root/.ssh
ssh-keygen -t rsa
cat /root/.ssh/id_dsa.pub >> /root/.ssh/authorized_keys
scp /root/.ssh/id_dsa.pub node2:/root/
scp /root/.ssh/id_dsa.pub node3:/root/
在node2上:
rm -rf /root/.ssh
ssh-keygen -t rsa
cat /root/id_dsa.pub >> /root/.ssh/authorized_keys
在node3:
rm -rf /root/.ssh
ssh-keygen -t rsa
cat /root/id_dsa.pub >> /root/.ssh/authorized_keys
2.1 集群时间同步
用主节点作为时间服务器
在节点node1上安装 ntp
# yum -y install ntp
## 启动
# systemctl start ntpd
## 状态
# systemctl status ntpd
## 设置随机器启动
# systemctl enable ntpd
2.2 配置(主节点上)
vi /etc/ntp.conf
第一处: 去掉注释, 修改网段 ;
第二处: 增加注释(无外网时添加),将下面四行注释掉;
第三处: 在配置文件最后增加一行:
设置机器的时间与 BIOS 系统时间同步,首行增加如 vi /etc/sysconfig/ntpd下内容
SYNC_HWCLOCK=yes
2.3 所有的机器(从节点上) 都与这台时间服务器进行同步时间,在配置文件最后加上这一行:
主节点:
[root@node1 yum.repos.d]# ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
*LOCAL(0) .LOCL. 10 l 63 64 377 0.000 0.000 0.000
从节点:
[root@node2 ~]# ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
*node1 LOCAL(0) 11 u 130 1024 377 0.380 0.033 0.066
[root@node3 /]# ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
*node1 LOCAL(0) 11 u 259 1024 377 0.407 0.269 0.184
备注: NTP 同步可能需要 10-20 分钟, 可以通过预先手动同步的手段, 来实现立即 同步的效果。 手动同步时需要临时停止 ntpd
服务 第一次配置后 从节点 同步时间需要停止 ntp 服务
# systemctl stop ntpd
# ntpdate node1
# systemctl start ntpd
3.1 搭建本地 yum 源
安装 HTTPD 服务(在主节点安装)
# yum install httpd
启动 HTTPD 服务(Apache 服务)
# systemctl start httpd
# systemctl enable httpd
本地 apache 服务(HTTPD 服务)的配置目录 /var/www/html
# 后续将所有安装包的软连接建立到该目录下
# 除非磁盘有规划, 否则不建议直接把安装包复制到该目录下, 会占用大量“/var目录” 或“/” 的空间
-
配置各安装包及其 yum源
4.1 CentOS7 系统安装包,挂载 centos7 系统镜像盘, 并复制到本地# mkdir -p /mnt/centos7 # mkdir -p /opt/yum-pkg/centos7 # mount -o loop /work/CentOS-7-x86_64-Minimal-1804.iso /mnt/centos7/ # cp -a /mnt/centos7 /opt/yum-pkg/centos7
建立软连接到 apache 服务目录下
# ln -s /opt/yum-pkg/centos7/ /var/www/html/centos7
yum 源配置
vi /etc/yum.repos.d/centos7.repo
[centos7]
name=centos7
baseurl=http://node1/centos7/centos7
enabled=1
gpgcheck=0
配置完成之后,在浏览器上访问http://192.168.38.146/centos7/centos7/,可以看到以下内容:
5 Ambari 安装包
解压
tar zxvf ambari-2.6.1.0-centos7.tar.gz -C /opt/yum-pkg/
ln -s /opt/yum-pkg/ambari /var/www/html/ambari
建软连接到 apache 服务目录下
yum 源配置
[ambari-2.6.1.0]
name=AMBARI-2.6.1
baseurl=http://192.168.38.146/ambari/centos7/2.6.1.0-143/
gpgcheck=0
gpgkey=http://192.168.38.146/ambari/centos7/2.6.1.0-143/RPM-GPG-KEY/RPM-GPG-KEY-Jenkins
enabled=1
priority=1
配置完成之后,在浏览器上访问http://192.168.38.146/ambari/centos7/2.6.1.0-143/可以看到以下内容:
配置完成之后,在浏览器上访问http://192.168.38.146/ambari/centos7/2.6.1.0-143/RPM-GPG-KEY/RPM-GPG-KEY-Jenkins 可以看到以下内容:
- HDP 安装包
解压HDP-2.6.4.0-centos7-rpm.tar.gz到/opt/yum-pkg目录下:
#tar zxvf HDP-2.6.4.0-centos7-rpm.tar.gz -C /opt/yum-pkg/
建立软连接到 apache 服务目录下
#ln -s /opt/yum-pkg/HDP/ /var/www/html/HDP-2.6.4.0-centos7
解压HDP-UTILS-1.1.0.21-centos7.tar.gz到/opt/yum-pkg目录下:
#tar zxvf HDP-UTILS-1.1.0.21-centos7.tar.gz -C /opt/yum-pkg/
建立软连接到apache服务目录下
#ln -s /opt/yum-pkg/HDP-UTILS-1.1.0.21 /var/www/html/HDP-UTILS-1.1.0.21 #vi /etc/yum.repos.d/HDP-2.6.4.0-centos7.repo [HDP-2.6.4.0] name=HDP-2.6.4.0 baseurl=http://192.168.38.146/HDP-2.6.4/centos7/2.6.4.0-91/ enabled=1 gpgcheck=1 gpgkey=http://192.168.38.146/HDP-2.6.4/centos7/2.6.4.0-91/RPM-GPG-KEY/RPM-GPG-KEY-Jenkins priority=1 [HDP-UTILS-1.1.0.21] name=HDP-UTILS-1.1.0.21 baseurl=http://192.168.38.146/HDP-UTILS-1.1.0.21/ gpgcheck=0 gpgkey=http://192.168.38.146/HDP-UTILS-1.1.0.21/RPM-GPG-KEY/RPM-GPG-KEY-Jenkins enabled=1 priority=1 yum源配置(HDP-GPL) #vi /etc/yum.repos.d/HDP-GPL.repo mkdir -p /opt/yum-pkg/ tar zxvf HDP-GPL-2.6.4.0-centos7-rpm.tar.gz -C /opt/yum-pkg/ ln -s /opt/yum-pkg/HDP-GPL /var/www/html/HDP-GPL
yum源配置
#vi /etc/yum.repos.d/HDP-GPL.repo [HDP-GPL] name=HDP-GPL baseurl=http://192.168.38.146/HDP-GPL/centos7/2.6.4.0-91/ gpgcheck=0 gpgkey=http://192.168.38.146/HDP-GPL/centos7/2.6.4.0-91/RPM-GPG-KEY/RPM-GPG-KEY-Jenkins enabled=1 priority=1 配置完成后,访问:http://192.168.38.146/HDP-GPL/centos7/2.6.4.0-91/
https://qizhanming.com/blog/2017/05/10/centos-7-yum-install-mysql-57
安装Mysql
7.1 CentOS 7(Minimal Install)
[root@node1 ~]# cat /etc/redhat-release
CentOS Linux release 7.5.1804 (Core)
安装和配置步骤
1.配置 yum 源
去 MySQL 官网下载 YUM 的 RPM 安装包,http://dev.mysql.com/downloads/repo/yum/
下载 mysql 源安装包
$ curl -LO http://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm
安装 mysql 源
$ sudo yum localinstall mysql57-community-release-el7-11.noarch.rpm
检查 yum 源是否安装成功
$ sudo yum repolist enabled | grep "mysql.*-community.*"
mysql-connectors-community MySQL Connectors Community 21
mysql-tools-community MySQL Tools Community 38
mysql57-community MySQL 5.7 Community Server 130
如上所示,找到了 mysql 的安装包
2.安装
$ sudo yum install mysql-community-server
3.启动
安装服务
$ sudo systemctl enable mysqld
启动服务
$ sudo systemctl start mysqld
查看服务状态
$ sudo systemctl status mysqld
4.修改 root 默认密码
MySQL 5.7 启动后,在 /var/log/mysqld.log 文件中给 root 生成了一个默认密码。通过下面的方式找到 root 默认密码,然后登录 mysql 进行修改:
$ grep 'temporary password' /var/log/mysqld.log
[Note] A temporary password is generated for root@localhost: **********
登录 MySQL 并修改密码
$ mysql -u root -p
Enter password:
mysql> update mysql.user set authentication_string=password('Bg1234') where user='root' and Host = 'localhost';
注意:MySQL 5.7
默认安装了密码安全检查插件(validate_password),默认密码检查策略要求密码必须包含:大小写字母、数字和特殊符号,并且长度不能少于
8 位。
通过 MySQL 环境变量可以查看密码策略的相关信息:
mysql> SHOW VARIABLES LIKE 'validate_password%';
+--------------------------------------+--------+
| Variable_name | Value |
+--------------------------------------+--------+
| validate_password_check_user_name | OFF |
| validate_password_dictionary_file | |
| validate_password_length | 8 |
| validate_password_mixed_case_count | 1 |
| validate_password_number_count | 1 |
| validate_password_policy | MEDIUM |
| validate_password_special_char_count | 1 |
+--------------------------------------+--------+
7 rows in set (0.01 sec)
具体修改,参见
http://dev.mysql.com/doc/refman/5.7/en/validate-password-options-variables.html#sysvar_validate_password_policy
指定密码校验策略
$ sudo vi /etc/my.cnf
[mysqld]
# 添加如下键值对, 0=LOW, 1=MEDIUM, 2=STRONG
validate_password_policy=0
禁用密码策略
$ sudo vi /etc/my.cnf
[mysqld]
# 禁用密码校验策略
validate_password = off
重启 MySQL 服务,使配置生效
$ sudo systemctl restart mysqld
5.添加远程登录用户
MySQL 默认只允许 root 帐户在本地登录,如果要在其它机器上连接 MySQL,必须修改 root 允许远程连接,或者添加一个允许远程连接的帐户,为了安全起见,本例添加一个新的帐户:
数据库密码:Bg1234
update mysql.user set authentication_string=password('Bg1234') where user='root' and Host = 'localhost';
授权:
grant all privileges on *.* to 'root'@'localhost' identified by 'Bg1234' with grant option;
flush privileges;
grant all privileges on *.* to 'root'@'node1' identified by 'Bg1234' with grant option ; --bigdata 集群用
flush privileges;
6.配置默认编码为 utf8
MySQL 默认为 latin1, 一般修改为 UTF-8
$ vi /etc/my.cnf
[mysqld]
# 在myslqd下添加如下键值对
character_set_server=utf8
init_connect='SET NAMES utf8'
重启 MySQL 服务,使配置生效
$ sudo systemctl restart mysqld
查看字符集
mysql> SHOW VARIABLES LIKE 'character%';
+--------------------------+----------------------------+
| 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
- 登陆mysql(密码:xxxxxx)
[root@node1 /]# mysql -uroot -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 625 Server version: 5.7.22 MySQL Community Server (GPL) Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql>
安装Ambari
ambari-server安装(在node1上部署)
yum安装ambari-server
清除 yum 源缓存
# yum clean all
检查指定安装包是否挂载(此处为 ambari 相关包)
# yum repolist
ambari-server 服务安装(仅主节点)
# yum install ambari-server
首先将centos7.repo,ambari.repo ,HDP-2.6.4.0-centos7.repo分别拷贝到node2和node3的节点上,让他们可以从node1上下载文件
[root@node1 yum.repos.d]# scp centos7.repo node2:/etc/yum.repos.d/
centos7.repo 100% 81 98.2KB/s 00:00
[root@node1 yum.repos.d]# scp centos7.repo node3:/etc/yum.repos.d/
centos7.repo 100% 81 77.0KB/s 00:00
[root@node1 yum.repos.d]# scp ambari.repo node2:/etc/yum.repos.d/
ambari.repo 100% 214 234.7KB/s 00:00
[root@node1 yum.repos.d]# scp ambari.repo node3:/etc/yum.repos.d/
ambari.repo 100% 214 159.0KB/s 00:00
[root@node1 yum.repos.d]# scp HDP-2.6.4.0-centos7.repo node2:/etc/yum.repos.d/
HDP-2.6.4.0-centos7.repo 100% 421 400.4KB/s 00:00
[root@node1 yum.repos.d]# scp HDP-2.6.4.0-centos7.repo node3:/etc/yum.repos.d/
HDP-2.6.4.0-centos7.repo
[root@node1 .ssh]# scp /etc/yum.repos.d/HDP-GPL.repo node2:/etc/yum.repos.d/
[root@node1 .ssh]# scp /etc/yum.repos.d/HDP-GPL.repo node3:/etc/yum.repos.d/
agent服务安装(所有节点)
# yum install ambari-agent
21.创建数据实例
安装到 mysql并增加mysql对应的用户和数据库
创建ambari数据库
CREATE DATABASE ambari CHARACTER SET utf8 ;
创建ambari用户,设置密码为:XXXX
GRANT ALL PRIVILEGES ON *.* TO 'ambari'@'localhost' IDENTIFIED BY 'xxxxxx' WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON *.* TO 'ambari'@'%' IDENTIFIED BY 'xxxxxx' WITH GRANT OPTION;
执行完后,执行 ambari 对应的 Mysql 脚本
source /var/lib/ambari-server/resources/Ambari-DDL-MySQL-CREATE.sql
flush privileges;
22.ambari-server 服务器安装
[root@node1 ~]# 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...
Do you want to change Oracle JDK [y/n] (n)? y
[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: /opt/modules/jdk
Validating JDK on Ambari Server...done.
Checking GPL software agreement...
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): node1
Port (3306): 3306
Database name (ambari): ambari
Username (ambari): ambari
Enter Database Password (bigdata):
Re-enter password:
Configuring ambari database...
WARNING: Before starting Ambari Server, you must copy the MySQL JDBC driver JAR file to /usr/share/java and set property "server.jdbc.driver.path=[path/to/custom_jdbc_driver]" in ambari.properties.
Press <enter> to continue.
ERROR: Before starting Ambari Server, you must copy the MySQL JDBC driver JAR file to /usr/share/java and set property "server.jdbc.driver.path=[path/to/custom_jdbc_driver]" in ambari.properties.
ERROR: Exiting with exit code -1.
REASON: Before starting Ambari Server, you must copy the MySQL JDBC driver JAR file to /usr/share/java
新建目录,并将mysql-connector-java-5.1.41-bin.jar文件放到这个目录下:
mkdir -p /usr/share/java/
ambari-server setup --jdbc-db=mysql --jdbc-driver=/usr/share/java/mysql-connector-java-5.1.41-bin.jar
[root@node1 java]# ambari-server setup --jdbc-db=mysql --jdbc-driver=/usr/share/java/mysql-connector-java-5.1.41-bin.jar
Using python /usr/bin/python
Setup ambari-server
Copying /usr/share/java/mysql-connector-java-5.1.41-bin.jar to /var/lib/ambari-server/resources
If you are updating existing jdbc driver jar for mysql with mysql-connector-java-5.1.41-bin.jar. Please remove the old driver jar, from all hosts. Restarting services that need the driver, will automatically copy the new jar to the hosts.
JDBC driver was successfully initialized.
Ambari Server 'setup' completed successfully.
报错解决方法:
ERROR: Before starting Ambari Server, you must copy the MySQL JDBC driver JAR file to /usr/share/java and set property "server.jdbc.driver.path=[path/to/custom_jdbc_driver]" in ambari.properties.
ERROR: Exiting with exit code -1.
REASON: Before starting Ambari Server, you must copy the MySQL JDBC driver JAR file to /usr/share/java
看到下面的报错,我们可以通过
#find / -name ambari.properties 找到配置文件ambari.properties,然后在最后一行加上,server.jdbc.driver.path=/usr/share/java/mysql-connector-java-5.1.41-bin.jar
(10)成功启动后在浏览器输入Ambari地址:http://主机名:8080
1、出现登录界面,默认管理员账户登录, 账户:admin 密码:admin
选择要安装的service:
配置不同的服务部署在不同的节点上
分配客户端
NameNode和DataNode的路径:/boot/efi/hadoop/hdfs/data 是系统路径,直接删除掉,只保留
/hadoop/hdfs/namenode和/hadoop/hdfs/data
安装组件:
创建hive组件的数据库hive
mysql> CREATE DATABASE hive CHARACTER SET utf8 ;
Query OK, 1 row affected (0.00 sec)
测试数据库的连通性:
设置Grafana组件的密码:
这里账号密码都为:admin/admin
开始安装之前,信息确认:
配置完成,确认之后就,开始正式的安装:
到这里就安装完成:
3.登录安装好的HDP集群
访问地址:http://192.168.38.146:8080
账号:admin/admin
接下来做一些HA方面的操作:
Namenode HA 截图
这里需要给 NameNode 一个命名空间名称: ns1
选择 HA NameNode 另外一台主机 :
按照提示进行以下操作:
1.Login to the NameNode host node1.
2.Put the NameNode in Safe Mode (read-only mode): sudo su hdfs -l -c ‘hdfs dfsadmin -safemode enter’
3.Once in Safe Mode, create a Checkpoint: sudo su hdfs -l -c ‘hdfs dfsadmin -saveNamespace’
4.You will be able to proceed once Ambari detects that the NameNode is in Safe Mode and the Checkpoint has been created successfully.
[root@node1 /]# hdfs -l -c 'hdfs dfsadmin -safemode enter'
Safe mode is ON
[root@node1 /]# hdfs -l -c 'hdfs dfsadmin -saveNamespace'
Save namespace successful
[root@node1 /]# sudo su hdfs -l -c ‘hdfs namenode -initializeSharedEdits’
Yarn HA 截图
参考文档:
https://www.yp14.cn/2016/12/09/Centos7-2%E5%AE%89%E8%A3%85Ambari2-4-2-HDP2-5-3%E6%90%AD%E5%BB%BAHadoop%E9%9B%86%E7%BE%A4/
Centos7.3安装Ambari2.4.2+HDP2.5.3搭建Hadoop集群
https://blog.csdn.net/sunshinepx/article/details/78385442
CentOS 7.4 安装 Ambari 2.6.0 + HDP 2.6.3 搭建Hadoop集群
https://blog.csdn.net/mawenwu1983/article/details/78983275
官方搭建文档:https://docs.hortonworks.com/HDPDocuments/Ambari-2.4.2.0/bk_ambari-installation/content/ch_Getting_Ready.html
离线搭建yum源,包下载列表:https://docs.hortonworks.com/HDPDocuments/Ambari-2.4.2.0/bk_ambari-installation/content/hdp_25_repositories.html
Centos 7安装 ambari-agent报错NetUtil.py-[SSL: CERTIFICATE_VERIFY_FAILED]