CDH6.3.1集群安装

前言:本文主要记录CDH6.3.1集群安装记录。总共在虚拟机上实践了2次,第二次增加了MySQL的双主服务和keepalived 服务。后续会实体机实操,和记录正式服务器的。第一次用了3台master,10台node,第二次用3台master,4台node。等服务器购买后实操的话,会有14个节点,预计如下图。具体硬件信息,等续物理机安装时再记录。如有问题,还请指教,qq:315675542。

预计部署


1. 软件准备:

System:CentOS7.8(CentOS Linux release 7.8.2003(core))  64bit

Packages needed to download offline:

mysql-5.7.31-1.el7.x86_64.rpm-bundle.tar

jdk-8u181-linux-x64.tar.gz

mysql-connector-java-5.1.46.jar

keepalived-2.0.8.tar.gz

cm6.3.1-redhat7.tar.gz

allkeys.asc

CDH-6.3.2-1.cdh6.3.2.p0.1605554-el7.parcel

CDH-6.3.2-1.cdh6.3.2.p0.1605554-el7.parcel.sha1

CDH-6.3.2-1.cdh6.3.2.p0.1605554-el7.parcel.sha256

manifest.json

DownUrls:

http://mirrors.163.com/mysql/Downloads/MySQL-5.7/mysql-5.7.31-1.el7.x86_64.rpm-bundle.tar

https://repo.huaweicloud.com/java/jdk/8u181-b13/jdk-8u181-linux-x64.tar.gz

http://mirrors.sohu.com/mysql/Connector-J/mysql-connector-java-5.1.46.tar.gz

https://www.keepalived.org/software/keepalived-2.0.8.tar.gz

https://archive.cloudera.com/cm6/6.3.1/repo-as-tarball/cm6.3.1-redhat7.tar.gz

https://archive.cloudera.com/cm6/6.3.1/allkeys.asc

https://archive.cloudera.com/cdh6/6.3.2/parcels/CDH-6.3.2-1.cdh6.3.2.p0.1605554-el7.parcel

https://archive.cloudera.com/cdh6/6.3.2/parcels/CDH-6.3.2-1.cdh6.3.2.p0.1605554-el7.parcel.sha1

https://archive.cloudera.com/cdh6/6.3.2/parcels/CDH-6.3.2-1.cdh6.3.2.p0.1605554-el7.parcel.sha256

https://archive.cloudera.com/cdh6/6.3.2/parcels/manifest.json

软件安装部署

2.安装过程

JDK配置(所有节点)

查看原有JDK: java  –version     //基本都是OpenJDK, CDH需要Oracle 的JDK,

查看所有JDK安装包:rpm -qa|grepjava

java-1.7.X-openjdk-1.6.0.0-1.66.1.13.0.el786_64

…………

卸载它们:

rpm -e --nodeps java-1.7.0-openjdk

rpm -e --nodeps java-1.7.0-openjdk-headless

rpm -e --nodeps java-1.8.0-openjdk

rpm -e --nodeps java-1.8.0-openjdk-headless

安装JDK:

tar -zxvf jdk-8u181-linux-x64.tar.gz -C/usr/lib/jvm

把安装目录rename成java-8,即为:/usr/lib/jvm/java-8

cd /usr/lib/jvm

mv jdk1.8.0_181/ java-8

然后在/etc/profile和/etc/bashrc两文件中添加:

export JAVA_HOME=/usr/lib/jvm/java-8

export JRE_HOME=/usr/lib/jvm/java-8/jre

export CLASSPATH=.:/usr/lib/jvm/java-8/lib:/usr/lib/jvm/java-8/jre/lib

export PATH=$PATH:/usr/lib/jvm/java-8/bin

source /etc/profile

source /etc/bashrc

在/usr/中创建:mkdir /usr/java  (5.9.2版本Spark内核只认这个Java路径)

在/usr/java中创建软连接:ln-s /usr/lib/jvm/java-8 /usr/java/default

最后查看java –version验证

修改Hostname(所有节点)

hostnamectl set-hostname master-41

hostnamectl set-hostname master-42

…………

………

重启生效:reboot

在/etc/hosts中添加IP,hostname关系表

vi /etc/hosts

192.168.1.41 master-41

192.168.1.42 master-42

192.168.1.43 master-43

192.168.1.31 node-31

192.168.1.32 node-32

192.168.1.33 node-33

192.168.1.34 node-34

192.168.1.35 node-35

192.168.1.36 node-36

192.168.1.37 node-37

192.168.1.38 node-38

192.168.1.39 node-39

192.168.1.40 node-40

重启:

/etc/init.d/network restart

SSH 免密配置

Master中:

ssh-keygen –t rsa // 一路回车

cat ~/.ssh/id_rsa.pub >>~/.ssh/authorized_keys

Node-1, Node-2, Node-3….中分别操作:

ssh-keygen –t rsa // 一路回车

可以使用xshell的“发送键盘输入的所有会话”

cat ~/.ssh/id_rsa.pub >>~/.ssh/authorized_keys_$(hostname)

scp ~/.ssh/authorized_keys_$(hostname)  root@master:~/.ssh

或者逐个进行:

cat ~/.ssh/id_rsa.pub >>

~/.ssh/authorized_keys_node1  //在node1

scp ~/.ssh/authorized_keys_node1  root@master:~/.ssh  

cat ~/.ssh/id_rsa.pub >>~/.ssh/authorized_keys_node2  //在node2

scp ~/.ssh/authorized_keys_node2  root@master:~/.ssh  

cat ~/.ssh/id_rsa.pub >>~/.ssh/authorized_keys_node3  //在node3

scp ~/.ssh/authorized_keys_node3  root@master:~/.ssh  

Master中:

cat ~/.ssh/authorized_keys_node1 >>~/.ssh/authorized_keys

cat ~/.ssh/authorized_keys_node2 >>~/.ssh/authorized_keys

cat ~/.ssh/authorized_keys_node3 >>~/.ssh/authorized_keys

最后再把master中的    ~/.ssh/authorized_keys  分发到各个节点

scp ~/.ssh/authorized_keys  root@node1:~/.ssh

scp ~/.ssh/authorized_keys  root@node2:~/.ssh

scp ~/.ssh/authorized_keys  root@node3:~/.ssh

所以节点两两测试免密登录, 第一次可能还会提醒是否需要连接,另外可以删除~/.ssh目录下的kown_hosts文件,重新ssh 测试。

ssh node1

ssh node2

防火墙和其他安全设置(所有节点)

FireWall:

service firewalld stop (临时关闭)

systemctl disable firewalld (重启后生效)

SELINUX

setenforce 0 (临时生效)

修改/etc/selinux/config 下的 SELINUX=disabled(重启后生效)

Swappiness

echo 0 > /proc/sys/vm/swappiness (临时生效)

vi /etc/sysctl.conf  文末添加vm.swappiness= 10 (重启生效)

设置透明大页面压缩:

 echo never > /sys/kernel/mm/transparent_hugepage/defrag

 echo never > /sys/kernel/mm/transparent_hugepage/enabled

NTP服务

systemctl start ntpd.service

systemctl enable ntpd.service

vim /etc/ntp.conf (主master:192.168.1.41)

添加:

server 127.127.1.0 iburst local clock

fudge 127.127.1.0 stratum 10

主master 中的ntp.conf

systemctl restart ntpd

vi /etc/ntp.conf (主master之外的所有其他节点)

主master之外的所有节点中的ntp.conf  

systemctl restart ntpd (需要等15分钟)

所有机台同步系统时间到NTP Server:

ntpdate -u 192.168.1.41

再查看状态:ntpstat

同步状态

所有机台同步硬件时钟到系统时钟:

hwclock  --systohc

Mysql安装(对所有节点)和双主设置(对VIP)

Mysql安装:

1.Centos7卸载mariadb

rpm -qa|grep mariadb

rpm -e --nodeps mariadb-libs-5.5.65-1.el7.x86_64

卸载mariadb

2.安装

安装包:

mysql安装包

解压:

tar -xvf mysql-5.7.31-1.el7.x86_64.rpm-bundle.tar

解压结果

依次安装:

rpm -ivh mysql-community-common-5.7.31-1.el7.x86_64.rpm

rpm -ivh mysql-community-libs-5.7.31-1.el7.x86_64.rpm

rpm -ivh mysql-community-client-5.7.31-1.el7.x86_64.rpm

rpm -ivh mysql-community-server-5.7.31-1.el7.x86_64.rpm

rpm -ivh mysql-community-libs-compat-5.7.31-1.el7.x86_64.rpm

检查是否成功,是否启动mysql服务

service mysqld status //检查

service mysqld start //启动

检查密码并登录:

grep password /var/log/mysqld.log

mysql -uroot -p 

修改密码:

set global validate_password_policy=0;

set global validate_password_length=1;

set password = password("123456");

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;

flush privileges;

mysql双主服务和keepalived服务(选取2个node节点)

mysql双主服务 node-48和node-49示例:

1,配置文件

分别对这两个节点:

vi /etc/my.cnf

Node-48中添加

# mysql服务id

server-id=1

#二进制日志 存储数据发生改变的sql语句

log-bin=mysql-bin

#增量值得起点

auto-increment-offset=1

#每次增量间隔

auto-increment-increment=2

#设置需要同步的数据库名称,目前不需要设置,保持注释状态

#binlog_do_db=<dbname>

node-49中添加:

# mysql服务id

server-id=2

#二进制日志 存储数据发生改变的sql语句

log-bin=mysql-bin

#增量值得起点

auto-increment-offset=2

#每次增量间隔

auto-increment-increment=2

#设置需要同步的数据库名称,目前不需要设置,保持注释状态

#binlog_do_db=<dbname>

保存退后,都重启mysql服务

service mysqld restart

2,数据同步授权

如果遇到密码设置过去简单问题,先执行:

set global validate_password_policy=0;

set global validate_password_length=1;

Node-48中:

mysql> grant replication slave,replication client on *.* to root@'192.168.1.%' identified by "123456";

Query OK, 0 rows

affected, 1 warning (0.00sec)

mysql>flush privileges;

Query OK, 0 rows

affected (0.00sec)

最好将库锁住,仅仅允许读,以保证数据一致性;待主主同步环境部署后再解锁;

锁住后,就不能往表里写数据,但是重启mysql服务后就会自动解锁!

注意该参数设置后,如果自己同步对方数据,同步前一定要记得先解锁!

mysql>flushtables with read lock;

Query OK, 0 rows

affected (0.01sec)

查看node-master status和position

Node-49中:

mysql> grant replication slave,replication client on *.* to root@'192.168.1.%' identified by "123456";

Query OK, 0 rows affected, 1 warning (0.01 sec)

mysql> flush privileges;

Query OK, 0 rows affected (0.00 sec)

mysql> flush tables with read lock;

Query OK, 0 rows affected (0.01 sec)

查看node-49中的master status和position  

同步操作:

解锁上个步骤中对node-48中的表解锁,保持数据的一致性。

mysql> unlock tables;

Query OK, 0 rows affected (0.00 sec)

先去stop slave 以下报错是slave未开启

mysql> slave stop;

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'slave stop' at line 1

mysql> change  master to master_host='192.168.1.49',

master_user='root',master_password='123456',

master_log_file='mysql-bin.000006',master_log_pos=630;

Query OK, 0 rows affected, 2 warnings (0.20 sec)

mysql> start slave;

Query OK, 0 rows affected (0.01 sec)

mysql> show slave status \G;

node-48

解锁上个步骤中对node-49中的表解锁,保持数据的一致性。

mysql> unlock tables;

Query OK, 0 rows affected (0.00 sec)

先去stop slave 以下报错是slave未开启

mysql> slave stop;

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'slave stop' at line 1

mysql> change  master to master_host='192.168.1.48',

master_user='root',master_password='123456',

master_log_file='mysql-bin.000003',master_log_pos=1106;

Query OK, 0 rows affected, 2 warnings (0.20 sec)

mysql> start slave;

Query OK, 0 rows affected (0.01 sec)

mysql> show slave status \G;

node-49

设置root远程登录:

Node-49都操作设置root远程登录:

mysql> grant all on *.* to root@'192.168.1.%' identified by "123456";

Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;

Query OK, 0 rows affected (0.01 sec)

Keepalived 服务:

安装

cd /usr/local/src

wget    http://www.keepalived.org/software/keepalived-2.0.8.tar.gz  #已经下载      

tar zxvf keepalived-2.0.8.tar.gz /usr/local/src/

cd keepalived-2.0.8/

yum install -y openssl-devel libnl-devel libnl3-devel    libnfnetlink-devel

yum groupinstall "Development Tools"

./configure --prefix=/usr/local/keepalived 

make && make install

cd /usr/local

tar zcvf keepalived.tar keepalived

cp keepalived/bin/* /bin/

cp keepalived/sbin/* /sbin/

cp keepalived/etc/keepalived/ /etc/ -rf

cp keepalived/etc/sysconfig/* /etc/sysconfig/

配置

Node-48中:vi /etc/keepalived/keepalived.conf  

! ConfigurationFile for keepalived

global_defs {

  router_id MASTER-HA

}

vrrp_instanceVI_1 {

 state MASTER

   interface ens192  #根据实际网络接口进行更改

   virtual_router_id 51

 priority 100 #优先权,backup设置为90

   advert_int 1

   nopreempt

   authentication {

       auth_type PASS

       auth_pass 1111

   }

   virtual_ipaddress {

 192.168.1.100

   }

}

virtual_server192.168.1.100 3306 {

   delay_loop 2

   lb_algo rr

   lb_kind DR

   persistence_timeout 60

   protocol TCP

   real_server 192.168.1.48 3306 {

       weight 3

       notify_down    /etc/keepalived/mysql.sh

       TCP_CHECK {

            connect_timeout 3

            nb_get_retry 3

            delay_before_retry 3

            connect_port 3306

       }

   }

}

保存,退出后:

service restart keepalived

systemctl enable keepalived

Node-49中:vi /etc/keepalived/keepalived.conf

! ConfigurationFile for keepalived

global_defs {

  router_id MASTER-HA

}

vrrp_instanceVI_1 {

  state BACKUP

interface ens192  #根据实际网络接口进行更改

   virtual_router_id 51

   priority 90

   advert_int 1

   nopreempt

   authentication {

       auth_type PASS

       auth_pass 1111

   }

   virtual_ipaddress {

 192.168.1.100

   }

}

virtual_server192.168.1.100 3306 {

   delay_loop 2

  lb_algo rr

   lb_kind DR

   persistence_timeout 60

   protocol TCP

   real_server 192.168.1.48 3306 {

       weight 3

       notify_down    /etc/keepalived/mysql.sh

       TCP_CHECK {

            connect_timeout 3

            nb_get_retry 3

            delay_before_retry 3

            connect_port 3306

       }

   }

}

保存,退出后:

service restart keepalived

systemctl enable keepalived

以下node-48,node-49都操作:

Mysql.sh 脚本:主要监控3306端口是否被监听,若不被监听关闭keepalived服务

#!/bin/bash

counter=$(netstat -na|grep "LISTEN"|grep "3306"|wc -l)

if [ "${counter}" -eq 0 ]; then

    service keepalived stop

fi

启动服务:

service keepalived start

service keepalived status

设置开机启动。

Vim  /opt/start_services.sh

#!/bin/bash

service mysqld start

while true

do

    counter=$(netstat -na|grep "LISTEN"|grep "3306"|wc -l)

    if [ "${counter}" -ne 0 ]; then

        service keepalived start

        exit 0

    fi

done

/etc/rc.d/rc.local 文件末尾追加sh /opt/start_services.sh,并修改/opt/start_services.sh和/etc/rc.d/rc.local的执行权限

chmod +x /opt/start_services.sh

chmod +x /etc/rc.d/rc.local

验证:

命令:IP a #看是否漂移

Shutdown 某一个台,看仍否能够通过VIP进入mysql,并成功建表,等该机台重启数据是否同步。

创建DB、用户以及权限:

连接VIP,进入mysql

mysql -h192.168.1.100 -uroot -p

创建mysql脚本:createDB.sql  (内容如下或参见createDB-sql.txt)

vi /root/createDB.sql

GRANT ALLPRIVILEGES ON amon.* TO 'amon'@'%' IDENTIFIED BY '123456';

GRANT ALLPRIVILEGES ON *.* TO 'amon'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;

CREATE DATABASErmgr DEFAULT CHARACTER SET utf8;

CREATE USER'rmgr'@'%'IDENTIFIED BY '123456';

GRANT ALLPRIVILEGES ON rmgr .* TO 'rmgr'@'%' IDENTIFIED BY '123456';

GRANT ALLPRIVILEGES ON *.* TO 'rmgr'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;

CREATE DATABASEhive DEFAULT CHARACTER SET utf8;

CREATE USER'hive'@'%'IDENTIFIED BY '123456';

GRANT ALLPRIVILEGES ON hive.* TO 'hive'@'%' IDENTIFIED BY '123456';

GRANT ALL PRIVILEGESON *.* TO 'hive'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;

CREATE DATABASEhue DEFAULT CHARACTER SET utf8;

CREATE USER'hue'@'%'IDENTIFIED BY '123456';

GRANT ALLPRIVILEGES ON hue.* TO 'hue'@'%' IDENTIFIED BY '123456';

GRANT ALLPRIVILEGES ON *.* TO 'hue'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;

CREATE DATABASEoozie DEFAULT CHARACTER SET utf8;

CREATE USER'oozie'@'%'IDENTIFIED BY '123456';

GRANT ALLPRIVILEGES ON oozie.* TO 'oozie'@'%' IDENTIFIED BY '123456';

GRANT ALLPRIVILEGES ON *.* TO 'oozie'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;

FLUSH PRIVILEGES;

进入mysql环境:

mysql -uroot-p

source /root/createDB.sql

所有节点部署JDBC

mkdir-p /usr/share/java

mvmysql-connector-java-5.1.46.jar mysql-connector-java.jar

cp mysql-connector-java-5.1.46.jar/usr/share/java/

cp mysql-connector-java.jar/usr/lib/java

所有节点安装httpd服务

yum install httpd

systemctl starthttpd

systemctl enable httpd.service

CM安装(在主master中)

mkdir -p /var/www/html/cloudera-repos/

tar -zxvf cm6.3.1-redhat7.tar.gz-C /var/www/html/cloudera-repos/

拷贝整理cloudera-repos文件夹中内容,必须和下图保持一致:

cloudera-repos

vim /etc/yum.repos.d/cloudera-manager.repo

写入:

[cloudera-manager]

name=ClouderaManager, Version cm6.3.1

baseurl=http://master-42/cloudera-repos/

gpgcheck=true

enabled=true

yum clean all

yum makecache

rpm --import http://master-42/cloudera-repos/RPM-GPG-KEY-cloudera

yum开始安装

yum install cloudera-manager-daemons  cloudera-manager-agent   cloudera-manager-server

安装好后,在/opt/cloudera/parcel-repo中放入:

CDH-6.3.2-1.cdh6.3.2.p0.1605554-el7.parcel

CDH-6.3.2-1.cdh6.3.2.p0.1605554-el7.parcel.sha1

manifest.json

重命名:

CDH-6.3.2-1.cdh6.3.2.p0.1605554-el7.parcel.sha1=> CDH-6.3.2-1.cdh6.3.2.p0.1605554-el7.parcel.sha

/opt/cloudera/parcel-repo/

/opt/cloudera/cm/schema/scm_prepare_database.sh  mysql   -h虚拟IP  scm  scm  123456

启动Server服务:

systemctl start cloudera-scm-server

网页进入安装页面:

master-42:7180

后面一路简单配置,基本没什么问题。

注意: 安装服务界面后,数据库设置的时候,使用VIP。

常用查错命令:

tail  -f/var/log/cloudera-scm-server/cloudera-scm-server.log

tail  -f/var/log/cloudera-scm-agent/cloudera-scm-agent.log

service  cloudera-scm-server start

后记:

cm安装页面中hdfs,hive,hue等各项服务如何配置,还需要具体看机器的内存和cpu配置而定。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 203,324评论 5 476
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 85,303评论 2 381
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 150,192评论 0 337
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 54,555评论 1 273
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 63,569评论 5 365
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,566评论 1 281
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 37,927评论 3 395
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,583评论 0 257
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 40,827评论 1 297
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,590评论 2 320
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,669评论 1 329
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,365评论 4 318
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 38,941评论 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,928评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,159评论 1 259
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 42,880评论 2 349
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,399评论 2 342