环境说明
名称 | 版本 |
---|---|
操作系统 | centos 7 |
Ambari | 2.7.3 |
HDP | 3.1.0 |
Oracle JDK | 1.8 |
机器配置
主机名称 | 备注 |
---|---|
repo.hdp.com | 仓库 |
ab1.hdp.com | 节点 ab1 |
ab2.hdp.com | 节点 ab2 |
ab3.hdp.com | 节点 ab3 |
am.hdp.com | 管理节点 |
所有机器的 hosts 文件修改如下(配置如下内容,并关闭防火墙,遇坑自动免疫):
172.xxx.xxx.xxx ab1.hdp.com
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
安装 ntpd 服务
yum install -y ntp
# 查看 ntpd 服务状态
chkconfig --list ntpd
# 设置开机启动
chkconfig ntpd on
# 启动服务
service ntpd start
关闭防火墙
# 关闭防火墙
$ systemctl stop firewalld
# 停止开机启动
$ systemctl disable firewalld
关闭 transparent_hugepage 功能
查看状态
cat /sys/kernel/mm/transparent_hugepage/enabled
开机自动修改
- 添加服务
通过命令 vi /etc/systemd/system/disable-thp.service
创建 disable-thp
服务,其内容如下:
[Unit]
Description=Disable Transparent Huge Pages (THP)
[Service]
Type=simple
ExecStart=/bin/sh -c "echo 'never' > /sys/kernel/mm/transparent_hugepage/enabled && echo 'never' > /sys/kernel/mm/transparent_hugepage/defrag"
[Install]
WantedBy=multi-user.target
- 启用服务
# 重新加载所有服务
$ systemctl daemon-reload
# 启动服务
$ systemctl start disable-thp
# 设置为开机启动
$ systemctl enable disable-thp
临时修改
# for hadoop , disable thp
echo never > /sys/kernel/mm/redhat_transparent_hugepage/enabled
echo never > /sys/kernel/mm/redhat_transparent_hugepage/defrag
参考 How to disable Transparent Huge Pages on CentOS
SSH 免密钥访问
- 主节点生产公钥
$ ssh-keygen -t rsa -P ''
- 子节点同步公钥
- 先将子节点
ip
放到/etc/hosts
中去即可
$ cat /etc/hosts
172.xxx.xxx.131 ab1.hdp.com
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
172.xxx.xxx.130 am.hdp.com
172.xxx.xxx.131 ab1.hdp.com
172.xxx.xxx.132 ab2.hdp.com
172.xxx.xxx.133 ab3.hdp.com
172.xxx.xxx.134 repo.hdp.com
将上述文件,同步发送到各个子节点。
- 同步主节点公钥
# ssh-copy-id -i root@<主机名>
$ ssh-copy-id -i root@am.hdp.com
$ ssh-copy-id -i root@ab1.hdp.com
$ ssh-copy-id -i root@ab2.hdp.com
$ ssh-copy-id -i root@ab3.hdp.com
$ ssh-copy-id -i root@repo.hdp.com
构建本地仓库
安装 NG 并配置相关的目录
# add the CentOS 7 EPEL repository
$ yum install epel-release
# install nginx
# 参考 https://www.digitalocean.com/community/tutorials/how-to-install-nginx-on-centos-7
$ yum install -y nginx
$ systemctl start nginx
$ systemctl enable nginx
配置 nginx ,将该机器配置为 repo.hdp.com 的域名, 并对 nginx 进行如下配置即可,通过命令 vi /etc/nginx/conf.d/repo.hdp.com.conf
创建文件,其内容如下:
server{
listen 80;
server_name repo.hdp.com; # 172.xxx.xxx.xxx;
root /data/www;
location / {
error_log /var/log/nginx/localhost_error.log notice;
# access_log /var/log/nginx/localhost_access.log custom_log;
# autoindex on; #开启目录浏览功能;
# autoindex_exact_size off; #关闭详细文件大小统计,让文件大小显示MB,GB单位,默认为b;
# autoindex_localtime on; #开启以服务器本地时区显示文件修改日期!
#proxy_redirect off;
proxy_set_header Host $http_host;
proxy_set_header cookie $http_cookie;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header TY-X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
proxy_set_header Connection "";
proxy_http_version 1.1;
# include black_list/black_list_forever;
allow all;
limit_conn_log_level info;
# limit_conn perip 100;
}
}
查看 nginx
当前用户命令 ps -ef | grep nginx
, 然后将 /data/www
切换为对应用户即可。
同步 hdp
源,从而做本地源安装,这里使用 hdp 3.1.0
,当前最高版本哦~
# 下载仓库基础包
$ mkdir /data/www/ambari -p && cd /data/www/ambari
# 下载 ambari 源
# 参考 https://docs.hortonworks.com/HDPDocuments/Ambari-2.7.3.0/bk_ambari-installation/content/ambari_repositories.html
$ wget http://public-repo-1.hortonworks.com/ambari/centos7/2.x/updates/2.7.3.0/ambari-2.7.3.0-centos7.tar.gz
$ tar xf ambari-2.7.3.0-centos7.tar.gz
# 下载 HDP 相关源
# 参考 https://docs.hortonworks.com/HDPDocuments/Ambari-2.7.3.0/bk_ambari-installation/content/hdp_31_repositories.html
$ wget http://public-repo-1.hortonworks.com/HDP/centos7/3.x/updates/3.1.0.0/HDP-3.1.0.0-centos7-rpm.tar.gz
$ tar xf HDP-3.1.0.0-centos7-rpm.tar.gz
$ wget http://public-repo-1.hortonworks.com/HDP-GPL/centos7/3.x/updates/3.1.0.0/HDP-GPL-3.1.0.0-centos7-gpl.tar.gz
$ tar xf HDP-GPL-3.1.0.0-centos7-gpl.tar.gz
$ wget http://public-repo-1.hortonworks.com/HDP-UTILS-1.1.0.22/repos/centos7/HDP-UTILS-1.1.0.22-centos7.tar.gz
$ mkdir HDP-UTILS-1.1.0.22/centos7 -p && cd HDP-UTILS-1.1.0.22/centos7 && tar xf HDP-UTILS-1.1.0.22-centos7.tar.gz
参考 Apache Ambari Installation
修改 ambari/centos7/2.7.3.0-139/ambari.repo
文件内容
#VERSION_NUMBER=2.7.3.0-139
[ambari-2.7.3.0]
#json.url = http://public-repo-1.hortonworks.com/HDP/hdp_urlinfo.json
name=ambari Version - ambari-2.7.3.0
baseurl=http://repo.hdp.com/ambari/centos7/2.7.3.0-139
gpgcheck=1
gpgkey=http://repo.hdp.com/ambari/centos7/2.7.3.0-139/RPM-GPG-KEY/RPM-GPG-KEY-Jenkins
enabled=1
priority=1
同样修改 hdp.repo
, 其内容如下:
#VERSION_NUMBER=3.1.0.0-78
[HDP-3.1.0.0]
name=HDP Version - HDP-3.1.0.0
baseurl=http://repo.hdp.com/HDP/centos7/3.1.0.0-78
gpgcheck=1
gpgkey=http://repo.hdp.com/HDP/centos7/3.1.0.0-78/RPM-GPG-KEY/RPM-GPG-KEY-Jenkins
enabled=1
priority=1
[HDP-UTILS-1.1.0.22]
name=HDP-UTILS Version - HDP-UTILS-1.1.0.22
baseurl=http://repo.hdp.com/HDP-UTILS/centos7/1.1.0.22
gpgcheck=1
gpgkey=http://repo.hdp.com/HDP-UTILS/centos7/1.1.0.22/RPM-GPG-KEY/RPM-GPG-KEY-Jenkins
enabled=1
priority=1
以及 hdp-util.repo
, 其内容如下:
[HDP-UTILS-1.1.0.22]
name=Hortonworks Data Platform Utils Version - HDP-UTILS-1.1.0.22
baseurl=http://repo.hdp.com/HDP-UTILS/centos7/1.1.0.22
gpgcheck=1
enabled=1
priority=1
由于在内网构建了 DNS 服务器,一下均采用域名进行配置
在 ambari-server
主机上执行如下命令进行安装:
# 从 repo 服务上拉取 repo 配置文件放置 /etc/yum.repos.d/ambari.repo
$ wget http://repo.hdp.com/ambari/centos7/2.7.3.0-139/ambari.repo
$ mv ambari.repo /etc/yum.repos.d/ambari.repo
$ yum install epel-release
# 安装 mysql client
$ yum install -y mysql-connector-java*
# 安装 ambari-server
$ yum install -y ambari-server
ambari 常用命令
# 初始化设置服务
# 依次按默认配置即可,默认配置如下:
# Oracle JDK 1.8 , 方便之后使用 presto 服务
$ wget http://repo.hdp.com/jdk-8u211-linux-x64.tar.gz
$ tar xvf jdk-8u211-linux-x64.tar.gz
# 在 Ambari 服务 setup 阶段设置 JAVA_HOME 为 /usr/jdk64/jdk1.8.0_211 即可
$ mkdir -p /usr/jdk64 && mv jdk1.8.0_211 /usr/jdk64/
# PostgreSQL,且其基础信息如下:
# Database admin user (postgres):
# Database name (ambari):
# Postgres schema (ambari):
# Username (ambari):
# Enter Database Password (bigdata):
$ ambari-server setup
# 接着执行,指定数据库方式初始化,否则后期安装会找不到driver
# 下载 postgresql 依赖包
# 安装 yum install -y mysql-connector-java
$ wget https://jdbc.postgresql.org/download/postgresql-42.2.5.jar
$ ambari-server setup --jdbc-db=postgres --jdbc-driver=/root/postgresql-42.2.5.jar
或
$ ambari-server setup --jdbc-db=mysql --jdbc-driver=/usr/share/java/mysql-connector-java.jar
# 启动服务
[root@am.hdp.com ]$ ambari-server start
Using python /usr/bin/python
Starting ambari-server
Ambari Server running with administrator privileges.
Organizing resource files at /var/lib/ambari-server/resources...
Ambari database consistency check started...
Server PID at: /var/run/ambari-server/ambari-server.pid
Server out at: /var/log/ambari-server/ambari-server.out
Server log at: /var/log/ambari-server/ambari-server.log
Waiting for server start.............................
Server started listening on 8080
DB configs consistency check: no errors and warnings were found.
Ambari Server 'start' completed successfully.
# 这时候可以通过 http://am.hdp.com:8080 链接访问 ambari server, 默认账户为(admin/admin)
# 停止服务
$ ambari-server stop
# 重置服务, 重置之后重新setup
$ ambari-server reset
ambari postgres 数据库默认配置
database admin user: postgres
database: ambari
username: ambari
password: bigdata
url: jdbc:postgresql://ambm.hdp.com:5432/ambari
网友评论