Cdh安装步骤

2018, Aug 10    

CDH安装步骤

2018年5月11日

1.安装前准备

  • 虚拟机配置

主节点 :8G、40G、1个双核处理器;从节点:4G、40G、1个双核处理器

  • 装CentOS 7

注意:装的所有虚拟机的用户名和密码一定要一致,不然会后悔的!!!

  • Master安装MySQL

注意:只在master节点安装MySQL

添加自启动chkconfig mysql on

启动MySQLservice mysql start

接下来执行:

mysql -uroot -proot

create database hive DEFAULT CHARSET utf8 COLLATE utf8_general_ci;
create database amon DEFAULT CHARSET utf8 COLLATE utf8_general_ci;
create database hue DEFAULT CHARSET utf8 COLLATE utf8_general_ci;
create database monitor DEFAULT CHARSET utf8 COLLATE utf8_general_ci;
create database oozie DEFAULT CHARSET utf8 COLLATE utf8_general_ci;

grant all privileges  on *.* to 'root'@'%' identified by 'root' with grant option;
flush privileges;
  • 每台机器安装JDK

source /etc/profile可以让修改后的profile立即生效

  • 每台机器修改主机名&映射、配置静态IP

如果是动态IP,我们的机器IP在某些时候会改变,这就要我们修改hosts文件配置!!!

我们设置为静态IP后就免去了这个麻烦!

修改主机名&映射

主机名的格式:bigdata-cdh01.bookcycle.cn

修改主机名

CentOS 6修改方法:

hostname 主机名(暂时生效) ,然后编辑vi /etc/sysconfig/network 在文件中修改主机名(下次重启后永久生效);

CentOS 7修改方法:hostnamectl set-hostname 主机名

修改CentOS映射

vi etc/hosts

注:hosts文件的第二行 ::1几乎没有什么用,可以删除掉,但是第一行不要全部删除调,然后调整位置

修改后的hosts文件如下

127.0.0.1  localhost.localdomain localhost
## BigData CDH 5.x
192.168.38.128  bigdata-cdh01.bookcycle.cn      bigdata-cdh01
192.168.38.129  bigdata-cdh02.bookcycle.cn      bigdata-cdh02
192.168.38.130  bigdata-cdh03.bookcycle.cn      bigdata-cdh03
192.168.38.131  bigdata-cdh04.bookcycle.cn      bigdata-cdh04
192.168.38.132  bigdata-cdh05.bookcycle.cn      bigdata-cdh05
192.168.38.133  bigdata-cdh06.bookcycle.cn      bigdata-cdh06

修改虚拟机所在主机的Windows映射

进入目录C:\Windows\System32\drivers\etc,编辑hosts文件,增加如下内容

192.168.38.128  bigdata-cdh01.bookcycle.cn      bigdata-cdh01
192.168.38.129  bigdata-cdh02.bookcycle.cn      bigdata-cdh02
192.168.38.130  bigdata-cdh03.bookcycle.cn      bigdata-cdh03
192.168.38.131  bigdata-cdh04.bookcycle.cn      bigdata-cdh04
192.168.38.132  bigdata-cdh05.bookcycle.cn      bigdata-cdh05
192.168.38.133  bigdata-cdh06.bookcycle.cn      bigdata-cdh06

√ 配置静态IP

ip addr查询到网卡的MAC地址

2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
   link/ether 00:0c:29:18:6d:ec brd ff:ff:ff:ff:ff:ff

/etc/sysconfig/network-scripts,修改ifcfg-ens33网卡:vi ifcfg-ens33(增加或者修改的内容用红色标出)

$\color{Red}{ONBOOT=”yes”}$(默认是yes,如果没有,记得更正)

$\color{red}{BOOTPROTO=”static”}$ (由dhcp改为static)

$\color{red}{HWADDR=”00:0c:29:18:6d:ec”}$ (增加MAC地址)

$\color{Red}{IPADDR=”192.168.38.131”}$(设置静态IP地址)

$\color{Red}{NETMASK=”255.255.255.0”}$(设置掩码)

$\color{Red}{GATEWAY=”192.168.38.2”}$(设置网关)

$\color{Red}{DNS1=”114.114.114.114”}$(设置首选DNS服务器,114DNS)

$\color{Red}{DNS2=”223.6.6.6”}$(设置备选DNS服务器,阿里DNS)

刷新网络配置systemctl restart network(CentOS 7的用法),service network restart(CentOS 6的用法)

注:

网关IP的查看方法

一般地,广播地址的最后一段是.255,网关的最后一段一般是.1或.2,

因为网关是一个可以ping 通的地址,我们可以通ping命令试试看,看哪个才是网关

netstat -rn #用于查看自己所在的网关

网关或DNS不对的后果

会造成上不了网,ping不通别的机器

  • 每台机器关闭IPV6

centos7上开启ipv6往往有些不太方便,有时走ipv4协议有时走ipv6协议,出现问题了将会很难排查。

[root@bigdata-cdh04 init.d]# ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.38.131  netmask 255.255.255.0  broadcast 192.168.38.255
        inet6 fe80::c3bb:e72e:9530:402b  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:18:6d:ec  txqueuelen 1000  (Ethernet)
        RX packets 1040939  bytes 1507951641 (1.4 GiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 65049  bytes 37646114 (35.9 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

发现我们的网卡开启了IPV6

vi /etc/sysctl.conf
最后一行增加net.ipv6.conf.all.disable_ipv6=1

vi /etc/sysconfig/network
最后一行增加NETWORKING_IPV6=no

cd /etc/sysconfig/network-scripts
vi ifcfg-ens33
设置IPV6INIT="no"

执行sysctl -p

然后,

  • 每台机器selinux关闭
[root@bigdata-cdh04 ~]# vi /etc/sysconfig/selinux
SELINUX=disabled // 重启才能生效,重启后检查
[root@bigdata-cdh04 ~]#sestatus -v
SELinux status: disabled // 表示已经关闭了
  • **每台机器防火墙关闭 **
[root@bigdata-cdh04 ~]# systemctl stop firewalld
[root@bigdata-cdh04 ~]# systemctl disable firewalld
[root@bigdata-cdh04 ~]# systemctl status firewalld
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
   Active: inactive (dead)
  • 打通主节点到所有节点(包括自己)的SSH免密登陆

在主节点执行以下命令:cd ~,然后继续执行ssh-keygen -t rsa,过程如下

[root@bigdata-cdh04 ~]# ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): 【敲回车】
Created directory '/root/.ssh'.
Enter passphrase (empty for no passphrase): 【敲回车】
Enter same passphrase again: 【敲回车】
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:DzzQmwi4PlGtWM5Go+itiz+zUmE9UnAN4B0HyYfInmI root@bigdata-cdh04.bookcycle.cn
The key's randomart image is:
+---[RSA 2048]----+
| .o==*.          |
| .o+=+o.         |
| .o+B.o .        |
|.E*Xo+ + o       |
|oo=o=.. S        |
|..oo     +       |
| oo.      .      |
|o +.             |
|.=++             |
+----[SHA256]-----+

ssh-copy-id命令(这条命令后面跟IP而不是主机名),将生成的公钥发送到所有节点(包括主机节点),执行命令如下

ssh-copy-id 192.168.38.131 (实现主节点自我免密码登陆)
ssh-copy-id 192.168.38.132 (实现主节点对从节点免密码登陆)
ssh-copy-id 192.168.38.133 (实现主节点对从节点免密码登陆)

其中一个的执行过程记录如下:

[root@bigdata-cdh04 .ssh]# ssh-copy-id 192.168.38.131
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
The authenticity of host '192.168.38.131 (192.168.38.131)' can't be established.
ECDSA key fingerprint is SHA256:rYwGGly4k547DJ+sP5RRyAt0YFPnachSjJiapX/BlIw.
ECDSA key fingerprint is MD5:05:01:78:79:71:4d:5f:36:61:37:62:f3:59:5b:d2:0b.
Are you sure you want to continue connecting (yes/no)? y
Please type 'yes' or 'no': yes【输入yes】
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
root@192.168.38.131's password: 【输入密码】

Number of key(s) added: 1

Now try logging into the machine, with:   "ssh '192.168.38.131'"
and check to make sure that only the key(s) you wanted were added.

最后,可以用ssh命令检测免密码登陆的效果,记录如下:

[root@bigdata-cdh04 .ssh]# ssh 192.168.38.132
The authenticity of host '192.168.38.132 (192.168.38.132)' can't be established.
ECDSA key fingerprint is SHA256:Q20qLvztmPfJq5ko6viMP1F0T1vgkLWcIDfKlnivobo.
ECDSA key fingerprint is MD5:a8:27:3a:0c:f3:47:32:87:7e:71:15:02:ad:5f:16:a6.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.38.132' (ECDSA) to the list of known hosts.
root@192.168.38.132's password: 
Last login: Sat May 12 20:00:29 2018 from 192.168.38.1
[root@bigdata-cdh05 ~]# exit
登出
Connection to 192.168.38.132 closed.
[root@bigdata-cdh04 .ssh]#
  • 每台机器NTP服务器设置(用于不同节点间实现时间同步)

安装NTPyum -y install ntp

编辑NTP的服务器vi /etc/ntp.conf,注释掉所有server ..*的指向,新添加一条可连接的ntp服务器;在其他节点上把ntp指向master服务器地址即可。

主节点设置:

#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 ntp1.aliyun.com iburst #阿里云NTP服务器

其余的从节点设置:

#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 bigdata-cdh04 iburst

启动NTPservice ntpd startsystemctl start ntpd.service

主节点与阿里云NTP服务器同步

[root@bigdata-cdh04 .ssh]# ntpdate -u ntp1.aliyun.com
12 May 20:41:46 ntpdate[1614]: adjust time server 182.92.12.11 offset 0.005925 sec

启动从节点,并与主节点NTP同步

[root@bigdata-cdh04 .ssh]# ntpdate -u bigdata-cdh04
12 May 20:46:11 ntpdate[1374]: adjust time server 192.168.38.131 offset -0.002510 sec
  • 下载素材

1.cloudera manager包 :5.7.2 cloudera-manager-centos7-cm5.7.2_x86_64.tar.gz

http://archive.cloudera.com/cm5/cm/5/cloudera-manager-centos7-cm5.7.2_x86_64.tar.gz

2.CDH-5.7.2-1.cdh5.7.2.p0.18-el7.parcel

3.CDH-5.7.2-1.cdh5.7.2.p0.18-el7.parcel.sha1

4.manifest.json

这三个下载地址在http://archive.cloudera.com/cdh5/parcels/5.7.2/

注:注意centos要下载el7的

5.下载yum源的素材

下载 https://archive.cloudera.com/cm5/redhat/7/x86_64/cm/5.7.2/的所有内容

  • 主节点配置本地yum源($\color{red}{等到以后步骤}$)

配置yum源是为了后面的快速安装,不然网速慢,会等很久!!!

首先,给主节点配置http服务

安装yum -y install httpd

配置vi /etc/httpd/conf/httpd.conf

Listen 80 (默认为80端口,修改为其他也可以),服务的根目录 /var/www/html

Listen 80
DocumentRoot "/var/www/html"

启动service httpd startsystemctl start httpd.service

接着,修改yum源

拷贝素材到/var/www/html/cm5目录下,并在浏览器中进行访问测试:

http://bigdata-cdh04.bookcycle.cn/cm5/

进入目录/etc/yum.repos.d

编辑cloudera-manager.repo,内容如下:

[cloudera-manager]
name = Cloudera Manager, Version 5.7.2
baseurl = http://bigdata-cdh04/cm5/redhat/7/x86_64/cm/5.7.2/
enabled = 1
gpgcheck = 0

然后,将这个yum配置同步到所有机器

2.开始安装

  • 主节点解压安装

解压cloudera-manager-centos7-cm5.7.2_x86_64.tar.gz到/opt目录下

执行tar -zxvf cloudera-manager-centos7-cm5.7.2_x86_64.tar.gz

  • 在主节点为Cloudera Manager 5建立数据库

mysql-connector-java-5.1.40-bin.jar放置到/opt/cm-5.7.2/share/cmf/lib目录下

执行/opt/cm-5.7.2/share/cmf/schema/scm_prepare_database.sh mysql -hlocalhost -uroot -proot --scm-host localhost scm scm scm记录如下:

[root@bigdata-cdh04 cm-5.7.2]# /opt/cm-5.7.2/share/cmf/schema/scm_prepare_database.sh mysql -hlocalhost -uroot -proot --scm-host localhost scm scm
Enter SCM password: 【这个为新增的scm用户的密码】
JAVA_HOME=/usr/local/jdk1.8.0_121
Verifying that we can write to /opt/cm-5.7.2/etc/cloudera-scm-server
Creating SCM configuration file in /opt/cm-5.7.2/etc/cloudera-scm-server
groups: cloudera-scm: no such user
Executing:  /usr/local/jdk1.8.0_121/bin/java -cp /usr/share/java/mysql-connector-java.jar:/usr/share/java/oracle-connector-java.jar:/opt/cm-5.7.2/share/cmf/schema/../lib/* com.cloudera.enterprise.dbutil.DbCommandExecutor /opt/cm-5.7.2/etc/cloudera-scm-server/db.properties com.cloudera.cmf.db.
2018-05-12 22:45:40,609 [main] INFO  com.cloudera.enterprise.dbutil.DbCommandExecutor  - Successfully connected to database.
All done, your SCM database is configured correctly!
  • 在主节点修改Agent配置

修改/opt/cm-5.7.2/etc/cloudera-scm-agent/config.ini中的server_host为主节点的主机名。

server_host=bigdata-cdh04

同步Agent到其他节点

scp -r /opt/cm-5.7.2 root@bigdata-cdh05:/opt/
scp -r /opt/cm-5.7.2 root@bigdata-cdh06:/opt/

// 记录如下
[root@bigdata-cdh04 cm-5.7.2]# scp -r /opt/cm-5.7.2 root@bigdata-cdh06:/opt/
The authenticity of host 'bigdata-cdh06 (192.168.38.133)' can't be established.
ECDSA key fingerprint is SHA256:lNToZwRMLYYyndcOZbmbZdpZqs0YKuatcVaaUzrLpB0.
ECDSA key fingerprint is MD5:db:28:ad:69:b4:53:35:55:88:fd:bd:6c:e6:a6:c2:69.
Are you sure you want to continue connecting (yes/no)? yes 【敲击yes】
......
......
  • 为所有节点创建cloudera-scm用户(每个节点都要执行)
useradd --system --home=/opt/cm-5.7.2/run/cloudera-scm-server --no-create-home --shell=/bin/false --comment "Cloudera SCM User" cloudera-scm
  • 准备Parcels,用以安装CDH5

将CHD5相关的Parcel包放到主节点/opt/cloudera/parcel-repo目录中(parcel-repo需要手动创建),相关包如下:

CDH-5.7.2-1.cdh5.7.2.p0.18-el7.parcel

CDH-5.7.2-1.cdh5.7.2.p0.18-el7.parcel.sha

manifest.json

注意:CDH-5.7.2-1.cdh5.7.2.p0.18-el7.parcel.sha1必须重命名为CDH-5.7.2-1.cdh5.7.2.p0.18-el7.parcel.sha,否则系统会重新下载CDH-5.7.2-1.cdh5.7.2.p0.18-el7.parcel文件。

  • 启动Cloudera Manager

登陆主节点执行:/opt/cm-5.7.2/etc/init.d/cloudera-scm-server start

可能会报这个错

[root@bigdata-cdh04 init.d]# ./cloudera-scm-server start
./cloudera-scm-server:行109: pstree: 未找到命令
Starting cloudera-scm-server:                              [  确定  ]

原因 因为系统是最小化安装,默认没有安装psmisc

解决方法:先./cloudera-scm-server stop停掉cloudera-scm-server,然后执行 yum -y install psmisc

接着,等待一会(在等待的这段时间可以去:/opt/cm-5.7.2/log/cloudera-scm-server执行tail -f /opt/cm-5.7.2/log/cloudera-scm-server/cloudera-scm-server.log追踪执行情况),然后访问:http://bigdata-cdh04:7180/,用户名和密码都是admin

登陆所有节点执行:/opt/cm-5.7.2/etc/init.d/cloudera-scm-agent start,然后查看agent日志,看是否有报错:cd /opt/cm-5.7.2/log/cloudera-scm-agent,查看tail -f /opt/cm-5.7.2/log/cloudera-scm-agent/cloudera-scm-agent.log

[13/May/2018 11:29:51 +0000] 2043 DnsResolutionMonitor throttling_logger INFO     Using java location: '/usr/local/jdk1.8.0_121/bin/java'.
[13/May/2018 11:30:54 +0000] 2043 Monitor-HostMonitor throttling_logger ERROR    Timeout with args ['chronyc', 'sources']
None
[13/May/2018 11:30:54 +0000] 2043 Monitor-HostMonitor throttling_logger ERROR    Failed to collect NTP metrics

发现错误,立即启动ntp服务器,并进行时间同步!!

  • 为 CDH 群集安装指定主机。

………

Cloudera 建议将 /proc/sys/vm/swappiness 设置为最大值 10。当前设置为 30。使用 sysctl 命令在运行时更改该设置并编辑 /etc/sysctl.conf,以在重启后保存该设置。您可以继续进行安装,但 Cloudera Manager 可能会报告您的主机由于交换而运行状况不良。以下主机将受到影响: 
bigdata-cdh[02-03].bookcycle.cn

swappiness 是交换区,用free -m命令检查内存,可以看到swap(交换区)的大小,本质上来说swap
就是硬盘空间,但内存容纳不下数据时会将数据放到硬盘的交换区,由于大数据平台的机器内存较大,我们
不希望把数据交换到磁盘,因此系统建议我们尽可能的不适用交换区,将其值设置为10

【解决方法】
sysctl -w vm.swappiness=10 (设置每台节点,立即生效,下次重启后却失效)

检查设置是否成功
cat /proc/sys/vm/swappiness

然后,需要编辑一个文件,然这种改变持久化
echo "vm.swappiness=10" >> /etc/sysctl.conf


===========================
	已启用透明大页面压缩,可能会导致重大性能问题。请运行“echo never > /sys/kernel/mm/transparent_hugepage/defrag”以禁用此设置,然后将同一命令添加到 /etc/rc.local 等初始脚本中,以便在系统重启时予以设置。以下主机将受到影响: 
bigdata-cdh[02-03].bookcycle.cn

【解决方法】每台机器
执行命令echo never > /sys/kernel/mm/transparent_hugepage/defrag

vi /etc/rc.local

echo never > /sys/kernel/mm/transparent_hugepage/defrag
添加命令到左后一行

【解决了所有问题之后一定要在检查!!!点击“重新运行”,再次检查】

安装的错误相关日志在/var/log/cloudera-manager-installer/