点击查看原文(包含源码和图片):http://note.youdao.com/noteshare?id=8176eba783c1d52c75691af1b007deb9&sub=EF8232BA90F64B5B8A736AF237C5984C
只要按照文档一步一步搭建,一定能搭建成功!
一、安装Vwmare
二 、安装Contos7 虚拟机(一台 hdp01)
三、配置网络环境
a.网卡设置为NAT或者桥接模式
b.设置主机名和ip的映射
-- 修改[/etc/hosts文件]
-- 清空内容
-- 添加新内容
127.0.0.1 localhost
192.168.150.151 hdp01
192.168.150.152 hdp02
192.168.150.153 hdp03
c.配置windows主机上的hosts文件:
C:\Windows\System32\drivers\etc\hosts,
127.0.0.1 localhost
192.168.150.151 hdp01
192.168.150.152 hdp02
192.168.150.153 hdp03
d.配置静态ip
1.切换到root用户 : su root
2.编辑/etc/sysconfig/network-scripts/ifcfg-eno16777736
$> cd /etc/sysconfig/network-scripts/
$> cp ifcfg-eno16777736 ifcfg-eno16777736.bak
3.编辑ifcfg-eno16777736文件
$> nano ifcfg-eno16777736
TYPE=Ethernet
BOOTPROTO=static
NAME=eno16777736
DEVICE=eno16777736
ONBOOT=yes
IPADDR=192.168.150.151
NETMASK=255.255.255.0
GATEWAY=192.168.150.2
DNS1=8.8.8.8
4.注意:GATEWAY和DNS的数值需要使用虚拟网卡的NAT网关地址,如何查看?
------:vwmare --> 编辑 --> 虚拟网络编辑器 -->V8条目--> NAT设置 -->查看网关地址
5.解决通过ip能访问网络,但是通过域名无法访问网络的问题
配置/etc/resolv文件,添加一行文本
$> nameserver 192.168.150.2
6.重启网络服务
$> su root
$> service network restart
四、更改主机名
a.$> sudo nano /etc/hostname
b.输入新的用户名,比如s101
c.修改主机名称之后,要特别主要修改主机和ip的映射,否则会造成java.net.UnknownHostException: 主机名: 主机名的异常
修改/etc/hosts文件
127.0.0.1 主机名 localhost.localdomain localhost
或是再添加一条
127.0.0.1 主机名
主机名是新加的,原来没有,保存,问题解决。
五、centos7 关闭防火墙
查看防火墙状态
firewall-cmd --state
停止firewall
systemctl stop firewalld.service
禁止firewall开机启动
systemctl disable firewalld.service
关闭selinux
进入到/etc/selinux/config文件
vi /etc/selinux/config
SELINUX=disabled
六、更改163源
修改yum repo -- CentOS7 配置163 yum源
1)下载repo文件
wget http://mirrors.163.com/.help/CentOS7-Base-163.repo
2)备份并替换系统的repo文件
cp CentOS7-Base-163.repo /etc/yum.repos.d/
cd /etc/yum.repos.d/
mv CentOS-Base.repo CentOS-Base.repo.bak
mv CentOS7-Base-163.repo CentOS-Base.repo
3)执行yum源更新命令
yum clean all
yum makecache
yum update
配置完毕。
七、 配置ssh免密码登录(三台机器互相操作)
a.首先在三台机器上配置对本机的ssh免密码登录
生成本机的公钥,过程中不断敲回车即可,ssh-keygen命令默认会将公钥放在/root/.ssh目录下
ssh-keygen -t rsa
b.将公钥复制为authorized_keys文件,此时使用ssh连接本机就不需要输入密码了
cd /root/.ssh | cp id_rsa.pub authorized_keys
ssh-keygen -t rsa | cd ~/.ssh | cp id_rsa.pub authorized_keys
3、接着配置三台机器互相之间的ssh免密码登录
使用ssh-copy-id -i hdp01 命令将本机的公钥拷贝到指定机器的authorized_keys文件中
八、配置ntp事件同步服务
- 安装ntp(hdp01)
yum -y install ntp
- 修改配置文件/etc/ntp.conf,把本机时间作为同步时间源
vim /etc/ntp.conf
# Hosts on local network are less restricted. # 要根据自己的集群环境配置网关、子网掩码 restrict 192.168.150.0 mask 255.255.255.0 nomodify notrap # 添加下面内容 server cn.pool.ntp.org perfer #网络时间同步 server 192.168.150.151 #你的集群中做时间服务器的主机的ip地址,自己调整 # 打开注释 server 127.127.1.0 # local clock fudge 127.127.1.0 stratum 10 # 注释掉这四行 # 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
- 编辑ntpd文件 vi /etc/sysconfig/ntpd
SYNC_HWCLOCK=yes # 打开的文本中输入如下内容,设置同步硬件时间
- 将主机时间与网络时间同步 ntpdate cn.pool.ntp.org
- 如提示占用 service ntpd stop ntpdate cn.pool.ntp.org service ntpd start
- systemctl start ntpd.service #启动ntpd时间服务器
- systemctl enable ntpd.service #开机自启动
- systemctl status ntpd # 查看状态
九、设置JAVA_HOME
1.查看jdk位置
cd /usr/lib/jvm ll
/etc/profile
export JAVA_HOME=/usr/lib/jvm/jre-1.8.0-openjdk-1.8.0.232.b09-0.el7_7.x86_64 export PATH=$PATH:$JAVA_HOME/bin
十 、克隆hdp02,hdp03两台机器
十一、hdp02,hdp03 配置网络环境和更改主机名
hdp02 ==> 192.168.150.152
hdp03 ==> 192.168.150.153
十二、hdp02,hdp03 配置ntp事件同步服务
设置定时事件
crontab -e
在打开的文本中输入如下内容,设置每1小时与主机同步时间
xxx为你的集群中master的主机名
*/1 * * * * /usr/sbin/ntpdate hdp01
十三、hdp01上配置本地yum源
- 安装httpd: yum install httpd -y
- 在官方下载镜像文件,此文件大概7G,可以使用p2p工具下载,其中包含两个repo文件和4个压缩包:(建议使用迅雷下载)
wget http://public-repo-1.hortonworks.com/ambari/centos7/2.x/updates/2.6.1.0/ambari.repo wget http://public-repo-1.hortonworks.com/HDP/centos7/2.x/updates/2.6.4.0/hdp.repo wget http://public-repo-1.hortonworks.com/ambari/centos7/2.x/updates/2.6.1.0/ambari-2.6.1.0-centos7.tar.gz wget http://public-repo-1.hortonworks.com/HDP-UTILS-1.1.0.22/repos/centos7/HDP-UTILS-1.1.0.22-centos7.tar.gz wget http://public-repo-1.hortonworks.com/HDP-GPL/centos7/2.x/updates/2.6.4.0/HDP-GPL-2.6.4.0-centos7-rpm.tar.gz wget http://public-repo-1.hortonworks.com/HDP/centos7/2.x/updates/2.6.4.0/HDP-2.6.4.0-centos7-rpm.tar.gz
- 将对应的tar包解压到httpd的文件目录[/var/www/html/]:
- cd /var/www/html/
[root@node-1 html]# tar xf ambari-2.6.1.0-centos7.tar.gz [root@node-1 html]# tar xf HDP-2.6.4.0-centos7-rpm.tar.gz [root@node-1 html]# tar xf HDP-GPL-2.6.4.0-centos7-rpm.tar.gz [root@node-1 html]# mkdir HDP-UTILS [root@node-1 html]# tar xf HDP-UTILS-1.1.0.22-centos7.tar.gz -C HDP-UTILS/
- 配置基础源,创建hadoop的repo文件,修改repo文件源路径:
# ambari 源 vim /etc/yum.repo.d/ambari.repo #VERSION_NUMBER=2.6.1.0-143 [ambari-2.6.1.0] name=ambari Version - ambari-2.6.1.0 baseurl=http://192.168.150.151/ambari/centos7/2.6.1.0-143 gpgcheck=1 gpgkey=http://192.168.150.151/ambari/centos7/2.6.1.0-143/RPM-GPG-KEY/RPM-GPG-KEY-Jenkins enabled=1 priority=1
# HDP源: vim /etc/yum.repo.d/hdp.repo #VERSION_NUMBER=2.6.4.0-91 [HDP-2.6.4.0] name=HDP Version - HDP-2.6.4.0 baseurl=http://192.168.150.151/HDP/centos7/2.6.4.0-91 gpgcheck=1 gpgkey=http://192.168.150.151/HDP/centos7/2.6.4.0-91/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://192.168.150.151/HDP-UTILS/centos7/1.1.0.22 gpgcheck=1 gpgkey=http://192.168.150.151/HDP-UTILS/centos7/1.1.0.22/RPM-GPG-KEY/RPM-GPG-KEY-Jenkins enabled=1 priority=1 [HDP-GPL-2.6.4.0] name=HDP-GPL Version - HDP-GPL-2.6.4.0 baseurl=http://192.168.150.151/HDP-GPL/centos7/2.6.4.0-91 gpgcheck=1 gpgkey=http://192.168.150.151/HDP-GPL/centos7/2.6.4.0-91/RPM-GPG-KEY/RPM-GPG-KEY-Jenkins enabled=1 priority=1
- 拷贝
cp hdp.repo /etc/yum.repos.d/ cp ambari.repo /etc/yum.repos.d/ scp ambari.repo root@hdp02:/etc/yum.repos.d/ scp ambari.repo root@hdp03:/etc/yum.repos.d/ scp hdp.repo root@hdp02:/etc/yum.repos.d/ scp hdp.repo root@hdp03:/etc/yum.repos.d/
- 启动httpd
service httpd start
- 检测一下
在windows的浏览器中输入 http://hdp01/ambari.repo
- 修改权限 777
[root@hdp01 html]# chmod 777 /etc/yum.repos.d/hdp.repo [root@hdp01 html]# chmod 777 /etc/yum.repos.d/ambari.repo [root@hdp02 html]# chmod 777 /etc/yum.repos.d/hdp.repo [root@hdp02 html]# chmod 777 /etc/yum.repos.d/ambari.repo [root@hdp03 html]# chmod 777 /etc/yum.repos.d/hdp.repo [root@hdp03 html]# chmod 777 /etc/yum.repos.d/ambari.repo
- 在各个节点创建缓存
[root@hdp01 ~]# yum clean all [root@hdp01 ~]# yum makecache fast
十四、各个节点安装java-1.8.0-openjdk:
yum install java-1.8.0-openjdk -y
十五、hdp01 安装配置数据库
yum install mariadb-server -y systemctl start mariadb systemctl enable mariadb # 开机自启 mysql_secure_installation
十六、创建数据库【mysql null / ambari bigdata / hive hive】hdp01
[root@hdp01 ~]# mysql # 创建数据库: MariaDB [(none)]> create database ambari default character set utf8; Query OK, 1 row affected (0.00 sec) MariaDB [(none)]> grant all on ambari.* to ambari@localhost identified by 'bigdata'; Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]> grant all on ambari.* to ambari@'%' identified by 'bigdata'; Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]> grant all on ambari.* to ambari@hdp01 identified by 'bigdata'; Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]> create database hive default character set utf8; Query OK, 1 row affected (0.00 sec) MariaDB [(none)]> grant all on hive.* to hive@localhost identified by 'hive'; Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]> grant all on hive.* to hive@'%' identified by 'hive';
十七、安装Amabri服务(hdp01)
- 在hdp01 上安装ambari-server,并启动配置向导:
yum install ambari-server -y
- 执行 >> 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):ambari Adjusting ambari-server permissions and ownership... Checking firewall status... Checking JDK... [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: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.161-0.b14.el7_4.x86_64/jre # 填写java_home Validating JDK on Ambari Server...done. 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)? 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): Port (3306): Database name (ambari): Username (ambari): Enter Database Password (bigdata): 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.
卡住,先别按下一步
到上面一步时,根据提示上传mysql的 jdbc驱动,并修改配置文件,指定jdbc驱动文件位置
[root@node-1 ~]# cd /usr/share/java [root@node-1 java]# ll total 3388 -rw-r--r-- 1 root root 3467861 Jan 22 16:16 mysql-connector-java-5.1.45.tar.gz [root@node-1 java]# tar xf mysql-connector-java-5.1.46.tar.gz [root@node-1 java]# mv mysql-connector-java-5.1.45/mysql-connector-java-5.1.46-bin.jar ./
然后,修改配置文件:
vim /etc/ambari-server/conf/ambari.properties # 添加一行 server.jdbc.driver.path=/usr/share/java/mysql-connector-java-5.1.46-bin.jar
配置完成后继续,会出现如下提示:
Press <enter> to continue. Configuring remote database connection properties... 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)?
然后别急下一步,先
mysql -uroot -p ambari < /var/lib/ambari-server/resources/Ambari-DDL-MySQL-CREATE.sql
然后 y
最后启动服务
[root@node-1 ~]# ambari-server start
服务启动成功后,会监听8080端口,使用浏览器登录,账号密码admin/admin正常登录,则安装完成。
此时出现错误:查看日志,发现 java.sql.SQLException: Access denied for user 'ambari'@'hdp01' (using password: YES) 更改权限 grant all on ambari.* to ambari@hdp01 identified by 'bigdata'; select host,user,password from mysql.user;
十八、创建集群
- 点击左上角Ambari图标,进入Get Start界面
- 使用ambari的web界面课完成对集群的所有管理操作,创建一个实例集群。
- 选择本地源,移除不必要的版本:
- 确认主机,检查主机(这里大家可能会失败),
需要在/etc/ambari-agent/conf/ambari-agent.ini中增加一行配置(在集群中的所有机器中操作) [security] force_https_protocol=PROTOCOL_TLSv1_2 增加完了别忘了重启ambari-agent(注意不是ambari-server,在集群中的所有机器中操作) ambari-agent restart
- 添加主机节点,上传id_rsa文件:
- 安装成功后,会显示如下界面:
- 选择需要安装的服务:
- 根据需要选择服务配置:
- 在后续的配置中,会提示配置账户密码,数据库等信息,根据提示配置即可。