其他分享
首页 > 其他分享> > Ambari2.7.1安装

Ambari2.7.1安装

作者:互联网

一、配置说明

1. 硬件环境

watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=

2. 软件环境

watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=

二、修改主机名和hosts文件

1. 修改主机名(三台主机都执行)
  1. vim /etc/hostname   # 该命令需要重启后生效

  2. # 还有另外一种方式,执行该命令后立即生效,只不过需要重启Xshell连接

  3. hostnamectl set-hostname node1.ambari.com

2. 修改hosts文件
  1. vim /etc/hosts

watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=

注:主机名修改后需要重启机器才可彻底生效。如果用户不想重启,可使用命令 hostnamectlset-hostname node1.ambari.com来修改主机名,可使用命令 hostname来检验主机名是否修改成功。这种修改方式只是暂时的,待机器重启后就恢复原样 localhost了。

三、关闭防火墙和selinux

1. 防火墙设置
  1. # 查看防火墙状态

  2. systemctl status firewalld

  3. # 查看开机是否启动防火墙服务

  4. systemctl is-enabled firewalld

  5. # 关闭防火墙

  6. systemctl stop firewalld

  7. systemctl disable firewalld

  8. # 再次查看防火墙状态和开机防火墙是否启动

  9. systemctl status firewalld

  10. systemctl is-enabled firewalld

2. 禁用selinux
  1. # 永久性关闭selinux(重启服务器生效)

  2. sed -i 's/SELINUX=enforcing/SELINUX =disabled/' /etc/selinux/config

  3. # 临时关闭selinux(立即生效,重启服务器失效)

  4. setenforce 0

  5. # 查看selinux状态

  6. getenforce

  7. # disabled为永久关闭,permissive为临时关闭,enforcing为开启

四、免密登陆

各个主机均执行以下操作:

  1. ## 生成密钥对

  2. ssh-keygen -t rsa   ## 一路回车即可

  3. ## 进入.ssh目录,如果目录不存在则创建

  4. cd ~/.ssh

  5. ## 将公钥导入至authorized_keys

  6. cat id_rsa.pub >> authorized_keys

  7. ## 修改文件权限

  8. chmod 700 ~/.ssh

  9. chmod 600 authorized_keys

在node1.ambari.com上执行:

  1. ## 配置主从互相免密登陆

  2. [root@node1 ~]# cat ~/.ssh/id_rsa.pub | ssh root@node2.ambari.com 'cat - >> ~/.ssh/authorized_keys'

  3. [root@node1 ~]# cat ~/.ssh/id_rsa.pub | ssh root@node3.ambari.com 'cat - >> ~/.ssh/authorized_keys'

  4. ssh node2.ambari.com

  5. ssh node3.ambari.com # 验证主机点是否可以免密登陆从节点,执行exit命令退出即可。

备注:要想实现多主机互相免密,可参考文章:Linux多台主机互相免密登陆

五、安装JDK

下载链接: https://pan.baidu.com/s/1rlqZejpZZqio9RPzgnGOEg 提取码: j47n ;内有 jdk-8u151-linux-x64.tar.gz和 mysql-connector-java.jar文件。

  1. # 编辑/etc/profile,文末插入以下内容:

  2. # set java

  3. export JAVA_HOME=/usr/java/jdk1.8.0_151

  4. export PATH=$JAVA_HOME/bin:$PATH

六、安装mysql

mysql5.7 centos7:

https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm

mysql5.7 centos6:

https://dev.mysql.com/get/mysql57-community-release-el6-11.noarch.rpm

mysql5.6 centos7:

https://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm

mysql5.6 centos6:

https://dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm

1. 检查本地资源库中是否有mysql的rpm包
  1. rpm -qa | grep mysql

  2. # 删除相关rpm包

  3. rpm -ev <rpm包名> --nodeps

2. 搭建mysql5.7的yum源
  1. # 下载mysql5.7的rpm包

  2. wget https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm

  3. # 安装第一步下载的rpm文件,安装成功后/etc/yum.repos.d/目录下会增加两个文件

  4. yum -y install mysql57-community-release-el7-11.noarch.rpm

  5. # 查看mysql57的安装源是否可用,如不可用请自行修改配置文件(/etc/yum.repos.d/mysql-community.repo)使mysql57下面的enable=1

  6. # 若有mysql其它版本的安装源可用,也请自行修改配置文件使其enable=0

  7. yum repolist enabled | grep mysql

3. 安装mysql
  1. yum install mysql-community-server

4. 设置mysql
  1. # 启动mysql服务

  2. service mysqld start

  3. # 查看root密码

  4. grep "password" /var/log/mysqld.log

  5. # 登陆mysql

  6. mysql -u root -p

  7. Enter password:

  8. # 为了可以设置简单密码

  9. set global validate_password_policy=0;

  10. set global validate_password_length=4;

  11. # 立即修改密码,执行其他操作报错:

  12. SET PASSWORD FOR 'root'@'localhost' = PASSWORD('newpass');

  13. # 我们创建密码为root123

5. 新增ambari用户并增加权限
  1. mysql -uroot -proot123

  2. CREATE USER 'ambari'@'%' IDENTIFIED BY 'ambari';

  3. GRANT ALL PRIVILEGES ON *.* TO 'ambari'@'%';

  4. CREATE USER 'ambari'@'localhost' IDENTIFIED BY 'ambari';

  5. GRANT ALL PRIVILEGES ON *.* TO 'ambari'@'localhost';

  6. CREATE USER 'ambari'@'node1.ambari.com' IDENTIFIED BY 'ambari';

  7. GRANT ALL PRIVILEGES ON *.* TO 'ambari'@'node1.ambari.com';  //本地主机名

  8. FLUSH PRIVILEGES;

注:删除用户命令:

  1. Delete FROM user Where User='your_user' and Host='your_host';

  2. FLUSH PRIVILEGES;

6. 使用ambari用户登陆并创建数据库
  1. mysql -uambari -pambari

  2. CREATE DATABASE ambari;

  3. exit;

七、设置时钟同步

自己写了一个脚本,前提条件是获取 /etc/hosts文件内的主机ip

watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=

脚本如下:

  1. #!/usr/bin/env bash

  2. host_list=$(sed -n '3,$p' /etc/hosts | awk '{print $1}')

  3. master_hostip=$(sed -n 3p /etc/hosts | awk '{print $1}')

  4. ips_no_host=$(sed -n '4,$p' /etc/hosts | awk '{print $1}')

  5.  

  6. # 遍历所有节点

  7. for host in $host_list

  8. do

  9.    # 设置时区

  10.    ssh $host ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

  11.    # 同步硬件时间

  12.    ssh $host hwclock --systohc

  13.    # 开机自启动

  14.    ssh $host echo service ntpd restart >> /etc/rc.d/rc.local

  15.    ssh $host echo "hwclock --systohc" >> /etc/rc.d/rc.local

  16.    ssh $host chmod +x /etc/rc.d/rc.local

  17.    # 安装ntp服务

  18.    ssh $host yum install -y -q ntp

  19. done

  20. # 主节点操作,修改配置文件

  21. sed -i -e '21 s/^/# /' -i -e '22 s/^/# /' -i -e '23 s/^/# /' -i -e '24 s/^/# /' /etc/ntp.conf

  22. echo server 127.127.1.0 >> /etc/ntp.conf

  23. echo fudge 127.127.1.0 stratum 10 >> /etc/ntp.conf

  24. service ntpd start

  25. # 从节点操作,开启ntp服务,使用ntpdate命令进行时钟同步

  26. for slave in $ips_no_host

  27. do

  28.    ssh $slave service ntpd start

  29.    ssh $slave ntpdate -u $master_hostip

  30. done

八、搭建yum本地源

1. 安装httpd和wget服务
  1. # 安装httpd

  2. yum -y install httpd.x86_64

  3. systemctl enable httpd.service

  4. systemctl start httpd.service

  5. # 安装wget

  6. yum -y install wget

2. 下载ambari和hdp包
  1. # 将tar包下载到/var/www/html

  2. cd /var/www/html

  3. wget http://public-repo-1.hortonworks.com/ambari/centos7/2.x/updates/2.7.1.0/ambari-2.7.1.0-centos7.tar.gz

  4. wget http://public-repo-1.hortonworks.com/HDP/centos7/3.x/updates/3.0.1.0/HDP-3.0.1.0-centos7-rpm.tar.gz

  5. wget http://public-repo-1.hortonworks.com/HDP-UTILS-1.1.0.22/repos/centos7/HDP-UTILS-1.1.0.22-centos7.tar.gz

  6. # 解压上面三个包

  7. tar zxvf ambari-2.7.1.0-centos7.tar.gz

  8. tar zxvf HDP-3.0.1.0-centos7-rpm.tar.gz

  9. tar zxvf HDP-UTILS-1.1.0.22-centos7.tar.gz

3. 新建repo文件
  1. [ambari]

  2. name=ambari

  3. baseurl=http://node1.ambari.com/CentOS-7/ambari-2.6.0.0

  4. enabled=1

  5. gpgcheck=0

  1. [HDP]

  2. name=HDP

  3. baseurl=http://node1.ambari.com/CentOS-7/HDP

  4. path=/

  5. enabled=1

  6. gpgcheck=0

  1. [HDP-UTILS]

  2. name=HDP-UTILS

  3. baseurl=http://liuyzh1.xdata/CentOS-7/HDP-UTILS

  4. path=/

  5. enabled=1

  6. gpgcheck=0

将以上文件放入 /etc/yum.repos.d/目录下。

九、在主节点安装ambari-server

1. 安装
  1. yum -y install ambari-server

2. 将mysql-connector-java.jar拷贝到/usr/share/java目录下
3. 修改配置文件
  1. echo server.jdbc.driver.path=/usr/share/java/mysql-connector-java.jar >> /etc/ambari-server/conf/ambari.properties

4. 安装ambari-server
  1. ambari-server setup

watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=

watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=

5. 初始化数据库
  1. mysql -uambari -pambari

  2. use ambari;

  3. source /var/lib/ambari-server/resources/Ambari-DDL-MySQL-CREATE.sql

6. 启动ambari-server
  1. ambari-server start

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

watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=

默认登陆账号/密码为:admin/admin。

 

watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=

标签:ambari,HDP,Ambari2.7,com,etc,ssh,mysql,安装
来源: https://blog.51cto.com/u_13193683/2994107