大数据
🗒️CDH6 集群搭建
00 分钟
2023-11-29
2023-12-4
type
status
date
slug
summary
tags
category
icon
password
Language

自测--CDH6.3.1 搭建 (2核16G阿里云环境)


1.准备工作

1.1部署方式

本次测试采用离线部署的方式 :
主要分为三块 :
  • Cloudera-Manager离线部署
  • MySQL离线部署
  • Parcel文件离线源部署

1.2集群规划

节点
MySQL部署组件
Parcel⽂文件离线源
CM服务进程
大数据组件
hadoop001
MySQL
Parcel
Activity Monitor
NN RM DN NM
hadoop002
Alert Publisher Event Server
DN NM
hadoop003
Host Monitor Service Monitor
DN NM

1.3下载源

  • CM
  • JDK
  • MySQL

2.集群节点初始化

2.1购买阿里云服务器

  • 按量量付费虚拟机
    • CentOS7.2操作系统,2核16G最低配置(8G 勉强也可以)
      • notion image
        notion image
        notion image
        notion image
        notion image
        notion image
        notion image

2.2当前机器配置hosts文件

  • Window: C:\windows\System32\drivers\etc\hosts
  • ps : hosts文件里面只放公网ip

2.3设置所有节点的hosts文件

      notion image
  • 查看主机之前能否ping通
      • notion image

2.4关闭所有节点的防⽕火墙及清空规则

2.5关闭所有节点的selinux

阿里云默认是disabled的

2.6设置所有节点的时区⼀一致及时钟同步 (云主机不用配置)

  • 增加
  • #当外部时间不不可⽤用时,可使⽤用本地硬件时间server 127.127.1.0 iburst local clock#允许哪些网段的机器来同步时间restrict 172.21.102.0 mask 255.255.255.0 nomodify notrap
      • notion image

2.7每个节点部署JDK

  • 先把所有软件上传到 hadoop001当中
    • [root@hadoop001 CDH6.3.1]# lltotal 4131080rw-r--r-- 1 root root 2083878000 Jun 28 16:26 CDH-6.3.1-1.cdh6.3.1.p0.1470567-el7.parcelrw-r--r-- 1 root root 40 Jun 28 16:26 CDH-6.3.1-1.cdh6.3.1.p0.1470567-el7.parcel.sha1rw-r--r-- 1 root root 1411444147 Jun 28 16:28 cm6.3.1-redhat7.tar.gzrw-r--r-- 1 root root 185646832 Jun 28 16:28 jdk-8u181-linux-x64.tar.gzrw-r--r-- 1 root root 33887 Jun 28 16:28 manifest.jsonrw-r--r-- 1 root root 548193637 Jun 28 16:29 mysql-5.7.11-linux-glibc2.5-x86_64.tar.gzrw-r--r-- 1 root root 1007502 Jun 28 16:29 mysql-connector-java-5.1.47.jar
  • 其他节点创建目录
    • [root@hadoop002 ~]# mkdir CDH6.3.1[root@hadoop003 ~]# mkdir CDH6.3.1
  • 传输JDK
    • [root@hadoop001 CDH6.3.1]# scp jdk-8u181-linux-x64.tar.gz hadoop002:/root/CDH6.3.1/[root@hadoop001 CDH6.3.1]# scp jdk-8u181-linux-x64.tar.gz hadoop003:/root/CDH6.3.1/# 输入yes和root账号的密码
  • 所有节点创建目录
    • mkdir /usr/java
  • 所有节点解压JDK包
    • tar -xzvf jdk-8u181-linux-x64.tar.gz -C /usr/java
  • 所有节点修正用户和用户组
    • cd /usr/javachown -R root:root /usr/java/jdk1.8.0_181
  • 所有节点配置环境变量
    • echo "export JAVA_HOME=/usr/java/jdk1.8.0_181" >> /etc/profileecho "export PATH=/usr/java/jdk1.8.0_181/bin:${PATH}" >> /etc/profilesource /etc/profilewhich java

3.离线部署MySQL5.7

我们选择hadoop001为我们的mysql节点
  • 解压
    • sudo tar -xzvf mysql-5.7.11-linux-glibc2.5-x86_64.tar.gz -C /usr/local
  • 重新命名
    • cd /usr/localmv mysql-5.7.11-linux-glibc2.5-x86_64 mysql
  • 修正用户组
    • chown -R root:root /usr/local/mysql/
  • 创建文件夹
    • mkdir mysql/arch/ mysql/data/ mysql/tmp/
  • 创建配置文件
    • vi /etc/my.cnf
      • 把默认的内容删掉 替换如下
    • [client]port = 3306socket = /usr/local/mysql/data/mysql.sockdefault-character-set=utf8mb4[mysqld]port = 3306socket = /usr/local/mysql/data/mysql.sockskip-slave-startskip-external-lockingkey_buffer_size = 256Msort_buffer_size = 2Mread_buffer_size = 2Mread_rnd_buffer_size = 4Mquery_cache_size= 32Mmax_allowed_packet = 16Mmyisam_sort_buffer_size=128Mtmp_table_size=32Mtable_open_cache = 512thread_cache_size = 8wait_timeout = 86400interactive_timeout = 86400max_connections = 600# Try number of CPU's*2 for thread_concurrency#thread_concurrency = 32 #isolation level and default engine default-storage-engine = INNODBtransaction-isolation = READ-COMMITTEDserver-id = 1739basedir = /usr/local/mysqldatadir = /usr/local/mysql/datapid-file = /usr/local/mysql/data/hostname.pid#open performance schemalog-warningssysdate-is-nowbinlog_format = ROWlog_bin_trust_function_creators=1log-error = /usr/local/mysql/data/hostname.errlog-bin = /usr/local/mysql/arch/mysql-binexpire_logs_days = 7innodb_write_io_threads=16relay-log = /usr/local/mysql/relay_log/relay-logrelay-log-index = /usr/local/mysql/relay_log/relay-log.indexrelay_log_info_file= /usr/local/mysql/relay_log/relay-log.infolog_slave_updates=1gtid_mode=OFFenforce_gtid_consistency=OFF# slaveslave-parallel-type=LOGICAL_CLOCKslave-parallel-workers=4master_info_repository=TABLErelay_log_info_repository=TABLErelay_log_recovery=ON#other logs#general_log =1#general_log_file = /usr/local/mysql/data/general_log.err#slow_query_log=1#slow_query_log_file=/usr/local/mysql/data/slow_log.err#for replication slavesync_binlog = 500#for innodb options innodb_data_home_dir = /usr/local/mysql/data/innodb_data_file_path = ibdata1:1G;ibdata2:1G:autoextendinnodb_log_group_home_dir = /usr/local/mysql/archinnodb_log_files_in_group = 4innodb_log_file_size = 1Ginnodb_log_buffer_size = 200M#根据生产需要,调整pool size innodb_buffer_pool_size = 2G#innodb_additional_mem_pool_size = 50M #deprecated in 5.6tmpdir = /usr/local/mysql/tmpinnodb_lock_wait_timeout = 1000#innodb_thread_concurrency = 0innodb_flush_log_at_trx_commit = 2innodb_locks_unsafe_for_binlog=1#innodb io features: add for mysql5.5.8performance_schemainnodb_read_io_threads=4innodb-write-io-threads=4innodb-io-capacity=200#purge threads change default(0) to 1 for purgeinnodb_purge_threads=1innodb_use_native_aio=on#case-sensitive file names and separate tablespaceinnodb_file_per_table = 1lower_case_table_names=1[mysqldump]quickmax_allowed_packet = 128M[mysql]no-auto-rehashdefault-character-set=utf8mb4[mysqlhotcopy]interactive-timeout[myisamchk]key_buffer_size = 256Msort_buffer_size = 256Mread_buffer = 2Mwrite_buffer = 2M
  • 创建用户组及用户
    • groupadd -g 101 dbauseradd -u 514 -g dba -G root -d /usr/local/mysql mysqladmin
  • copy配置文件
    • cp /etc/skel/.* /usr/local/mysql
  • 切换用户
    • su - mysqladminll -a #查看文件是否copyexit
  • 编辑配置文件
    • vi ./bashrc
    • # .bashrc# Source global definitionsif [ -f /etc/bashrc ]; then . /etc/bashrcfi# Uncomment the following line if you don't like systemctl's auto-paging feature:# export SYSTEMD_PAGER=export MYSQL_BASE=/usr/local/mysqlexport PATH=${MYSQL_BASE}/bin:$PATH
  • 赋予权限 记得切换为root
    • [root@hadoop001 local]# chown mysqladmin:dba /etc/my.cnf[root@hadoop001 local]# chmod 640 /etc/my.cnf[root@hadoop001 local]# chown -R mysqladmin:dba /usr/local/mysql[root@hadoop001 local]# chmod -R 755 /usr/local/mysql
  • 配置服务和开机自启动
    • [root@hadoop001 local]# cd /usr/local/mysql#将服务文件拷贝到init.d下,并重命名为mysql[root@hadoop001 mysql]# cp support-files/mysql.server /etc/rc.d/init.d/mysql#赋予可执行权限[root@hadoop001 mysql]# chmod +x /etc/rc.d/init.d/mysql#删除服务[root@hadoop001 mysql]# chkconfig --del mysql#添加服务[root@hadoop001 mysql]# chkconfig --add mysql
  • 安装libaio及安装mysql的初始db
    • [hejiahao@hadoop001 mysql]$ sudo yum -y install libaio# 初始化启动[root@hadoop001 mysql]# bin/mysqld \> --defaults-file=/etc/my.cnf \> --user=mysqladmin \> --basedir=/usr/local/mysql/ \> --datadir=/usr/local/mysql/data/ \> --initialize[root@hadoop001 mysql]#[root@hadoop001 mysql]#[root@hadoop001 mysql]# cd data/# 查看临时密码[root@hadoop001 data]# cat hostname.err |grep password2020-06-28T10:00:55.318092Z 1 [Note] A temporary password is generated for root@ localhost: Wwh*do<PE1sH[root@hadoop001 data]#
  • 启动并登陆
    • su - mysqladminservice mysql start
    • mysql -uroot -pWwh*do<PE1sH
  • 重置密码
    • alter user root@localhost identified by 'hadoop';GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'hadoop' ;flush privileges;exit;mysql> show databases;ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.mysql> alter user root@localhost identified by 'hadoop';Query OK, 0 rows affected (0.00 sec)mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'hadoop' ;Query OK, 0 rows affected, 1 warning (0.00 sec)mysql> flush privileges;Query OK, 0 rows affected (0.00 sec)mysql> exit;Bye[mysqladmin@hadoop001 ~]$# 再次登陆mysql -uroot -phadoop
  • 创建CDH的元数据库和⽤用户、amon服务的数据库及⽤用户
    • create database cmf DEFAULT CHARACTER SET utf8;grant all on cmf.* TO 'cmf'@'%' IDENTIFIED BY 'cmf';create database amon DEFAULT CHARACTER SET utf8;grant all on amon.* TO 'amon'@'%' IDENTIFIED BY 'amon';flush privileges;
  • hadoop001节点部署mysql jdbc jar
    • cd ~mkdir -p /usr/share/java/# 不要版本号cp mysql-connector-java-5.1.47.jar /usr/share/java/mysql-connector-java.jar

4.CDH部署

4.1离线部署cm server及agent

  • 解压rpm包并安装server
    • [root@hadoop001 CDH6.3.1]# tar -xzvf cm6.3.1-redhat7.tar.gz
    • cd cm6.3.1cd RPMS/cd x86_64/[root@hadoop001 x86_64]# lltotal 1380424rw-r--r-- 1 2001 2001 10483568 Sep 25 2019 cloudera-manager-agent-6.3.1-1466458.el7.x86_64.rpmrw-r--r-- 1 2001 2001 1203832464 Sep 25 2019 cloudera-manager-daemons-6.3.1-1466458.el7.x86_64.rpmrw-r--r-- 1 2001 2001 11488 Sep 25 2019 cloudera-manager-server-6.3.1-1466458.el7.x86_64.rpm# 官方提供的数据库 (不用) : 因为你不知道你安装在哪里 也不知道密码rw-r--r-- 1 2001 2001 10996 Sep 25 2019 cloudera-manager-server-db-2-6.3.1-1466458.el7.x86_64.rpmrw-r--r-- 1 2001 2001 14209868 Sep 25 2019 enterprise-debuginfo-6.3.1-1466458.el7.x86_64.rpmrw-rw-r-- 1 2001 2001 184988341 Sep 25 2019 oracle-j2sdk1.8-1.8.0+update181-1.x86_64.rpm[root@hadoop001 x86_64]#server需要安装:cloudera-manager-daemons-6.3.1-1466458.el7.x86_64.rpmcloudera-manager-server-6.3.1-1466458.el7.x86_64.rpmagent需要安装:cloudera-manager-daemons-6.3.1-1466458.el7.x86_64.rpmcloudera-manager-agent-6.3.1-1466458.el7.x86_64.rpm
    • # 裸装 不用yum源rpm -ivh cloudera-manager-daemons-6.3.1-1466458.el7.x86_64.rpm --nodeps --forcerpm -ivh cloudera-manager-server-6.3.1-1466458.el7.x86_64.rpm --nodeps --force[root@hadoop001 x86_64]# rpm -ivh cloudera-manager-daemons-6.3.1-1466458.el7.x86_64.rpm --nodeps --forcewarning: cloudera-manager-daemons-6.3.1-1466458.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID b0b19c9f: NOKEYPreparing... ################################# [100%]Updating / installing... 1:cloudera-manager-daemons-6.3.1-14################################# [100%][root@hadoop001 x86_64]# rpm -ivh cloudera-manager-server-6.3.1-1466458.el7.x86_64.rpm --nodeps --forcewarning: cloudera-manager-server-6.3.1-1466458.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID b0b19c9f: NOKEYPreparing... ################################# [100%]Updating / installing... 1:cloudera-manager-server-6.3.1-146####################### ########## [100%]Created symlink from /etc/systemd/system/multi-user.target.wants/cloudera-scm-server.service to /usr/lib/systemd/system/cloudera-scm-server.service.[root@hadoop001 x86_64]#[root@hadoop001 cloudera-scm-server]# cd /etc/cloudera-scm-server/[root@hadoop001 cloudera-scm-server]# lltotal 20rw-r--r-- 1 root root 8197 Sep 25 2019 cmSubCaCert.profilerw------- 1 cloudera-scm cloudera-scm 757 Sep 25 2019 db.propertiesrw-r--r-- 1 root root 3027 Sep 25 2019 log4j.properties[root@hadoop001 cloudera-scm-server]#
    • vi db.properties# Copyright (c) 2012 Cloudera, Inc. All rights reserved.## This file describes the database connection.## The database type# Currently 'mysql', 'postgresql' and 'oracle' are valid databases.com.cloudera.cmf.db.type=mysql# The database host# If a non standard port is needed, use 'hostname:port'com.cloudera.cmf.db.host=hadoop001:3306# The database namecom.cloudera.cmf.db.name=cmf# The database usercom.cloudera.cmf.db.user=cmf# The database user's passwordcom.cloudera.cmf.db.password=cmf# The db setup type# After fresh install it is set to INIT# and will be changed post config.# If scm-server uses Embedded DB then it is set to EMBEDDED# If scm-server uses External DB then it is set to EXTERNALcom.cloudera.cmf.db.setupType=EXTERNAL
  • 启动server
    • service cloudera-scm-server start# 需要等待一分钟
    • # 去 /var/log/cloudera-scm-server/ 下查看日志tail -F /var/log/cloudera-scm-server/cloudera-scm-server.log
      • notion image
    • 去阿里云开放7180端口
        • notion image
          notion image
  • hadoop001继续安装rpm包 先前安装了daemons和server
    • cd /root/CDH6.3.1/cm6.3.1/RPMS/x86_64[root@hadoop001 x86_64]# rpm -ivh cloudera-manager-agent-6.3.1-1466458.el7.x86_64.rpm --nodeps --forcewarning: cloudera-manager-agent-6.3.1-1466458.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID b0b19c9f: NOKEYPreparing... ################################# [100%]Updating / installing... 1:cloudera-manager-agent-6.3.1-1466################################# [100%]Created symlink from /etc/systemd/system/multi-user.target.wants/cloudera-scm-agent.service to /usr/lib/systemd/system/cloudera-scm-agent.service.Created symlink from /etc/systemd/system/multi-user.target.wants/supervisord.service to /usr/lib/systemd/system/supervisord.service.[root@hadoop001 x86_64]#
  • 编辑文件
    • vi /etc/cloudera-scm-agent/config.ini修改server_host=hadoop001
  • 其他的机器安装rpm包
    • # 先传输软件包scp cloudera-manager-agent-6.3.1-1466458.el7.x86_64.rpm hadoop002:/root/CDH6.3.1/scp cloudera-manager-agent-6.3.1-1466458.el7.x86_64.rpm hadoop003:/root/CDH6.3.1/scp cloudera-manager-daemons-6.3.1-1466458.el7.x86_64.rpm hadoop002:/root/CDH6.3.1/scp cloudera-manager-daemons-6.3.1-1466458.el7.x86_64.rpm hadoop003:/root/CDH6.3.1/# hadoop002 和 hadoop003 安装rpm -ivh cloudera-manager-daemons-6.3.1-1466458.el7.x86_64.rpm --nodeps --forcerpm -ivh cloudera-manager-agent-6.3.1-1466458.el7.x86_64.rpm --nodeps --force
  • 其他的机器编辑文件 hadoop002 和 hadoop003
    • vi /etc/cloudera-scm-agent/config.ini修改server_host=hadoop001
  • 所有机器启动 agent
    • service cloudera-scm-agent start

5.浏览器登陆

默认账号密码
admin
admin

5.1进入欢迎页面

      notion image

5.2同意许可证

      notion image

5.3选择免费版本

      notion image

5.4集群安装

      notion image

5.5设置集群名称

      notion image

5.6选择主机

      notion image

5.7选择存储库

  • 配置
    • cd CDH6.3.1/yum install -y httpdmkdir /var/www/html/cdh6_parcel[root@hadoop001 CDH6.3.1]# mv CDH-6.3.1-1.cdh6.3.1.p0.1470567-el7.parcel /var/www/html/cdh6_parcel/# 这里记得要不sha1的1去掉[root@hadoop001 CDH6.3.1]# mv CDH-6.3.1-1.cdh6.3.1.p0.1470567-el7.parcel.sha1 /var/www/html/cdh6_parcel/CDH-6.3.1-1.cdh6.3.1.p0.1470567-el7.parcel.sha[root@hadoop001 CDH6.3.1]# mv manifest.json /var/www/html/cdh6_parcel/[root@hadoop001 CDH6.3.1]#[root@hadoop001 CDH6.3.1]# cd /var/www/html/cdh6_parcel/[root@hadoop001 cdh6_parcel]# lltotal 2035084rw-r--r-- 1 root root 2083878000 Jun 28 16:26 CDH-6.3.1-1.cdh6.3.1.p0.1470567-el7.parcelrw-r--r-- 1 root root 40 Jun 28 16:26 CDH-6.3.1-1.cdh6.3.1.p0.1470567-el7.parcel.sharw-r--r-- 1 root root 33887 Jun 28 16:28 manifest.json[root@hadoop001 cdh6_parcel]#
  • 启动httpd 服务
    • [root@hadoop001 CDH6.3.1]# service httpd startRedirecting to /bin/systemctl start httpd.service[root@hadoop001 CDH6.3.1]#
  • 设置路径
      notion image
  • 这时候页面自动找到了我们的parcel包了
      • notion image

5.8安装 Parcels

      notion image

5.9集群检测

      notion image
  • 显示检查器结果
      • notion image
  • 所有机器运行
    • echo never > /sys/kernel/mm/transparent_hugepage/defragecho never > /sys/kernel/mm/transparent_hugepage/enabled
      • notion image
  • 回到页面选择忽略警告,再点击继续

5.10群集设置

      notion image
  • 选择自定义服务
    • 先选择 ZooKeeper , YARN , HDFS
        • notion image

5.11自定义角色分配

      notion image

5.12数据库设置

      notion image

5.13审核更改

      notion image

5.14首次运行

      notion image

5.15汇总

      notion image

6.解决报错

      notion image
      notion image
因为官方配置里的内存大小设置跟我们的不一样
生产上要设置成推荐大小, 不设置可以先点击Suppress
大部分可以抑制掉
  • 解决
notion image

7.停止关闭集群

7.1先停止集群

notion image

7.2再停止Cloudera Management Service

notion image

7.3停止所有机器的Agent

7.4 停止Server

7.5 停止MySQL

7.6阿里云服务器选择停机不收费

notion image

8.卸载集群

9.清理日志


评论