CDH (Cloudera’s Distribution, including Apache Hadoop),是Hadoop众多分支中的一种,由Cloudera维护,基于稳定版本的Apache Hadoop构建,并集成了很多补丁,可直接用于生产环境。
Cloudera Manager则是为了便于在集群中进行Hadoop等大数据处理相关的服务安装和监控管理的组件,对集群中主机、Hadoop、Hive、Spark等服务的安装配置管理做了极大简化。
vi /etc/sysconfit/network
vi /etc/hosts
[root@master data]# ssh-keygen -t rsa
[root@master data]# cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
[root@master data]# scp ~/authorized_keys root@ndoe1:~/.ssh
[root@master data]# ssh node1
[root@localhost java]# rpm -ivh jdk-8u201-linux-x64.rpm
#Java Home directory configuration
export JAVA_HOME=/usr/java/default
export PATH="$PATH:$JAVA_HOME/bin"
使其生效
[root@master data]# . /etc/profile
[root@master data]# java -version
java version "1.8.0_201"
Java(TM) SE Runtime Environment (build 1.8.0_201-b09)
Java HotSpot(TM) 64-Bit Server VM (build 25.201-b09, mixed mode)
参考博文:
https://blog.csdn.net/Vchen_hao/article/details/76613788
参考博文:
https://blog.csdn.net/vchen_hao/article/details/88820711
防火墙:
service iptables stop (临时关闭)
chkconfig iptables off (重启后生效)
SElinux:
setenforce 0 (临时生效)
修改 /etc/selinux/config 下的 SELINUX=disabled (重启后永久生效)
集群中所有主机必须保持时间同步,如果时间相差较大会引起各种问题。 具体思路如下:
master节点作为ntp服务器与外界对时中心同步时间,随后对所有datanode节点提供时间同步服务。
所有datanode节点以master节点为基础同步时间。
参考博文:
https://blog.csdn.net/Vchen_hao/article/details/88822056
cloudera manager 的目录默认位置在/opt下,解压:
tar xzvf cloudera-manager*.tar.gz
将解压后的cm-cm-5.16.1和cloudera目录放到/opt目录下。
为Cloudera Manager 5建立数据库
首先需要去MySql的官网下载JDBC驱动,http://dev.mysql.com/downloads/connector/j/,
解压后,找到mysql-connector-java-5.1.33-bin.jar,
放到 /opt/cm-5.1.3/share/cmf/lib/ 中。
/opt/cm-cm-5.16.1/share/cmf/schema/scm_prepare_database.sh mysql cm -hlocalhost -uroot -pxxxx --scm-host localhost scm scm scm
Agent配置
scp -r /opt/cm-5.16.1 root@n2:/opt/
在所有节点创建cloudera-scm用户
useradd --system --home=/opt/cm-5.1.3/run/cloudera-scm-server/ --no-create-home --shell=/bin/false --comment "Cloudera SCM User" cloudera-scm
相关的文件如下:
最后将CDH-5.16.1-1.cdh5.16.1.p0.3-el6.parcel.sha1,重命名为CDH-5.16.1-1.cdh5.16.1.p0.3-el6.parcel.sha,这点必须注意,否则,系统会重新下载CDH-5.1.3-1.cdh5.1.3.p0.12-el6.parcel文件。
相关启动脚本
通过/opt/cm-5.16.1/etc/init.d/cloudera-scm-server start启动服务端。
/opt/cm-5.16.1/etc/init.d/cloudera-scm-server start
通过/opt/cm-5.16.1/etc/init.d/cloudera-scm-agent start启动Agent服务。
/opt/cm-5.16.1/etc/init.d/cloudera-scm-agent start
我们启动的其实是个service脚本,需要停止服务将以上的start参数改为stop就可以了,重启是restart。
Cloudera Manager Server和Agent都启动以后,就可以进行CDH5的安装配置了。
这时可以通过浏览器访问主节点的7180端口测试一下了(由于CM Server的启动需要花点时间,这里可能要等待一会才能访问),默认的用户名和密码均为admin:
可以看到,免费版本的CM5已经没有原来50个节点数量的限制了。
各个Agent节点正常启动后,可以在当前管理的主机列表中看到对应的节点。选择要安装的节点,点继续。
接下来,出现以下包名,说明本地Parcel包配置无误,直接点继续就可以了。
点击,继续,如果配置本地Parcel包无误,那么下图中的已下载,应该是瞬间就完成了,然后就是耐心等待分配过程就行了,大约10多分钟吧,取决于内网网速。
接下来是服务器检查,可能会遇到以下问题:
Cloudera 建议将 /proc/sys/vm/swappiness 设置为 0。当前设置为 60。使用 sysctl 命令在运行时更改该设置并编辑 /etc/sysctl.conf 以在重启后保存该设置。您可以继续进行安装,但可能会遇到问题,Cloudera Manager 报告您的主机由于交换运行状况不佳。以下主机受到影响:
通过 echo 0 > /proc/sys/vm/swappiness 即可解决。
接下来是选择安装服务:
服务配置,一般情况下保持默认就可以了(Cloudera Manager会根据机器的配置自动进行配置,如果需要特殊调整,自行进行设置就可以了):
接下来是数据库的设置,检查通过后就可以进行下一步的操作了:
下面是集群设置的审查页面,我这里都是保持默认配置的:
终于到安装各个服务的地方了,注意,这里安装Hive的时候可能会报错,因为我们使用了MySql作为hive的元数据存储,hive默认没有带mysql的驱动,通过以下命令拷贝一个就行了:
cp /opt/cm-5.1.3/share/cmf/lib/mysql-connector-java-5.1.33-bin.jar /opt/cloudera/parcels/CDH-5.1.3-1.cdh5.1.3.p0.12/lib/hive/lib/
服务的安装过程大约半小时内就可以完成:
安装完成后,就可以进入集群界面看一下集群的当前状况了。
这里可能会出现无法发出查询:对 Service Monitor 的请求超时的错误提示,如果各个组件安装没有问题,一般是因为服务器比较卡导致的,过一会刷新一下页面就好了:
测试
在集群的一台机器上执行以下模拟Pi的示例程序:
sudo -u hdfs hadoop jar /opt/cloudera/parcels/CDH/lib/hadoop-mapreduce/hadoop-mapreduce-examples.jar pi 10 100
执行过程需要花一定的时间,通过YARN的后台也可以看到MapReduce的执行状态:
MapReduce执行过程中终端的输出如下:
Number of Maps = 10
Samples per Map = 100
Wrote input for Map #0
Wrote input for Map #1
Wrote input for Map #2
Wrote input for Map #3
Wrote input for Map #4
Wrote input for Map #5
Wrote input for Map #6
Wrote input for Map #7
Wrote input for Map #8
Wrote input for Map #9
Starting Job
14/10/13 01:15:34 INFO client.RMProxy: Connecting to ResourceManager at n1/192.168.1.161:8032
14/10/13 01:15:36 INFO input.FileInputFormat: Total input paths to process : 10
14/10/13 01:15:37 INFO mapreduce.JobSubmitter: number of splits:10
14/10/13 01:15:39 INFO mapreduce.JobSubmitter: Submitting tokens for job: job_1413132307582_0001
14/10/13 01:15:40 INFO impl.YarnClientImpl: Submitted application application_1413132307582_0001
14/10/13 01:15:40 INFO mapreduce.Job: The url to track the job: http://n1:8088/proxy/application_1413132307582_0001/
14/10/13 01:15:40 INFO mapreduce.Job: Running job: job_1413132307582_0001
14/10/13 01:17:13 INFO mapreduce.Job: Job job_1413132307582_0001 running in uber mode : false
14/10/13 01:17:13 INFO mapreduce.Job: map 0% reduce 0%
14/10/13 01:18:02 INFO mapreduce.Job: map 10% reduce 0%
14/10/13 01:18:25 INFO mapreduce.Job: map 20% reduce 0%
14/10/13 01:18:35 INFO mapreduce.Job: map 30% reduce 0%
14/10/13 01:18:45 INFO mapreduce.Job: map 40% reduce 0%
14/10/13 01:18:53 INFO mapreduce.Job: map 50% reduce 0%
14/10/13 01:19:01 INFO mapreduce.Job: map 60% reduce 0%
14/10/13 01:19:09 INFO mapreduce.Job: map 70% reduce 0%
14/10/13 01:19:17 INFO mapreduce.Job: map 80% reduce 0%
14/10/13 01:19:25 INFO mapreduce.Job: map 90% reduce 0%
14/10/13 01:19:33 INFO mapreduce.Job: map 100% reduce 0%
14/10/13 01:19:51 INFO mapreduce.Job: map 100% reduce 100%
14/10/13 01:19:53 INFO mapreduce.Job: Job job_1413132307582_0001 completed successfully
14/10/13 01:19:56 INFO mapreduce.Job: Counters: 49
File System Counters
FILE: Number of bytes read=91
FILE: Number of bytes written=1027765
FILE: Number of read operations=0
FILE: Number of large read operations=0
FILE: Number of write operations=0
HDFS: Number of bytes read=2560
HDFS: Number of bytes written=215
HDFS: Number of read operations=43
HDFS: Number of large read operations=0
HDFS: Number of write operations=3
Job Counters
Launched map tasks=10
Launched reduce tasks=1
Data-local map tasks=10
Total time spent by all maps in occupied slots (ms)=118215
Total time spent by all reduces in occupied slots (ms)=11894
Total time spent by all map tasks (ms)=118215
Total time spent by all reduce tasks (ms)=11894
Total vcore-seconds taken by all map tasks=118215
Total vcore-seconds taken by all reduce tasks=11894
Total megabyte-seconds taken by all map tasks=121052160
Total megabyte-seconds taken by all reduce tasks=12179456
Map-Reduce Framework
Map input records=10
Map output records=20
Map output bytes=180
Map output materialized bytes=340
Input split bytes=1380
Combine input records=0
Combine output records=0
Reduce input groups=2
Reduce shuffle bytes=340
Reduce input records=20
Reduce output records=0
Spilled Records=40
Shuffled Maps =10
Failed Shuffles=0
Merged Map outputs=10
GC time elapsed (ms)=1269
CPU time spent (ms)=9530
Physical memory (bytes) snapshot=3792773120
Virtual memory (bytes) snapshot=16157274112
Total committed heap usage (bytes)=2856624128
Shuffle Errors
BAD_ID=0
CONNECTION=0
IO_ERROR=0
WRONG_LENGTH=0
WRONG_MAP=0
WRONG_REDUCE=0
File Input Format Counters
Bytes Read=1180
File Output Format Counters
Bytes Written=97
Job Finished in 262.659 seconds
Estimated value of Pi is 3.14800000000000000000
检查Hue
首次登陆Hue会让设置一个初试的用户名和密码,设置好,登陆到后台,会做一次检查,一切正常后会提示:
到这里表明我们的集群可以使用了。
遇到的问题
Agent启动后,安装阶段“当前管理的主机”中显示的节点不全,每次刷新显示的都不一样。
Agent的错误日志表现如下:
[18/Nov/2014 21:12:56 +0000] 22681 MainThread agent ERROR Heartbeating to master:7182 failed.
Traceback (most recent call last):
File "/home/opt/cm-5.2.0/lib64/cmf/agent/src/cmf/agent.py", line 820, in send_heartbeat
response = self.requestor.request('heartbeat', dict(request=heartbeat))
File "/home/opt/cm-5.2.0/lib64/cmf/agent/build/env/lib/python2.6/site-packages/avro-1.6.3-py2.6.egg/avro/ipc.py", line 139, in request
return self.issue_request(call_request, message_name, request_datum)
File "/home/opt/cm-5.2.0/lib64/cmf/agent/build/env/lib/python2.6/site-packages/avro-1.6.3-py2.6.egg/avro/ipc.py", line 255, in issue_request
return self.read_call_response(message_name, buffer_decoder)
File "/home/opt/cm-5.2.0/lib64/cmf/agent/build/env/lib/python2.6/site-packages/avro-1.6.3-py2.6.egg/avro/ipc.py", line 235, in read_call_response
raise self.read_error(writers_schema, readers_schema, decoder)
File "/home/opt/cm-5.2.0/lib64/cmf/agent/build/env/lib/python2.6/site-packages/avro-1.6.3-py2.6.egg/avro/ipc.py", line 244, in read_error
return AvroRemoteException(datum_reader.read(decoder))
File "/home/opt/cm-5.2.0/lib64/cmf/agent/build/env/lib/python2.6/site-packages/avro-1.6.3-py2.6.egg/avro/io.py", line 444, in read
return self.read_data(self.writers_schema, self.readers_schema, decoder)
File "/home/opt/cm-5.2.0/lib64/cmf/agent/build/env/lib/python2.6/site-packages/avro-1.6.3-py2.6.egg/avro/io.py", line 448, in read_data
if not DatumReader.match_schemas(writers_schema, readers_schema):
File "/home/opt/cm-5.2.0/lib64/cmf/agent/build/env/lib/python2.6/site-packages/avro-1.6.3-py2.6.egg/avro/io.py", line 379, in match_schemas
w_type = writers_schema.type
AttributeError: 'NoneType' object has no attribute 'type'
这是由于在主节点上启动了Agent后,又将Agent scp到了其他节点上导致的,首次启动Agent,它会生成一个uuid,路径为:/opt/cm-5.1.3/lib/cloudera-scm-agent/uuid,这样的话每台机器上的Agent的uuid都是一样的了,就会出现紊乱的情况。
解决方案:
删除/opt/cm-5.1.3/lib/cloudera-scm-agent/目录下的所有文件。
清空主节点CM数据库。
最佳实践
在内网单独搭建yum的repo,然后CM的管理界面安装Agent,这样安装比较快,也不会出现什么问题。
如果手动添加添加Agent的话,需要注意启动之前删除相关的标示文件,否则Server端在数据库中记录Agent的信息,还得清理数据库中的信息,就麻烦了。
转自:https://www.cnblogs.com/jasondan/p/4011153.html
cdh6 离线安装:
https://blog.csdn.net/u010514380/article/details/88083139