概念介绍
CDH概览
CDH是Apache Hadoop和相关项目的最完整、最受测试和最流行的发行版。CDH提供Hadoop的核心元素-可伸缩存储和分布式计算-以及基于web的用户界面和重要的企业功能。CDH是Apache许可的开放源码,是唯一提供统一批处理、交互式SQL和交互式搜索以及基于角色的访问控制的Hadoop解决方案。
CDH 提供以下特性:
- 灵活性:存储任何类型的数据并使用各种不同的计算框架进行操作,包括批处理、交互式SQL、免费文本搜索、机器学习和统计计算。
- 集成:在一个完整的Hadoop平台上快速启动和运行,该平台与广泛的硬件和软件解决方案一起工作。
- 安全:处理和控制敏感数据。
- 可伸缩性:启用广泛的应用程序和规模,并扩展它们以满足您的需求。
- 高可用性:满怀信心地执行任务关键的业务任务。
- 兼容性:利用您现有的IT基础设施和投资。
CDH Cloudera Manager 概览
Cloudera Manager 是用于管理cdh集群的端到端应用程序。Cloudera Manager通过向CDH集群的每个部分提供细粒度的可见性并对其进行控制来设置企业部署标准-授权运营商提高性能、提高服务质量、提高遵从性和降低管理成本。使用Cloudera Manager,您可以轻松地部署和集中操作完整的CDH堆栈和其他托管服务。应用程序自动化安装过程,将部署时间从数周减少到分钟;为您提供在集群范围内运行主机和服务的实时视图;提供一个单一的中央控制台来执行整个集群的配置更改;并集成各种报告和诊断工具,以帮助您进行操作
环境准备
前要
搭建方式的比较
方式 | 费用成本 | 时间成本 | 难易度 | 适宜场景 |
---|---|---|---|---|
自己购买机器搭建 | 短期投入高 | 高 | 需要自己掌握虚机和大数据组件的搭建细节,比较复杂 | 1.个人技术学习2.大公司构建自己的大数据集群 |
基于云服务器搭建 | 较高 | 较高 | 同上 | 中小型的大数据服务 |
使用阿里云E-MapReduce | 可按小时付费,成本可控 | 低 | 环境由EMR搭建,使用即可 | 短期、灵活的大数据服务 |
软件版本选择
类目 | 版本 | 下载地址 |
---|---|---|
操作系统 | CentOS Linux release 7.5.1804 (Core) | 阿里云服务器 |
数据库 | mysql-5.7.24-linux-glibc2.12-x86_64.tar.gz | 官网下载 |
JDK | jjdk-8u181-linux-x64.tar.gz | |
Cloudera Manager | Cloudera Manager 6.1.1 | |
CDH | CDH 6.1.1 |
节点准备
三台8G+的主机
名称 | CM管理软件 |
---|---|
cdh-master | Cloudera Manager Server&Agent 、Mysql |
cdh-slave001 | Cloudera Manager Agent |
cdh-slave002 | Cloudera Manager Agent |
安装前配置
配置主机名和hosts解析
所有节点都需要配置 vim /etc/hosts
172.26.86.11 cdh-master172.26.86.12 cdh-slave001172.26.86.10 cdh-slave002
配置免密登录
- 在master主机上生成密钥对:
ssh-keygen -t rsa -P '' -f ~/.ssh/id_rsa
将master主机的公钥文件id_rsa.pub远程复制到cdh002、cdh003主机上。并放置/home/root/.ssh/authorized_keys
/root/.ssh>scp ~/.ssh/id_rsa.pub root@cdh-slave001:/root/.ssh/authorized_keys/root/.ssh>scp ~/.ssh/id_rsa.pub root@cdh-slave002:/root/.ssh/authorized_keys
所有主机都赋权600
chmod 600 ~/.ssh/authorized_keys
安装NTP
所有节点
yum install ntp -y# 开机启动chkconfig ntpd on# 启动ntpservice ntpd start
修改文件打开限制
echo "* soft nofile 65536" >> /etc/security/limits.conf echo "* hard nofile 65536" >> /etc/security/limits.conf echo "* soft memlock unlimited" >> /etc/security/limits.conf echo "* hard memlock unlimited" >> /etc/security/limits.conf
设置swap空间
所有节点
echo "vm.swappiness = 0" >> /etc/sysctl.conf
关闭大页面缓存
所有节点
echo never > /sys/kernel/mm/transparent_hugepage/enabledecho never > /sys/kernel/mm/transparent_hugepage/defrag
关闭防火墙
所有节点
systemctl stop firewalld.service systemctl disable firewalld.service
JDK安装
可以选择CM管理页面进行jdk安装,但在之前需要安装一个
wget http://blog-jupiter.oss-cn-shenzhen.aliyuncs.com/jdk-8u181-linux-x64.tar.gzmkdir -p /usr/javatar -zxvf jdk-8u181-linux-x64.tar.gz -C /usr/java/jdk1.8
vim /etc/profile
JAVA_HOME=/usr/java/jdk1.8CLASS_PATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jarPATH=$JAVA_HOME/bin:$PATHexport JAVA_HOME CLASS_PATH PATH
source /etc/profile
Mysql安装
这里也可以选择mariadb,但是我安装mariadb后,启动服务建表步骤时,始终报用户名或密码错误
# 检查系统是否存在mariadbrpm -qa | grep mariadb# 强制删除rpm -e --nodeps mariadb-libs-5.5.56-2.el7.x86_64wget https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.24-linux-glibc2.12-x86_64.tar.gz# 解压tar -zxvf mysql-5.7.24-linux-glibc2.12-x86_64.tar.gz -C /usr/local/mv /usr/local/mysql-5.7.24-linux-glibc2.12-x86_64 /usr/local/mysqlmkdir /usr/local/mysql/datachmod 777 /usr/local/mysql/data# 增加mysql用户和组groupadd mysqluseradd -r -g mysql mysql chown -R mysql:mysql /usr/local/mysql
vim /etc/my.cnf
[mysqld]basedir=/usr/local/mysqldatadir=/usr/local/mysql/dataport=3306socket=/tmp/mysql.sockpid-file=/tmp/mysqld/mysqld.pidcharacter-set-server=utf8log-error=/var/log/mysqld.log
安装命令
touch /tmp/mysql.sockchown mysql:mysql /tmp/mysql.sockchmod 755 /tmp/mysql.sockmkdir -p /tmp/mysqldtouch /tmp/mysqld/mysqld.pidchown -R mysql:mysql /tmp/mysqldchmod 755 /tmp/mysqld/mysqld.pidmkdir -p /var/log/touch /var/log/mysqld.logchown -R mysql:mysql /var/log/chmod 755 /var/log/mysqld.log yum install -y libaio # 初始化cd /usr/local/mysql/bin/./mysqld --initialize --user=mysql --basedir=/usr/local/mysql--datadir=/usr/local/mysql/data# 安全启动./mysqld_safe --user=mysql &# 查看密码cat /var/log/mysqld.log | grep passwordMy!U5LUWhjk3# 登录mysqlcd /usr/local/mysql/bin/./mysql -u root -pmysql> set password=password("root");mysql> grant all privileges on *.* to 'root'@'%' identified by 'root';mysql> flush privileges;# 开机服务启动设置cp -a /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqlchkconfig --add mysql# 创建快捷方式ln -s /usr/local/mysql/bin/mysql /usr/bin
JDBC驱动安装
下载mysql-connector-java.jar,并保存到所有主机的/usr/share/java目录下
wget http://central.maven.org/maven2/mysql/mysql-connector-java/5.1.47/mysql-connector-java-5.1.47.jarmv mysql-connector-java-5.1.47.jar mysql-connector-java.jarmkdir /usr/share/javacp mysql-connector-java.jar /usr/share/java/scp mysql-connector-java.jar root@cdh-slave001:/usr/share/java/scp mysql-connector-java.jar root@cdh-slave002:/usr/share/java/
依赖包下载
yum -y install chkconfig bind-utils psmisc libxslt zlib sqlite cyrus-sasl-plain cyrus-sasl-gssapi fuse portmap fuse-libs redhat-lsb
安装
RHEL compatible
## wget-P /etc/yum.repos.d/wget https://archive.cloudera.com/cm6/6.1.1/redhat7/yum/cloudera-manager.repo -P /etc/yum.repos.d/ rpm --import https://archive.cloudera.com/cm6/6.1.1/redhat7/yum/RPM-GPG-KEY-cloudera
master节点安装
安装 CM Server 和 Agent
yum install cloudera-manager-daemons cloudera-manager-agent cloudera-manager-serversudo systemctl enable cloudera-scm-agentsudo systemctl enable cloudera-scm-serversystemctl start cloudera-scm-serversystemctl start cloudera-scm-agent
数据节点安装
安装 CM Agent
yum install cloudera-manager-daemons cloudera-manager-agentsudo systemctl enable cloudera-scm-agentsystemctl start cloudera-scm-agent
建表
需要创建scm、hue、hive,官网推荐建表如下
create database scm default character set utf8 default collate utf8_general_ci;grant all privileges on *.* to 'scm'@'%' identified by 'scm' with grant option ;create database amon default character set utf8 default collate utf8_general_ci;grant all privileges on amon.* to 'amon'@'%' identified by 'amon' with grant option;create database rman default character set utf8 default collate utf8_general_ci;grant all privileges on rman.* to 'rman'@'%' identified by 'rman' with grant option;create database hue default character set utf8 default collate utf8_general_ci;grant all privileges on *.* to 'hue'@'%' identified by 'hue' with grant option;create database metastore default character set utf8 default collate utf8_general_ci;grant all privileges on *.* to 'hive'@'%' identified by 'hive' with grant option;create database sentry default character set utf8 default collate utf8_general_ci;grant all privileges on sentry.* to 'sentry'@'%' identified by 'sentry' with grant option;create database nav default character set utf8 default collate utf8_general_ci;grant all privileges on nav.* to 'nav'@'%' identified by 'nav' with grant option;create database oozie default character set utf8 default collate utf8_general_ci;grant all privileges on oozie.* to 'oozie'@'%' identified by 'oozie' with grant option;
检测服务连接
/opt/cloudera/cm/schema/scm_prepare_database.sh mysql scm scm scm
常用命令
tail -f /var/log/cloudera-scm-server/cloudera-scm-server.logvim /etc/cloudera-scm-agent/config.ini
Question
磁盘块不足
- 将负责因子从3修改为2
2.运行如下命令
sudo -u hdfs hadoop fs -setrep -R 2 /
Hue不能连接数据库
hue连接数据库时使用python连接
yum install -y python-lxml
HDFS启动报错: Canary 测试无法在目录
sudo -u
sudo -u hdfs hdfs dfsadmin -safemode leave
CDH中yarn的JobHistory Server角色运行状况异常
YarnRuntimeException: Error creating done directory: [hdfs://cdh001:8020/user/history/done
su hdfs后
hdfs dfs -chmod 777 /userhadoop fs -chmod -R 777 /tmp/
启动server端口起不来
chmod 777 -R /var/log
运行spark shell无法启动,无权限问题
su hdfs后sudo -u hdfs hdfs dfs -chmod 777 /usersudo -u hdfs hadoop fs -chmod -R 777 /tmp