【Ambari】ambari-2.7.5.0集群保姆级安装教程

ambari 集群安装

本文都是基于centos 7

     Icon name: computer-vm
       Chassis: vm
    Machine ID: f558be45108255582ad8d58b6942b15e
       Boot ID: c1758553408341f8a76be977d7c3db08
Virtualization: kvm
Operating System: CentOS Linux 7 (Core)
   CPE OS Name: cpe:/o:centos:centos:7
        Kernel: Linux 3.10.0-693.el7.x86_64
  Architecture: x86-64

1. 硬件环境

ip hostname 说明
192.168.1.152 abc-1 8C64G
192.168.1.153 abc-2 8C64G
192.168.1.154 abc-3 8C64G

2. 软件环境

软件名称 版本号
jdk 1.8.0_291
mysql 5.7.23
ambari ambari-2.7.5.0
hdp HDP-3.1.5.6091

3. 准备待安装的ip列表

准备一个ip列表供后续使用 /root/ip.txt

192.168.1.152
192.168.1.153
192.168.1.154

准备一个ip-域名映射列表供后续使用 /root/ip_host.txt

192.168.1.152 abc-1
192.168.1.153 abc-2
192.168.1.154 abc-3

4. 安装基本工具

在节点abc-1上安装远程操作工具

yum -y install sshpass
cat /root/ip.txt | xargs -i sshpass -p xxx ssh root@{} "yum -y install wget"

5. 修改主机名和hosts文件

直接远程连接某台主机: sshpass -p xxx ssh root@ip

本地执行远程机器的命令:sshpass -p xxx ssh root@ip “ethtool eth0”

从远程主机上拉取文件到本地: sshpass -p xxx scp root@ip:/home/test /tmp/

配置 主机名

#!/usr/bin/env bash
hosts=/root/ip_host.txt

while read line
do
    ip=`echo ${line} | awk -F " " '{print $1}'`
    hostname=`echo ${line} | awk -F " " '{print $2}'`
    sshpass -p xxx ssh root@${ip} "hostnamectl set-hostname ${hostname}"
done < ${hosts}

配置 hosts文件

在 abc-1 主机上配置 /etc/hosts

127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

192.168.1.152 abc-1
192.168.1.153 abc-2
192.168.1.154 abc-3

分发 hosts

cat /root/ip.txt | xargs -i sshpass -p xxx scp /etc/hosts root@{}:/etc/

6. 配置免密登录

cat /root/ip.txt | xargs -i sshpass -p xxx ssh root@{} "ssh-keygen -t rsa"

cat /root/ip.txt | xargs -i sshpass -p xxx ssh root@{} "ssh-copy-id -i /root/.ssh/id_rsa.pub abc-1"
cat /root/ip.txt | xargs -i sshpass -p xxx ssh root@{} "ssh-copy-id -i /root/.ssh/id_rsa.pub abc-2"
cat /root/ip.txt | xargs -i sshpass -p xxx ssh root@{} "ssh-copy-id -i /root/.ssh/id_rsa.pub abc-3"

7. 关闭防火墙和selinux

防火墙设置

# 查看防火墙状态
systemctl status firewalld
# 查看开机是否启动防火墙服务
systemctl is-enabled firewalld
# 关闭防火墙
systemctl stop firewalld
systemctl disable firewalld
# 再次查看防火墙状态和开机防火墙是否启动
systemctl status firewalld
systemctl is-enabled firewalld

禁用selinux

# 永久性关闭selinux(重启服务器生效)
sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
# 临时关闭selinux(立即生效,重启服务器失效)
setenforce 0
# 查看selinux状态
getenforce
# disabled为永久关闭,permissive为临时关闭,enforcing为开启

7. 安装JDK

# 下载 jdk-8u291-linux-x64.tar.gz

# 解压
tar -xvzf jdk-8u291-linux-x64.tar.gz

cp -r jdk1.8.0_291 /data/jdk1.8.0_291

cat /root/ip.txt | xargs -i sshpass -p xxx scp -r /data/jdk1.8.0_291 root@{}:/data

cat /root/ip.txt | xargs -i sshpass -p xxx ssh {} "echo 'export JAVA_HOME=/data/jdk1.8.0_291' >> /etc/profile "

cat /root/ip.txt | xargs -i sshpass -p xxx ssh {} "echo 'export PATH=$JAVA_HOME/bin:$PATH' >> /etc/profile "

cat /root/ip.txt | xargs -i sshpass -p xxx ssh {} "source /etc/profile"


#cat >> /etc/profile <

8. 配置本地yum

在 abc-3 主机下

安装httpd

ssh abc-3

yum install -y createrepo httpd

# 修改端口号为 6080
sed -i 's/Listen 80/Listen 6080/g' conf/httpd.conf

# 在httpd 资源目录下配置 ambari包目录,供访问
cat >> /etc/httpd/conf.d/ambari.conf <
    Options Indexes FollowSymLinks
    IndexOptions NameWidth=* DescriptionWidth=* FoldersFirst
    IndexOptions SuppressIcon HTMLTable Charset=UTF-8 SuppressHTMLPreamble
    Order allow,deny
    Allow from all
    Require all granted

EOF

# 重启
systemctl enable httpd.service && systemctl restart httpd.service

拷贝ambari、HDP包到/data/ambari-yum

安装包都在 abc-3 主机的 /data/ambari目录下

[root@abc-3 ambari]# cd /data/ambari
[root@abc-3 ambari]# ll
total 11569460
-rw-r--r-- 1 root root 2062874048 Sep  3 10:06 ambari-2.7.5.0-centos7.tar.gz
-rw-r--r-- 1 root root 9693460093 Sep  3 10:08 HDP-3.1.5.6091-centos7-rpm.tar.gz
-rw-r--r-- 1 root root     161653 Sep  3 10:08 HDP-GPL-3.1.5.6091-centos7-gpl.tar.gz
-rw-r--r-- 1 root root        567 Sep  3 10:06 hdp.repo
-rw-r--r-- 1 root root   90606616 Sep  3 10:06 HDP-UTILS-1.1.0.22-centos7.tar.gz
-rw-r--r-- 1 root root         18 Sep  3 10:06 ips

开始解压,并拷贝到 /data/ambari-yum目录下

[root@abc-3 ambari]# cd /data/ambari
[root@abc-3 ambari]# tar -xvzf ambari-2.7.5.0-centos7.tar.gz
[root@abc-3 ambari]# mv ambari /data/ambari-yum/
[root@abc-3 ambari]# tar -xvzf HDP-3.1.5.6091-centos7-rpm.tar.gz
[root@abc-3 ambari]# mv HDP /data/ambari-yum/
[root@abc-3 ambari]# tar -xvzf HDP-UTILS-1.1.0.22-centos7.tar.gz
[root@abc-3 ambari]# mv HDP-UTILS /data/ambari-yum/

[root@abc-3 ambari]# cd /etc/yum.repos.d/

cat >> /etc/yum.repos.d/ambari.repo <> /etc/yum.repos.d/hdp.repo <

检验下是否有ambari-server

[root@abc-3 ambari]# yum list | grep ambari-server

分发repo文件

[root@abc-3 ambari]# scp /etc/yum.repos.d/ambari.repo root@abc-1:/etc/yum.repos.d/
[root@abc-3 ambari]# scp /etc/yum.repos.d/hdp.repo root@abc-1:/etc/yum.repos.d/

[root@abc-3 ambari]# scp /etc/yum.repos.d/ambari.repo root@abc-2:/etc/yum.repos.d/
[root@abc-3 ambari]# scp /etc/yum.repos.d/hdp.repo root@abc-2:/etc/yum.repos.d/

cat /etc/hosts | awk 'NR>3 {print $1}' | head -n 3 | xargs -i ssh {} "yum clean all && yum makecache"

9. 安装mysql

安装mysql 此处省略,见其他文档

新增ambari用户并增加权限

mysql -habc-1 -uroot -p123456
CREATE USER 'ambari'@'%' IDENTIFIED BY 'ambari';
GRANT ALL PRIVILEGES ON *.* TO 'ambari'@'%';
FLUSH PRIVILEGES;

使用ambari用户登陆并创建数据库

mysql -habc-1 -uambari -pambari
CREATE DATABASE ambari;
exit;

10. 安装ambari-server

安装 ambari-server

[root@abc-1 ~]# yum install -y ambari-server

将mysql-connector-java.jar拷贝到/usr/share/java目录下

mkdir /usr/share/java/
cp ../maven/repo/mysql/mysql-connector-java/8.0.21/mysql-connector-java-8.0.21.jar /usr/share/java/

修改配置文件

echo server.jdbc.driver.path=/usr/share/java/mysql-connector-java.jar >> /etc/ambari-server/conf/ambari.properties

安装ambari-server

[root@abc-1 data]# ambari-server setup --jdbc-db=mysql --jdbc-driver=/usr/share/java/mysql-connector-java-8.0.21.jar

[root@abc-1 data]# 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...
Do you want to change Oracle JDK [y/n] (n)? y
[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: /data/jdk1.8.0_291
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 (3): 3
Hostname (192.168.1.152):
Port (3306):
Database name (ambari):
Username (ambari): root
Enter Database Password (ambari
):
Re-enter password:
Configuring ambari database...
Configuring remote database connection properties...
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 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.

初始化数据库

mysql -habc-1 -uambari -pambari
use ambari;
source /var/lib/ambari-server/resources/Ambari-DDL-MySQL-CREATE.sql

11. 启动ambari-server

ambari-server start

12. 访问ambari-server

登陆浏览器访问: http://abc-1:8080/  利用界面部署集群。

组件安装详见我的另外一篇文章

【Ambari】ambari组件安装

希望对正在查看文章的您有所帮助,记得关注、评论、收藏,谢谢您

你可能感兴趣的:(大数据,devops,服务运维部署,ambari,linux,运维)