安装前先安装好 Centos 7.2, jdk-8u91, mysql5.7.13
主节点里root用户登录执行如下步骤
ssh-keygen cd ~/.ssh/ cat id_rsa.pub >>authorized_keys chmod ~/.ssh chmod ~/.ssh/authorized_keys先在从节点登录root执行命令
mkdir ~/.ssh/分发主节点里配置好的authorized_keys到各从节点
scp /root/.ssh/authorized_keys root@172.31.83.172:/root/.ssh/authorized_keys只在主节点操作
添加ambari安装、运行用户和用户组,也可以不创建新用户,直接使用root或者系统其他账号
adduser ambari passwd ambari所有集群上节点都需要操作
Centos 7 命令
yum install ntp systemctl is-enabled ntpd systemctl enable ntpd systemctl start ntpdCentos 6 命令
yum install ntpd chkconfig --list ntpd chkconfig ntpd service ntpd start所有节点都要设置
ambari在安装时需要配置全域名,所以需要检查DNS。为了减轻DNS的负担, 建议在节点里用 Name Service Caching Daemon (NSCD)
vi /etc/hosts 172.31.83.171 SY-001 SY-001.hadoop 172.31.83.172 SY-002 SY-002.hadoop 172.31.83.173 SY-003 SY-003.hadoop每台节点里配置FQDN,如下以主节点为例
vi /etc/sysconfig/network NETWORKING=yes HOSTNAME=SY-001.hadoop所有节点都要设置
Centos 7 命令
systemctl disable firewalld systemctl stop firewalldCentos 6 命令
chkconfig iptables off /etc/init.d/iptables stop所有节点都要设置
查看SELinux状态:
sestatus如果SELinux status参数为enabled即为开启状态 SELinux status: enabled
临时关闭,不用重启机器:
setenforce 0修改配置文件需要重启机器:
vi /etc/sysconfig/selinux SELINUX=disabled制作本地源只需在主节点上进行即可
安装HTTP 服务器,允许 http 服务通过防火墙(永久)
yum install httpd firewall-cmd --add-service=http firewall-cmd --permanent --add-service=http添加 Apache 服务到系统层使其随系统自动启动
systemctl start httpd.service systemctl enable httpd.service下载 Ambari 2.2.2 , HDP 2.4.2 的安装资源,本次安装是在Centos 7 上,只列出centos7的资源,其他系统的请现在对用系统的资源
Ambari 2.2.2 下载资源
OSFormatURLCentOS 7Base URLhttp://public-repo-1.hortonworks.com/ambari/centos7/2.x/updates/2.2.2.0CentOS 7Repo Filehttp://public-repo-1.hortonworks.com/ambari/centos6/2.x/updates/2.2.2.0/ambari.repoCentOS 7Tarball md5 aschttp://public-repo-1.hortonworks.com/ambari/centos7/2.x/updates/2.2.2.0/ambari-2.2.2.0-centos7.tar.gzHDP 2.4.2 下载资源
OSRepository NameFormatURLCentOS 7HDPBase URLhttp://public-repo-1.hortonworks.com/HDP/centos7/2.x/updates/2.4.2.0CentOS 7HDPRepo Filehttp://public-repo-1.hortonworks.com/HDP/centos7/2.x/updates/2.4.2.0/hdp.repoCentOS 7HDPTarball md5 aschttp://public-repo-1.hortonworks.com/HDP/centos7/2.x/updates/2.4.2.0/HDP-2.4.2.0-centos7-rpm.tar.gzCentOS 7HDP-UTILSBase URLhttp://public-repo-1.hortonworks.com/HDP-UTILS-1.1.0.20/repos/centos7CentOS 7HDP-UTILSRepo Filehttp://public-repo-1.hortonworks.com/HDP-UTILS-1.1.0.20/repos/centos7/HDP-UTILS-1.1.0.20-centos7.tar.gz下载上面列表的中的压缩包, 需要下载的压缩包如下:
Ambari 2.2.2 http://public-repo-1.hortonworks.com/HDP/centos7/2.x/updates/2.4.0.0/HDP-2.4.0.0-centos7-rpm.tar.gz HDP 2.4.2 http://public-repo-1.hortonworks.com/ambari/centos7/2.x/updates/2.2.2.0/ambari-2.2.2.0-centos7.tar.gz HDP-UTILS 1.1.0 http://public-repo-1.hortonworks.com/HDP-UTILS-1.1.0.20/repos/centos7/HDP-UTILS-1.1.0.20-centos7.tar.gz在httpd网站根目录,默认是即/var/www/html/,创建目录ambari, 并且将下载的压缩包解压到/var/www/html/ambari目录
cd /var/www/html/ mkdir ambari cd /var/www/html/ambari/ tar -zxvf ambari-2.2.2.0-centos7.tar.gz tar -zxvf HDP-2.4.2.0-centos7-rpm.tar.gz tar -zxvf HDP-UTILS-1.1.0.20-centos7.tar.gz验证httd网站是否可用,可以使用links 命令或者浏览器直接访问下面的地址:
links http://172.31.83.171/ambari/结果如下:
首先下载上面资源列表中的相应repo文件,修改其中的URL为本地的地址,相关配置如下:
ambari.repo
#VERSION_NUMBER=2.2.2.0-460 [Updates-ambari-2.2.2.0] name=ambari-2.2.2.0 - Updates baseurl=http://172.31.83.171/ambari/AMBARI-2.2.2.0/centos7/2.2.2.0-460 gpgcheck=1 gpgkey=http://172.31.83.171/ambari/AMBARI-2.2.2.0/centos7/2.2.2.0-460/RPM-GPG-KEY/RPM-GPG-KEY-Jenkins enabled=1 priority=1hdp.repo
#VERSION_NUMBER=2.4.2.0-258 [HDP-2.4.2.0] name=HDP Version - HDP-2.4.2.0 baseurl=http://172.31.83.171/ambari/HDP/centos7/2.x/updates/2.4.2.0 gpgcheck=1 gpgkey=http://172.31.83.171/ambari/HDP/centos7/2.x/updates/2.4.2.0/RPM-GPG-KEY/RPM-GPG-KEY-Jenkins enabled=1 priority=1 [HDP-UTILS-1.1.0.20] name=HDP Utils Version - HDP-UTILS-1.1.0.20 baseurl=http://172.31.83.171/ambari/HDP-UTILS-1.1.0.20/repos/centos7 gpgcheck=1 gpgkey=http://172.31.83.171/ambari/HDP/centos7/2.x/updates/2.4.2.0/RPM-GPG-KEY/RPM-GPG-KEY-Jenkins enabled=1 priority=1将上面的修改过的源放到/etc/yum.repos.d/下面
yum clean all yum list update yum makecache yum repolistAmbari安装会将安装等信息写入数据库,建议使用自己安装的Mysql数据库,也可以不安装而使用默认数据库PostgreSQL
Mysql数据库安装过程请参考下面文章:
http://blog.csdn.net/lochy/article/details/51721319
安装完成后创建ambari数据库及用户,登录root用户执行下面语句:
create database ambari character set utf8 ; CREATE USER 'ambari'@'%'IDENTIFIED BY 'Ambari-123'; GRANT ALL PRIVILEGES ON *.* TO 'ambari'@'%'; FLUSH PRIVILEGES;如果要安装Hive,再创建Hive数据库和用户 再执行下面的语句:
create database hive character set utf8 ; CREATE USER 'hive'@'%'IDENTIFIED BY 'Hive-123'; GRANT ALL PRIVILEGES ON *.* TO 'hive'@'%'; FLUSH PRIVILEGES;如果要安装Oozie,再创建Oozie数据库和用户 再执行下面的语句:
create database oozie character set utf8 ; CREATE USER 'oozie'@'%'IDENTIFIED BY 'Oozie-123'; GRANT ALL PRIVILEGES ON *.* TO 'oozie'@'%'; FLUSH PRIVILEGES;安装mysql jdbc 驱动
yum install mysql-connector-java安装解压版JDK,先到官网下载jdk-8u91-linux-x64.tar.gz ,再执行下面命令:
tar -zxvf jdk-8u91-linux-x64.tar.gz -C /opt/java/ vim /etc/profile export JAVA_HOME=/opt/java/jdk1.8.0_91 export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar PATH=$PATH:$HOME/bin:$JAVA_HOME/bin source /etc/profile4.1.1安装Ambari
yum install ambari-server4.1.2配置Ambari
ambari-server setup下面是配置执行流程,按照提示操作
1.检查SELinux是否关闭,如果关闭不用操作
Using python /usr/bin/python Setup ambari-server Checking SELinux... SELinux status is 'disabled'2.提示是否自定义设置。输入:y
Customize user account for ambari-server daemon [y/n] (n)? y3.ambari-server 账号。输入:ambari
Enter user account for ambari-server daemon (root):ambari Adjusting ambari-server permissions and ownership...4.检查防火墙,如果关闭则不用操作
Checking firewall status... Redirecting to /bin/systemctl status iptables.service5.设置JDK。输入:3
Checking JDK... Do you want to change Oracle JDK [y/n] (n)? y [] Oracle JDK 1.8 + Java Cryptography Extension (JCE) Policy Files 8 [] Oracle JDK 1.7 + Java Cryptography Extension (JCE) Policy Files 7 [] Custom JDK ============================================================================== Enter choice (1): 36.如果上面选择3自定义JDK,则需要设置JAVA_HOME。输入:/opt/java/jdk1.8.0_91
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/java/jdk1.8.0_91 Validating JDK on Ambari Server...done. Completing setup...7.数据库配置。选择:y
Configuring database... Enter advanced database configuration [y/n] (n)? y8.选择数据库类型。输入: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): 39.设置数据库的具体配置信息,根据实际情况输入,如果和括号内相同,则可以直接回车。
Hostname (localhost): Port (): Database name (ambari): Username (ambari): Enter Database Password (Ambari-123):10.提示必须安装MySQL JDBC,回车结束ambari配置
WARNING: Before starting Ambari Server, you must copy the MySQL JDBC driver JAR file to /usr/share/java. Press <enter> to continue.11.将Ambari数据库脚本导入到数据库
如果使用自己定义的数据库,必须在启动Ambari服务之前导入Ambari的sql脚本
用Ambari用户(上面设置的用户)登录mysql mysql -u ambari -p use ambari source /var/lib/ambari-server/resources/Ambari-DDL-MySQL-CREATE.sql4.1.3启动Amabri
执行启动命令,启动Ambari服务
ambari-server start成功启动后在浏览器输入Ambari地址:
http://sy-001.hadoop:8080/出现登录界面,默认管理员账户登录, 账户:admin 密码:admin
登录成功后出现下面的界面,至此Ambari的安装成功
点击上面登录成功页面的Launch Install Wizard 按钮进行集群配置
4.2.1设置集群名称
4.2.2设置HDP 安装源
选择HDP2.4 ,并且设置Advanced Repository Options 的信息,本次使用本地源,所以修改对用系统的安装源为本地源地址。
4.2.3设置集群机器
4.2.4 Host 确认
确认前面配置集群中hosts列表 中的机器是否都可用,也可以移除相关机器,集群中机器Success后进行下一步操作。
4.2.5 选择要安装的服务
4.2.6各个服务Master配置
4.2.6 服务的Slaves 和 Clients节配置
4.2.7 服务的客制化配置
4.2.8 显示配置信息
4.2.9开始安装
安装各个服务,并且完成安装后会启动相关服务,安装过程比较长,如果中途出现错误,请根据具体提示或者log进行操作。
安装过程可以随时查看每个节点的安装进度及日志 全部安装成功界面如下
4.2.10安装完成