写作目的:参考的原文还有些步骤有问题,遂自己记录一遍,方便日后使用

安装环境:vmware12,centos-7-x86_64-minimal-2009_aliyun.iso

本人拿了两台16G的主机来搭环境,i7-8700和i5-3340m

主机\配置

cpu

core

内存

硬盘

ip

角色规划

hadoop202

1

4

13G

50G

192.168.10.202

nn,dn,nm,hs2,hms,zk,CM,hue,Ooize

hadoop203

1

2

7G

50G

192.168.10.203

dn,rm,nm,zk,jhs

hadoop204

1

2

7G

50G

192.168.10.204

2nn,dn,nm,zk

以下步骤都以root角色操作:

静态IP及hosts设置(所有节点)

# 修改ip
vim /etc/sysconfig/network-scripts/ifcfg-ens33
BOOTPROTO=static
ONBOOT=yes
IPADDR=192.168.10.202
GATEWAY=192.168.10.2
DNS1=192.168.10.2

# 修改主机名
vim /etc/hostname
hadoop202

# 修改hosts映射
vim /etc/hosts
192.168.10.202 hadoop202
192.168.10.203 hadoop203
192.168.10.204 hadoop204

关闭防火墙、禁止防火墙开机自启(所有节点)

# 关闭防火墙,禁止防火墙开机自启
systemctl stop firewalld
systemctl disable firewalld
# 禁用selinux
sed -i s/SELINUX=enable/SELINUX=disabled/g /etc/selinux/config

ssh无密码登录(每个节点都操作,相互设置)

ssh-keygen -t rsa
ssh-copy-id root@hadoop202
ssh-copy-id root@hadoop203
ssh-copy-id root@hadoop204

配置NTP服务(所有节点)

# 修改时区(改为中国标准时区)
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

# 安装ntp
yum -y install ntp

# manager配置,指向阿里云
vim /etc/ntp.conf
#server 0.centos.pool.ntp.org iburst
#server 1.centos.pool.ntp.org iburst
#server 2.centos.pool.ntp.org iburst
#server 3.centos.pool.ntp.org iburst
server ntp.aliyun.com

# 其余节点,指向manager
vim /etc/ntp.conf
#server 0.centos.pool.ntp.org iburst
#server 1.centos.pool.ntp.org iburst
#server 2.centos.pool.ntp.org iburst
#server 3.centos.pool.ntp.org iburst
server hadoop202

# 设置开机自启:
systemctl enable ntpd
# 启动 ntp 服务,一定要确认ntp同步了
systemctl start ntpd
# 一般会在5分钟内同步,着急可以手动同步操作,hadoop202必须先与阿里ntp同步,从机203和204才能与hadoop202同步
ntpdate -u hadoop202

# 查看当前同步的时间服务器,前面要带*才是正常同步
ntpq -4p
# 查看服务器时间状态
timedatectl
# 查看ntp状态
ntpstat
# 查看与时间同步服务器的时间偏差
ntpdc -4c loopinfo

设置虚拟内存占用 “vm.swappiness=1”(所有节点)

# Centos 7.2以上设置“vm.swappiness=1”,cloudera建议10以下,mysql建议要有1

# 执行此命令,查找到存在vm.swappiness参数的配置文件
find /usr/lib/tuned -name '*.conf' -type f -exec grep "vm.swappiness" {} \+

# 修改以下三个文件为:vm.swappiness=1
/usr/lib/tuned/latency-performance/tuned.conf:vm.swappiness=10
/usr/lib/tuned/throughput-performance/tuned.conf:vm.swappiness=10
/usr/lib/tuned/virtual-guest/tuned.conf:vm.swappiness = 30

禁用透明页(所有节点)

cat << EOF >> /etc/rc.local
echo never > /sys/kernel/mm/transparent_hugepage/defrag
echo never > /sys/kernel/mm/transparent_hugepage/enabled
EOF

chmod +x /etc/rc.d/rc.local

JDK安装(所有节点)

rpm -qa | grep -i java | xargs -n1 rpm -e --nodeps
# 卸载已安装的java

rpm -ivh oracle-j2sdk1.8-1.8.0+update181-1.x86_64.rpm

#末尾添加
vi /etc/profile
export JAVA_HOME=/usr/java/jdk1.8.0_181-cloudera
export CLASSPATH=.:$CLASSPATH:$JAVA_HOME/lib
export PATH=$PATH:$JAVA_HOME/bin

source /etc/profile
java -version #验证

拷贝mysql-jdbc包(所有节点)

mkdir -p /usr/share/java
mv /opt/mysql-j/mysql-connector-java-5.1.48.jar /usr/share/java/mysql-connector-java.jar
# 一定要命名为mysql-connector-java.jar

删除自带 mariadb(所有节点)

rpm -qa | grep -i mariadb | xargs -n1 rpm -e --nodeps


安装mysql-5.7.16并初始化配置和库(manager节点):

1.安装:
rpm -ivh 01_mysql-community-common-5.7.16-1.el7.x86_64.rpm
rpm -ivh 02_mysql-community-libs-5.7.16-1.el7.x86_64.rpm
rpm -ivh 03_mysql-community-libs-compat-5.7.16-1.el7.x86_64.rpm
rpm -ivh 04_mysql-community-client-5.7.16-1.el7.x86_64.rpm
rpm -ivh 05_mysql-community-server-5.7.16-1.el7.x86_64.rpm


2.初始化配置:
# 初始化mysql使mysql目录的拥有者为mysql用户
mysqld --initialize --user=mysql
# 最后一行将会有随机生成的密码
cat /var/log/mysqld.log
# 设置mysql服务自启
systemctl start mysqld.service
mysql -uroot –p
# 如果不能登陆
systemctl restart mysqld
# 登录并修改mysql的管理者密码
mysql -uroot -p
 mysql>set password = PASSWORD('root');

3.初始化库(后续安装服务等使用):
create database cmserver default charset utf8 collate utf8_general_ci;
grant all on cmserver.* to 'cmserveruser'@'%' identified by 'root';

create database metastore default charset utf8 collate utf8_general_ci;
grant all on metastore.* to 'hiveuser'@'%' identified by 'root';

create database amon default charset utf8 collate utf8_general_ci;
grant all on amon.* to 'amonuser'@'%' identified by 'root';

create database rman default charset utf8 collate utf8_general_ci;
grant all on rman.* to 'rmanuser'@'%' identified by 'root';

create database oozie default charset utf8 collate utf8_general_ci;
grant all on oozie.* to 'oozieuser'@'%' identified by 'root';

create database hue default charset utf8 collate utf8_general_ci;
grant all on hue.* to 'hueuser'@'%' identified by 'root';

安装httpd服务(manager节点, 阿里云版本默认已安装并开机自启, 本次可忽略):

yum install -y httpd
systemctl start httpd
systemctl enable httpd.service #设置httpd服务开机自启

配置Cloudera Manager包的本机yum源(manager节点):

# 将下载的cm包文件移到此目录下:
mkdir -p /var/www/html/cloudera-repos/cm6
mv cm6/* /var/www/html/cloudera-repos/

# 使用createrepo命令创建repodata:
yum install -y createrepo
cd /var/www/html/cloudera-repos/cm6/
createrepo .

# 新增并配置repo文件
touch /etc/yum.repos.d/cloudera-manager.repo
cat << EOF >> /etc/yum.repos.d/cloudera-manager.repo
[cloudera-manager]
name = Cloudera Manager, Version 6.3.1
baseurl = http://hadoop202/cloudera-repos/cm6/
gpgcheck = 0
EOF

# 重建yum缓存
yum clean all
yum makecache
# 如果yum makecache提示404,需要重启一下httpd服务,再不行就重启系统

安装 Cloudera Manager(manager节点):

yum install -y cloudera-manager-daemons cloudera-manager-agent cloudera-manager-server

# 安装完CM后, /opt/下会出现cloudera目录, 将parcel包移动到指定位置
mv /opt/parcels/* /opt/cloudera/parcel-repo
# 在/opt/cloudera/parcel-repo执行以下命令:
sha1sum CDH-6.3.2-1.cdh6.3.2.p0.1605554-el7.parcel | awk '{ print $1 }' > CDH-6.3.2-1.cdh6.3.2.p0.1605554-el7.parcel.sha

# 执行scm初始化脚本:
/opt/cloudera/cm/schema/scm_prepare_database.sh mysql cmserver cmserveruser 数据库密码
# 打开server服务:
service cloudera-scm-server start

静候几分钟,打开http://hadoop202:7180

安装引导配置:

1.自定义parcels配置路径:
http://hadoop202/cloudera-repos/cm6

2.选择标准安装Essential

3.数据库配置,按照上面创建的库信息配置


初始化告警处理:

1.HDFS告警: 不良 : 群集中有 1,814 个 副本不足的块
处理:默认为3,本次设置块副本为2,且不开启纠删码

4.其他Java Heap Size告警暂未处理,虚拟机内存小,不太有修改意义,后期再慢慢研究

初始化配置:

1.hadoop集群初次搭建好后,通过以下方式创建root用户:
sudo -uhdfs hdfs dfs -mkdir /user/root
sudo -uhdfs hdfs dfs -chown root:root /user/root




出现问题并解决:

parcel安装的时候,显示正在获取安装锁,删除进程及文件,页面会重新安装
# kill 带scm_prepare_node 的进程
ps aux|grep scm_prepare_node|awk '{print $2}'|xargs kill -9
# cd /tmp目录,删除scm_prepare_node.*的文件
cd /tmp
ls -a
rm -rf scm_prepare_node.*





参考:

https://www.yangxingzhen.com/7820.html
https://www.cnblogs.com/swordfall/p/10816797.html


出现的奇怪问题1:

mysql启动失败:[ERROR] InnoDB: The innodb_system data file 'ibdata1' must be writable

解决方式:
无效1. chmod -R 777 /var/lib/mysql
chown mysql:mysql -R /var/lib/mysql
无效2:系统openfile文件问题,mysql配置最小需要max_connections=2000
cat << EOF>> /etc/security/limits.conf
* soft nofile 65535
* hard nofile 65535
EOF


parcels包卡在正在分配,进度条红色:尝试重启agent操作
rm -rf /var/lib/cloudera-scm-agent/cm_guid
service cloudera-scm-agent restart