CDH6.1.1阿里云安装实践
概念介绍
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 | oracle 官网下载 |
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-master 172.26.86.12 cdh-slave001 172.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 # 启动ntp service 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/enabled echo 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.gz mkdir -p /usr/java tar -zxvf jdk-8u181-linux-x64.tar.gz -c /usr/java/jdk1.8
vim /etc/profile
java_home=/usr/java/jdk1.8 class_path=.:$java_home/lib/dt.jar:$java_home/lib/tools.jar path=$java_home/bin:$path export java_home class_path path
source /etc/profile
mysql安装
这里也可以选择mariadb,但是我安装mariadb后,启动服务建表步骤时,始终报用户名或密码错误
# 检查系统是否存在mariadb rpm -qa | grep mariadb # 强制删除 rpm -e --nodeps mariadb-libs-5.5.56-2.el7.x86_64 wget 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/mysql mkdir /usr/local/mysql/data chmod 777 /usr/local/mysql/data # 增加mysql用户和组 groupadd mysql useradd -r -g mysql mysql chown -r mysql:mysql /usr/local/mysql
vim /etc/my.cnf
[mysqld] basedir=/usr/local/mysql datadir=/usr/local/mysql/data port=3306 socket=/tmp/mysql.sock pid-file=/tmp/mysqld/mysqld.pid character-set-server=utf8 log-error=/var/log/mysqld.log
安装命令
touch /tmp/mysql.sock chown mysql:mysql /tmp/mysql.sock chmod 755 /tmp/mysql.sock mkdir -p /tmp/mysqld touch /tmp/mysqld/mysqld.pid chown -r mysql:mysql /tmp/mysqld chmod 755 /tmp/mysqld/mysqld.pid mkdir -p /var/log/ touch /var/log/mysqld.log chown -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 password my!u5luwhjk3 # 登录mysql cd /usr/local/mysql/bin/ ./mysql -u root -p mysql> 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/mysql chkconfig --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.jar mv mysql-connector-java-5.1.47.jar mysql-connector-java.jar mkdir /usr/share/java cp 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 <repo_file_url> -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-server sudo systemctl enable cloudera-scm-agent sudo systemctl enable cloudera-scm-server systemctl start cloudera-scm-server systemctl start cloudera-scm-agent
数据节点安装
安装 cm agent
yum install cloudera-manager-daemons cloudera-manager-agent sudo systemctl enable cloudera-scm-agent systemctl 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.log vim /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 /user hadoop fs -chmod -r 777 /tmp/
启动server端口起不来
chmod 777 -r /var/log
运行spark shell无法启动,无权限问题
su hdfs后 sudo -u hdfs hdfs dfs -chmod 777 /user sudo -u hdfs hadoop fs -chmod -r 777 /tmp
推荐阅读