一 docker部署cdh-5.x
cloudera/quickstart
cloudera/clusterdock
二 docker部署cdh-6.x
cdh安装包下载
- docker拉取centos7镜像
docker pull centos:7.7.1908 - 启动docker container
2.1 设置网桥
docker network create --subnet=172.18.0.0/24 cdh-network
2.2 运行4个centos7的容器
docker run -d --privileged=true -ti -v /etc/localtime:/etc/localtime:ro -v /root/package:/docker/cdh-package --name cdh-master -h cdh-master -p 3306:3306 -p 7180:7180 -p 7187:7187 -p 1080:1080 -p 4200:4200 -p 7777:7777 -p 7788:7788 -p 8000:8000 -p 8080:8080 -p 8744:8744 -p 8886:8886 -p 9088:9088 -p 9089:9089 -p 61080:61080 -p 61888:61888 -p 4040:4040 -p 6080:6080 -p 8042:8042 -p 8088:8088 -p 8188:8188 -p 8888:8888 -p 9995:9995 -p 11000:11000 -p 15000:15000 -p 16010:16010 -p 18081:18081 -p 19888:19888 -p 21000:21000 -p 21050:21050 -p 50010:50010 -p 50020:50020 -p 50070:50070 -p 50075:50075 -p 50111:50111 -p 8081:8081 -p 2182:2182 -p 2202:2202 -p 4557:4557 -p 6627:6627 -p 6667:6667 -p 9090:9090 -p 9091:9091 -p 15500:15500 -p 1100:1100 -p 1111:1111 -p 1988:1988 -p 2100:2100 -p 2181:2181 -p 2201:2201 -p 2222:2222 -p 3000:3000 -p 4242:4242 -p 5007:5007 -p 5011:5011 -p 6001:6001 -p 6003:6003 -p 6008:6008 -p 6188:6188 -p 8005:8005 -p 8020:8020 -p 8032:8032 -p 8040:8040 -p 8082:8082 -p 8086:8086 -p 8090:8090 -p 8091:8091 -p 8443:8443 -p 8765:8765 -p 8889:8889 -p 8983:8983 -p 8993:8993 -p 9000:9000 -p 9996:9996 -p 10000:10000 -p 10001:10001 -p 10015:10015 -p 10016:10016 -p 10500:10500 -p 10502:10502 -p 12049:12049 -p 12200:12200 -p 15002:15002 -p 16000:16000 -p 16020:16020 -p 16030:16030 -p 18080:18080 -p 33553:33553 -p 39419:39419 -p 42111:42111 -p 50079:50079 -p 50095:50095 -p 60000:60000 -p 60080:60080 --net cdh-network --ip 172.18.0.2 centos:7.7.1908 /usr/sbin/init
docker run -d --privileged=true -ti -v /etc/localtime:/etc/localtime:ro -v /root/package:/docker/cdh-package --name cdh-slave1 -h cdh-slave1 --net cdh-network --ip 172.18.0.3 centos:7.7.1908 /usr/sbin/init
docker run -d --privileged=true -ti -v /etc/localtime:/etc/localtime:ro -v /root/package:/docker/cdh-package --name cdh-slave2 -h cdh-slave2 --net cdh-network --ip 172.18.0.4 centos:7.7.1908 /usr/sbin/init
docker run -d --privileged=true -ti -v /etc/localtime:/etc/localtime:ro -v /root/package:/docker/cdh-package --name cdh-slave3 -h cdh-slave3 --net cdh-network --ip 172.18.0.5 centos:7.7.1908 /usr/sbin/init
修改容器名称
docker rename great_banach cdh_manager
根据容器ID进入容器
docker attach 容器UUID 会卡住不动
docker exec -it 容器ID /bin/bash
进入容器后发现无法使用ifconfig等基本命令, 于是
yum install -y net-tools
3. 容器初始化
3.1 进入容器
docker exec -ti 容器UUID /bin/bash
3.2 修改root密码(所有容器)
passwd root
3.3 修改/etc/hosts
172.18.0.2 cdh-master
172.18.0.3 cdh-slave1
172.18.0.4 cdh-slave2
172.18.0.5 cdh-slave3
复制代码3.4 配置免密(所有容器)
安装依赖
yum -y install openssh openssh-server openssh-clients
systemctl start sshd
设置免密
ssh-keygen -t rsa #三次回车
ssh-copy-id -f -i ~/.ssh/id_rsa.pub cdh-master
ssh-copy-id -f -i ~/.ssh/id_rsa.pub cdh-slave1
ssh-copy-id -f -i ~/.ssh/id_rsa.pub cdh-slave2
ssh-copy-id -f -i ~/.ssh/id_rsa.pub cdh-slave3
3.5 ntp 时间同步
** 这种方式配置ntp的方式只适合cdh, ambari还有kudu集群对ntp要求更严 **
yum install -y ntp
vi /etc/ntp.conf 添加
server 0.cn.pool.ntp.org
server 1.cn.pool.ntp.org
server 2.cn.pool.ntp.org
server 3.cn.pool.ntp.org
systemctl enable ntpd #开机自启
systemctl start ntpd
docker run -d -v /etc/localtime:/etc/localtime:ro # 容器时间同步宿主机时间
3.6 关闭防火墙 (宿主机)
systemctl disable firewalld
systemctl stop firewalld
4. 安装JDK1.8
tar -zxf /docker/cdh-package/jdk-8u172-linux-x64.tar.gz -C /usr/java
export JAVA_HOME=/usr/java/jdk1.8.0_172
export PATH=
J
A
V
A
H
O
M
E
/
b
i
n
:
JAVA_HOME/bin:
JAVAHOME/bin:PATH
export CLASSPATH=.:
J
A
V
A
H
O
M
E
/
l
i
b
/
d
t
.
j
a
r
:
JAVA_HOME/lib/dt.jar:
JAVAHOME/lib/dt.jar:JAVA_HOME/lib/tools.jar
source ~/.bashrc
- 安装Mysql
5.1 复制mysql-connect-java.jar 到所有容器
mkdir -p /usr/share/java/
cp /docker/cdh-package/mysql-connector-java-5.1.46-bin.jar /usr/share/java/mysql-connector-java.jar
更换阿里YUM镜像
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
yum makecache
5.2 yum安装Mysql
yum install -y wget
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 #会卡住,但是mysql可启动成功
systemctl status mysqld.service
获取默认密码
grep “password” /var/log/mysqld.log
登录
mysql -uroot -p
更改密码策略(取消密码复杂度的校验)
set global validate_password_policy=0;
set global validate_password_length=1;
修改密码
ALTER USER ‘root’@‘localhost’ IDENTIFIED BY ‘123456’;
设置可视化客户端连接
grant all on . to root@’%’ identified by ‘123456’;
创建数据库
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;
create database report DEFAULT CHARSET utf8 COLLATE utf8_general_ci;
flush privileges;
6.安装cloudera manager
所有容器执行
mkdir /opt/cloudera-manager
tar -zxf /docker/cdh-package/cm6.1.0-redhat7.tar.gz -C /opt/cloudera-manager/
新建用户
useradd --system --no-create-home --shell=/bin/false --comment “Cloudera SCM User” cloudera-scm
主节点
创建cloudera-manager-server的本地元数据保存目录
mkdir /var/cloudera-scm-server
chown cloudera-scm:cloudera-scm /var/cloudera-scm-server
RPM开始安装
rpm -ivh /opt/cloudera-manager/cm6.1.0/RPMS/x86_64/cloudera-manager-daemons-6.1.0-769885.el7.x86_64.rpm
yum install -y perl
rpm -ivh /opt/cloudera-manager/cm6.1.0/RPMS/x86_64/cloudera-manager-agent-6.1.0-769885.el7.x86_64.rpm
yum install bind-utils psmisc cyrus-sasl-plain cyrus-sasl-gssapi fuse portmap fuse-libs /lib/lsb/init-functions httpd mod_ssl openssl-devel python-psycopg2 MySQL-python libxslt iproute initscripts -y
rpm -ivh /opt/cloudera-manager/cm6.1.0/RPMS/x86_64/cloudera-manager-server-6.1.0-769885.el7.x86_64.rpm(从节点不需要执行)
chown cloudera-scm:cloudera-scm /opt/cloudera-manager(所有节点)
- 配置cm-agent
配置从节点cloudera-manger-agent指向主节点服务器
vi /etc/cloudera-scm-agent/config.ini
server_host=cdh-master
8.用parcle离线安装
主节点中创建parcel-repo仓库目录
mkdir -p /opt/cloudera/parcel-repo
cp /docker/cdh-package/CDH-6.1.0-1.cdh6.1.0.p0.770702-el7.parcel /opt/cloudera/parcel-repo/
cp /docker/cdh-package/CDH-6.1.0-1.cdh6.1.0.p0.770702-el7.parcel.sha256 /opt/cloudera/parcel-repo/CDH-6.1.0-1.cdh6.1.0.p0.770702-el7.parcel.sha
cp /docker/cdh-package/manifest.json /opt/cloudera/parcel-repo/
chown cloudera-scm:cloudera-scm /opt/cloudera/parcel-repo
9.创建parcels目录(所有容器)
mkdir -p /opt/cloudera/parcels
chown cloudera-scm:cloudera-scm /opt/cloudera/parcels
解释:Clouder-Manager将CDHs从主节点的/opt/cloudera/parcel-repo目录中抽取出来,分发解压激活到各个节点的/opt/cloudera/parcels目录中
10.主节点配置数据库
/opt/cloudera/cm/schema/scm_prepare_database.sh mysql -hlocalhost -uroot -p123456 --scm-host localhost scmdbn scmdbu scmdbp
说明:这个脚本就是用来创建和配置CMS需要的数据库的脚本。各参数是指:
mysql:数据库用的是mysql
-hDBhost:数据库建立在DBhost主机上面,也就是主节点上面。
-uroot:root身份运行mysql。
-p123456:mysql的root密码是***。
–scm-host master:CMS的主机,一般是和mysql安装的主机是在同一个主机上。
最后三个参数是:数据库名,数据库用户名,数据库密码。
-
启动
systemctl start cloudera-scm-server
systemctl start cloudera-scm-agent -
浏览器进入安装导向
浏览器输入http://宿主Ip:7180 admin/admin进行安装
页面安装的时候, 如果无法识别parcel库 重新生成.sha文件就可以了
sha1sum CDH-6.1.0-1.cdh6.1.0.p0.770702-el7.parcel| cut -d ’ ’ -f 1 > CDH-6.1.0-1.cdh6.1.0.p0.770702-el7.parcel.sha