有道有笔记地址: http://note.youdao.com/noteshare?id=4a8bb0f1a02e3b9605824bc6ce3a1c9e
一、官方链接
- Ambari
版本:ambari-2.5.0.3-centos7
http://ambari.apache.org/
- HDP
版本:HDP-2.6.0.3-centos7-rpm HDP-UTILS-1.1.0.21-centos7.tar
https://docs.hortonworks.com/HDPDocuments/Ambari-2.5.0.3/bk_ambari-installation/content/hdp_26_repositories.html
- CentOS
版本:CentOS-7-x86_64
https://www.centos.org/
在物理机下载好Ambari、HDP和HDP-UTILS的安装包,文件比较大在虚拟机下载速度太慢。注意下载的版本,和系统
二、配置系统环境
- 配置ip
1、设置虚拟机的网络连接方式为NAT
2、打开虚拟机网络编辑器:编辑——虚拟机网络编辑器——NAT设置
记录网关IP、子网掩码的信息
3、配置虚拟机网卡信息
#vi /etc/sysconfig/network-scripts/ifcfg-ens33
BOOTPROTO=static(此处设置为静态,默认为dhcp)
ONBOOT=yes(此处设置为yes,开机就自动执行)
IPADDR=192.168.42.201(设置IP地址,需要和子网在同一IP段)
GATEWAY=192.168.42.2(网关,网关地址在VM的网络连接设置里面)
NETMASK=255.255.255.0(子网掩码,子网掩码也在VM网络连接设置里面)
4、 重启网络设置
# systemctl restart network.service
5、查看网络连接情况,就看到ip地址更改为你设置的ip
# ifconfig
7 测试外网连接情况
#ping www.baidu.com
如果成功,则配置没问题。
- 配置hosts
#vi /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.42.201 hdp1.hadoop
192.168.42.202 hdp2.hadoop
更改为以上信息,注意必须要写成aaaa.aaaa的格式,需要配置几个节点就设置几个。
- 配置hostname
#vi /etc/hosts
设置为2步骤中对应节点的名字
- 安装基础软件包
#yum install openssh wget vim openssh-clients openssl gcc openssh-server mysql-connector-odbc -y
#systemctl enable sshd && systemctl start sshd
- 配置FQDN
# vi /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=hdp1.hadoop
- 关闭防火墙和SELinux
#systemctl disable firewalld.service
#systemctl stop firewalld.service
#vi /etc/sysconfig/selinux
找到以下参数设置为关闭
SELINUX=disabled
- 修改为Yum源为阿里云
1、 echo 备份当前的yum源
#mv /etc/yum.repos.d /etc/yum.repos.d.backup4comex
2、echo 新建空的yum源设置目录
#mkdir /etc/yum.repos.d
3、echo 下载阿里云的yum源配置(根据系统版本,修改CentOS-后面的数值)
#wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
4、重建缓存
#yum clean all
#yum makecache
- 配置JDK
Oarcle官方链接:
http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
1、下载jdk
# mkdir ~/hadoop/java
#cd ~/hadoop/java
#wget
http://download.oracle.com/otn-pub/java/jdk/8u151-b12/e758a0de34e24606bca991d704f6dcbf/jdk-8u151-linux-x64.tar.gz?AuthParam=1514519833_6514c37c7d6bc350d11cb6e334ccbde5
2、解压jdk到/opt/java
# mkdir -p /opt/java/ && tar xf jdk-8u151-linux-x64.tar.gz -C /opt/java
3、配置环境变量
# vim /etc/profile
添加下面内容:
export JAVA_HOME=/opt/java/jdk1.8.0_151
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
PATH=$PATH:$HOME/bin:$JAVA_HOME/bin
4、启用环境变量
# source /etc/profile
5、测试是否配置成功
#java -version
显示结果:
java version "1.8.0_151"
Java(TM) SE Runtime Environment (build 1.8.0_151-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.151-b12, mixed mode)
以下两项有结果显示说明tools配置成功
#javac
#java
- 安装NTP
开启ntpd服务(确保集群内部时钟统一)
#yum -y install ntp
# systemctl is-enabled ntpd
# systemctl enable ntpd
# systemctl start ntpd
- 克隆虚拟机
1、关机
# shutdown -h now
2、克隆
点击VMware菜单栏的虚拟机——管理——克隆
出来对话框,点击两次下一步,在克隆类型选择创建完整克隆,虚拟机名称填写HDP2,点击完 成;需要几台虚拟机就克隆几台
- 配置克隆后的虚拟机ip、hosts、hostname
1、将克隆后的虚拟机依次开机
2、配置虚拟机网卡信息
#vi /etc/sysconfig/network-scripts/ifcfg-ens33
IPADDR=192.168.42.202(按照hosts中的映射,依次往后写)
3、 重启网络设置
# systemctl restart network.service
4、 测试外网连接情况
#ping www.baidu.com
如果成功,则配置没问题。
5、修改hostname
#vi /etc/hosts
修改为hosts中ip对应的值
- 配置ssh免密登陆
1、配置各个节点的私钥,并分发到主节点,各个节点都执行以下命令
#ssh-keygen -t rsa -P '' -f ~/.ssh/id_rsa
#cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
#chmod 0600 ~/.ssh/authorized_keys
#cp ~/.ssh/id_rsa.pub ~/.ssh/id_rsa_hdp1(此处为各个节点名字).pub
传输的过程需要输入密码
2、把主节点的密钥分发到各个节点,在主节点执行以下代码
#for i in `seq (此处填写节点数) `;do cat ~/id_rsa_hdp$i.pub >>~/.ssh/authorized_keys ;done
#for i in `seq (此处填写节点数)`;do scp ~/.ssh/authorized_keys root@hdp$i.hadoop:~/.ssh/authorized_keys;done
3、测试
在各个节点测试以下能不能免密登陆,如果没问题则成功。
三、制作本地源
- 把下载好的Ambari、HDP、HDP-UTILs安装包传输到虚拟机
在物理机安装xfile软件,通过xfile连接虚拟机,把下载的文件传输到虚拟机的/root/hadoop/路径下。
- 安装httpd服务
# yum install httpd -y
#systemctl enable httpd && systemctl start httpd
- 解压源文件到到源目录下
#mkdir /var/www/html/ambari-HDP
#mkdir /var/www/html/ambari-HDP/HDP-UTILS
#mkdir /var/www/html/ambari-HDP/ambari
#mkdir /var/www/html/ambari-HDP/HDP
#tar xf /root/hadoop/ambari-2.5.0.3-centos7.tar.gz -C /var/www/html/ambari-HDP/ambari
# tar xf /root/hadoop/HDP-2.6.0.3-centos7-rpm.tar.gz -C /var/www/html/ambari-HDP/HDP
# tar xf /root/hadoop/HDP-UTILS-1.1.0.21-centos7.tar.gz -C /var/www/html/ambari-HDP/HDP-UTILS
- 安装links测试是否可用
#yum install links -y
# links
http://hdp1.hadoop/ambari
结果显示的为刚刚解压的路径
- 复制ambari、HDP、HDP-UTILS的repo到yum
#cp /var/www/html/ambari-HDP/ambari/ambari/centos7/ambari.repo /etc.yum.repos.d
#cp /var/www/html/ambari-HDP/HDP/HDP/centos7/hdp.repo /etc.yum.repos.d
#cp /var/www/html/ambari-HDP/HDP-UTILS/hdp-utils.repo /etc.yum.repos.d
- 配置ambari、HDP、HDP-UTILS的repo
1、ambari
#vi /etc.yum.repos.d/ambari.repo
修改为如下配置
#VERSION_NUMBER=2.5.0.3-7
[ambari-2.5.0.3]
name=ambari Version - ambari-2.5.0.3
baseurl=http://hdp1.hadoop/ambari-HDP/ambari/ambari/centos7/
gpgcheck=1
gpgkey=http://hdp1.hadoop/ambari-HDP/ambari/ambari/centos7/RPM-GPG-KEY/RPM-GPG-KEY-Jenkins
enabled=1
priority=1
2、HDP
#vi /etc.yum.repos.d/hdp.repo
修改为如下配置:
#VERSION_NUMBER=2.6.0.3-8
[HDP-2.6.0.3]
name=HDP Version - HDP-2.6.0.3
baseurl=http://hdp1.hadoop/ambari-HDP/HDP/HDP/centos7/
gpgcheck=1
gpgkey=http://hdp1.hadoop/ambari-HDP/HDP/HDP/centos7/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://hdp1.hadoop/ambari-HDP/HDP-UTILS
gpgcheck=1
gpgkey=http://hdp1.hadoop/ambari-HDP/HDP/HDP/centos7/RPM-GPG-KEY/RPM-GPG-KEY-Jenkins
enabled=1
priority=1
3、HDP-UTILS
#vi /etc.yum.repos.d/hdp-utils.repo
修改为如下配置:
[HDP-UTILS-1.1.0.21]
name=Hortonworks Data Platform Version - HDP-UTILS-1.1.0.21
baseurl= http://hdp1.hadoop/ambari-HDP/HDP-UTILS
gpgcheck=1
enabled=1
priority=1
- 安装本地源制作工具
#yum install yum-utils createrepo -y
#cd /var/www/html/
#createrepo ./
- 更新yum缓存
# yum clean all
# yum makecache
# yum repolist
四、安装Ambari-server
- 安装搭建mysql数据库
1.下载mysql的repo源
# wget https://repo.mysql.com//mysql57-community-release-el7-11.noarch.rpm
2安装mysql-community-release-el7-5.noarch.rpm包
#sudo rpm -ivh mysql-community-release-el7-11.noarch.rpm
安装这个包后,会获得两个mysql的yum repo源:
/etc/yum.repos.d/mysql-community.repo
/etc/yum.repos.d/mysql-community-source.repo
3.安装mysql
# sudo yum install mysql-server
根据提示安装就可以了,不过安装完成后没有密码,需要重置密码
如果此时提示关于 mariadb的错误,则是因为系统中装了mariadb我们需要卸载掉mariadb
查看系统是否安装mariadb
# rpm -qa | grep mariadb
如果显示有安装的信息,则卸载
# rpm -ev 此处填写上一步里面的列表 --nodeps
完成后再次执行 # yum install mysql-server
4.重置mysql密码
# mysql -u root
登录时有可能报这样的错:ERROR 2002 (HY000): Can‘t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock‘ (2),原因是/var/lib/mysql的访问权限问题。下面的命令把/var/lib/mysql的拥有者改为当前用户:
# sudo chown -R root:root /var/lib/mysql
重启mysql服务
# service mysqld restart
接下来登录重置密码:
# mysql -u root //直接回车进入mysql控制台
mysql > use mysql;
mysql > update user set password=password('你的密码') where user='你的用户名,一般是root';
mysql > exit;
- 写入Ambari的信息到MySQL
#mysql -u root -p
输入密码,进入mysql的编辑命令
输入以下sql语句:
CREATE DATABASE ambari;
use ambari;
CREATE USER 'ambari'@'%' IDENTIFIED BY 'bigdata';
GRANT ALL PRIVILEGES ON *.* TO 'ambari'@'%';
CREATE USER 'ambari'@'localhost' IDENTIFIED BY 'bigdata';
GRANT ALL PRIVILEGES ON *.* TO 'ambari'@'localhost';
CREATE USER 'ambari'@'hdp1.hadoop' IDENTIFIED BY 'bigdata';
GRANT ALL PRIVILEGES ON *.* TO 'ambari'@'hdp1.hadoop';
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'@'hdp1.hadoop' IDENTIFIED BY 'hive';
GRANT ALL PRIVILEGES ON *.* TO 'hive'@'hdp1.hadoop';
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'@'hdp1.hadoop' IDENTIFIED BY 'oozie';
GRANT ALL PRIVILEGES ON *.* TO 'oozie'@'hdp1.hadoop';
FLUSH PRIVILEGES;
- 安装ambari-server
1、开始安装
#yum install ambari-server
2、配置驱动
#mkdir /usr/share/java
通过xfile将物理机上的mysql-connector-java.jar复制到/usr/share/java目录下
将mysql-connector-java.jar复制到/var/lib/ambari-server/resources目录下
#cp /usr/share/java/mysql-connector-java.jar /var/lib/ambari-server/resources/mysql-jdbc- driver.jar
编辑ambari.properties
#vi /etc/ambari-server/conf/ambari.properties
修改server.jdbc.driver.path=/usr/share/java/mysql-connector-java.jar
- 配置Ambari-server
1、开始配置
#ambari-server setup
2、配置流程
(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)检查防火墙是否关闭,输入:y
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,自定义JAVA_HOME
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_151
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,选择MySQL数据库
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):127.0.0.1
Port (3306):3306
Database name (ambari):ambari
Username (ambari):root
Enter Database Password (bigdata):root
Re-Enter password: root
(8)将Ambari数据库脚本导入到数据库,选择y
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)?
- 启动ambari-server
# ambari-server start
- 测试
如果第四步成功执行,则在浏览器输入
http://hdp1.haoop:8080
就显示以下界面:
- 登陆
访问物理机浏览器访问
http://192.168.42.201:8080
用户名admin,密码admin
- 安装向导
点击Launch install wizard,进入安装向导
- 集群命名
- 选择安装HDP版本
我们选择HDP2.6的版本。
我们在URL输入之前创建的本地源,然后点击下一步。
- 设置集群的节点信息
hosts设置为我们之前设置的hosts内容。
host registration information,我们选择/root/.ssh/id_rad 文件的内容,设置为root用户,22端口。如果在物理机打不开这个文件,可以在主节点的命令行下# cat /root/.ssh/id_rad,复制里面的内容到窗口中。
- Host信息确认
等待成功配置完成之后点击next
- 选择安装的服务
选择自己需要的服务。
- 节点分配设置
- 节点客户端分配
- 自定义服务
- 确认配置信息
- 安装、启动和测试
- 安装成功