[关闭]
@zhaikun 2018-05-09T16:36:45.000000Z 字数 8121 阅读 1221

CDH安装

大数据


准备工作

以下步骤要在所有节点上执行

1、修改hostname

  1. vim /etc/sysconfig/network

2、关闭SELinux

  1. SELinux没有关闭,按照下述方式关闭
  2. [root@BigDataMaster ~]# vi /etc/selinux/config
  3. # This file controls the state of SELinux on the system.
  4. # SELINUX= can take one of these three values:
  5. # enforcing - SELinux security policy is enforced.
  6. # permissive - SELinux prints warnings instead of enforcing.
  7. # disabled - No SELinux policy is loaded.
  8. SELINUX=disabled
  9. # SELINUXTYPE= can take one of these two values:
  10. # targeted - Targeted processes are protected,
  11. # mls - Multi Level Security protection.
  12. SELINUXTYPE=targeted

3、安装软件包依赖关系

  1. [root@BigDataNode04 ~]# yum install bind-utils chkconfig cyrus-sasl-gssapi cyrus-sasl-plain fuse fuse-libs gcc httpd init-functions libxslt mod_ssl MySQL-python openssl openssl-devel perl portmap psmisc python-psycopg2 python-setuptools sed service sqlite swig useradd zlib

关闭防火墙

  1. service iptables stop

配置NTP服务(所有节点)(略)

修改hosts文件

  1. 把所有要添加到集群中的主机都要加入hosts中,格式如下:
  2. 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
  3. ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
  4. 172.16.132.160 BigDataMaster
  5. 172.16.132.161 BigDataMaster02
  6. 172.16.132.162 BigDataNode01
  7. 172.16.132.163 BigDataNode02
  8. 172.16.132.164 BigDataNode03
  9. 172.16.132.165 BigDataNode04
  10. 172.16.132.166 BigDataNode05
  11. 172.16.132.167 BigDataNode06
  12. 172.16.132.168 BigDataNode07
  13. 172.16.132.169 BigDataNode08

提前下载(本教程中,CM和CDH版本均为5.7.1)

软件的下载地址下载地址
下载CDH Parcel文件,只需要下载图中所示的3个文件
此处输入图片的描述

这里注意下,将.sha1文件后缀更改为.sha,同时把内容只保留hash码部分。

SSH免密登陆

  1. 1、生成一个key
  2. [root@BigDataMaster ~]# ssh-keygen -t rsa
  3. 2、将这个key传到所有节点
  4. [root@BigDataMaster ~]# ssh-copy-id -i .ssh/id_rsa.pub root@172.16.132.161

安装JAVA环境

  1. [root@BigDataNode01 ~]# mkdir /usr/local/java && tar zxvf jdk-8u101-linux-x64.tar.gz -C /usr/local/java
  2. [root@BigDataMaster parcel-repo]# vim /etc/profile
  3. export JAVA_HOME=/usr/local/java/jdk1.8.0_101
  4. export PATH=$PATH:$JAVA_HOME/bin
  5. [root@BigDataMaster parcel-repo]# . /etc/profile

配置Agent

  1. [root@BigDataMaster ~]# vim /opt/cm-5.7.6/etc/cloudera-scm-agent/config.ini
  2. [General]
  3. # Hostname of the CM server.
  4. server_host=172.16.132.160
  5. # Port that the CM server is listening on.
  6. server_port=7182

优化建议

  1. echo "vm.swappiness = 0" >>/etc/sysctl.conf && sysctl -p && echo never >/sys/kernel/mm/redhat_transparent_hugepage/defrag && echo "echo never >/sys/kernel/mm/redhat_transparent_hugepage/defrag" >>/etc/rc.local

Cloudera Manager安装

数据库安装

  1. [root@BigDataMaster] tar zxvf mysql-5.6.27-linux-glibc2.5-x86_64.tar.gz -C /usr/local/
  2. [root@BigDataMaster] mv mysql-5.6.27-linux-glibc2.5-x86_64/ mysql
  3. [root@BigDataMaster] mkdir -p /data/mysql/mysql3306/{data,logs,tmp}
  4. [root@BigDataMaster] vim my3306.cnf
  5. #my.cnf
  6. [client]
  7. port = 3306
  8. socket = /tmp/mysql.sock
  9. [mysql]
  10. prompt='(test)\u@\h [\d]>'
  11. #tee=/data/mysql/mysql3306/data/query.log
  12. no-auto-rehash
  13. [mysqld]
  14. #misc
  15. user = mysql
  16. basedir = /usr/local/mysql/
  17. datadir = /data/mysql/mysql3306/data
  18. port = 3306
  19. socket = /tmp/mysql.sock
  20. event_scheduler = 0
  21. #tmp
  22. tmpdir=/data/mysql/mysql3306/tmp
  23. lower_case_table_names = 1
  24. #timeout
  25. interactive_timeout = 300
  26. wait_timeout = 300
  27. #character set
  28. character-set-server = utf8
  29. open_files_limit = 65535
  30. max_connections = 100
  31. max_connect_errors = 100000
  32. #skip-name-resolve = 1
  33. #logs
  34. log-output=file
  35. slow_query_log = 1
  36. slow_query_log_file = slow.log
  37. log-error = error.log
  38. pid-file = mysql.pid
  39. long_query_time = 1
  40. #log-slow-admin-statements = 1
  41. log-queries-not-using-indexes = 1
  42. log-slow-slave-statements = 1
  43. explicit_defaults_for_timestamp=1
  44. #binlog
  45. binlog_format = row
  46. server-id = 2203306
  47. log-bin = /data/mysql/mysql3306/logs/mysql-bin
  48. binlog_cache_size = 4M
  49. max_binlog_size = 1G
  50. max_binlog_cache_size = 2G
  51. sync_binlog = 1
  52. innodb_flush_log_at_trx_commit = 1
  53. expire_logs_days = 10
  54. binlog_checksum = NONE # for GR
  55. #relay log
  56. relay-log = /data/mysql/mysql3306/logs/relay-bin
  57. skip_slave_start = 1
  58. max_relay_log_size = 1G
  59. relay_log_purge = 0
  60. relay_log_recovery = 1
  61. log_slave_updates = 1
  62. #slave-skip-errors=1032,1053,1062
  63. # replication
  64. relay_log_recovery = ON
  65. master_info_repository = TABLE
  66. relay_log_info_repository = TABLE
  67. #buffers & cache
  68. table_open_cache = 2048
  69. table_definition_cache = 2048
  70. table_open_cache = 2048
  71. max_heap_table_size = 96M
  72. sort_buffer_size = 2M
  73. join_buffer_size = 2M
  74. thread_cache_size = 256
  75. query_cache_size = 0
  76. query_cache_type = 0
  77. query_cache_limit = 256K
  78. query_cache_min_res_unit = 512
  79. thread_stack = 192K
  80. tmp_table_size = 96M
  81. key_buffer_size = 8M
  82. read_buffer_size = 2M
  83. read_rnd_buffer_size = 16M
  84. bulk_insert_buffer_size = 32M
  85. #myisam
  86. myisam_sort_buffer_size = 128M
  87. myisam_max_sort_file_size = 10G
  88. myisam_repair_threads = 1
  89. #innodb
  90. innodb_buffer_pool_size = 100M
  91. innodb_buffer_pool_instances = 4
  92. innodb_data_file_path = ibdata1:1G:autoextend
  93. innodb_flush_log_at_trx_commit = 1
  94. innodb_log_buffer_size = 64M
  95. innodb_log_file_size = 500M
  96. innodb_log_files_in_group = 3
  97. innodb_max_dirty_pages_pct = 50
  98. innodb_file_per_table = 1
  99. innodb_rollback_on_timeout
  100. innodb_status_file = 1
  101. innodb_io_capacity = 2000
  102. transaction_isolation = READ-COMMITTED
  103. innodb_flush_method = O_DIRECT
  104. [mysqld_safe]
  105. #malloc-lib=/usr/local/mysql/lib/jmalloc.so
  106. nice=-19
  107. open-files-limit=65535
  108. [root@BigDataMaster] /usr/local/mysql_install_db --defaults-file=/data/mysql/mysql3306/my3306.cnf

进入mysql并创建以下数据库:

1、首先需要去MySql的官网下载JDBC驱动,http://dev.mysql.com/downloads/connector/j/,解压后,找到mysql-connector-java-5.1.35-bin.jar,放到/opt/cm-5.7.6/share/cmf/lib/中。

  1. [root@BigDataMaster mysql-connector-java-5.1.41]# cp mysql-connector-java-5.1.41-bin.jar /opt/cm-5.7.6/share/cmf/lib/

2、在主节点初始化CM5的数据库:

  1. mysql> CREATE USER 'scm'@'%' IDENTIFIED BY 'scm';
  2. Query OK, 0 rows affected (0.01 sec)
  3. mysql> grant all privileges on *.* to 'scm'@'%' with grant option;
  4. Query OK, 0 rows affected (0.01 sec)
  5. mysql> grant all privileges on *.* to 'root'@'%' with grant option;
  6. Query OK, 0 rows affected (0.00 sec)
  7. mysql> flush privileges;
  8. Query OK, 0 rows affected (0.00 sec)
  9. mysql> create database hive DEFAULT CHARSET utf8 COLLATE utf8_general_ci;

初始化

  1. [root@BigDataMaster schema]# /opt/cm-5.7.6/share/cmf/schema/scm_prepare_database.sh mysql -hlocalhost -uroot -p123456 --scm-host localhost scm scm scm
  2. JAVA_HOME=/usr/local/java/jdk1.8.0_101
  3. Verifying that we can write to /opt/cm-5.7.6/etc/cloudera-scm-server
  4. Creating SCM configuration file in /opt/cm-5.7.6/etc/cloudera-scm-server
  5. groups: cloudera-scm:无此用户
  6. Executing: /usr/local/java/jdk1.8.0_101/bin/java -cp /usr/share/java/mysql-connector-java.jar:/usr/share/java/oracle-connector-java.jar:/opt/cm-5.7.6/share/cmf/schema/../lib/* com.cloudera.enterprise.dbutil.DbCommandExecutor /opt/cm-5.7.6/etc/cloudera-scm-server/db.properties com.cloudera.cmf.db.
  7. [ main] DbCommandExecutor INFO Successfully connected to database.
  8. All done, your SCM database is configured correctly!

安装

把cm传到各个节点

  1. [root@BigDataNode04 ~]# scp -r /opt/cm-5.7.6/ root@172.16.132.169:/opt/

启动sever端

  1. [root@BigDataNode04 ~]# /opt/cm-5.7.6/etc/init.d/cloudera-scm-server start

各个节点启动agent端

  1. [root@BigDataNode04 ~]# /opt/cm-5.7.6/etc/init.d/cloudera-scm-agent start

登录

登录

选择版本(本次选择免费版)

版本

各节点安装CDH集群

此处输入图片的描述

选择CDH版本

此处输入图片的描述

集群安装

此处输入图片的描述

主机检查

此处输入图片的描述

集群设置,选择服务

此处输入图片的描述

自定义服务

此处输入图片的描述

自定义角色服务

此处输入图片的描述

出现问题

此处输入图片的描述
据说此问题是BUG,修复方法
错误日志

  1. -yarn/stacks', u'bytes_free_warning_threshhold_bytes': 0, u'group': u'hadoop', u'user': u'yarn', u'mode': 493}, u'cpu': None, u'contents': None
  2. Traceback (most recent call last):
  3. File "/opt/cm-5.7.6/lib64/cmf/agent/build/env/lib/python2.6/site-packages/cmf-5.7.6-py2.6.egg/cmf/agent.py", line 1605, in handle_heartbeat_p
  4. new_process.activate()
  5. File "/opt/cm-5.7.6/lib64/cmf/agent/build/env/lib/python2.6/site-packages/cmf-5.7.6-py2.6.egg/cmf/agent.py", line 3144, in activate
  6. self.write_process_conf()
  7. File "/opt/cm-5.7.6/lib64/cmf/agent/build/env/lib/python2.6/site-packages/cmf-5.7.6-py2.6.egg/cmf/agent.py", line 3251, in write_process_conf
  8. "source_parcel_environment", env))
  9. File "/opt/cm-5.7.6/lib64/cmf/agent/build/env/lib/python2.6/site-packages/cmf-5.7.6-py2.6.egg/cmf/util.py", line 373, in source
  10. raise e
  11. ValueError: dictionary update sequence element #93 has length 1; 2 is required

修复方法:

  1. [root@BigDataNode06 cloudera-scm-agent]# vim /opt/cm-5.7.6/lib64/cmf/agent/build/env/lib/python2.6/site-packages/cmf-5.7.6-py2.6.egg/cmf/util.py
  2. #原样子
  3. LOG.warn("None environment value: %s=%s" % (k, v,))
  4. pipe = subprocess.Popen(['/bin/bash', '-c', ". %s; %s; env" % (path, command)],
  5. stdout=subprocess.PIPE, env=caller_env)
  6. data = pipe.communicate()[0]
  7. try:
  8. #修复
  9. pipe = subprocess.Popen(['/bin/bash', '-c', ". %s; %s; env| grep -v { | grep -v }" % (path, command)],
  10. stdout=subprocess.PIPE, env=caller_env)
  11. data = pipe.communicate()[0]
  12. try:
  13. return dict((line.split("=", 1) for line in data.splitlines()))
  14. except Exception, e:

通过CM启动hive报错.org.apache.hadoop.hive.metastore.HiveMetaException: Failed to load driver

  1. [root@BigDataNode04 tools]# cp mysql-connector-java-5.1.41-bin.jar /opt/cloudera/parcels/CDH/lib/hive/lib/

最好从已经运行的slave机器上scp对应的文件夹,不用修改server_host了,但是需要把对应的[/opt/cm-5.7.0/lib/cloudera-scm-agent]下的文件全部删除;同时删除[/opt/cm-5.7.0/log/cloudera-scm-agent]目录下的所有内容。

安装完成

此处输入图片的描述

此处输入图片的描述

添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注