一、环境准备
1.配置 Cloudera Manager 仓库(所有节点)
wget https://archive.cloudera.com/cm6/6.0.1/redhat7/yum/cloudera-manager.repo -P /etc/yum.repos.d/
rpm --import https://archive.cloudera.com/cm6/6.0.0/redhat7/yum/RPM-GPG-KEY-cloudera
2.安装jdk 1.8(略)
3.安装mysql 5.7(略)
wget https://cdn.mysql.com//archives/mysql-5.7/mysql-5.7.22-linux-glibc2.12-x86_64.tar.gz
或者yum
这里 不详细说明了
二、开始准备安装
1.修改hostname
修改集群中各机器的hosts和hostname,并使之永久生效。步骤如下:
输入命令 hostname:查看当前hostname;
输入命令 hostname <new.hostname>:修改new hostname并立即生效(临时有效,重启系统后失效)
输入命令 vim /etc/hosts:为集群中的各机器添加对应的hosts;
输入命令 vim /etc/sysconfig/network:修改HOSTNAME=new.hostname,使new.hostname永久生效。(如果没有该值则手动添加,并重启确认是否永久生效)
2.配置SSH登录
设置集群中的各机器能互相SSH免密登录,并且能够ssh locahost登录本机。步骤如下:
输入命令 ssh-keygen -t rsa,一路回车即可;
输入命令 ssh-copy-id -i .ssh/id_rsa.pub username@target.machine.ip;
ssh登录各机器进行确认。
可能会有的报错:
/usr/bin/ssh-copy-id: ERROR: Host key verification failed.
因为我输入ssh-copy-id -i .ssh/id_rsa.pub root@10.1.2.104.master时没有输入yes 直接回车,再次输入yes成功
3.开放端口防火墙
sudo firewall-cmd --zone=public --add-port=7180/tcp --permanent
sudo firewall-cmd --reload
临时关闭防火墙
systemctl stop firewalld
4. 设置SELinux的模式
检查SELinux当前状态:getenforce;
如果输出为Permissive或Disabled,那么就可以不用设置SELinux的模式了。如果输出是enforcing,就接着做下一步;
vim /etc/selinux/config (有些系统里是 /etc/sysconfig/selinux);
将 SELINUX=enforcing 修改为 SELINUX=permissive,保存并退出;
输入 setenforce 0,使设置立即生效
5. 配置NTP服务(时间同步)
集群中各机器都要配
https://docs.cloudera.com/documentation/enterprise/6/6.0/topics/install_cdh_enable_ntp.html
三、下载安装CDH包
1.下载CHD_manger
wget http://archive.cloudera.com/cm5/cm/5/cloudera-manager-centos7-cm5.11.0_x86_64.tar.gz
2.下载CDH
wget http://archive.cloudera.com/cdh5/parcels/5.11.2/CDH-5.11.2-1.cdh5.11.2.p0.4-el7.parcel
wget http://archive.cloudera.com/cdh5/parcels/5.11.2/CDH-5.11.2-1.cdh5.11.2.p0.4-el7.parcel.sha1
wget http://archive.cloudera.com/cdh5/parcels/5.11.2/manifest.json
3.安装CDH_manger
解压cloudera-manager-centos7-cm5.11.0_x86_64.tar.gz
cloudera manager的目录默认位置在/opt下
mv cm-5.11.0 /opt/
mv cloudera /opt/
添加mysql 驱动
cp /opt/cm-5.11.0/share/cmf/common_jars/mysql-connector-java-5.1.15.jar /opt/cm-5.11.0/share/cmf/lib
cd /opt/cloudera/parcel-repo/
复制以下文件到该目录
CDH-5.11.0-1.cdh5.11.0.p0.34-el6.parcel.sha1
CDH-5.11.0-1.cdh5.11.0.p0.34-el6.parcel
manifest.json
修改
CDH-5.11.0-1.cdh5.11.0.p0.34-el6.parcel.sha1为
CDH-5.11.0-1.cdh5.11.0.p0.34-el6.parcel.sha
4.创建用户scm
useradd --system --no-create-home --shell=/bin/false --comment "Cloudera SCM User" scm
CREATE DATABASE scm DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
CREATE DATABASE amon DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
CREATE DATABASE rman DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
CREATE DATABASE hue DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
CREATE DATABASE metastore DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
CREATE DATABASE sentry DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
CREATE DATABASE nav DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
CREATE DATABASE navms DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
CREATE DATABASE oozie DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
GRANT ALL ON scm.* TO 'scm'@'%' IDENTIFIED BY 'scm';
GRANT ALL ON amon.* TO 'amon'@'%' IDENTIFIED BY 'amon';
GRANT ALL ON rman.* TO 'rman'@'%' IDENTIFIED BY 'rman';
GRANT ALL ON hue.* TO 'hue'@'%' IDENTIFIED BY 'hue';
GRANT ALL ON metastore.* TO 'hive'@'%' IDENTIFIED BY 'hive';
GRANT ALL ON sentry.* TO 'sentry'@'%' IDENTIFIED BY 'sentry';
GRANT ALL ON nav.* TO 'nav'@'%' IDENTIFIED BY 'nav';
GRANT ALL ON navms.* TO 'navms'@'%' IDENTIFIED BY 'navms';
GRANT ALL ON oozie.* TO 'oozie'@'%' IDENTIFIED BY 'oozie';
各Service所需的库如下图,其中库名和user名可以自定义,但自己必须记住。(建议库名使用图中所示的,user名可以自定义,并且可以相同)
5.在主节点初始化CM5数据库
运行
/opt/cm-5.11.2/share/cmf/schema/scm_prepare_database.sh mysql scm scm
六、启动:
/opt/cm-5.11.2/etc/init.d/cloudera-scm-server start
登录:
http://10.1.4.44:7180/cmf/login
遇到的报错总结:
1 启动报错:
启动server/agent失败,报错pstree: command not found
安装 psmisc
yum -y install psmisc
2 我重装了HDFS所以报错
对当前 NameNode 的名称目录进行格式化。如果名称目录不为空,此操作将失败。
删除 /dfs下的nn目录重试即可
3 datanode启动失败报错
Failed to add storage directory [DISK]file:/dfs/dn/
java.io.IOException: Incompatible clusterIDs in /dfs/dn: namenode clusterID = cluster18; datanode clusterID = cluster4
at org.apache.hadoop.hdfs.server.datanode.DataStorage.doTransition(DataStorage.java:779)
at org.apache.hadoop.hdfs.server.datanode.DataStorage.loadStorageDirectory(DataStorage.java:302)
at org.apache.hadoop.hdfs.server.datanode.DataStorage.loadDataStorage(DataStorage.java:418)
at org.apache.hadoop.hdfs.server.datanode.DataStorage.addStorageLocations(DataStorage.java:397)
at org.apache.hadoop.hdfs.server.datanode.DataStorage.recoverTransitionRead(DataStorage.java:575)
at org.apache.hadoop.hdfs.server.datanode.DataNode.initStorage(DataNode.java:1523)
at org.apache.hadoop.hdfs.server.datanode.DataNode.initBlockPool(DataNode.java:1483)
at org.apache.hadoop.hdfs.server.datanode.BPOfferService.verifyAndSetNamespaceInfo(BPOfferService.java:313)
at org.apache.hadoop.hdfs.server.datanode.BPServiceActor.connectToNNAndHandshake(BPServiceActor.java:219)
at org.apache.hadoop.hdfs.server.datanode.BPServiceActor.run(BPServiceActor.java:673)
at java.lang.Thread.run(Thread.java:745)
5月 24, 下午2点50:03.457分 FATAL org.apache.hadoop.hdfs.server.datanode.DataNode
Initialization failed for Block pool <registering> (Datanode Uuid f3f7f49f-ad45-484d-b83a-9ce7c15ab759) service to 10.1.2.104.master/10.1.2.104:8022. Exiting.
java.io.IOException: All specified directories are failed to load.
at org.apache.hadoop.hdfs.server.datanode.DataStorage.recoverTransitionRead(DataStorage.java:576)
at org.apache.hadoop.hdfs.server.datanode.DataNode.initStorage(DataNode.java:1523)
at org.apache.hadoop.hdfs.server.datanode.DataNode.initBlockPool(DataNode.java:1483)
at org.apache.hadoop.hdfs.server.datanode.BPOfferService.verifyAndSetNamespaceInfo(BPOfferService.java:313)
at org.apache.hadoop.hdfs.server.datanode.BPServiceActor.connectToNNAndHandshake(BPServiceActor.java:219)
at org.apache.hadoop.hdfs.server.datanode.BPServiceActor.run(BPServiceActor.java:673)
at java.lang.Thread.run(Thread.java:745)
将/dfs/nn 和 dn的 VERSION中的clusterIDs改为一致即可
出现该问题的原因:在第一次格式化dfs后,启动并使用了hadoop,后来又重新执行了格式化命令,这时namenode的clusterID会重新生成,而datanode的clusterID 保持不变。