Apache Ambari项目旨在通过开发用于配置,管理和监控Apache Hadoop集群的软件来简化Hadoop管理。Ambari提供了一个直观,易用的Hadoop管理Web UI。
注意:以下操作三台机器都需要进行
克隆三台虚拟机(node61、node62、node63),配置好对应主机的网络IP、主机名称、关闭防火墙。
[root@node62 ~]# systemctl status firewalld #查看防火墙状态
[root@node62 ~]# systemctl start firewalld #开启防火墙服务
[root@node62 ~]# systemctl stop firewalld #关闭防火墙服务[root@node62 ~]# systemctl disable firewalld #设置开机不启动
临时关闭:setenforce 0
修改配置文件vi /etc/selinux/config(重启生效init 6):将 SELINUX=enforcing 改为 SELINUX=disabled
查看 SELINUX 状态:
1) /usr/sbin/sestatus -v
SELinux status: enabled(enabled:开启;disabled:关闭)
2) 使用命令:getenforce
1)在hadoop102的/opt目录下创建module和software文件夹
2)将jdk-8u144-linux-x64.tar.gz导入到hadoop102的/opt/software目录下
3)在Linux系统下的opt目录中查看软件包是否导入成功
4)解压JDK到/opt/module目录下: [root@node61 software]# tar -zxvf jdk-8u181-linux-x64.tar.gz -C /opt/module/
5)配置JDK环境变量
(1)先获取JDK路径::/opt/module/jdk1.8.0_181
(2)打开/etc/profile文件:vi /etc/profile
在profile文件末尾添加JDK路径
- #JAVA_HOME
- export JAVA_HOME=/opt/module/jdk1.8.0_181
- export PATH=$PATH:$JAVA_HOME/bin
(3)保存后退出: :wq
(4)让修改后的文件生效:source /etc/profile
6)测试JDK是否安装成功:[root@node61 ~]# java -version
7)将node61中的JDK和环境变量分发到node62、node63两台主机
- [root@node61 ~]# scp -r /opt/module/ 192.168.18.162:/opt/module/
- [root@node61 ~]# scp -r /opt/module/ 192.168.18.163:/opt/module/
- [root@node61 ~]# scp -r /etc/profile 192.168.18.162:/etc/profile
- [root@node61 ~]# scp -r /etc/profile 192.168.18.163:/etc/profile
配置host文件:[root@node61 ~]# vi /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.18.161 node61
192.168.18.162 node62
192.168.18.163 node63[root@node61 ~]# scp /etc/hosts 192.168.18.163:/etc/hosts
[root@node61 ~]# scp /etc/hosts 192.168.18.163:/etc/hosts
配置node61对node61、node62、node63三台主机的免密登陆
1)生成公钥和私钥:
[root@node61 ~]# ssh-keygen -t rsa
然后敲(三个回车),就会生成两个文件id_rsa(私钥)、id_rsa.pub(公钥)
2)将公钥拷贝到要免密登录的目标机器上
同样配置其它两台机器的免密登录
[root@node61 ~]# yum install -y wget
[root@node61 ~]# mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bk
[root@node61 ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.rep
[root@node61 ~]# yum makecache #把服务器的包下载到本地缓存
[root@node61 ~]# yum install -y ntp
[root@node61 ~]# chkconfig --list ntpd
[root@node61 ~]# chkconfig ntpd on
[root@node61 ~]# service ntpd start
如果不关闭transparent_hugepage,HDFS会因为这个性能严重受影响。
关闭transparent_hugepage方法是:
[root@node61 ~]# vim /etc/grub.conf
添加 transparent_hugepage=never[root@node61 ~]# vim /etc/rc.local
添加:
if test -f /sys/kernel/mm/transparent_hugepage/defrag; then
echo never > /sys/kernel/mm/transparent_hugepage/defrag
fi
if test -f /sys/kernel/mm/transparent_hugepage/enabled; then
echo never > /sys/kernel/mm/transparent_hugepage/enabled
fi
exit 0
重启之后,用下面的命令检查:
[root@node61 yum.repos.d]#
cat /sys/kernel/mm/redhat_transparent_hugepage/enabledalways madvise [never]
有 [never]则表示THP被禁用
设定用户所创建目录的初始权限:[root@node61 ~]# umask 0022
修改文件:vi /etc/yum/pluginconf.d/refresh-packagekit.conf
新增:enabled=0
注意:以下操作主节点操作即可
制作本地源是因为在线安装Ambari太慢。制作本地源只需在主节点上进行。
3.1.1 配置HTTPD 服务
配置HTTPD 服务到系统层使其随系统自动启动
[root@node61 ~]# yum list installed | grep httpd
[root@node61 ~]# yum install -y httpd[root@node61 ~]# systemctl status httpd.service
[root@node61 ~]# systemctl enable httpd.service
3.1.2 安装工具
安装本地源制作相关工具
[root@node61 ~]# yum install yum-utils createrepo yum-plugin-priorities -y
[root@hadoop102 ~]# vi /etc/yum/pluginconf.d/priorities.conf添加gpgcheck=0(关闭权限检查)
3.1.3 将下载的3个tar包解压
使用wget获取,实在太慢,我是这样做的,先用迅雷下载到本地,然后才上传到服务器。
注意一下,是否下载完整:
[root@node61 software]# tar -zxvf /opt/software/ambari-2.7.3.0-centos7.tar.gz -C /var/www/html/
[root@node61 software]# mkdir -p /var/www/html/hdp
[root@node61 software]# tar -zxvf /opt/software/HDP-3.1.0.0-centos7-rpm.tar.gz -C /var/www/html/hdp
[root@node61 software]# tar -zxvf /opt/software/HDP-UTILS-1.1.0.22-centos7.tar.gz -C /var/www/html/hdp[root@node61 software]# tar -zxvf /opt/software/HDP-GPL-3.1.0.0-centos7-gpl.tar.gz -C /var/www/html/hdp
注:各级目录的用户权限一致 ,否者容易访问不到([root@node61 centos7]# chown root:root ./2.7.3.0-139/ -R)
3.1.4 创建本地源
[root@node61 software]# cd /var/www/html/
[root@node61 html]# createrepo ./
3.1.5 将Ambari存储库文件下载到安装主机上的目录中
[root@node61 html]# wget -nv http://public-repo-1.hortonworks.com/ambari/centos7/2.x/updates/2.7.3.0/ambari.repo -O /etc/yum.repos.d/ambari.repo
2020-03-15 00:36:19 URL:http://public-repo-1.hortonworks.com/ambari/centos7/2.x/updates/2.7.3.0/ambari.repo [376/376] -> "/etc/yum.repos.d/ambari.repo" [1]
[root@node61 html]#
3.1.6 修改配置文件,配置为本地源
[root@node61 html]# vi /etc/yum.repos.d/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://node61/ambari/centos7/2.7.3.0-139/
gpgcheck=0
gpgkey=http://node61/ambari/centos7/2.7.3.0-139/RPM-GPG-KEY/RPM-GPG-KEY-Jenkins
enabled=1
priority=1
[root@node61 html]# vci /var/www/html/hdp/HDP-UTILS/centos7/1.1.0.22/hdp-util.repo
[HDP-UTILS-1.1.0.22]
name=Hortonworks Data Platform Utils Version - HDP-UTILS-1.1.0.22
baseurl=http://node61/hdp/HDP-UTILS/centos7/1.1.0.22/
gpgcheck=0
enabled=1
priority=1
[root@node61 html]# vi /var/www/html/hdp/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://node61/hdp/HDP/centos7/3.1.0.0-78/
gpgcheck=0
gpgkey=http://node61/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://node61/hdp/HDP-UTILS/centos7/1.1.0.22/
gpgcheck=0
gpgkey=http://node61/hdp/HDP-UTILS/centos7/1.1.0.22/RPM-GPG-KEY/RPM-GPG-KEY-Jenkins
enabled=1
priority=1
[root@node61 3.1.0.0-78]# vi /var/www/html/hdp/HDP-GPL/centos7/3.1.0.0-78/hdp.gpl.repo
#VERSION_NUMBER=3.1.0.0-78
[HDP-GPL-3.1.0.0]
name=HDP-GPL Version - HDP-GPL-3.1.0.0
baseurl=http://node61/hdp/HDP-GPL/centos7/3.1.0.0-78/
gpgcheck=0
gpgkey=http://node61/hdp/HDP-GPL/centos7/3.1.0.0-78/RPM-GPG-KEY/RPM-GPG-KEY-Jenkins
enabled=1
priority=1
查看Ambari 与 HDP 资源的资源库。
也可以打开浏览器查看一下:
Ambari使用的默认数据库是PostgreSQL,用于存储安装元数据,可以使用自己安装MySQL数据库作为Ambari元数据库。
注意:一定要用root用户操作如下步骤;先卸载MySQL再安装
参考:https://lixinkuan.blog.csdn.net/article/details/99699411
1)安装ambari-server:[root@node61 ~]# yum install ambari-server
2) 拷贝mysql驱动
将mysql-connector-java.jar复制到/usr/share/java目录下并改名为mysql-connector-java.jar
[root@node61 software]# mkdir /usr/share/java
[root@node61 software]# cp ./mysql-connector-java.jar /usr/share/java/
将mysql-connector-java.jar复制到/var/lib/ambari-server/resources目录下并改名为mysql-jdbc-driver.jar
[root@node61 software]# cp /usr/share/java/mysql-connector-java.jar /var/lib/ambari-server/resources/mysql-jdbc-driver.jar
修改ambari.properties文件
[root@node61 software]# vi /etc/ambari-server/conf/ambari.properties
添加:server.jdbc.driver.path=/usr/share/java/mysql-connector-java.jar
1)创建ambari库
[root@node61 mysql-libs]# rpm -ivh MySQL-client-5.6.24-1.el6.x86_64.rpm
准备中... ################################# [100%]
正在升级/安装...
1:MySQL-client-5.6.24-1.el6 ################################# [100%]
[root@node61 mysql-libs]#
[root@node61 mysql-libs]#
[root@node61 mysql-libs]# mysql -h 192.168.18.102 -P 3306 -u root -p123mysql> create database ambari;
2)使用Ambari自带脚本创建表
mysql> use ambari;
Database changed
mysql> source /var/lib/ambari-server/resources/Ambari-DDL-MySQL-CREATE.sql;
Query OK, 0 rows affected (0.01 sec)Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
执行:[root@node61 ~]# 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用户
3)设置JDK。输入:2
Checking JDK...
[1] Oracle JDK 1.8 + Java Cryptography Extension (JCE) Policy Files 8
[2] Custom JDK
==============================================================================
Enter choice (1): 2
如果上面选择3自定义JDK,则需要设置JAVA_HOME。输入:/opt/module/jdk1.8.0_144
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/module/jdk1.8.0_18
Validating JDK on Ambari Server...done.
Completing setup...
4)数据库配置。选择:y
Configuring database...
Enter advanced database configuration [y/n] (n)? y
5)选择数据库类型。输入:3
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
6)设置数据库的具体配置信息,根据实际情况输入,如果和括号内相同,则可以直接回车。如果想重命名,就输入。
Hostname (localhost): 192.168.18.102
Port (3306):
Database name (ambari):
Username (ambari): root
Enter Database Password (bigdata):
Re-enter password:
Configuring ambari database...
7)将Ambari数据库脚本导入到数据库
WARNING: Before starting Ambari Server, you must run the following DDL directly from the database shell 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
Extracting system views...
ambari-admin-2.7.3.0.139.jar
....
Ambari repo file contains latest json url http://public-repo-1.hortonworks.com/HDP/hdp_urlinfo.json, updating stacks repoinfos with it...
Adjusting ambari-server permissions and ownership...
Ambari Server 'setup' completed successfully.
如果使用自己定义的数据库,必须在启动Ambari服务之前导入Ambari的sql脚本。