本文主要记录Centos7.3 离线安装CDH和Cloudera Manager。安装的版本为Cloudera Manager 5.15.1,如遇不同版本,安装方式大致相同。
内容 | 版本 |
OS | CentOS Linux release 7.3.1611 |
JDK | 1.7 |
Cloudera Manager | 5.15.1 |
本次安装使用了3台虚拟机服务器
主机名 | 配置 | IP | 用途 |
cdh01 | 4核8G内存 | 192.168.1.21 | 主,安装CM |
cdh02 | 4核8G内存 | 192.168.1.22 | 从,slaver |
cdh03 | 4核8G内存 | 192.168.1.23 | 从,slaver |
systemctl disable firewalld
systemctl stop firewalld
echo '192.168.1.21 cdh01
192.168.1.22 cdh02
192.168.1.23 cdh03' >> /etc/hosts
先在cdh01上执行:
ssh-keygen -t rsa #一路回车到完成
ssh-copy-id -i ~/.ssh/id_rsa.pub root@cdh01 #将公钥拷贝到本机的authorized_keys上
再在其他节点分别执行以下命令:
ssh-keygen -t rsa #一路回车到完成
ssh-copy-id -i ~/.ssh/id_rsa.pub root@cdh01 #注意此处不变,将公钥拷贝到cdh01的authorized_keys上
在cdh01上,将authorized_keys分发到其他节点服务器:
scp ~/.ssh/authorized_keys root@cdh02:~/.ssh/
scp ~/.ssh/authorized_keys root@cdh03:~/.ssh/
1)所有节点执行yum install -y ntp安装ntp服务
2)在cdh02, cdh03上修改/etc/ntp.conf配置,修改成如下配置
server cdh01
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
3)检查每个节点的ntp服务状态:ntpq -p
cdh01:
[root@cdh01 ~]# ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
*cn.ntp.faelix.n 185.134.196.169 2 u 21 64 377 286.756 14.200 184.209
CDH02/03:
[root@cdh02 ~]# ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
cdh01 185.134.197.4 3 u 49 64 0 0.000 0.000 0.000
*biisoni.miuku.n 204.123.2.72 2 u 38 64 1 193.145 15.573 0.137
wget http://archive.cloudera.com/cm5/redhat/7/x86_64/cm/5.15.1/RPMS/x86_64/cloudera-manager-agent-5.15.1-1.cm5151.p0.3.el7.x86_64.rpm
wget http://archive.cloudera.com/cm5/redhat/7/x86_64/cm/5.15.1/RPMS/x86_64/cloudera-manager-server-5.15.1-1.cm5151.p0.3.el7.x86_64.rpm
wget http://archive.cloudera.com/cm5/redhat/7/x86_64/cm/5.15.1/RPMS/x86_64/cloudera-manager-server-db-2-5.15.1-1.cm5151.p0.3.el7.x86_64.rpm
wget http://archive.cloudera.com/cm5/redhat/7/x86_64/cm/5.15.1/RPMS/x86_64/enterprise-debuginfo-5.15.1-1.cm5151.p0.3.el7.x86_64.rpm
wget http://archive.cloudera.com/cm5/redhat/7/x86_64/cm/5.15.1/RPMS/x86_64/cloudera-manager-daemons-5.15.1-1.cm5151.p0.3.el7.x86_64.rpm
wget http://archive.cloudera.com/cm5/redhat/7/x86_64/cm/5.15.1/RPMS/x86_64/oracle-j2sdk1.7-1.7.0+update67-1.x86_64.rpm
wget http://archive.cloudera.com/cm5/installer/5.15.1/cloudera-manager-installer.bin
wget http://archive.cloudera.com/cdh5/parcels/5.15.1/CDH-5.15.1-1.cdh5.15.1.p0.4-el7.parcel
wget http://archive.cloudera.com/cdh5/parcels/5.15.1/CDH-5.15.1-1.cdh5.15.1.p0.4-el7.parcel.sha1
下载rpm仓库文件
wget http://archive.cloudera.com/cm5/redhat/7/x86_64/cm/cloudera-manager.repo
修改仓库文件cloudera-manager.repo
,把版本号加上5.15.1
[cloudera-manager]
# Packages for Cloudera Manager, Version 5, on RedHat or CentOS 7 x86_64
name=Cloudera Manager
baseurl=https://archive.cloudera.com/cm5/redhat/7/x86_64/cm/5.15.1/
gpgkey =https://archive.cloudera.com/cm5/redhat/7/x86_64/cm/RPM-GPG-KEY-cloudera
gpgcheck = 1
1)在每个节点上建立/root/soft目录
2)使用xftp工具将下载的软件按下表上传到/root/soft目录下
主机 | 用途 | 软件包 |
cdh01 | 主 | cloudera-manager-agent-5.15.1-1.cm5151.p0.3.el7.x86_64.rpm cloudera-manager-daemons-5.15.1-1.cm5151.p0.3.el7.x86_64.rpm cloudera-manager.repo oracle-j2sdk1.7-1.7.0+update67-1.x86_64.rpm cloudera-manager-server-5.15.1-1.cm5151.p0.3.el7.x86_64.rpm cloudera-manager-server-db-2-5.15.1-1.cm5151.p0.3.el7.x86_64.rpm enterprise-debuginfo-5.15.1-1.cm5151.p0.3.el7.x86_64.rpm cloudera-manager-installer.bin CDH-5.15.1-1.cdh5.15.1.p0.4-el7.parcel CDH-5.15.1-1.cdh5.15.1.p0.4-el7.parcel.sha1 |
cdh02-03 | 从 | cloudera-manager-agent-5.15.1-1.cm5151.p0.3.el7.x86_64.rpm cloudera-manager-daemons-5.15.1-1.cm5151.p0.3.el7.x86_64.rpm cloudera-manager.repo oracle-j2sdk1.7-1.7.0+update67-1.x86_64.rpm |
3)在每个节点上将cloudera-manager.repo拷贝到/etc/yum.repos.d/
cp /root/soft/cloudera-manager.repo /etc/yum.repos.d/
在每个节点/root/soft目录下执行:1)安装命令
yum localinstall -y --nogpgcheck *.rpm
2)添加java环境变量
echo 'export JAVA_HOME=/usr/java/jdk1.7.0_67-cloudera
export CLASSPATH=.:$CLASSPTAH:$JAVA_HOME/lib
export PATH=$PATH:$JAVA_HOME/bin ' >> /etc/profile
source /etc/profile
安装完后检查
yum list | grep cloudera
yum list | grep oracle-j2sdk
service cloudera-scm-agent status #检查agent状态
检查java命令是否正常
java -version
每个节点配置sudoers,否则后面安装HDFS/Hive等服务时会报错误
echo 'cloudera-scm ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers
由于上面的软件包是使用root用户安装的,而运行时用户为cloudera-scm,需要在每个节点上重设一下/var/log/cloudera-scm-agent下文件的权限
chown cloudera-scm:cloudera-scm /var/log/cloudera-scm-agent/ -R
service cloudera-scm-agent restart
进入cdh01的/root/soft所在目录
设置安装权限并执行安装:
chmod u+x cloudera-manager-installer.bin
./cloudera-manager-installer.bin
如果提示需要删除配置文件,则删除该文件
rm -rf /etc/cloudera-scm-server/db.properties
重新执行安装命令,根据安装向导一路next。注意,如果之前master上没有手动安装rpm包此时就会联网下载,下载速度一般都较慢,太费时间。如果出现下面的错误,可以重新执行安装命令,直到提示安装成功。
相同配置下顺利安装时间在1分钟内即可完成。
然后我们在web浏览器访问 http://192.168.1.21:7180/,看是否能打开页面即可,先不要进行登录操作。
注意:chd server服务器启动需要一些时间,等1分钟左右。
如果能访问,那证明 cloudera manager安装正常。
前面完成cloudera manager安装之后cdh01会在/opt目录下生成cloudera文件夹,将之前下载好的CDH-*文件移动到parcel-repo文件夹中,在cdh01中执行:
mv CDH-5.15.1-1.cdh5.15.1.p0.4-el7.parcel /opt/cloudera/parcel-repo
mv CDH-5.15.1-1.cdh5.15.1.p0.4-el7.parcel.sha1 /opt/cloudera/parcel-repo/CDH-5.15.1-1.cdh5.15.1.p0.4-el7.parcel.sha #注意后缀名有重命名
将cloudera manager的用户授权给/opt和日志目录:
chown cloudera-scm:cloudera-scm /opt/cloudera/ -R
chown cloudera-scm:cloudera-scm /var/log/cloudera-scm-agent/ -R
重启cloudera-scm-server(重要)
/etc/init.d/cloudera-scm-server restart #或者 systemctl restart cloudera-scm-server
重启速度较慢,约1-2分钟后访问 http://192.168.1.21:7180/ 登陆,账号密码 admin, 密码admin
选择免费版本,一路next开始安装。
建议不启用单用户模式,单用户模式不成熟,后面安装会遇到一些问题。本篇错误排查之安装失败是单用户下碰到的问题
如果之前的操作没有问题,这里将会很快完成
接下来,根据需要进行配置或保持默认不变即可,一路继续完成安装。
完成安装后,进入系统
systemctl status cloudera-scm-server #主
systemctl status cloudera-scm-server-db #主
systemctl status cloudera-scm-agent
1. 添加节点时安装失败:
1) service cloudera-scm-agent status检查状态,如果状态异常且出现bash: /var/log/cloudera-scm-agent/cloudera-scm-agent.out: Permission denied,则需要给/var/log/cloudera-scm-agent/cloudera-scm-agent.out赋权限(参考4.1节)
2)安装失败
重启机器重试
2. 安装hadoop失败
Removing any leveldbjni library files left over from previous runs
此步安装过程中如果出现失败,则查看stderr的日志。
检查/var/lib/zookeeper和/var/log/zookeeper、/var/lib/zookeeper/version-2目录是否存在且属主为cloudera-scm
stderr日志错误最后打印为sudo /usr/sbin/update-alternatives --auto hive-conf。重新执行即成功
stderr日志:1)/var/lib/oozie/tomcat-deployment目录不存在时创建目录并修改属主
2)Can't load server.xml from /var/lib/oozie/tomcat-deployment/conf/server.xml,在/usr/lib64/cmf/service/oozie/oozie.sh中加sleep,原因未知
mkdir /var/log/hadoop-yarn && chown cloudera-scm:cloudera-scm /var/log/hadoop-yarn
查看stderr中的日志,发现在/var/log下还需要zookeeper、cloudera-scm-eventserver、cloudera-scm-firehose目录
mkdir /var/log/zookeeper && chown cloudera-scm:cloudera-scm /var/log/zookeeper
mkdir /var/log/cloudera-scm-eventserver && chown cloudera-scm:cloudera-scm /var/log/cloudera-scm-eventserver
mkdir /var/log/cloudera-scm-firehose && chown cloudera-scm:cloudera-scm /var/log/cloudera-scm-firehose
mkdir /var/lib/zookeeper && chown cloudera-scm:cloudera-scm /var/lib/zookeeper