Ambari 是 Apache Software Foundation 的一个顶级开源项目,是一个集中部署、管理、监控 Hadoop 分布式集群的工具。可是这里的 Hadoop 是一个广义概念,并不只仅指的是 Hadoop(HDFS、MapReduce),而是指 Hadoop 生态圈(包括 Spark、Hive、Hbase,Sqoop,Zookeeper、Flume 等),Ambari 可使 Hadoop 大数据软件更容易使用,且能够方便的集成咱们本身的服务让 Ambari 统一管理。html
这次采用HDP2.5版本java
集群hostname | 软件安装 |
---|---|
nn1 | ambari-agent,namenode,datanode,zookeeper |
nn2 | ambari-agent,namenode,datanode,zookeeper |
rm | ambari-server,resourcemanager,historyserver,datanode |
前提先下载好须要的离线包。
并将这些包上传到节点rm上。
须要的离线包介绍:node
ulimit -n 10000
永久更改,须要修改配置文件,且须要重启,建议和selinux关闭一块儿作完了,再作重启动做。python
vi /etc/security/limits.conf 添加 * soft nofile 10000 * hard nofile 10000
注意:后续步骤,使用的是ansible的命令,若是没有安装ansible,则请使用原始命令。
例: ansible all -m command -a 'systemctl stop firewalld'
等同于在每台主机上执行命令 systemctl stop firewalld
mysql
ansible安装与操做linux
修改hosts,增长你的集群信息,每台配置同样git
192.168.0.135 nn1.ambari nn1 192.168.0.136 nn2.ambari nn2 192.168.0.137 rm.ambari rm
在rm节点上,执行命令ssh-keygen
,直接敲enter键四次,而后再执行github
ssh-copy-id nn1 ssh-copy-id nn2 ssh-copy-id rm
ansible all -m command -a 'systemctl stop firewalld'
ansible all -m command -a 'systemctl disable firewalld'
web
修改/etc/selinux/config,改成SELINUX=disable,须要重启sql
一、解压包
cd /opt tar -zxvf jdk-8u111-linux-x64.tar.gz
二、在/etc/profile添加配置
export JAVA_HOME=/opt/jdk1.8.0_111 export PATH=$JAVA_HOME/bin:$PATH export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
三、复制jdk包和配置文件到nn一、nn2节点
scp -r jdk1.8.0_111 nn2:/opt/ scp /etc/profile nn2:/etc/ scp -r jdk1.8.0_111 nn1:/opt/ scp /etc/profile nn1:/etc/
四、验证一下 java -version
一、新建一个准备挂载的目录(为了后面方便httpd源,直接建立在httpd的默认目录上) mkdir -p /var/www/html/centos7
二、挂载镜像文件 mount -t iso9660 -o loop /opt/CentOS-7-x86_64-DVD-1511.iso /var/www/html/centos7
三、备份其余repo文件,构建离线源
cd /etc/yum.repos.d mkdir backup mv Centos-* backup touch centos-media.repo
在centos-media.repo写入如下内容
[centos7-media] name=Centos linux 7.0 baseurl=file:///var/www/html/centos7 enabled=1 gpgcheck=0
四、验证离线源是否可用。
yum clean all yum makecache
一、配置路径
cd /var/www/html mkdir ambari mkdir hdp
二、解压包到相应路径
tar -zxvf /opt/Ambari/ambari-2.4.1.0-centos7.tar.gz -C /var/www/html/ambari/ tar -zxvf /opt/Ambari/HDP-2.5.0.0-centos7-rpm.tar.gz -C /var/www/html/hdp/ tar -zxvf /opt/Ambari/HDP-UTILS-1.1.0.21-centos7.tar.gz -C /var/www/html/hdp/
三、构建离线源
3.一、 在rm节点上构建
ambari离线源 vi /etc/yum.repos.d/ambari.repo
[ambari-2.4.1.0] name=ambari-2.4.1.0 - Updates baseurl=http://rm/ambari/AMBARI-2.4.1.0/centos7/2.4.1.0-22 gpgcheck=0 #gpgkey=http://public-repo-1.hortonworks.com/ambari/centos7/RPM-GPG-KEY/RPM-GPG-KEY-Jenkins enabled=1 priority=1
hdp离线源 vi /etc/yum.repos.d/hdp.repo
[HDP-2.5] name=HDP-2.5 baseurl=http://rm/hdp/HDP/centos7 enabled=1 gpgcheck=0
hdp-utils离线源 vi /etc/yum.repos.d/hdp-utils.repo
[HDP-UTILS-1.1.0.21] name=HDP-UTILS-1.1.0.21 baseurl=http://rm/hdp/HDP-UTILS-1.1.0.21/repos/centos7 enabled=1 gpgcheck=0
一、安装 yum install httpd -y
二、修改配置 vi /etc/httpd/conf/httpd.conf
将图中标示的红色,分别修改成 ServerName rm:80
<Directory /> Options FollowSymLinks AllowOverride None Order allow,deny Allow from all </Directory>
三、启动httpd systemctl start httpd
systemctl enable httpd
四、验证一下,离线源是否可用了
在本身电脑打开浏览器,输入rm/centos7(前提本机须要配置好hosts),出现以下图,表示成功了。
ansible all -m yum -a "name=chrony"
在rm节点修改chrony的配置文件
在nn1和nn2节点上修改配置文件,只须要增长要同步的服务器便可
启动chrony服务 ansible all -m command -a 'systemctl start chronyd'
自行检查时间是否已经同步了。
一、安装 yum install ambari-server -y
二、配置 ambari-server setup
大多数照着默认往下走就行了。
[root@rm ~]# 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):root 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: /opt/jdk1.8.0_111 Validating JDK on Ambari Server...done. 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): 1 Database name (ambari): ambari Postgres schema (ambari): ambari Username (ambari): ambari Enter Database Password (bigdata): Invalid characters in password. Use only alphanumeric or _ or - characters Enter Database Password (bigdata): Default properties detected. Using built-in database. Configuring ambari database... Checking PostgreSQL... Running initdb: This may take up to a minute. Initializing database ... OK About to start PostgreSQL Configuring local database... Connecting to local database...done. Configuring PostgreSQL... Restarting PostgreSQL Extracting system views... ambari-admin-2.4.1.0.22.jar ........... Adjusting ambari-server permissions and ownership... Ambari Server 'setup' completed successfully.
三、启动 ambari-server start
做为ambari-agent的条件:
由于前面四个条件,在安装ambari-server的时候已经安装好了。
要作的工做只有配置离线源
离线源配置
删除默认repo rm -f /etc/yum.repos.d/*.repo
复制rm的离线源到其余节点
scp /etc/yum.repos.d/ambari.repo nn1:/etc/yum.repos.d/ scp /etc/yum.repos.d/ambari.repo nn2:/etc/yum.repos.d/ scp /etc/yum.repos.d/hdp.repo nn2:/etc/yum.repos.d/ scp /etc/yum.repos.d/hdp.repo nn1:/etc/yum.repos.d/ scp /etc/yum.repos.d/hdp-utils.repo nn1:/etc/yum.repos.d/ scp /etc/yum.repos.d/hdp-utils.repo nn2:/etc/yum.repos.d/
3.3 在nn1和nn2上验证一下
yum makecache
你须要从新配置前面提到的前置环境。
另外须要修改ambari-server的/etc/hosts,把新的机子加进来,而且执行ssh-copy-id $new_hostname
打开浏览器,输入ambari-server所在节点的IP/HostName:8080,接下来就是直接在界面上操做了。
注意一些坑就行了。
因为界面这边忘记截屏了,因此给个连接-部署一个Hadoop2.X集群做为参考。
resource_management.core.exceptions.Fail: Execution of '/usr/bin/yum -d 0 -e 0 -y install snappy-devel' returned 1. Error: Package: snappy-devel-1.0.5-1.el6.x86_64 (HDP-UTILS-1.1.0.21) Requires: snappy(x86-64) = 1.0.5-1.el6 Installed: snappy-1.1.0-3.el7.x86_64 (@anaconda) snappy(x86-64) = 1.1.0-3.el7 Available: snappy-1.0.5-1.el6.x86_64 (HDP-UTILS-1.1.0.21) snappy(x86-64) = 1.0.5-1.el6 You could try using --skip-broken to work around the problem You could try running: rpm -Va --nofiles --nodigest
卸载自带的snappy ansible all -m yum -a 'name=snappy state=removed'
安装snappy-devel ansible all -m yum -a 'name=snappy-devel'
这个很方便,基本10分钟就能够搭建一个测试集群,但美中不足的是,做者的源不是离线的,要搭建集群须要有网络环境。
一、安装docker
二、下载github docker ambari
github docker-ambari
三、根据网址上的readme文档,进行简单部署就行了
3.1 解压包 3.2 进入解压包目录 `. ambari-functions or source ambari-functions` 3.3 启动集群 `amb-start-cluster 3` 
做者在readme中提到
Ambari containers started by ambari-function are using bridge networking. This means that you will not be able to communicate with containers directly from host unless you specify the route to containers. You can do this with:
# Getting the IP of docker-machine or boot2docker docker-machine ip <name-of-docker-vm> # or boot2docker ip # Setting up the sudo route add -net 172.17.0.0/16 <docker-machine or boot2docker> # e.g: sudo route add -net 172.17.0.0/16 192.168.99.100
大致的意思就是能够经过本机能够经过配置路由来连通172.17.0.0的网络,也就是说做者并无把端口映射出来,我配置了本身的网络路由,但并不能连通。
后面是经过修改docker启动ambari-server的命令来启动ambari-server,而后输入宿主机IP:映射端口号,就能够访问做者建立的ambari-server镜像了。如图:
一、 先把ambari和HDP离线源放在宿主机上,并解压出来
二、 开始构建Dockerfile
准备文件以下
ambari.repo Dockerfile hdp.repo hdp-utils.repo httpd.conf jdk-8u111-linux-x64.tar.gz supervisord.conf
Dockerfile内容
FROM centos MAINTAINER linjk # 安装JDK ADD jdk-8u111-linux-x64.tar.gz /usr/local/src/ ENV JAVA_HOME=/usr/local/src/jdk1.8.0_111 ENV PATH=$PATH:$JAVA_HOME/bin ENV CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar # 安装httpd以及其余必要工具 RUN yum makecache Fast \ && yum install httpd openssh-server net-tools chrony -y # 安装supervisor RUN yum -y install python-setuptools \ && easy_install supervisor \ && mkdir -p /etc/supervisor COPY supervisord.conf /etc/supervisor/ COPY httpd.conf /etc/httpd/conf/httpd.conf RUN mkdir -p /var/www/html/centos/ \ && mkdir -p /var/www/html/ambari/ \ && mkdir -p /var/www/html/hdp/ COPY *.repo /etc/yum.repos.d/ # 安装mariadb和mariadb-server yum install -y mariadb mariadb-server mysql-connector-java EXPOSE 22 80 9001 8080 3306 CMD supervisord -c /etc/supervisor/supervisord.conf
ambari.repo内容
[ambari-2.4.1.0] name=ambari-2.4.1.0 - Updates baseurl=http://ambari-server/ambari/AMBARI-2.4.1.0/centos7/2.4.1.0-22 gpgcheck=0 #gpgkey=http://public-repo-1.hortonworks.com/ambari/centos7/RPM-GPG-KEY/RPM-GPG-KEY-Jenkins enabled=1 priority=1
hdp.repo内容
[HDP-2.5] name=HDP-2.5 baseurl=http://ambari-server/hdp/HDP/centos7 enabled=1 gpgcheck=0
hdp-utils.repo内容
[HDP-UTILS-1.1.0.21] name=HDP-UTILS-1.1.0.21 baseurl=http://ambari-server/hdp/HDP-UTILS-1.1.0.21/repos/centos7 enabled=1 gpgcheck=0
httpd.conf修改的内容
ServerName ambari-server:80 # # Deny access to the entirety of your server's filesystem. You must # explicitly permit access to web content directories in other # <Directory> blocks below. # <Directory /> Options FollowSymLinks AllowOverride None Order allow,deny Allow from all </Directory>
supervisor内容
unix_http_server] file=/var/run/supervisor.sock [supervisord] nodaemon=true [rpcinterface:supervisor] supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface [supervisorctl] serverurl=unix:///var/run/supervisor.sock [inet_http_server] port=*:9001 [program:sshd] command=/usr/sbin/sshd -D [program:httpd] command=/usr/sbin/httpd
三、 构建镜像ambari-server(以前压缩包放在/opt/ambari和/opt/hdp/下) docker run -d -P -v /opt/ambari/:/var/www/html/ambari/ -v /opt/hdp/:/var/www/html/hdp/ -h ambari-server --name as ambari-server /usr/sbin/init
四、 进入容器启动和配置mariaDB
4.一、 启动 systemctl start mariadb
4.二、 设置开机启动 systemctl enable mariadb
4.三、 配置 mysql_secure_installation
会出现一个交互界面,基本一路回车,设置密码界面
首先是设置密码,会提示先输入密码 Enter current password for root (enter for none):<–初次运行直接回车 设置密码 Set root password? [Y/n] <– 是否设置root用户密码,输入y并回车或直接回车 New password: <– 设置root用户的密码 Re-enter new password: <– 再输入一次你设置的密码 其余配置 Remove anonymous users? [Y/n] <– 是否删除匿名用户,回车 Disallow root login remotely? [Y/n] <–是否禁止root远程登陆,回车, Remove test database and access to it? [Y/n] <– 是否删除test数据库,回车 Reload privilege tables now? [Y/n] <– 是否从新加载权限表,回车
4.四、 (自选)配置mariadb的字符集 vi /etc/my.cnf
4.五、 添加用户设置权限
create database ambari; use ambari; CREATE USER 'ambari'@'%' IDENTIFIED BY 'bigdata'; GRANT ALL PRIVILEGES ON *.* TO 'ambari'@'%'; CREATE USER 'ambari'@'ambari-server' IDENTIFIED BY 'bigdata'; GRANT ALL PRIVILEGES ON *.* TO 'ambari'@'ambari-server';
五、 安装ambari-server并配置和启动
5.一、 安装 yum install ambari-server
5.二、 配置 ambari-server setup
出现交互界面
Using python /usr/bin/python Setup ambari-server Checking SELinux... WARNING: Could not run /usr/sbin/sestatus: OK Customize user account for ambari-server daemon [y/n] (n)? y Enter user account for ambari-server daemon (root):root Adjusting ambari-server permissions and ownership... Checking firewall status... 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 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 o Path to JAVA_HOME: /usr/local/src/jdk1.8.0_111 Validating JDK on Ambari Server...done. 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 (3): 3 Hostname (ambari-server): Port (3306): Database name (ambari): Username (ambari): Enter Database Password (bigdata): Configuring ambari database... Copying JDBC drivers to server resources... 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)? y Extracting system views... ambari-admin-2.4.1.0.22.jar ........... Adjusting ambari-server permissions and ownership... Ambari Server 'setup' completed successfully.
根据警告到mysql去执行sql语句,注意use ambari;
use ambari; source /var/lib/ambari-server/resources/Ambari-DDL-MySQL-CREATE.sql
验证一下,是否有生成一些ambari配置表
show tables;
六、 启动 ambari-server start
七、 验证 在浏览器打开 $宿主机IP:映射端口