系统环境:CentOS-7-x86_64-Minimal-1804.iso,离线安装CDH和Cloudera Manager过程,软件版本如下:
NO. | 软件名称 | 版本 |
1 | 操作系统 | CentOS-7-x86_64-Minimal-1804.iso |
2 | JDK | |
3 | Clouder Manager | |
4 | CDH | |
5 | 数据库 | |
6 | JDBC |
本次安装在7台服务器上,服务器相关情况如下:
NO. | 服务器 | 内网IP地址 |
配置 | 用途 |
1 | node00 | 172.16.2.100 | 主节点,CM,Mysql | |
2 | node01 | 172.16.2.112 | 从 | |
3 | node02 | 172.16.2.129 | 从 | |
4 | node03 | 172.16.2.134 | 从 | |
5 | node04 | 172.16.2.144 | 从 | |
6 | node05 | 172.16.2.159 | 从 | |
7 | node06 | 172.16.2.161 | 从 |
JDK版本:1.8.0_151
jdk-8u151-linux-x64.rpm
下载地址:http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
CM版本:5.13.1
cloudera-manager-centos7-cm5.13.1_x86_64.tar.gz
下载地址:http://archive-primary.cloudera.com/cm5/cm/5/cloudera-manager-centos7-cm5.13.1_x86_64.tar.gz
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-primary.cloudera.com/cdh5/parcels/5.13.1/manifest.json
http://archive-primary.cloudera.com/cdh5/parcels/5.13.1/CDH-5.13.1-1.cdh5.13.1.p0.2-el7.parcel.sha1
http://archive-primary.cloudera.com/cdh5/parcels/5.13.1/CDH-5.13.1-1.cdh5.13.1.p0.2-el7.parcel
jar包版本:5.1.43,
mysql-connector-java-5.1.43.jar
下载地址:http://central.maven.org/maven2/mysql/mysql-connector-java/5.1.43/mysql-connector-java-5.1.43.jar
#查看服务器名称
hostname
#修改服务器名称
vi /etc/hostname
#或者下面这种方式
hostnamectl set-hostname xxx
#修改hosts配置文件
vi /etc/hosts
127.0.0.1 localhost //建议保留这行
#查看防火墙状态
firewall-cmd --state
#开启防火墙
systemctl start firewalld.service
#关闭防火墙
systemctl stop firewalld.service
#禁止防火漆开机启动
systemctl disable firewalld.service
设置防火墙策略,在所有节点执行下面脚本(执行前要启动防火墙):
//集群机器间可以相互访问
firewall-cmd --permanent --add-rich-rule="rule family='ipv4' source address='node00' port protocol='tcp' port='0-65535' accept"
firewall-cmd --permanent --add-rich-rule="rule family='ipv4' source address='node01' port protocol='tcp' port='0-65535' accept"
firewall-cmd --permanent --add-rich-rule="rule family='ipv4' source address='node02' port protocol='tcp' port='0-65535' accept"
firewall-cmd --permanent --add-rich-rule="rule family='ipv4' source address='node03' port protocol='tcp' port='0-65535' accept"
firewall-cmd --permanent --add-rich-rule="rule family='ipv4' source address='node04' port protocol='tcp' port='0-65535' accept"
firewall-cmd --permanent --add-rich-rule="rule family='ipv4' source address='node05' port protocol='tcp' port='0-65535' accept"
firewall-cmd --permanent --add-rich-rule="rule family='ipv4' source address='node06' port protocol='tcp' port='0-65535' accept"
//设置可以访问的端口
firewall-cmd --permanent --add-port=0-65535/tcp
firewall-cmd --reload
注意: 需要在所有的节点上执行,因为涉及到的端口太多了,临时开放所有端口是为了安装起来方便,安装完毕后可以根据需要设置防火墙策略,保证集群安全。
#cd ~/.ssh
#ssh-keygen -t rsa
#三次回车键之后会生成无密码的钥匙对
#拷贝公钥至各个节点实现免密登录
#ssh-copy-id root@node00
#下面根据提示配置完成yes和节点密码
#查看是否关闭SELINUX
sestatus
#临时生效
setenforce 0
#永久生效
vi /etc/selinux/config
SELINUX=disabled
#需要重启才能生效,这一步暂时不用重启,后面的步骤也需要重启
为避免安装过程中出现的异常问题,首先调整Linux内核参数。
================================================================
1) 设置swappiness,控制换出运行时内存的相对权重,Cloudera 建议将 swappiness 设置为 10:
//查看swappiness
# cat /proc/sys/vm/swappiness
//永久性修改,执行下面两条命令
# sysctl -w vm.swappiness=10
# echo vm.swappiness = 10 >> /etc/sysctl.conf
=================================================================
2) 关闭透明大页面:
自CentOS6版本开始引入了Transparent Huge Pages(THP),从CentOS7版本开始,该特性默认就会启用。尽管THP的本意是为提升内存的性能,不过某些数据库厂商还是建议直接关闭THP,否则可能会导致性能出现下降。
首先查看透明大页是否启用,[always] never表示已启用,always [never]表示已禁用:
# cat /sys/kernel/mm/transparent_hugepage/defrag
[always] madvise never
# cat /sys/kernel/mm/transparent_hugepage/enabled
[always] madvise never
以上状态就说明是启用的。
临时关闭(重启机器会变回默认开启状态):
# echo never > /sys/kernel/mm/transparent_hugepage/defrag
#echo never > /sys/kernel/mm/transparent_hugepage/enabled
永久关闭:
//编辑/etc/rc.d/rc.local
# 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状态,显示状态被禁用了。
===============================================================
3) 修改文件句柄数:
修改系统文件句柄数限制:
//查看文件句柄数,显示1024,显然太小
# ulimit -n
1024
//修改限制
#vi /etc/security/limits.conf
//在文件后加入下面内容:
* soft nofile 100000
* hard nofile 100000
修改后需要重启机器。
为避免安装过程中出现异常问题,安装相关依赖包:
# 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
集群中所有主机必须保持时间同步,如果时间相差较大会引起各种问题。 具体建设过程如下:
所有节点安装相关组件:
# yum install ntp ntpdate -y
NTP服务端(主节点):
1) 查找时间同步服务器http://www.pool.ntp.org/zone/asia:
2) 编辑 /etc/ntp.conf:
# vi /etc/ntp.conf
//在文件中输入上面网页内容:
server 0.asia.pool.ntp.org
server 1.asia.pool.ntp.org
server 2.asia.pool.ntp.org
server 3.asia.pool.ntp.org
3) 启动ntp服务:
# systemctl start ntpd
4) 配置开机启动:
# systemctl enable ntpd.service
注意:如果ntpd 开机启动失效,有可能是因为安装了chronyd 并且是开机自启状态,所以导致ntpd开机自启失败。
# 查看 chronyd设置状态
# systemctl status chronyd
将chronyd设为禁用状态:
# systemctl disable chronyd.service
此时,NTP的服务开机自启动完成!
5) 检查是否设置成功:
# ntpq -p
//更新时间
#timedatectl
NTP客户端(所有从节点):
6) 远程客户端时间同步测试
# date
# ntpdate 172.16.3.168
172.16.3.168是NTP服务端IP,显示如下信息,测试成功:
7) 客户端设置计划任务,每30分钟同步时间
#crontab -e
//加入内容:
0-59/30 * * * * /usr/sbin/ntpdate 172.16.3.168 && /sbin/hwclock -w
8) 设置定时任务开机启动
//设置开机启动
# systemctl enable crond.service
//查看状态
# systemctl status crond
下载rpm 安装包jdk-8u151-linux-x64.rpm
CentOS系统一般自带OpenJdk,需要卸载掉自带的OpenJdk
# rpm -qa | grep java
查询java相关的包
# rpm -e –nodeps +包名
强制卸载掉,下面安装oralce JDK
# rpm -ivh jdk-8u151-linux-x64.rpm
配置JAVA_HOME环境变量:
修改/etc/profile文件配置环境变量, 执行命令:
# vi /etc/profile
在profile文件最后,输入下面内容,保存并退出。
export JAVA_HOME=/usr/java/jdk1.8.0_151
export PATH=$PATH:$JAVA_HOME/bin
执行下面命令,让配置生效
# source /etc/profile //使修改立即生效
# echo $PATH //查看PATH值
# echo $JAVA_HOME //查看JAVA_HOME值
在Centos7中修改/etc/profile文件配置环境变量,机器启动后有时不生效,可以修改/etc/ bashrc文件配置环境变量:
# vi /etc/bashrc
//在文件最后加入:
export JAVA_HOME=/usr/java/jdk1.8.0_151
export PATH=$PATH:$JAVA_HOME/bin
//使修改立即生效
# source /etc/bashrc
//查看JAVA_HOME值
# echo $JAVA_HOME
如果安装时出现问题可根据提示修改,rpm安装时可 --nodeps(忽略关联包) --force(强制安装)
到官网https://dev.mysql.com/downloads/file/?id=469456选择对应安装包:
1) 下载安装包
#wget https://cdn.mysql.com//archives/mysql-5.7/mysql-5.7.18-1.el7.x86_64.rpm-bundle.tar
2) 解压安装包
# 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
3) 按次序安装
按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
//安装下面包,否则Hue安装报连接错误
# rpm -ivh mysql-community-libs-compat-5.7.18-1.el7.x86_64.rpm
4) 启动数据库
# systemctl start mysqld
查看状态:
# systemctl status mysqld
5) 修改MySQL初始密码
1、先修改配置文件/etc/my.cnf令MySQL跳过登录时的权限检验,在[mysqld]下加入一行:
skip-grant-tables
2、重启MySQL
#service mysqld restart
3、免密码登录MySQL。
#mysql
4、mysql客户端执行如下命令,修改root密码
mysql> use mysql;
mysql> UPDATE user SET authentication_string = password('your-password') 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(这一步非常重要,不执行可能导致严重的安全问题)
#service mysqld restart //重启 Mysql
在主节点上下载相关软件包,这里将软件包下载到/data/ cdh/目录下。
#cd /data/cdh
下载Mysql JDBC包:
#wget http://central.maven.org/maven2/mysql/mysql-connector-java/5.1.43/mysql-connector-java-5.1.43.jar
下载CM:
#wget http://archive-primary.cloudera.com/cm5/cm/5/cloudera-manager-centos7-cm5.13.1_x86_64.tar.gz
下载CDH:
#wget http://archive-primary.cloudera.com/cdh5/parcels/5.13.1/manifest.json
#wget http://archive-primary.cloudera.com/cdh5/parcels/5.13.1/CDH-5.13.1-1.cdh5.13.1.p0.2-el7.parcel.sha1
#wget http://archive-primary.cloudera.com/cdh5/parcels/5.13.1/CDH-5.13.1-1.cdh5.13.1.p0.2-el7.parcel
将CM解压到/opt/目录:
# tar -zxvf cloudera-manager-centos7-cm5.13.1_x86_64.tar.gz -C /opt/
# ls /opt/
cloudera cm-5.13.1
在主节点上:
# 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 'root' with grant option;
grant all on *.* to root@"%" Identified by "root";
flush privileges;
exit;
//复制Mysql JDBC包到/opt/cm-5.13.1/share/cmf/lib/目录
#cp mysql-connector-java-5.1.43-bin.jar /opt/cm-5.13.1/share/cmf/lib/
//初始化CM,执行下面脚本
# /opt/cm-5.13.1/share/cmf/schema/scm_prepare_database.sh mysql cm -hnode168 -uroot -proot --scm-host node168 scm scm scm
//如果出现下面错误:
java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)
//解决办法:
在/etc/hosts 文件中,加上
127.0.0.1 localhost.node168