我有三台虚拟机,都是最新安装的centos7,下面是资源分配
主机名 | ip | 内存 | 磁盘大小 | 主从 |
s201 | 192.168.0.201 | 10g | 40g | 主 |
s202 | 192.168.0.202 | 4g | 20g | 从 |
s203 | 192.168.0.203 | 4g | 20g | 从 |
【安装过程中默认都是使用root用户进行安装】
Inspector did not run successfully.
java.io.FileNotFoundException: /dfs/nn/current/VERSION (权限不够)
1. 先提前下载好所需的各种安装包
CM包:
CM版本:5.13.1
cloudera-manager-centos7-cm5.13.1_x86_64.tar.gz
下载地址:http://archive.cloudera.com/cm5/cm/5/cloudera-manager-centos7-cm5.13.1_x86_64.tar.gz
CDH包
CDH版本:5.13.1;
CDH-5.13.1-1.cdh5.13.1.p0.2-el7.parcel;
CDH-5.13.1-1.cdh5.13.1.p0.2-el7.parcel.sha1;
manifest.json
下载地址:
http://archive.cloudera.com/cdh5/parcels/5.13.1/manifest.json
http://archive.cloudera.com/cdh5/parcels/5.13.1/CDH-5.13.1-1.cdh5.13.1.p0.2-el7.parcel.sha1
http://archive.cloudera.com/cdh5/parcels/5.13.1/CDH-5.13.1-1.cdh5.13.1.p0.2-el7.parcel
将所有包上传至s201的/soft目录下
2. 安装JDK(默认是全新的最小化安装的centos7)
- 卸载openJDK,安装sunJdk
# rpm -qa|grep java
# rpm -e --nodeps java开头的
# java -version检查是否卸载完了
- 开始安装(此处更换为你的jdk压缩包的名字)
# tar -zxvf jdk-8u171-linux-x64.tar.gz -C /usr/local/
# cd /usr/local/
# ln -s jdk1.8.0_171/ jdk
- 创建环境变量
# vi /etc/profile
在文件最下方或者指定文件添加
# export JAVA_HOME=/usr/local/jdk
# export CLASSPATH=$:CLASSPATH:$JAVA_HOME/lib/
# export PATH=$PATH:$JAVA_HOME/bin
# source /etc/profile
# java -version查看是否成功
3.修改机器名(所有节点)
# hostnamectl set-hostname xxx //设置机器名
# hostname // 查看本机名
每个节点机器,都要配置hosts
# vi /etc/hosts
添加以下内容:
192.168.0.201 localhost.s201
192.168.0.201 s201
192.168.0.202 s202
192.168.0.203 s203
4.关闭防火墙(所有节点)
# systemctl disable firewalld
可以安装完成后再打开
5.设置免密登录(主节点能ssh免密登录到从节点)
主节点上依次执行:
# cd ~
# ssh-keygen -t rsa
# scp /root/.ssh/id_rsa.pub root@s202:~
# scp /root/.ssh/id_rsa.pub root@s203:~
所有从节点上执行:
# cd ~
# mkdir .ssh(如果没有.ssh目录)
# cat id_rsa.pub >> ~/.ssh/authorized_keys
# chmod 600 ~/.ssh/authorized_keys
6.关闭SELINUX(所有节点)
# vi /etc/selinux/config
增加:
SELINUX=disabled
重启后生效:
# reboot
查看SELINUX 是否关闭:
# sestatus
查看结果:
# SELinux status: disabled
7.修改Linux内核参数(所有节点)
(1)为避免安装过程中出现的异常问题,首先调整Linux内核参数,设置swappiness,控制换出运行时内存的相对权重, Cloudera 建议将 swappiness 设置为 10:
查看swappiness :cat /proc/sys/vm/swappiness
永久性修改,执行下面两条命令
sysctl -w vm.swappiness=10
echo vm.swappiness = 10 >> /etc/sysctl.conf
(2)关闭透明大页面:
cat /sys/kernel/mm/transparent_hugepage/defrag
显示:[always] madvise never
cat /sys/kernel/mm/transparent_hugepage/enabled
显示:[always] madvise never
以上状态就说明是启用的
永久关闭:
vi /etc/rc.d/rc.local
在文件后添加下面内容:
if test -f /sys/kernel/mm/transparent_hugepage/enabled; then
echo never > /sys/kernel/mm/transparent_hugepage/enabled
fi
if test -f /sys/kernel/mm/transparent_hugepage/defrag; then
echo never > /sys/kernel/mm/transparent_hugepage/defrag
fi
保存退出,然后赋予rc.local文件执行权限:
chmod +x /etc/rc.d/rc.local
重启系统,以后再检查THP状态
cat /sys/kernel/mm/transparent_hugepage/defrag
显示:always madvise [never]
cat /sys/kernel/mm/transparent_hugepage/enabled
显示:always madvise [never]
显示状态被禁用了
(3)修改文件句柄数:
查看文件句柄数,显示1024,显然太小
ulimit -n
显示:1024
修改限制
vi /etc/security/limits.conf
在文件后加入下面内容:
* soft nofile 100000
* hard nofile 100000
修改后需要重启机器,再次查看句柄数:ulimit -n
8.其他安装与配置(所有节点)
为避免安装过程中出现异常问题,安装相关依赖包:
#yum -y install psmisc MySQL-python at bc bind-libs bind-utils cups-client cups-libs cyrus-sasl-gssapi cyrus-sasl-plain ed fuse fuse-libs httpd httpd-tools keyutils-libs-devel krb5-devel libcom_err-devel libselinux-devel libsepol-devel libverto-devel mailcap noarch mailx mod_ssl openssl-devel pcre-devel postgresql-libs python-psycopg2 redhat-lsb-core redhat-lsb-submod-security x86_64 spax time zlib-devel
#yum install -y python-lxml
#yum install krb5-devel cyrus-sasl-gssapi cyrus-sasl-deve libxml2-devel libxslt-devel mysql mysql-devel openldap-devel python-devel python-simplejson sqlite-devel
# chmod +x /etc/rc.d/rc.local
# yum -y install rpcbind
# systemctl start rpcbind
# echo "systemctl start rpcbind" >> /etc/rc.d/rc.local
9.配置NTP服务
集群中所有主机必须保持时间同步,如果时间相差较大会引起各种问题。 具体安装过程如下:
所有节点安装相关组件:
# yum install ntp ntpdate -y
-
NTP服务端(主节点)
# vi /etc/ntp.conf
注释主节点中配置文件的:
#restrict default nomodify notrap nopeer noquery
//在文件中添加以下内容:
restrict default nomodify
server 0.cn.pool.ntp.org
server 1.asia.pool.ntp.org
server 2.asia.pool.ntp.org
server 127.0.0.1
fudge 127.0.0.1 stratum 10
启动ntp服务:
# systemctl start ntpd
配置开机启动:
# systemctl enable ntpd.service
注意:如果启动ntp服务或者ntpd 开机启动失效,有可能是因为安装了chronyd 并且是开机自启状态,所以导致ntpd开机自启失败。
# 查看 chronyd设置状态
# systemctl status chronyd
chronyd.service - NTP client/server
Loaded: loaded (/usr/lib/systemd/system/chronyd.service; disabled; vendor preset: enabled)
Active: inactive (dead)
Docs: man:chronyd(8)
man:chrony.conf(5)
以面表明,chronyd显示为开机启动状态。
将chronyd设为禁用状态:
# systemctl disable chronyd.service
此时,NTP的服务开机自启动完成!
检查是否设置成功:
# ntpq -p
//更新时间
#timedatectl
-
NTP客户端(所有从节点)
远程客户端时间同步测试
# date
# ntpdate 192.168.0.201
192.168.0.201是NTP服务端IP,显示如下信息,测试成功:
如果出现:ntpdate[10821]: no server suitable for synchronization found
查看是否关闭s201的防火墙
客户端设置计划任务,每30分钟同步时间
#crontab -e
//加入内容:
0-59/30 * * * * /usr/sbin/ntpdate 192.168.0.201 && /sbin/hwclock -w
设置定时任务开机启动
//设置开机启动
# systemctl enable crond.service
//查看状态
# systemctl status crond
10.Mysql安装(主节点)
先卸载mariadb:
# yum remove mariadb*
# wget https://cdn.mysql.com//archives/mysql-5.7/mysql-5.7.18-1.el7.x86_64.rpm-bundle.tar
- 解压安装包
# tar -xvf mysql-5.7.18-1.el7.x86_64.rpm-bundle.tar
//解压后文件列表:
mysql-community-embedded-devel-5.7.18-1.el7.x86_64.rpm
mysql-community-devel-5.7.18-1.el7.x86_64.rpm
mysql-community-client-5.7.18-1.el7.x86_64.rpm
mysql-community-common-5.7.18-1.el7.x86_64.rpm
mysql-community-embedded-5.7.18-1.el7.x86_64.rpm
mysql-community-embedded-compat-5.7.18-1.el7.x86_64.rpm
mysql-community-libs-5.7.18-1.el7.x86_64.rpm
mysql-community-server-minimal-5.7.18-1.el7.x86_64.rpm
mysql-community-test-5.7.18-1.el7.x86_64.rpm
mysql-community-minimal-debuginfo-5.7.18-1.el7.x86_64.rpm
mysql-community-libs-compat-5.7.18-1.el7.x86_64.rpm
- 按次序安装
按common–>libs–>client–>server的顺序安装:
# rpm -ivh mysql-community-common-5.7.18-1.el7.x86_64.rpm
# rpm -ivh mysql-community-libs-5.7.18-1.el7.x86_64.rpm
# rpm -ivh mysql-community-client-5.7.18-1.el7.x86_64.rpm
# rpm -ivh mysql-community-server-5.7.18-1.el7.x86_64.rpm
# rpm -ivh mysql-community-devel-5.7.18-1.el7.x86_64.rpm
如安装出现依赖错误:
# wget http://www.percona.com/redir/downloads/Percona-XtraDB-Cluster/5.5.37-25.10/RPM/rhel6/x86_64/Percona-XtraDB-Cluster-shared-55-5.5.37-25.10.756.el6.x86_64.rpm
# rpm -ivh Percona-XtraDB-Cluster-shared-55-5.5.37-25.10.756.el6.x86_64.rpm
//安装下面包,否则Hue安装报连接错误
# rpm -ivh mysql-community-libs-compat-5.7.18-1.el7.x86_64.rpm
- 启动数据库
# systemctl start mysqld
查看状态:
# systemctl status mysqld
- 修改MySQL初始密码
1、先修改配置文件/etc/my.cnf令MySQL跳过登录时的权限检验
# vi /etc/my.cnf
新增:
validate_password=off
skip-grant-tables
2、重启MySQL
#service mysqld restart
3、免密码登录MySQL。
#mysql
4、mysql客户端执行如下命令,修改root密码
mysql> use mysql;
mysql> UPDATE user SET authentication_string = password('root') WHERE host = 'localhost' AND user = 'root';
mysql> select host,user, authentication_string, password_expired from user;
mysql> update user set password_expired='N' where password_expired='Y'; //密码不过期
mysql> update user set host='%' where user='root' and host='localhost'; //远程可访问
mysql> flush privileges; //刷新
mysql> exit;//退出
5、修改配置文件/etc/my.cnf删除此前新增那一行skip-grant-tables,并重启MySQL(这一步非常重要,不执行可能导致严重的安全问题)
#systemctl restart mysqld.service //重启 Mysql
11.安装CM
(1)在主节点上将CM解压到/opt/目录:
# tar -zxvf cloudera-manager-centos7-cm5.13.1_x86_64.tar.gz -C /opt/
# ls /opt/
cloudera cm-5.13.1
(2)创建数据库
在主节点上:
# mysql -h127.0.0.1 -uroot -p //加参数-h127.0.0.1 指定本机方式,否则可能不允许执行grant
Enter password: \\输入数据库密码
//在MariaDB [(none)]>命令状态输入下面脚本:
create database hive DEFAULT CHARSET utf8 COLLATE utf8_general_ci;
create database amon DEFAULT CHARSET utf8 COLLATE utf8_general_ci;
create database hue DEFAULT CHARSET utf8 COLLATE utf8_general_ci;
create database monitor DEFAULT CHARSET utf8 COLLATE utf8_general_ci;
create database oozie DEFAULT CHARSET utf8 COLLATE utf8_general_ci;
grant all privileges on *.* to root@localhost identified by '123456' with grant option;
grant all on *.* to root@"%" Identified by "123456";
flush privileges;
exit;
//复制Mysql JDBC包到/opt/cm-5.13.1/share/cmf/lib/目录
wget http://central.maven.org/maven2/mysql/mysql-connector-java/5.1.43/mysql-connector-java-5.1.43.jar
#cp mysql-connector-java-5.1.43.jar /opt/cm-5.13.1/share/cmf/lib/
cp mysql-connector-java-5.1.47-bin.jar /opt/cm-5.13.1/share/cmf/lib/
1.创建用户
# useradd --system --home=/opt/cm-5.13.1/run/cloudera-scm-server --shell=/bin/false --comment "Cloudera SCM User" cloudera-scm
2.制作本地YUM源
进入软件包目录
#cd /soft
//拷贝三个文件到/opt/cloudera/parcel-repo/目录
#cp CDH-5.13.1-1.cdh5.13.1.p0.2-el7.parcel CDH-5.13.1-1.cdh5.13.1.p0.2-el7.parcel.sha1 manifest.json /opt/cloudera/parcel-repo/
//进入/opt/cloudera/parcel-repo/目录
#cd /opt/cloudera/parcel-repo/
//修改文件名
#mv CDH-5.13.1-1.cdh5.13.1.p0.2-el7.parcel.sha1 CDH-5.13.1-1.cdh5.13.1.p0.2-el7.parcel.sha
3.拷贝jar包
在所有节点上:
//如果没有/usr/share/java/目录,则创建:mkdir /usr/share/java
# cp mysql-connector-java-5.1.43.jar /usr/share/java/mysql-connector-java.jar
在主节点上:
//将mysql JDBC jar 包拷贝到 /opt/cm-5.13.1/share/cmf/lib/ 目录
#cp mysql-connector-java-5.1.43.jar /opt/cm-5.13.1/share/cmf/lib/
4.修改cloudera-scm-agent配置
在主节点上,修改/opt/cm-5.13.1/etc/cloudera-scm-agent/config.ini文件:
//将config.ini server_host=localhost 内容改为server_host=192.168.0.201
在主节点上:
//将cm-5.13.1 打包,并复制到其他节点
#cd /opt
#tar czf cm-5.13.1.tar.gz cm-5.13.1/
//复制到其他节点
#scp cm-5.13.1.tar.gz s202:/opt/
#scp cm-5.13.1.tar.gz s203:/opt/
在所有从节点上解压:
//将cm-5.13.1 包解压
#cd /opt
#tar -xzvf cm-5.13.1.tar.gz
//解压后删除
#rm -rf cm-5.13.1.tar.gz
5.初始化cm
//初始化CM,执行下面脚本
(对应于:数据库类型、数据库服务器、用户名、密码、CMServer 所在节点…….)
#/opt/cm-5.13.1/share/cmf/schema/scm_prepare_database.sh mysql cm -hs201 -uroot -p123456 --scm-host s201 scm scm scm
//如果出现下面错误:
java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)
//解决办法:
查看在/etc/hosts 文件中,是否加上
127.0.0.1 localhost.s201
6.启动CM Server和Agent
在主节点上,启动cloudera-scm-server:
# /opt/cm-5.13.1/etc/init.d/cloudera-scm-server start
启动过程较慢,可通过/opt/cm-5.13.1/log/cloudera-scm-server日志,查看启动过程。
在所有节点上,启动cloudera-scm-agent:
# /opt/cm-5.13.1/etc/init.d/cloudera-scm-agent start
7.访问CM
地址:http://s201:7180[使用s201的前提是在windows的hosts文件中进行了配置,如果没有则使用192.168.0.201]
用户名、密码:admin
12.在ui界面安装时可能发生的问题
-
安装失败,想要重新安装
每台机器执行:
# ps -ef |grep cloudera |grep -v 'grep'|awk '{print $2}'|xargs -t -i sudo kill -9 {}
删除Agent节点的UUID,每台机器执行:
# rm -rf /opt/cm-5.13.1/lib/cloudera-scm-agent/*
进入主节点的Mysql数据库,然后drop database cm;
在主节点上重新初始化CM数据库:
# /opt/cm-5.13.1/share/cmf/schema/scm_prepare_database.sh mysql cm -hs201 -uroot -p123456 --scm-host s201 scm scm scm
执行重新启动脚本:
主节点:# /opt/cm-5.13.1/etc/init.d/cloudera-scm-server restart
Agent节点:# /opt/cm-5.13.1/etc/init.d/cloudera-scm-agent restart
-
主机运行状态不良
该主机上运行:
# find / -name cm_guid
# rm -rf 查询出来的目录
重启:
# /etc/init.d/cloudera-scm-agent restart
-
安装失败。 无法接收 Agent 发出的检测信号。
排除是否是防火墙的问题;
排除是否端口被占用:
netstat -tunlp |grep 9000
netstat -tunlp |grep 9001
-
Inspector did not run successfully.
vi /opt/cm-5.13.1/etc/default/cloudera-scm-server
添加:
export JAVA_HOME=/usr/local/jdk
重启:
# /opt/cm-5.13.1/etc/init.d/cloudera-scm-agent restart
或者:
http://s201:7180/cmf/hardware/hosts/config?q=java_home#filterfreeText=java_home
设置java_home
-
启动zookeeper失败
Unable to access datadir, exiting abnormally org.apache.zookeeper.server.persistence.FileTxnSnapLog$DatadirException: Missing data directory /var/lib/zookeeper/version-2, automatic data directory creation is disabled (zookeeper.datadir.autocreate is false). Please create this directory manually.
# mkdir /var/lib/zookeeper/version-2
# chown zookeeper:zookeeper version-2/
-
NameNode is not formatted
# /opt/cloudera/parcels/CDH-5.13.1-1.cdh5.13.1.p0.2/bin/hadoop namenode -format
-
java.io.FileNotFoundException: /dfs/nn/current/VERSION (权限不够)
在启动日志中可以查看到如下信息:
STARTUP_MSG: user = hdfs
进行授权操作:
# chown hdfs:root -R /dfs/nn/*
-
启动yarn报错
Service org.apache.hadoop.yarn.server.nodemanager.recovery.NMLeveldbStateStoreService failed in state INITED; cause: org.fusesource.leveldbjni.internal.NativeDB$DBException: IO error: /var/lib/hadoop-yarn/yarn-nm-recovery/yarn-nm-state/LOCK: 权限不够
STARTUP_MSG: Starting NodeManager
STARTUP_MSG: user = yarn
# chown yarn:root -R /var/lib/hadoop-yarn/*