Ambari 搭建
基于华为云服务器,CentOS 7.x系统搭建
一、搭建前准备
1、修改主机名
#因为服务器默认主机名为t2 所以先修改主机名
#重启系统后生效
hostnamectl set-hostname xxx
#临时修改主机名
hostname xxx
2、配置服务器免密登陆
#在同一默认路径下进行 如~
ssh-keygen -t rsa
ssh-copy-id xxx
#配置本机免密登陆
ssh-copy-id -i ~/.ssh/id_rsa.pub
3、配置JDK环境
tar -zxvf jdk-8u181-linux-x64.tar.gz -C /user/java/jdk1.8.0
vim /etc/profile
export JAVA_HOME=/usr/java/jdk1.8.0_181
PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
#环境变量生效
source /etc/profile
4、配置单机版Mysql
#卸载系统自带mariadb
yum remove mariadb-libs -y
#下载解压mysql(不要使用mysql8.0版本 不兼容)
tar -xf mysql-5.7.30-1.el7.x86_64.rpm-bundle.tar
#安装软件包
yum localinstall mysql-community-client-5.7.30-1.el7.x86_64.rpm mysql-community-common-5.7.30-1.el7.x86_64.rpm mysql-community-devel-5.7.30-1.el7.x86_64.rpm mysql-community-libs-5.7.30-1.el7.x86_64.rpm mysql-community-libs-compat-5.7.30-1.el7.x86_64.rpm mysql-community-server-5.7.30-1.el7.x86_64.rpm -y
#配置mysql mysql配置文件如下图所示
#启动Mysql&配置开机自启动
service mysqld start
chkconfig mysqld on
#获取自动生成的密码
grep password /var/log/mysqld.log |awk -F 'root@localhost: ' '{print $2}'|tail -1
#mysql驱动文件 mysql-connector-java.jar 上传到服务器 /usr/share/java 下
--修改root密码并创建数据库以及授权
mysql -uroot -p --connect-expired-password -e "alter user 'root'@'localhost' identified by 'TS1qaz@WSX';
create database hive DEFAULT CHARACTER SET utf8;
create database oozie DEFAULT CHARACTER SET utf8;
create database ambari DEFAULT CHARACTER SET utf8;
create database ranger DEFAULT CHARACTER SET utf8;
create database rangerkms DEFAULT CHARACTER SET utf8;
create user 'root'@'%' identified by 'TS1qaz@WSX';
create user 'hive'@'%' identified by 'hiveTS1qaz@WSX';
create user 'oozie'@'%' identified by 'oozieTS1qaz@WSX';
create user 'ambari'@'%' identified by 'ambari_DL-1qaz';
create user 'rangeradmin'@'%' identified by 'rangeradmin1qaz@WSX';
create user 'rangerkms'@'%' identified by 'rangerkms1qaz@WSX';
USE mysql;
grant all on *.* TO 'root'@'%';
grant all on hive.* TO 'hive'@'%';
grant all on oozie.* TO 'oozie'@'%';
grant all on ambari.* TO 'ambari'@'%';
grant all on ranger.* TO 'rangeradmin'@'%';
grant all on rangerkms.* TO 'rangerkms'@'%';
FLUSH PRIVILEGES;
--修改mysql配置
set global validate_password_policy=0;
set global validate_password_mixed_case_count=0;
set global validate_password_number_count=3;
set global validate_password_special_char_count=0;
set global validate_password_length=3;
FLUSH PRIVILEGES;
5、配置本地yum源
#Ambari官网需要登录才能下载,把准备好的安装包上传到服务器制作一个本地yum源,后续安装直接使用本地yum源
#安装 Apache
sudo yum -y install httpd
#将 Apache 设置为开机启动
sudo systemctl enable httpd
#修改默认端口
vim /etc/httpd/conf/httpd.conf
#启动 关闭 状态
systemctl start httpd
systemctl stop httpd
systemctl status httpd
#在/var/www/html/ 下放置各安装包 或者解压缩在路径下
cd /var/www/html/
#yum 源配置完成
http://172.25.110.12:8099/HDP/centos7/3.1.5.0-152/
http://172.25.110.12:8099/HDP-GPL/centos7/3.1.5.0-152/
http://172.25.110.12:8099/HDP-UTILS/centos7/1.1.0.22/
#配置本地源
#/etc/yum.repos.d/目录下,创建 ambari.repo 文件 并将该分发到各个节点下
[ambari-repo]
name=ambari
#指向 yum 源的地址
baseurl=http://chery-0012:8099/ambari/centos7/2.7.5.0-72/
#若是 1 将对下载的 rpm 将进行 gpg 的校验,校验密钥就是 gpgkey,一般自己的 yum 源是不需要检测的。
gpgcheck=0
#enable=0 是指这个组不可用;enable=1 是指这个组可用;若是没写就默认可用。
enabled=1
二、安装 Ambari-Server
#ambari 停止 重新配置 配置 启动
ambari-server stop
ambari-server reset
ambari-server setup
ambari-server start
#安装 ambari-server
yum install -y ambari-server
#配置mysql包
ambari-server setup --jdbc-db=mysql --jdbc-driver=/usr/share/java/mysql-connector-java.jar
#开始配置
ambari-server setup
--登陆mysql
use ambari;
source /var/lib/ambari-server/resources/Ambari-DDL-MySQL-CREATE.sql;
三、安装 Ambari 集群
--启动 Ambari 默认端口 8080 用户名密码默认都是admin
ambari-server start
四、遇到的一点问题
1、
Caused by: java.sql.SQLException: null, message from server: "Host '172.25.110.12' is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts'"
解决:登陆mysql 将 max_connect_errors 调高解决
show global variables like 'max_connect_errors';
select * from performance_schema.host_cache
mysqld_safe --max_connect_errors=1000
flush hosts
2、
Ambari fails because previous action finished with non-zero exit code (255)
解决:1)经过检查是没有对本地配置免密登陆,本机ssh本机失败;2)检查 id_rsa.pub 密钥文件是否正确找到
ssh-copy-id -i /root/.ssh/id_rsa.pub