一、SRC
前面那篇文章是在生产环境实践之前本地安的,在生产环境安装了一遍之后,有很多地方做了修改,所以重新写一篇。
CDH文档
CDH里组件的版本信息
CDH6组件的版本信息
CDH安装文档
二、需求
1. 节点规划
完全模拟公司环境,centos7.6 + CDH5.16.2
5台虚拟机。4个cdh,1个应用和数据库服务器。
ip | 作用 |
---|---|
101 | cdh管理节点 |
102-104 | cdh工具+数据节点 |
105 | 数据库和应用节点 |
2. 配置hdfsHA和yarnHA
3. CDH服务规划
ip | 角色 |
---|---|
101 | NN,RM,JS,SHS,ZK,LB,HUE,mysql,KDC,sentry |
102 | CM,CMS,HM,HS2,ICS,IS,HUE,OOZIE,Gateway,DN,NM,Impalad |
103 | DN,NM,Impalad |
104 | DN,NM,Impalad |
105 | 数据库和应用节点,yum源,ntp server |
4. 资源分配
ip | 内存 |
---|---|
101 | 9 |
102 | 9 |
103 | 3 |
104 | 3 |
105 | 3 |
三、用户和目录
cdh节点用root管理,
数据库和应用服务器使用应用特权用户dchao
cdh内容均放在/cdh下
四、介质
1. 介质清单
1 | 2 |
---|---|
linux7.6的min和everything | |
mysql | https://downloads.mysql.com/archives/community/ |
tomcat | |
CDH的3个 | |
spark2的3个 | |
CM的5个rpm | http://archive.cloudera.com/cm5/redhat/7/x86_64/cm/5.16.2/RPMS/x86_64/,注意里面里面的jdk版本太低 |
jdk | cdh6.1的cm仓库里的jdk是1.8的 |
注意:如果是自己用解压的方式安装jdk,一定要注意jdk |
2. 介质下发
各节点根据需要创建/insfiles
或者/dchao/insfiles
用来保存介质
五、创建5个虚拟机
1. 创建standard
https://blog.csdn.net/qq_34224565/article/details/105877614
2. 克隆
{1} 修改硬件配置
扩展硬盘后,需要在linux中将扩展的硬盘加到已经存在的分区中
df -Th,发现 / 只有18G,因为standard一开始只划了20G
lsblk,会发现物理硬盘已经加上了
fdisk /dev/sda 将sda硬盘重新划分
p是查询,m是帮助,n是新建,d是删除
输入d,将sda3删除 (那原来sda3上的东西放哪???暂时不知道)
然后再输入n,新建3,此时sda3包含增加的硬盘,比原来大
输入w,会有警告,不管
输入partprobe,会有警告,不管
输入xfs_growfs /dev/sda3
再输入 df -Th,会发现空间已经加到sda3上了
修改网卡配文
vi /etc/sysconfig/network-scripts/ifcfg-ens32
#如果是桥接,这里是ens33
TYPE=Ethernet # 网络类型为以太网
BOOTPROTO=static # 手动分配ip
NAME=ens32 # 网卡设备名,设备名一定要跟文件名一致
DEVICE=ens32 # 网卡设备名,设备名一定要跟文件名一致
ONBOOT=yes # 该网卡是否随网络服务启动
IPADDR=192.168.233.101 # 该网卡ip地址就是你要配置的固定IP,如果你要用xshell等工具连接,220这个网段最好和你自己的电脑网段一致,否则有可能用xshell连接失败
GATEWAY=192.168.233.2 # 网关,这2个配置去虚拟机的编辑选项卡中查看
NETMASK=255.255.255.0 # 子网掩码
DNS1=8.8.8.8 # DNS,8.8.8.8为Google提供的免费DNS服务器的IP地址
主机名
hostnamectl set-hostname standard
注意:主机名修改不需要重启,只需要exit后重新连接即可。
hosts已经配置,不需要修改
六、克隆之后的配置
1. 免密
所有节点执行ssh-keygen
所有节点执行ssh-copy-id n1;ssh-copy-id n2;ssh-copy-id n3;ssh-copy-id n4;ssh-copy-id n5;
tips
先所有节点执行ssh-copy-id n1;ssh-copy-id n2;ssh-copy-id n3;ssh-copy-id n4;ssh-copy-id n5;,然后复制上密码,这样快一点
2. 时间同步
2种方式,所有节点同步网络时间,或者设置一个节点同步,其他的client跟server同步
{1} cs模式
[1] 所有节点无论cs都安装
yum install -y ntp ntpdate
[2] server配置
(1) 确定一个节点作为server,设置时区,设置server配置
tzselect 5 9 1 1
vim /etc/ntp.conf
driftfile /var/lib/ntp/drift
restrict default nomodify notrap nopeer noquery
restrict 127.0.0.1
restrict ::1
server 127.127.1.0
fudge 127.127.1.0 stratum 10
includefile /etc/ntp/crypto/pw
keys /etc/ntp/keys
disable monitor
(2) client
vim /etc/ntp.conf
driftfile /var/lib/ntp/drift
restrict default nomodify notrap nopeer noquery
restrict 127.0.0.1
restrict ::1
server 192.168.233.105
includefile /etc/ntp/crypto/pw
keys /etc/ntp/keys
disable monitor
[3] 所有节点启动ntpd并设置开机自启
systemctl start ntpd;systemctl enable ntpd;systemctl status ntpd
[4] 验证
要等较长时间才能同步完成
ntpq -p
ntpstat
3. yum
将全量的centos作为yum源
everythiing版的linux iso10G,而minimal只有900多M
{1} 上传iso文件到自定义的/iso下
{2} 创建挂载目录
mkdir /media/CentOS7
{3} 挂载iso文件
mount -t iso9660 -o loop /iso/CentOS-7-x86_64-Everything-1810.iso /media/CentOS7/
{4} 创建yum的仓库配文
vi /etc/yum.repos.d/CentOS7-Localsource.repo
[CentOS7-Localsource]
name=CentOS7
baseurl=file:///media/CentOS7
enabled=1
gpgcheck=0
{5} 清空缓存,重新加载缓存
yum clean all
yum makecache
{6} 下个东西试下
将这个全量系统iso发布
注意:netch不要开,开了windows访问不了虚拟机的地址
{1} 安装httpd + 配置 + 启动、自启
yum -y install httpd
vi /etc/httpd/conf/httpd.conf
AddType application/x-gzip .gz .tgz 添加.parcel,修改为:
AddType application/x-gzip .gz .tgz .parcel
systemctl start httpd
systemctl status httpd
systemctl enable httpd
systemctl is-enabled httpd
systemctl start httpd;systemctl status httpd;systemctl enable httpd;systemctl is-enabled httpd
{2} 创建仓库目录,将挂载目录(不是iso文件)复制到仓库目录下
yum -y install createrepo
mkdir /var/www/html/CentOS7.6-everything
cp -r /media/CentOS7/* /var/www/html/CentOS7.6-everything/
createrepo /var/www/html/CentOS7.6-everything/
七、安装mysql并建库
1. 规划
将mysql程序解压到/mysql下,数据放在/mysqldata下
mkdir /mysqldata
2. 解压
tar zxf /insfiles/mysql-5.7.20-linux-glibc2.12-x86_64.tar.gz -C /
mv /mysql-5.7.20-linux-glibc2.12-x86_64/ /mysql
3. 创建mysql用户,给目录授权
useradd mysql;passwd mysql
chown -R mysql:mysql /mysql;chown -R mysql:mysql /mysqldata
4. /etc/my.cnf
{1} [client]和[mysqld]中的socket要配,不然会去/tmp下创建,会导致没权限而报错
[client]
socket=/mysql/mysql.sock
[mysqld]
basedir=/mysql
datadir=/mysqldata
socket=/mysql/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mariadb according to the
# instructions in http://fedoraproject.org/wiki/Systemd
#
# include all files from the config directory
#
!includedir /etc/my.cnf.d
5. 初始化
/mysql/bin/mysqld --initialize --user=mysql --basedir=/mysql/ --datadir=/mysqldata/
如果报:
yum install -y libaio
6. 加入开机启动
cd /mysql/support-files/
vim mysql.server
if test -z "$basedir"
then
basedir=/mysql
bindir=/mysql/bin
if test -z "$datadir"
then
datadir=/mysqldata
fi
sbindir=/mysql/bin
libexecdir=/mysql/bin
else
bindir="$basedir/bin"
if test -z "$datadir"
then
datadir="$basedir/data"
fi
sbindir="$basedir/sbin"
libexecdir="$basedir/libexec"
fi
cp mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
chkconfig --add mysqld
chkconfig --list mysqld
设了这2步才能用systemctl来操作mysqld
7. 配置env
export JAVA_HOME=/usr/java/jdk1.8.0_181-cloudera
#mysql
export MYSQL_HOME=/mysql
export CLASSPATH=$:CLASSPATH:$JAVA_HOME/lib/
export PATH=${JAVA_HOME}/bin:${PATH}:$MYSQL_HOME/bin
8. 启动,进入客户端进行基本配置
systemctl start mysqld;systemctl status mysqld
mysql -uroot -pjhzU+4b+PDqI
set password=password(“dcdcdc”);
grant all privileges on . to ‘root’@‘%’ identified by ‘dcdcdc’;
flush privileges;
select Host,User from mysql.user;
9. 为cdh建库
官网https://docs.cloudera.com/documentation/enterprise/5-16-x/topics/cm_ig_mysql.html#cmig_topic_5_5
-- scm
create database scm DEFAULT CHARSET utf8 COLLATE utf8_general_ci;
-- 集群监控数据库
create database amon DEFAULT CHARSET utf8 COLLATE utf8_general_ci;
-- rm
create database rman DEFAULT CHARSET utf8 COLLATE utf8_general_ci;
-- hue数据库
create database hue DEFAULT CHARSET utf8 COLLATE utf8_general_ci;
-- metastore
create database metastore DEFAULT CHARSET utf8 COLLATE utf8_general_ci;
-- sentry
create database sentry DEFAULT CHARSET utf8 COLLATE utf8_general_ci;
-- nav
create database nav DEFAULT CHARSET utf8 COLLATE utf8_general_ci;
-- navms
create database navms DEFAULT CHARSET utf8 COLLATE utf8_general_ci;
-- oozie
create database oozie DEFAULT CHARSET utf8 COLLATE utf8_general_ci;
GRANT ALL ON scm.* TO 'scm'@'%' IDENTIFIED BY 'dcdcdc';
GRANT ALL ON amon.* TO 'amon'@'%' IDENTIFIED BY 'dcdcdc';
GRANT ALL ON rman.* TO 'rman'@'%' IDENTIFIED BY 'dcdcdc';
GRANT ALL ON hue.* TO 'hue'@'%' IDENTIFIED BY 'dcdcdc';
GRANT ALL ON metastore.* TO 'hive'@'%' IDENTIFIED BY 'dcdcdc';
GRANT ALL ON sentry.* TO 'sentry'@'%' IDENTIFIED BY 'dcdcdc';
GRANT ALL ON nav.* TO 'nav'@'%' IDENTIFIED BY 'dcdcdc';
GRANT ALL ON navms.* TO 'navms'@'%' IDENTIFIED BY 'dcdcdc';
GRANT ALL ON oozie.* TO 'oozie'@'%' IDENTIFIED BY 'dcdcdc';
SHOW DATABASES;
SHOW GRANTS FOR 'scm'@'%';
10. 所有节点安装mysql驱动
yum install -y mysql-connector-java
八、安装cm
在n2
yum install cloudera-manager-daemons cloudera-manager-server -y
在cm启动之前就把spark的jar放到csd下,不然装完还要重启
scp SPARK2_ON_YARN-2.2.0.cloudera4.jar n2:/opt/cloudera/csd/
创建scm库下的表
/usr/share/cmf/schema/scm_prepare_database.sh -h node101 --scm-host node102 mysql scm scm dcdcdc
systemctl start cloudera-scm-server
查看是否启动
tailf /var/log/cloudera-scm-server/cloudera-scm-server.log
INFO WebServerImpl:com.cloudera.server.cmf.WebServerImpl: Started Jetty server.
九、安装cdh的服务
1. 选节点
2. 设仓库,parcel和rpm的要分别设
注意:如果这里选了spark2,要把jar提前放到csd中
3. 过场
4. 分发
prb:
分发agent时遇到一个问题,一共4个节点,只有node104报失败,日志里写一个依赖找不到,httpd版本当前是93,应该是88。最后的解决办法是把原来系统自带的repo复制到/etc/yum.repo.d中(一开始给把系统自带的给删掉了),之后就好了
5. 角色
6. 设置目录
一般将cdh相关的目录都放在一个跟目录下,比如/cdh
cdh好像能自动检测,生产上在/hadoop下设置了24个目录,挂了24个硬盘,cdh能自动检测到并在这个设置页上默认设上