每个人的搭建部署都不一样,以下是我最近在搭建过程中的详细步骤以及遇到的错误的一个总结。
系统环境:Centos 7.0、JDK1.8、cdh5.13.0
集群环境:内存32、系统盘100G、数据盘400G、CPU 8核 、集群规模5台
环境建议以root用户建立,可以减少一些权限的设置
一、准备工作
Centos7.0离线搭建cdh5.13.0
安装包:
Cm:cloudera-manager-centos7-cm5.13.0_x86_64.tar.gz
网址: http://archive-primary.cloudera.com/cm5/cm/5/
Cdh:CDH-5.13.0-1.cdh5.13.0.p0.29-el7.parcel
CDH-5.13.0-1.cdh5.13.0.p0.29-el7.parcel.sha1
manifest.json
网址:http://archive.cloudera.com/cdh5/parcels/5.13.0/
Mysql:MySQL-5.6.26-1.linux_glibc2.5.x86_64.rpm-bundle.tar
网址:http://ftp.nchu.edu.tw/Unix/Database/MySQL/Downloads/MySQL-5.6/
JDK:jdk-8u171-linux-x64.rpm
网址:
http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
1.2 vi /etc/sysconfig/network-scripts/ifcfg-enp5s0(每台)
(网络配置 contos7和6的配置有些不同)
修改 BOOTPROTO=static
ONBOOT=yes
添加
IPADDR=192.168.1.106
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
DNS1=114.114.114.114
启动网卡
service network start
1.3修改主机名称
vi /etc/sysconfig/network(每台)
Windows中用名字代替ip访问设置的地方
在关闭防火墙这7和6是有区别的
启动: systemctl start firewalld
查看状态: systemctl status firewalld
停止: systemctl disable firewalld
禁用: systemctl stop firewalld
vi /etc/selinux/config
将SELINUX改为disabled , 如下
1.6 配置时间同步(主机)
yum -y install ntp 下载ntp服务
systemctl start ntpd 启动ntp服务
查看服务器是否开机启动 systemctl is-enabled ntpd
设置开机启动命令 chkconfig ntpd on
解决服务器ntp开机无法启动问题:systemctl is-enabled chronyd(查看状态)
systemctl disable chronyd
在启动服务中加上 systemctl start ntpd
vi /etc/rc.local
在其他节点上输入
ntpdate 10.10.1.95
并在所有非主节点中添加cronta定时任务,用命令crontab –e,并添加如下语句
30 * * * * /usr/sbin/ntpdate 10.10.1.95
1.7 配置ssh免密
1.在主节点上运行
ssh-keygen -t rsa
回车三次
生成一个秘钥
2.分发到所有节点
ssh-copy-id ip
1.8 安装JDK
Centos7自带openJDK,我们需要先把openJDK卸载
java -version
rpm -qa | grep jdk查看自带的java
在解压自己下载的jdk
rpm -ivh jdk-8u101-linux-x64.rpm
1.9 配置ulimit(ulimit主要是用来限制进程对资源的使用情况的 可以不配置)
vi /etc/security/limits.conf
mapred - nofile 32768
mapred soft nproc 65535
mapred hard nproc 65535
boco - nofile 32768
boco soft nproc 65535
boco hard nproc 65535
hdfs - nofile 32768
hdfs soft nproc 65535
配置完毕这些之后,重启集群内的每一台机器,让参数生效。
重启:reboot
二 、在主节点上的安装mysql
Centos7自带的是mariadb,需要先把它卸载掉
查看自带的mariadb:
mariadb
将mariadb卸载
rpm -e --nodeps mariadb-libs-5.5.44-2.el7.centos.x86_64
将mysql解压
然后安装全部的rpm -ivh MySQL-*.rpm
修改配置的文件路径:cp /usr/share/mysql/my-default.cnf /etc/my.cnf
在配置文件中增加以下配置并保存
vim /etc/my.cnf
[mysqld]
default-storage-engine = innodb
innodb_file_per_table
collation-server = utf8_general_ci
init-connect = ‘SET NAMES utf8’
character-set-server = utf8
以上安装好后进行初始化mysql
执行以下命令:
/usr/bin/mysql_install_db
启动mysql:
service mysql restart
Mysql有一个初始的密码使用以下命令查看初始密码:
cat /root/.mysql_secret
进行root口令配置
/usr/bin/mysql_secure_installation
[…]
Enter current password for root (enter for none):
OK, successfully used password, moving on…
[…]
Set root password? [Y/n] Y
New password:------输入登陆mysql的root口令
Re-enter new password:----再次输入登陆mysql的root口令
Remove anonymous users? [Y/n] Y
[…]
Disallow root login remotely? [Y/n] N
[…]
Remove test database and access to it [Y/n]Y
[…]
Reload privilege tables now? [Y/n] Y
All done!
安装mysql jdbc驱动
(驱动是cdh连接mysql的驱动)
拷贝文件(安装介质中的mysql-connector-java-5.1.31)到对应路径/usr/share/java/,并重新命名为 mysql-connector-java.jar
2.1.进入mysql:
Mysql -u root -p
2.2.打开mysql数据库
Use mysql
2.3.允许mysql远程访问
update user set host=’%’ where user=‘root’ and host=‘localhost’;
2.4.更新权限
flush privileges;
2.5.配置开机启动
chkconfig mysql on
2.6.创建数据库
create database hive DEFAULT CHARACTER SET utf8;
create user ‘hive’ identified by ‘hive’;
grant all on hive.* TO ‘hive’@’%’ with grant option;
create database amon DEFAULT CHARACTER SET utf8;
create user ‘amon’ identified by ‘amon’;
grant all on amon.* TO ‘amon’@’%’ with grant option;
create database rman DEFAULT CHARACTER SET utf8;
create user ‘rman’ identified by ‘rman’;
grant all on rman.* TO ‘rman’@’%’ with grant option;
create database oozie DEFAULT CHARACTER SET utf8;
create user ‘oozie’ identified by ‘oozie’;
grant all on oozie.* TO ‘oozie’@’%’ with grant option;
create database hue DEFAULT CHARACTER SET utf8;
create user 'hue ’ identified by ‘hue’;
grant all on hue .* TO ‘hue ‘@’%’ with grant option;
拷贝mysql-connector-java到各个节点指定的目录下(所有节点)
cp mysql-connector-java-5.1.36-bin.jar/usr/share/java/mysql-connector-java.jar
三.安装Cloudera-Manager
3.1 解压cm tar包到指定的目录所有节点都要(在主节点解压,scp到子节点)
(1)在所有节点上创建目录
mkdir /opt/cloudera-manager
(2).解压cm tar包
tar -axvf cloudera-manager-centos7-cm5.13.0_x86_64.tar.gz -C /opt/cloudera-manager
(3)Scp到所有的节点
scp -r cloudera/ cm-5.13.0/ 192.168.114.21:/opt/cloudera-manager/
(4)创建cloudera-scm用户(所有节点)
useradd --system --home=/opt/cloudera-manager/cm-5.13.0/run/cloudera-scm-server --no-create-home --shell=/bin/false --comment “Cloudera SCM User” cloudera-scm
3.2.在主节创建cloudera-manager-server的本地元数据保存目录
(1).mkdir /var/cloudera-scm-server
(2).chown cloudera-scm:cloudera-scm /var/cloudera-scm-server
(3).chown cloudera-scm:cloudera-scm /opt/cloudera-manager
3.3.配置所有节点cloudera-manager-agent指向主节点服务器
vi /opt/cloudera-manager/cm-5.13.0/etc/cloudera-scm-agent/config.ini
将server_host改为CMS所在的主机名即192.168.114.20
3.4.在主节点中创建parcel-repo仓库目录
(1) mkdir -p /opt/cloudera/parcel-repo
(2) chown cloudera-scm:cloudera-scm /opt/cloudera/parcel-repo
(3) cp CDH-5.13.0-1.cdh5.13.0.p0.18-el7.parcel CDH-5.13.0-1.cdh5.13.0.p0.18-el7.parcel.sha manifest.json /opt/cloudera/parcel-repo
注意将CDH-5.13.0-1.cdh5.13.0.p0.18-el7.parcel.sha1后缀1去掉否则会重新下载
3.5所有节点创建parcels目录
(1) mkdir -p /opt/cloudera/parcels
(2) chown cloudera-scm:cloudera-scm /opt/cloudera/parcels
解释:Clouder-Manager将CDHS从主节点的/opt/cloudera/parcel-repo目录中抽取出来,分发解压激活到各个节点的/opt/cloudera/parcels目录中
3.6.初始脚本配置数据库scm_prepare_database.sh(在主节点上)
/opt/cloudera-manager/cm-5.13.0/share/cmf/schema/scm_prepare_database.sh mysql -h192.168.114.20 -uroot -p123456 --scm-host 192.168.114.20 scmdbn scmdbu scmdbp
/opt/cm-5.7.0/share/cmf/schema/scm_prepare_database.sh mysql cm -hlocalhost -uroot -p1234.com --scm-host localhost scm scm scm
3.7.配置主节点cloudera-scm-server
在主节点上执行以下命令
(1).cp /opt/cloudera-manager/cm-5.13.0/etc/init.d/cloudera-scm-server /etc/init.d/cloudera-scm-server
(2)chkconfig cloudera-scm-server on
(3)修改CMF_DEFAULTS
vi /etc/init.d/cloudera-scm-server
把CMF_DEFAULTS=${CMF_DEFAULTS:-/etc/default}
改为CMF_DEFAULTS=/opt/cloudera-manager/cm-5.13.0/etc/default
(4).vi /etc/rc.local加入service cloudera-scm-server restart命令
3.8配置所有节点,在所有节点上执行以下命令
(1).mkdir /opt/cloudera-manager/cm-5.13.0/run/cloudera-scm-agent
(2).cp/opt/cloudera-manager/cm-5.13.0/etc/init.d/cloudera-scm-agent/etc/init.d/cloudera-scm-agent
(3).chkconfig cloudera-scm-agent on
(4).修改CMF_DEFAULTS
vim /etc/init.d/cloudera-scm-agent
把CMF_DEFAULTS=${CMF_DEFAULTS:-/etc/default}
改为CMF_DEFAULTS=/opt/cloudera-manager/cm-5.13.0/etc/default
(5).vi /etc/rc.local加入service cloudera-scm-agent restart命令
service cloudera-scm-server start
service cloudera-scm-agent start
四.安装cdh.
4.1.登陆控制台
打开浏览器(火狐或者谷歌浏览器,因为CM并不支持IE浏览器), 输入自己主节点的IP加7180端口登陆控制台, 用户名密码默认为admin/admin
4.2.选择Free版
4.4.选择安装方式
4.5.安装cdh
4.6选择相应的组件
4.7.对个别组件进行配
4.8.数据库设置
4.9.启动服务,完成安装
五、错误总结
5.1为cdh集群安装指定主机找不到:
可能是没有配置所有节点cloudera-manager-agent指向主节点服务器
vi /opt/cloudera-manager/cm-5.13.0/etc/cloudera-scm-agent/config.ini
将server_host改为CMS所在的主机名即可
5.2 正在安装选定的parcel界面不动不下载
可能是因为/etc/hosts 下面的主机名映射没有配置对,查看一下
5.3 cloudera-scm-agent start 启动失败
经过查找后发现/opt/cm-5.7.0/run目录下没有cloudera-scm-agent文件夹
mkdir /opt/cm-5.7.0/run/cloudera-scm-agent
5.4 /opt/cm-5.7.0/etc/init.d/cloudera-scm-server startinstall: invalid user ‘cloudera-scm’
可能是因为 没有创建运行server的用户
解决办法:
useradd --system --home=/opt/cm-5.7.0/run/cloudera-scm-server --shell=/bin/false --comment "Cloudera SCM User" cloudera-scm
5.5 检查主机正确性警告
5.6 启动hive失败
根据提示发现是没有mysql-java连接的驱动jar包
解决办法:
**cp mysql-connector-java-6.0.2.jar /opt/cloudera/parcels/CDH-5.7.0-1.cdh5.7.0.p0.45/lib/hive/lib/**
5.7 启动NFS GateWay失败
**解决办法:
yum -y install rpcbind
systemctl start rpcbind
echo "systemctl start rpcbind" >> /etc/rc.d/rc.local
chmod +x /etc/rc.d/rc.local**
5.8 启动oozie impala失败
**原因是
没有mysql-java连接jar包
解决办法:
ls
CDH-5.7.0-1.cdh5.7.0.p0.45-el7.parcel cloudera-manager-centos7-cm5.7.0_x86_64.tar.gz manifest.json
CDH-5.7.0-1.cdh5.7.0.p0.45-el7.parcel.sha1 jdk-8u91-linux-x64.rpm mysql-connector-java-6.0.2.jar
cp mysql-connector-java-6.0.2.jar /usr/share/java/mysql-connector-java.jar**