一、ambari架构解析
二、基础环境配置
以两台节点为例来组件Hadoop分布式集群,这里采用的系统版本为Centos7 1511,如下表所示:
主机名 |
内存 |
硬盘 |
IP地址 |
角色 |
master |
8192MB |
100G |
192.168.200.6 |
Ambari-Server Ambari-Agent |
slaver |
8192MB |
100G |
192.168.200.7 |
Ambari-Agent |
搭建所需各软件版本信息
①ambari-2.7.1.0-centos7.tar.gz
②jdk-8u151-linux-x64.tar.gz
③HDP-3.0.1.0-centos7-rpm.tar.gz
④HDP-UTILS-1.1.0.22-centos7.tar
⑤CentOS-7-x86_64-DVD-1511.iso
1.在iaas平台创建两台云主机
- 主机名、主机名解析配置
vi /etc/hosts
- 挂载镜像并配置本地yum源
首先将所需镜像、安装包等,通过secureFX上传至master 的/opt目录
Master节点
3.1进入/opt目录,解压ambari.tar.gz压缩包
[[email protected] ~]# cd /opt
[[email protected] opt]# ls
ambari-2.7.1.0-centos7.tar.gz HDP-3.0.1.0-centos7-rpm.tar.gz
centos HDP-UTILS-1.1.0.22-centos7.tar
[[email protected] opt]# tar -zxvf ambari-2.7.1.0-centos7.tar.gz
解压完成后获得一个ambari的文件夹
[[email protected] ~]# ls
CentOS-7-x86_64-DVD-1511.iso
[[email protected] ~]# mount -o loop CentOS-7-x86_64-DVD-1511.iso /mnt/
[[email protected] ~]# mkdir /opt/centos
[[email protected] ~]# cp -rvf /mnt/* /opt/centos/
[[email protected] ~]# cd /etc/yum.repos.d/
[[email protected] yum.repos.d]# ls
CentOS-Base.repo CentOS-Debuginfo.repo CentOS-Sources.repo
CentOS-CR.repo CentOS-fasttrack.repo CentOS-Vault.repo
[[email protected] yum.repos.d]# rm -rf *
[[email protected] yum.repos.d]# vi local.repo
[centos]
name=centos
baseurl=file:///opt/centos
gpgcheck=0
enable=1
[ambari]
name=ambari
baseurl=file:///opt/ambari/centos7/2.7.1.0-169/
gpgcheck=0
enable=1
保存退出
清理源,并列出源
[[email protected] ~]# yum clean all
Loaded plugins: fastestmirror
Cleaning repos: ambari centos
Cleaning up everything
Cleaning up list of fastest mirrors
[[email protected] ~]# yum list
[[email protected] ~]# yum install vsftpd
[[email protected] ~]# vi /etc/vsftpd/vsftpd.conf
添加
anon_root=/opt/
3.2配置开机启动vsftpd
[[email protected] ~]# systemctl enable vsftpd
[[email protected] ~]# systemctl start vsftpd
Slaver节点
[[email protected] ~]# cd /etc/yum.repos.d/
[[email protected] yum.repos.d]# ls
CentOS-Base.repo CentOS-Debuginfo.repo CentOS-Sources.repo
CentOS-CR.repo CentOS-fasttrack.repo CentOS-Vault.repo
[[email protected] yum.repos.d]# rm -rf *
[[email protected] yum.repos.d]# vi ftp.repo
[centos]
name=centos
baseurl=ftp://192.168.200.6/centos
gpgcheck=0
enable=1
[ambari]
name=ambari
baseurl=ftp://192.168.200.6/ambari/centos7/2.7.1.0-169/
gpgcheck=0
enable=1
保存退出
- 配置NTP服务
Master节点
[[email protected] ~]# yum -y install ntp
[[email protected] ~]# vi /etc/ntp.conf
4.1将原有server注释
添加
server 127.127.1.0
fudge 127.127.1.0 stratum 10
[[email protected] ~]# systemctl enable ntpd
[[email protected] ~]# systemctl start ntpd
Slaver节点
[[email protected] ~]# yum -y install ntpdate
[[email protected] ~]# ntpdate master
[[email protected] ~]# systemctl enable ntpdate
- 配置SSH 免密访问
Master节点
[[email protected] ~]# yum install openssh-clients
[[email protected] ~]# ssh-keygen
[[email protected] ~]# ssh-copy-id slaver.hadoop
Slaver节点
[[email protected] ~]# yum install openssh-clients
[[email protected] ~]# ssh-keygen
[[email protected] ~]# ssh-copy-id master.hadoop
- 禁用Transparent Huge Pages
操作系统后台有一个叫做khugepaged的进程,它会一直扫描所有进程占用的内存,在可能的情况下会把4kpage交换为Huge Pages,在这个过程中,对于操作的内存的各种分配活动都需要各种内存锁,直接影响程序的内存访问性能,并且,这个过程对于应用是透明的,在应用层面不可控制,对于专门为4k page优化的程序来说,可能会造成随机的性能下降现象。
master & slaver
[[email protected] ~]# echo never > /sys/kernel/mm/transparent_hugepage/enabled
[[email protected] ~]# echo never > /sys/kernel/mm/transparent_hugepage/defrag
[[email protected] ~]# cat /sys/kernel/mm/transparent_hugepage/enabled
always advise [never]
重启后失效,需要再次执行
- 安装配置jdk
Master节点
[[email protected] ~]# mkdir /usr/jdk64/
[[email protected] ~]# tar -zxvf jdk-8u151-linux-x64.tar.gz -C /usr/jdk64/
[[email protected] ~]# vi /etc/profile
7.1添加以下两条变量
export JAVA_HOME=/usr/jdk64/jdk1.8.0_151
export PATH=$JAVA_HOME/bin:$PATH
[[email protected] ~]# source /etc/profile
[[email protected] ~]# 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)
Slaver节点
[[email protected] ~]# mkdir /usr/jdk64/
[[email protected] ~]# scp 192.168.200.6://root/jdk-8u151-linux-x64.tar.gz .
jdk-8u151-linux-x64.tar.gz 100% 181MB 90.5MB/s 00:02
[[email protected] ~]# tar -zxvf jdk-8u151-linux-x64.tar.gz -C /usr/jdk64/
[[email protected] ~]# vi /etc/profile
export JAVA_HOME=/usr/jdk64/jdk1.8.0_151
export PATH=$JAVA_HOME/bin:$PATH
[[email protected] ~]# source /etc/profile
[[email protected] ~]# 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)
- 安装httpd服务
8.1安装httpd
[[email protected] ~]# yum -y install httpd
[[email protected] ~]# systemctl enable httpd.service
[[email protected] ~]# systemctl start httpd.service
[[email protected] ~]# systemctl status httpd.service
8.2解压HDP
将/opt目录下的
HDP-3.0.1.0-centos7-rpm.tar.gz
HDP-UTILS-1.1.0.22-centos7.tar
解压,并复制到 /var/www/html
[[email protected] opt]# tar -zvxf HDP-3.0.1.0-centos7-rpm.tar.gz -C /var/www/html/
[[email protected] opt]# tar -zvxf HDP-UTILS-1.1.0.22-centos7.tar -C /var/www/html/
三、ambari-server 安装配置
Master节点
[[email protected] ~]# yum -y install ambari-server
1.安装MariaDB数据库
[[email protected] ~]# yum install mariadb mariadb-server mysql-connector-java
1.1启动数据库服务
[[email protected] ~]# systemctl enable mariadb
[[email protected] ~]# systemctl start mariadb
1.2配置数据库服务
[[email protected] ~]# mysql_secure_installation
Set root password? [Y/n] y (设置密码为bigdata)
Remove anonymous users? [Y/n] y
Disallow root login remotely? [Y/n] n
Remove test database and access to it? [Y/n] y
Reload privilege tables now? [Y/n] y
[[email protected] ~]# mysql -uroot -pbigdata
MariaDB [(none)]> create database ambari;
MariaDB [(none)]> grant all privileges on ambari.* to ‘ambari‘@‘localhost‘ identified by ‘bigdata‘;
MariaDB [(none)]> grant all privileges on ambari.* to ‘ambari‘@‘%‘ identified by ‘bigdata‘;
MariaDB [(none)]> use ambari;
MariaDB [ambari]> source /var/lib/ambari-server/resources/Ambari-DDL-MySQL-CREATE.sql
MariaDB [ambari]> quit
- 配置ambari-server
[[email protected] ~]# vi /etc/profile
添加
export buildNumber=2.7.1.0
[[email protected] ~]# 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)? n
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/jdk64/jdk1.8.0_151
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)? 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...
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 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)?
Extracting system views...
ambari-admin-2.7.1.0.169.jar
....
Ambari repo file doesn‘t contain latest json url, skipping repoinfos modification
Adjusting ambari-server permissions and ownership...
Ambari Server ‘setup‘ completed successfully.
[[email protected] ~]# ambari-server setup --jdbc-db=mysql --jdbc-driver=/usr/share/java/mysql-connector-java.jar
- 启动ambari-server服务
[[email protected] ~]# ambari-server start
DB configs consistency check: no errors and warnings were found.
Ambari Server ‘start‘ completed successfully.
四、ambari-agent 安装配置
master & slaver
1.安装ambari-agent
[[email protected] ~]# yum -y install ambari-agent
[[email protected] ~]# yum -y install ambari-agent
- 修改变量
[[email protected] ~]# vi /etc/ambari-agent/conf/ambari-agent.ini
[[email protected] ~]# vi /etc/ambari-agent/conf/ambari-agent.ini
将[server]项修改为master.hadoop
hostname=master.hadoop
3.重启ambari-agent服务
[[email protected] ~]# ambari-agent restart
[[email protected] ~]# ambari-agent restart
五、部署Hadoop集群
1.访问WEB界面
打开浏览器输入IP:8080访问ambari的web界面
本机为http://192.168.200.6:8080
默认用户名 admin
默认密码 admin
- 创建新的集群
3.1命名集群
3.2选择本地仓库源
选择redhat 7
http://192.168.200.6/HDP/centos7/3.0.1.0-187/
http://192.168.200.6/HDP-UTILS/centos7/1.1.0.22/
3.3配置主机名
3.4主机状态注册检查
3.5服务安装选择
这里我们选择了
YARN + MapReduce2
HDFS
ZooKeeper
Ambari Metrics
Spark2
3.6服务分配大师
默认即可。
3.7节点服务选择
设置Grafana密码
默认下一步即可
确认部署
开始部署
原文地址:https://www.cnblogs.com/huangwentao/p/12070932.html