--环境信息:
182.15.240.145 master
182.15.240.146 slave1
182.15.240.147 slave2
--安装所需的包:
ambari-2.7.3.0-centos7.tar.gz
HDP-3.1.0.0-centos7-rpm.tar.gz
HDP-UTILS-1.1.0.22-centos7.tar.gz
jdk-8u102-linux-x64.tar.gz
mysql-5.7.27-1.el7.x86_64.rpm-bundle.tar
注:以下所有操作都是用root权限!
一、卸载自带jdk - 所有机器
(1)查看自带JDk版本
rpm -qa|grep java
(2)卸载自带JDK
rpm -e --nodeps java-1.8.0-openjdk-headless-1.8.0.161-0.b14.el7_4.x86_64
rpm -e --nodeps java-1.8.0-openjdk-1.8.0.161-0.b14.el7_4.x86_64
(3)上传JDk并解压
jdk版本:jdk-8u102-linux-x64.tar.gz
上传JDk包至/usr/local/jdk目录下,并切换到该目录(没有jdk目录则手动创建)。
执行远程拷贝命令如,每个节点的jdk安装路径一样。拷贝完后解压JDK包。
scp jdk-8u102-linux-x64.tar.gz [email protected]:/usr/local/jdk
scp jdk-8u102-linux-x64.tar.gz [email protected]:/usr/local/jdk
解压后路径:/usr/local/jdk/jdk1.8.0_102
(4)配置JDk
每个节点都需要配置,且配置JDK的内容相同。
vim /etc/profile
末尾加入下配置:
export JAVA_HOME=/usr/local/jdk/jdk1.8.0_102
export CLASSPATH=$:CLASSPATH:$JAVA_HOME/lib/
export PATH=$PATH:$JAVA_HOME/bin
(5)jdk生效
source /etc/profile
二、设置主机名称 - 所有机器
vim /etc/hostname
若有三个节点,选一个节点作为主节点,修改其hostname中为master,其他节点的主机名称依次修改为slave1、slave2。
然后使用命令:reboot重启生效。
三、修改Hosts - 所有机器
vim /etc/hosts
每个节点的hosts文件中添加如下配置:
182.15.240.145 master
182.15.240.146 slave1
182.15.240.147 slave2
四、修改network - 所有机器
vim /etc/sysconfig/network
添加如下配置:
# Created by anaconda
NETWORKING=yes
通过ping主机名看是否通讯正常。
ping slave1
五、打开安全限制 - 所有机器
vim /etc/security/limits.conf
文件末尾新增如下:
# End of file
* soft nofile 65536
* hard nofile 65536
* soft nproc 131072
* hard nproc 131072
六、关闭防火墙 - 所有机器
[root@master~]#systemctl disable firewalld
[root@master~]#systemctl stop firewalld
另外所有机器还需修改:
[root@master ~]# vim /etc/selinux/config
参数修改如下:
SELINUX=disabled
SELINUXTYPE=targeted
七、同步时钟
1、安装chrony服务 - 所有机器
yum -y install chrony
2、设置master为主服务器,开启nptd服务(主服务器)
主服务器上该配置文件修改项如下:
vim /etc/chrony.conf
----------------------------
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
# 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 182.15.240.145 iburst
# Record the rate at which the system clock gains/losses time.
driftfile /var/lib/chrony/drift
# Allow the system clock to be stepped in the first three updates
# if its offset is larger than 1 second.
makestep 1.0 3
# Enable kernel synchronization of the real-time clock (RTC).
rtcsync
# Enable hardware timestamping on all interfaces that support it.
#hwtimestamp *
# Increase the minimum number of selectable sources required to adjust
# the system clock.
#minsources 2
# Allow NTP client access from local network.
#allow 192.168.0.0/16
allow 182.15.240.0/24
# Serve time even if not synchronized to a time source.
#local stratum 10
local stratum 10
# Specify file containing keys for NTP authentication.
#keyfile /etc/chrony.keys
# Specify directory for log files.
logdir /var/log/chrony
# Select which information is logged.
#log measurements statistics tracking
----------------------------------------------
修改保存后执行:
[root@master ~]# systemctl restart chronyd.service #启动服务
[root@master ~]# systemctl status chronyd.service #开机自启动
chronyc -a makestep
chronyc sourcestats
chronyc sources -v
3、子节点时间同步配置
vim /etc/chrony.conf
注释原来的server并新增如下配置即可然后重启服务:
server 182.15.240.145
[root@master ~]# systemctl restart chronyd.service #启动服务
[root@master ~]# systemctl status chronyd.service #开机自启动
每个子节点的chrony.conf里都要配置server 182.15.240.145,并重启服务!
八、SSH无密码登录 - 主节点
1、免密钥操作
[root@master ~]# ssh-keygen -t rsa 连接提示选yes ,密码提示填登录密码
[root@master ~]# ssh-copy-id slave1
[root@master ~]# ssh-copy-id slave2
[root@master ~]# ssh-copy-id master
测试是否实现了无密码登录:
[root@master ~]# ssh slave1 date ;ssh slave2 date;ssh master date;
2018年 04月 23日 星期一 14:18:13 CST
2018年 04月 23日 星期一 14:18:13 CST
2018年 04月 23日 星期一 14:18:13 CST
2、保存密钥
将创建的秘钥拷贝出来,因为后面ambari安装的时候需要上传这个秘钥
。创建秘钥是在隐藏文件夹/root/.ssh/下面的,
所以需要先把秘钥拷贝到可见区域,然后拷贝到电脑上。
[root@master ~]# cd /root/.ssh/
[root@master .ssh]# ls
authorized_keys id_rsa id_rsa.pub known_hosts
[root@master .ssh]# cp id_rsa /root/
[root@master .ssh]# ls /root/
anaconda-ks.cfg id_rsa jdk-8u161-linux-x64.rpm
id_rsa为密钥!
九、其他系统设置 - 所有机器
root@master ~]# sudo sh -c "echo umask 0022 >> /etc/profile"
-------------------------------------------------------------------
十、修改yum源,实现离线安装
1、安装httpd服务 - 主服务器
[root@master ~]# yum -y install httpd
[root@master ~]# service httpd restart
Redirecting to /bin/systemctl restart httpd.service
[root@master ~]# chkconfig httpd on
2、上传三个包放到/var/www/html目录下 - 主服务器
安装完成后,会生成 /var/www/html目录(相当于Tomcat的webapps目录),进入到/var/www/html目录下,
创建ambari和hdp目录,用来存放安装文件.
[root@yum ~]# mkdir /var/www/html/ambari
[root@yum ~]# mkdir /var/www/html/hdp
[root@yum ~]# mkdir /var/www/html/hdp/HDP-UTILS-1.1.0.22
[root@yum ~]# tar -zxvf ambari-2.7.3.0-centos7.tar.gz -C /var/www/html/ambari/
[root@yum ~]# tar -zxvf HDP-3.1.0.0-centos7-rpm.tar.gz -C /var/www/html/hdp/
[root@yum ~]# tar -zxvf HDP-UTILS-1.1.0.22-centos7.tar.gz -C /var/www/html/hdp/HDP-UTILS-1.1.0.22/
3、启动httpd服务:
[root@yum ~]# systemctl start httpd # 启动httpd
[root@yum ~]# systemctl status httpd # 查看httpd状态
[root@yum ~]# systemctl enable httpd # 设置httpd开机自启
现在可以通过访问
http://182.15.240.145/ambari/
http://182.15.240.145/hdp/
十一、制作本地源
https://docs.hortonworks.com/HDPDocuments/Ambari-2.7.3.0/bk_ambari-installation/content/ambari_repositories.html
https://docs.hortonworks.com/HDPDocuments/Ambari-2.7.3.0/bk_ambari-installation/content/hdp_31_repositories.html
1、安装本地源 - 主服务器
(1)下载ambari.repo文件
[root@master ambari]# wget -O /etc/yum.repos.d/ambari.repo http://public-repo-1.hortonworks.com/ambari/centos7/2.x/updates/2.7.3.0/ambari.repo
注:路径一定要配置正确!!!
修改配置文件:vim /etc/yum.repos.d/ambari.repo
[root@master ambari]# vi ambari/centos7/2.7.3.0-139/ambari.repo
#VERSION_NUMBER=2.7.3.0-139
[ambari-2.7.3.0]
#json.url = http://public-repo-1.hortonworks.com/HDP/hdp_urlinfo.json
name=ambari Version - ambari-2.7.3.0
baseurl=http://182.15.240.145/ambari/ambari/centos7/2.7.3.0-139
gpgcheck=1
gpgkey=http://182.15.240.145/ambari/ambari/centos7/2.7.3.0-139/RPM-GPG-KEY/RPM-GPG-KEY-Jenkins
enabled=1
priority=1
(2)配置HDP和HDP-TILS
创建配置文件:[root@yum yum.repos.d]# touch /etc/yum.repos.d/HDP.repo
--[root@master ambari]# vim HDP/centos7/3.1.0.0-78/hdp.repo
#VERSION_NUMBER=3.1.0.0-78
[HDP-3.1.0.0]
name=HDP Version - HDP-3.1.0.0
baseurl=http://182.15.240.145/hdp/HDP/centos7
gpgcheck=1
gpgkey=http://182.15.240.145/hdp/HDP/centos7/3.1.0.0-78/RPM-GPG-KEY/RPM-GPG-KEY-Jenkins
enabled=1
priority=1
[HDP-UTILS-1.1.0.22]
name=HDP-UTILS Version - HDP-UTILS-1.1.0.22
baseurl=http://182.15.240.145/hdp/HDP-UTILS-1.1.0.22
gpgcheck=1
gpgkey=http://182.15.240.145/hdp/HDP-UTILS-1.1.0.22/HDP-UTILS/centos7/1.1.0.22/RPM-GPG-KEY/RPM-GPG-KEY-Jenkins
enabled=1
priority=1
2、清理一下yum的缓存
[root@master ambari]# yum clean all
[root@master ambari]# yum makecache
[root@master ambari]# yum repolist
3、将创建好的文件拷贝到子节点 - 主服务器
[root@master ambari]#cd /etc/yum.repos.d
[root@master yum.repos.d]# scp ambari.repo HDP.repo slave1:$PWD
[root@master yum.repos.d]# scp ambari.repo HDP.repo slave2:$PWD
十二、安装ambari-server
1、以mysql为数据库安装 - 主服务器
mysql包版本:mysql-5.7.27-1.el7.x86_64.rpm-bundle.tar
上传到主节点/usr/local/mysql目录下并解压。
rpm -qa |grep -i mysql
rpm -qa |grep -i mariadb
用rpm -e 删除包
强制卸载mariadb
rpm -e --nodeps mariadb-libs-5.5.44-2.el7.centos.x86_64
这里是为了避免安装mysql时出现依赖错误,提前删除系统已有的mariadb和mysql包!
安装mysql可能用到的工具:
yum -y install libaio
yum -y install net-tools
2、安装mysql-server:按照common–>libs–>client–>server的顺序。若不按照此顺序,也会有一定“依赖”关系的提醒。
[root@hadoop mysql]# rpm -ivh mysql-community-common-5.7.18-1.el7.x86_64.rpm
warning: mysql-community-common-5.7.18-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:mysql-community-common-5.7.18-1.e################################# [100%]
[root@hadoop mysql]# rpm -ivh mysql-community-libs-5.7.18-1.el7.x86_64.rpm
warning: mysql-community-libs-5.7.18-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:mysql-community-libs-5.7.18-1.el7################################# [100%]
[root@hadoop mysql]# rpm -ivh mysql-community-client-5.7.18-1.el7.x86_64.rpm
warning: mysql-community-client-5.7.18-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:mysql-community-client-5.7.18-1.e################################# [100%]
[root@hadoop mysql]# rpm -ivh mysql-community-server-5.7.18-1.el7.x86_64.rpm
warning: mysql-community-server-5.7.18-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:mysql-community-server-5.7.18-1.e################################# [100%]
3、初始化mysql
[root@hadoop mysql]# mysqld --initialize
4、更改mysql数据库所属于用户及其所属于组
[root@hadoop mysql]# chown mysql:mysql /var/lib/mysql -R
5、启动mysql数据库
启动mysql数据库
[root@hadoop mysql]# cd /var/lib/mysql
[root@hadoop mysql]# systemctl start mysqld.service
[root@hadoop ~]# cd /var/log/
[root@hadoop log]# grep 'password' mysqld.log
2019-02-26T04:33:06.989818Z 1 [Note] A temporary password is generated for root@localhost: mxeV&htW-3VC
更改root用户密码,新版的mysql在第一次登录后更改密码前是不能执行任何命令的
[root@hadoop log]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.18
Copyright (c) 2000, 2017, 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> set password=password('oracle');
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> grant all privileges on *.* to root@'%' identified by 'oracle' with grant option;
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
安装和配置ambari-server
yum -y install ambari-server
6、登录mysql创建ambari安装所需要的库
设置的账号后面配饰ambari-server的时候会用到!!!
执行如下语句:
CREATE DATABASE ambari;
use ambari;
CREATE USER 'ambari'@'%' IDENTIFIED BY 'ambari123';
GRANT ALL PRIVILEGES ON *.* TO 'ambari'@'%';
CREATE USER 'ambari'@'localhost' IDENTIFIED BY 'ambari123';
GRANT ALL PRIVILEGES ON *.* TO 'ambari'@'localhost';
CREATE USER 'ambari'@'master' IDENTIFIED BY 'ambari123';
GRANT ALL PRIVILEGES ON *.* TO 'ambari'@'master';
FLUSH PRIVILEGES;
source /var/lib/ambari-server/resources/Ambari-DDL-MySQL-CREATE.sql
show tables;
use mysql;
select Host User Password from user where user='ambari';
CREATE DATABASE hive;
use hive;
CREATE USER 'hive'@'%' IDENTIFIED BY 'hive';
GRANT ALL PRIVILEGES ON *.* TO 'hive'@'%';
CREATE USER 'hive'@'localhost' IDENTIFIED BY 'hive';
GRANT ALL PRIVILEGES ON *.* TO 'hive'@'localhost';
CREATE USER 'hive'@'master' IDENTIFIED BY 'hive';
GRANT ALL PRIVILEGES ON *.* TO 'hive'@'master';
FLUSH PRIVILEGES;
CREATE DATABASE oozie;
use oozie;
CREATE USER 'oozie'@'%' IDENTIFIED BY 'oozie';
GRANT ALL PRIVILEGES ON *.* TO 'oozie'@'%';
CREATE USER 'oozie'@'localhost' IDENTIFIED BY 'oozie';
GRANT ALL PRIVILEGES ON *.* TO 'oozie'@'localhost';
CREATE USER 'oozie'@'master' IDENTIFIED BY 'oozie';
GRANT ALL PRIVILEGES ON *.* TO 'oozie'@'master';
FLUSH PRIVILEGES;
如果要重新执行以上语句,则需要先删除:
1. delete from mysql.user where user='sonar'; 删除用户
2.CREATE USER 'sonar'@'%'IDENTIFIED BY 'sonar';天假用户
3. flush privileges; 清理缓存
4. select * from mysql.user where user='sonar';查看该用户是否存在 ,结果是null
5. flush privileges;清理缓存
6. GRANT ALL ON sonar.* TO 'sonar'@'%' IDENTIFIED BY 'sonar';用户操作授权
---------------------
7、mysql与ambari-server的连接
下载mysql-connector-java-5.1.40.jar放到root文件下
mkdir /usr/share/java
cp /root/mysql-connector-java-5.1.40.jar /usr/share/java/mysql-connector-java.jar
cp /usr/share/java/mysql-connector-java.jar /var/lib/ambari-server/resources/mysql-jdbc-driver.jar
vi /etc/ambari-server/conf/ambari.properties
添加server.jdbc.driver.path=/usr/share/java/mysql-connector-java.jar
8、初始化ambari-server
[root@master ~]# ambari-server setup
下面是配置执行流程,按照提示操作
(1) 提示是否自定义设置。输入:y
Customize user account for ambari-server daemon [y/n] (n)? y
(2)ambari-server 账号。
Enter user account for ambari-server daemon (root):
如果直接回车就是默认选择root用户
如果输入已经创建的用户就会显示:
Enter user account for ambari-server daemon (root):ambari
Adjusting ambari-server permissions and ownership...
(3)检查防火墙是否关闭
Adjusting ambari-server permissions and ownership...
Checking firewall...
WARNING: iptables is running. Confirm the necessary Ambari ports are accessible. Refer to the Ambari documentation for more details on ports.
OK to continue [y/n] (y)?
直接回车
(4)设置JDK。输入:3
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
如果上面选择3自定义JDK,则需要设置JAVA_HOME。输入:/usr/java/jdk1.8.0_161
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_131
Validating JDK on Ambari Server...done.
Completing setup...
(5)数据库配置。选择:y
Configuring database...
Enter advanced database configuration [y/n] (n)? y
(6)选择数据库类型。输入:3
Configuring database...
==============================================================================
Choose one of the following options:
[1] - PostgreSQL (Embedded)
[2] - Oracle
[3] - MySQL
[4] - PostgreSQL
[5] - Microsoft SQL Server (Tech Preview)
[6] - SQL Anywhere
==============================================================================
Enter choice (3): 3
(7)设置数据库的具体配置信息,根据实际情况输入,如果和括号内相同,则可以直接回车。如果想重命名,就输入。
Hostname (localhost): master
Port (3306): 3306
Database name (ambari): ambari
Username (ambari): ambari
Enter Database Password (bigdata):ambari123
Re-Enter password: ambari123
(8)将Ambari数据库脚本导入到数据库
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
[root@master ~]# ambari-server start
错误处理:
如果出现错误,请注意查看日志,根据具体的错误内容进行处理,默认ambari-server的日志在/var/log/ambari-server/ambari-server.log里面。如果在处理日志的过程中或者后面安装的过程中出现一些莫名的错误,可以重置的安装。
如果上面进行的默认数据库的配置,可以使用下面的代码重置ambari-server。
[root@master ~]# ambari-server stop
[root@master ~]# ambari-server reset
[root@master ~]# ambari-server setup
如果选择的是第二种方式,就需要先执行上面的语句,然后手动将mysql里面创建的数据库进行删除。然后再重新执行第二步的操作
[root@master ~]# mysql -uroot -p
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| ambari |
| hive |
| oozie |
| performance_schema |
+--------------------+
rows in set (0.00 sec)
mysql> drop database ambari;
mysql> drop database hive;
mysql> drop database oozie;
先在mysql库的User表中删除ambari、hive和oozie用户,再重复第六小结的用户创建操作,然后执行第八小结
的命令:ambari-server setup。
9、启动ambari-server服务
[root@master ~]# ambari-server start
Using python /usr/bin/python
Starting ambari-server
Ambari Server running with administrator privileges.
Organizing resource files at /var/lib/ambari-server/resources...
Ambari database consistency check started...
Server PID at: /var/run/ambari-server/ambari-server.pid
Server out at: /var/log/ambari-server/ambari-server.out
Server log at: /var/log/ambari-server/ambari-server.log
Waiting for server start..................................
Server started listening on 8080
DB configs consistency check: no errors and warnings were found.
Ambari Server 'start' completed successfully.
十三、安装部署HDP集群
1、登录界面
默认管理员账户登录, 账户:admin 密码:admin
http://182.15.240.145:8080
2、安装向导
(1)Launch Install Wizard
(2)配置集群名称;
(3)选择版本并修改本地源地址;
选HDP-3.1.00;
选Use Local Repository;
选redhat7:
HDP-3.1: http://182.15.240.145/hdp/HDP/centos7/
HDP-3.1-GPL: http://public-repo-1.hortonworks.com/HDP-GPL/centos7/3.x/updates/3.1.0.0/
HDP-UTILS-1.1.0.22: http://182.15.240.145/hdp/HDP-UTILS-1.1.0.22/
配置节点和密钥
Target hosts填
master
slave1
slave2
从主节点的/root目录下下载密钥id_rsa,并上传即可!
使用第三方数据库mysql的时候需要执行:
ambari-server setup --jdbc-db=mysql --jdbc-driver=/var/lib/ambari-agent/lib/mysql-connector-java-5.1.24.jar
[root@master lib]# ambari-server setup --jdbc-db=mysql --jdbc-driver=/var/lib/ambari-agent/lib/mysql-connector-java-5.1.24.jarUsing python /usr/bin/python
Setup ambari-server
Copying /var/lib/ambari-agent/lib/mysql-connector-java-5.1.24.jar to /var/lib/ambari-server/resources/mysql-connector-java-5.1.24.jar
Creating symlink /var/lib/ambari-server/resources/mysql-connector-java-5.1.24.jar to /var/lib/ambari-server/resources/mysql-connector-java.jar
If you are updating existing jdbc driver jar for mysql with mysql-connector-java-5.1.24.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.
Database URL: jdbc:mysql://master/hive
Database Password: hive/hive
----------------最后一步的信息----------------------------------------
Admin Name : admin
Cluster Name : leap
Total Hosts : 3 (3 new)
Repositories:
redhat7 (HDP-3.1):
redhat7 (HDP-3.1-GPL):
redhat7 (HDP-UTILS-1.1.0.22):
Services:
HDFS DataNode : 3 hosts
NameNode : master
NFSGateway : 1 host
SNameNode : slave1
YARN + MapReduce2 Timeline Service V1.5 : slave1
NodeManager : 3 hosts
ResourceManager : master
Timeline Service V2.0 Reader : master
Registry DNS : master
Tez Clients : 3 hosts
Hive Metastore : slave1
HiveServer2 : slave1
Database : Existing MySQL / MariaDB Database
HBase Master : master
RegionServer : 2 hosts
Phoenix Query Server : 3 hosts
ZooKeeper Server : 3 hosts
Ambari Metrics Metrics Collector : slave2
Grafana : master
Kafka Broker : master
SmartSense Activity Analyzer : master
Activity Explorer : master
HST Server : master
Spark2 Livy for Spark2 Server : 2 hosts
History Server : master
Thrift Server : 2 hosts
-----------------------------------
主页: http://182.15.240.145:8080 admin/admin
yarn: http://master:8088/cluster