前言
CDH搭建涉及到太多东西,有关硬件软件、也有关系统。之前总结时写了一份,自以为是较为完整的。但是后来发现,还是缺漏了好多东西,也有好多知识是点到为止,知其然不知其所以然,所以此次打算在先前的基础上补齐缺漏的知识点,然后争取一次性全部搞懂,避免下次花时间再复习N
遍。
准备工作
系统版本
- 需要Redhat (非定制版) / CentOS / Ubuntu …
1 2
| cat /etc/redhat-release
|
最小化安装
- 在安装系统时,采用最小化安装,避免默认安装其他多余用不到的程序,占磁盘空间,还有一些不必要的服务运行着占内存,最小化安装时一般附带基本的
yum
、vi/vim/nano
和ssh
就行。
配置主机名
1 2 3 4
| vi /etc/hostname source /etc/profile
hostnamectl set-hostname cdh1
|
设置静态IP
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
| vim /etc/sysconfig/network-scripts/ifcfg-enp2s0
TYPE="Ethernet" PROXY_METHOD="none" BROWSER_ONLY="no" BOOTPROTO="static" DEFROUTE="yes" IPV4_FAILURE_FATAL="no" IPV6INIT="yes" IPV6_AUTOCONF="yes" IPV6_DEFROUTE="yes" IPV6_FAILURE_FATAL="no" IPV6_ADDR_GEN_MODE="stable-privacy" NAME="enp2s0" UUID="5c447edd-1c2e-4910-bcaf-4892b56bd042" DEVICE="enp2s0" ONBOOT="yes" IPADDR=172.16.10.6 NETMASK=255.255.255.0 GATEWAY=172.16.10.254 DNS1=202.96.128.86
/etc/init.d/network restart service network restart
ping www.baidu.com
|
配置 yum 源
默认 yum
源是去系统官网下载,下载地址都是在国外,所以下载速度会慢一大截,修改成国内源下载软件速度会快很多。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| cd /etc/yum.repos.d/
mkdir backup mv *.repo backup
wget http://mirrors.163.com/.help/CentOS7-Base-163.repo vim CentOS7-Base-163.repo :1,$s/$releasever/7/g :wq!
yum clean all yum makecache
yum –y install tree
yum repolist all
|
安装网络工具包
由于是最小化安装,所以默认缺少一些网络相关的软件,比如ipconfig
、netstat
等等,需要安装网络工具包。
修改 Host
1 2 3 4 5 6 7
| vi /etc/hosts 192.168.2.1 cdh1 192.168.2.2 cdh2 192.168.2.3 cdh3 192.168.2.4 cdh4 source /etc/hosts
|
永久关闭SElinux
- SELinux是一个安全体系结构,它通过
LSM (Linux Security Modules)
框架被集成到Linux Kernel 2.6.x
中。它是NSA (United States National Security Agency)
和SELinux
社区的联合项目。
- 这个策略严谨而复杂,只有非常看重安全的用途而且需要专门的人员管理才需要,大数据集群用不到就关闭
- 使用
root
用户 1 2 3 4 5 6 7 8 9 10
| sestatus
echo 0 > /selinux/enforce setenforce 0
vi /etc/sysconfig/selinux
|
关闭防火墙
Http容器
- Http服务端,也可以是Nginx。用作yum本地源。
1 2 3 4 5 6 7 8
| yum install httpd vi /etc/httpd/conf/httpd.conf
<Directory "/var/www/html"> Options Indexes FollowSymLinks AllowOverride None Allow from all </Directory>
|
数据库
一个是MySQL,一个是Mariadb,其中之一。
Mariadb
1 2 3 4 5 6 7 8 9 10
| yum -y install mariadb mariadb-server
systemctl start mariadb
systemctl enable mariadb
systemctl status mariadb
/usr/bin/mysql_secure_installation
|
- 按照提示
- 空密码登录
- 设置 root 密码
- 是否删除访客用户
- 是否禁止 root 用户远程登录
- 是否删除 test 数据库
- 是否刷新设置生效
MySQL
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
| wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
yum -y install mysql57-community-release-el7-10.noarch.rpm
yum -y install mysql-community-server
systemctl start mysqld.service
systemctl status mysqld.service
grep "password" /var/log/mysqld.log
mysql -uroot -p
ALTER USER 'root'@'localhost' IDENTIFIED BY '123';
update user set host = '%' WHERE user = 'root';
flush privileges;
yum -y remove mysql57-community-release-el7-10.noarch
systemctl enable mysqld systemctl daemon-reload
|
数据库创建
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
| create database metastore default character set utf8; CREATE USER 'hive'@'%' IDENTIFIED BY 'password'; GRANT ALL PRIVILEGES ON metastore.* TO 'hive'@'%'; FLUSH PRIVILEGES;
create database cm default character set utf8; CREATE USER 'cm'@'%' IDENTIFIED BY 'password'; GRANT ALL PRIVILEGES ON cm.* TO 'cm'@'%'; FLUSH PRIVILEGES;
create database rm default character set utf8; CREATE USER 'rm'@'%' IDENTIFIED BY 'password'; GRANT ALL PRIVILEGES ON rm.* TO 'rm'@'%'; FLUSH PRIVILEGES;
create database am default character set utf8; CREATE USER 'am'@'%' IDENTIFIED BY 'password'; GRANT ALL PRIVILEGES ON am.* TO 'am'@'%'; FLUSH PRIVILEGES;
create database hue default character set utf8; CREATE USER 'hue'@'%' IDENTIFIED BY 'password'; GRANT ALL PRIVILEGES ON hue.* TO 'hue'@'%'; FLUSH PRIVILEGES;
create database oozie default character set utf8; CREATE USER 'oozie'@'%' IDENTIFIED BY 'password'; GRANT ALL PRIVILEGES ON oozie.* TO 'oozie'@'%'; FLUSH PRIVILEGES;
create database sentry default character set utf8; CREATE USER 'sentry'@'%' IDENTIFIED BY 'password'; GRANT ALL PRIVILEGES ON sentry. * TO 'sentry'@'%'; FLUSH PRIVILEGES;
create database nav_ms default character set utf8; CREATE USER 'nav_ms'@'%' IDENTIFIED BY 'password'; GRANT ALL PRIVILEGES ON nav_ms. * TO 'nav_ms'@'%'; FLUSH PRIVILEGES;
create database nav_as default character set utf8; CREATE USER 'nav_as'@'%' IDENTIFIED BY 'password'; GRANT ALL PRIVILEGES ON nav_as. * TO 'nav_as'@'%'; FLUSH PRIVILEGES;
|
安装MySQL驱动
NTP 服务
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| yum -y install ntp
systemctl enable ntpd
systemctl start ntpd
vi /etc/ntp.conf
server 127.127.1.0 fudge 127.127.1.0 stratum 10
server master的ip
systemctl restart ntpd
ntpq -p
|
制作 yum 源
- 制作yum源,便于集群内网安装
CM
和 CDH
。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| yum install yum-utils createrepo
cd /var/www/html/cdh5/5.16.2/cm5.16.2
createrepo .
vi /etc/yum.repos.d/cm.repo
[cloudera-manager] name = Cloudera Manager, Version cloudera-repos baseurl = http://master_ip/cdh5/5.16.2/cm5.16.2 gpgcheck = 0 enable = 1
yum clean all yum makecache
|
集群节点免密登录(可选)
1 2 3 4 5
| ssh-keygen -t rsa cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys scp ~/.ssh/id_rsa.pub master:~/.ssh/authorized_keys sudo chmod 700 ~/.ssh sudo chmod 600 ~/.ssh/authorized_keys
|
Java 环境
要用CDH的专用JDK,不然可能出现不明崩溃,系统卡死。
1 2 3 4
| yum -y install oracle-j2sdk1.7-1.7.0+update67-1.x86_64
java -version
|