CDH6.1.1阿里云安装实践

2019-08-21  本文已影响0人  explorren

概念介绍

CDH概览

CDH是Apache Hadoop和相关项目的最完整、最受测试和最流行的发行版。CDH提供Hadoop的核心元素-可伸缩存储和分布式计算-以及基于web的用户界面和重要的企业功能。CDH是Apache许可的开放源码,是唯一提供统一批处理、交互式SQL和交互式搜索以及基于角色的访问控制的Hadoop解决方案。

CDH 提供以下特性:

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 使用parcels安装

节点准备

三台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

配置免密登录

  1. 在master主机上生成密钥对:
ssh-keygen -t rsa -P '' -f ~/.ssh/id_rsa
  1. 将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
    
  2. 所有主机都赋权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

磁盘块不足

  1. 将负责因子从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


上一篇下一篇

猜你喜欢

热点阅读