CDH 7.1.4 大数据平台搭建-新手指南
环境介绍
笔记本硬件
硬盘 1T SSD
内存 48G
处理器 I5 8代
软件及版本
系统 Win10 家庭版
虚拟机 VMware 15.5.1
Linux rhel-server-7.9-x86_64-dvd.iso Redhat Linux 7.9 下载地址
CM Cloudera Manager CM下载地址
CDH Cloudera Runtime集群 CDH下载地址
环境准备
虚拟系统安装
准备安装5个节点
192.168.101.141 C1(主节点) 10G
192.168.101.142 C2 8G
192.168.101.143 C3 8G
192.168.101.144 C4 8G
192.168.101.145 C5 8G
每个节点1个CPU
每个节点100G硬盘
电脑之前试过2G内存 20G 内存和空间都不够
改为4G内存 60G硬盘 内存不够,空间也快满了
现改为8G内存 100G硬盘空间
1.安装虚拟机配置
2.克隆虚拟机*4
3.开启5台虚拟机
挂载离线安装ISO文件
为了使用yum安装软件,方便安装软件,系统安装后未配置的情况如下
yum repolist
1.创建软件挂载路径
mkdir -p /soft
2.将系统ISO镜像文件复制到该路径下(使用Xftp 7)
3.修改yum源
cd /etc/yum.repos.d/
vi redhat.repo
添加如下内容,先为了安装httpd,安装之后再改为http方式进行repo分发。
[iso]
name=iso
baseurl=file:///mnt/iso/
gpgcheck=0
enabled=1
创建文件夹挂载磁盘镜像
mkdir -p /mnt/iso
mount /soft/rhel-server-7.9-x86_64-dvd.iso /mnt/iso
成功挂载
执行yum repolist看是否成功
yum repolist
安装httpd搭建http服务器
yum -y install httpd
安装成功
启动http服务
systemctl enable httpd
systemctl start httpd
关闭防火墙后访问
systemctl disable firewalld.service 禁止开机启动
systemctl stop firewalld.service 关闭防火墙
用浏览器访问
下载CM和CDH安装包
CM Cloudera Manager CM下载地址
CDH Cloudera Runtime集群 CDH下载地址
下载后将其放置在http服务器路径下,用于其他机器访问安装软件
/var/www/html/cm
/var/www/html/cdh
截图
安装createrepo软件
yum -y install createrepo
打包CM文件
cd /var/www/html/cm
createrepo .
配置hostname和hosts
hostname
/etc/hostname文件
cat /etc/hostname
修改为C1
hostnamectl set-hostname CDH1
并将其余几台电脑改名
hostnamectl set-hostname CDH2
hostnamectl set-hostname CDH3
hostnamectl set-hostname CDH4
hostnamectl set-hostname CDH5
hosts
/etc/hosts
cat /etc/hosts
vi /etc/hosts
追加如下,里面主机的名称重新修改为CDH1-5了,每个节点都需要修改
192.168.101.141 CDH1
192.168.101.142 CDH2
192.168.101.143 CDH3
192.168.101.144 CDH4
192.168.101.145 CDH5
保存退出
建立互信
在管理节点生成秘钥,并放到其他节点上
ssh-keygen
一直按回车
将秘钥分发给其他节点
for i in {
2..5}; do ssh-copy-id -i ~/.ssh/id_rsa.pub CDH$i ; done
需要输入yes和密码
检查互信
for i in {
2..5}; do ssh CDH$i " hostname -A" ; done
互信配置完成
重新制作ISO的repo,方便其他机器访问通过http
创建对应文件夹,将ISO对应内容全部拷贝过去
mkdir -p /var/www/html/iso/
cp -r /mnt/iso/* /var/www/html/iso/
修改yum的repo文件为http派发
vi /etc/yum.repos.d/redhat.repo
http://192.168.101.141/iso/
[iso]
name=iso
#baseurl=file:///mnt/iso/
baseurl=http://192.168.101.141/iso/
gpgcheck=0
enabled=1
192.168.101.141 主机master ip
repo分发到其他电脑
for i in {
2..5}; do scp /etc/yum.repos.d/redhat.repo CDH$i:/etc/yum.repos.d/redhat.repo; done
升级软件和系统内核
for i in {
1..5}; do ssh CDH$i " yum -y update " ; done
禁用SELinux
for i in {
1..5}; do ssh CDH$i 'echo "SELINUX=disabled" > /etc/selinux/config ' ;done
关闭防火墙
for i in {
2..5}; do ssh CDH$i 'systemctl disable firewalld.service' ;done
for i in {
2..5}; do ssh CDH$i 'systemctl stop firewalld.service ' ;done
集群时钟同步
卸载chrony
for i in {
1..5}; do ssh CDH$i 'yum -y remove chrony' ;done
安装ntp和ntpdate
for i in {
1..5}; do ssh CDH$i 'yum install -y ntp ntpdate ' ;done
for i in {
1..5}; do ssh CDH$i ' timedatectl set-timezone Asia/Shanghai' ;done
for i in {
1..5}; do ssh CDH$i 'chkconfig --level 345 ntpd on ' ;done
主节点时钟修改为
vi /etc/ntp.conf
#server 0.rhel.pool.ntp.org iburst
#server 1.rhel.pool.ntp.org iburst
#server 2.rhel.pool.ntp.org iburst
#server 3.rhel.pool.ntp.org iburst
server 127.127.1.0 # local clock
fudge 127.127.1.0 stratum 10
根据实际情况编辑时钟同步
其余节点按照主节点同步
注释四行,追加
server 192.168.101.141
停止服务,同步NTP
for i in {
2..5}; do ssh CDH$i ' systemctl stop ntpd' ;done
for i in {
2..5}; do ssh CDH$i ' ntpdate CDH1' ;done
报这个错误说明,ntpd没有停止掉
正常同步
验证时钟同步
for i in {
1..5}; do ssh CDH$i 'systemctl enable ntpd ' ;done
for i in {
1..5}; do ssh CDH$i 'systemctl start ntpd ' ;done
for i in {
1..5}; do ssh CDH$i ' ntpq -p' ;done
设置swap
for i in {
1..5}; do ssh CDH$i ' echo "vm.swappiness = 1" >> /etc/sysctl.conf' ;done
for i in {
1..5}; do ssh CDH$i ' sysctl vm.swappiness=1' ;done
设置透明大页面
如下脚本追加到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
for i in {
2..5}; do scp /etc/rc.d/rc.local CDH$i:/etc/rc.d/rc.local; done
每个节点执行
echo never > /sys/kernel/mm/transparent_hugepage/defrag
echo never > /sys/kernel/mm/transparent_hugepage/enabled
for i in {
1..5}; do ssh CDH$i ' echo never > /sys/kernel/mm/transparent_hugepage/defrag' ;done
for i in {
1..5}; do ssh CDH$i ' echo never > /sys/kernel/mm/transparent_hugepage/enabled' ;done
同步到其他节点
关闭iptables
执行后,发现没有该服务
for i in {
1..5}; do ssh CDH$i 'systemctl stop iptables' ;done
for i in {
1..5}; do ssh CDH$i 'chkconfig iptables off' ;done
设置limits
for i in {
1..5}; do ssh CDH$i 'echo "hdfs - nofile 32768" >> /etc/security/limits.conf';done
for i in {
1..5}; do ssh CDH$i 'echo "mapred - nofile 32768" >> /etc/security/limits.conf';done
for i in {
1..5}; do ssh CDH$i 'echo "hbase - nofile 32768" >> /etc/security/limits.conf';done
for i in {
1..5}; do ssh CDH$i 'echo "hdfs - noproc 32768" >> /etc/security/limits.conf';done
for i in {
1..5}; do ssh CDH$i 'echo "mapred - noproc 32768" >> /etc/security/limits.conf';done
for i in {
1..5}; do ssh CDH$i 'echo "hbase - noproc 32768" >> /etc/security/limits.conf';done
安装Mysql
wget https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm
rpm -Uvh mysql57-community-release-el7-11.noarch.rpm
检查yum
yum repolist enabled | grep mysql
按照mysql
yum install -y mysql-community-server
启动MySQL
systemctl start mysqld.service
查看状态
systemctl status mysqld.service
查找初始密码
grep "password" /var/log/mysqld.log
kjNAA_K11;_#
进入数据库
mysql -uroot -p
修改密码
set password=password("Cdh123456-");
停止服务
systemctl stop mysqld
修改配置文件
最好先做备份
vi /etc/my.cnf
追加
character_set_server=utf8
init_connect='SET NAMES utf8'
transaction-isolation = READ-COMMITTED
key_buffer_size = 32M
max_allowed_packet = 32M
thread_stack = 256K
thread_cache_size = 64
query_cache_limit = 8M
query_cache_size = 64M
query_cache_type = 1
max_connections = 550
binlog_format = mixed
read_buffer_size = 2M
read_rnd_buffer_size = 16M
sort_buffer_size = 8M
join_buffer_size = 8M
innodb_file_per_table = 1
innodb_flush_log_at_trx_commit = 2
innodb_log_buffer_size = 64M
innodb_buffer_pool_size = 4G
innodb_thread_concurrency = 8
innodb_flush_method = O_DIRECT
innodb_log_file_size = 512M
sql_mode = STRICT_ALL_TABLES
如下
设置mysql自启动
sudo systemctl enable mysqld
sudo systemctl start mysqld
配置数据库
sudo /usr/bin/mysql_secure_installation
n y n y y
链接数据库
mysql -uroot -p
创建数据库
CREATE DATABASE scm DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
GRANT ALL ON scm.* TO 'scm'@'%' IDENTIFIED BY 'Cdh123456-';
CREATE DATABASE amon DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
GRANT ALL ON amon.* TO 'amon'@'%' IDENTIFIED BY 'Cdh123456-';
CREATE DATABASE rman DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
GRANT ALL ON rman.* TO 'rman'@'%' IDENTIFIED BY 'Cdh123456-';
CREATE DATABASE hue DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
GRANT ALL ON hue.* TO 'hue'@'%' IDENTIFIED BY 'Cdh123456-';
CREATE DATABASE hive DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
GRANT ALL ON hive.* TO 'hive'@'%' IDENTIFIED BY 'Cdh123456-';
CREATE DATABASE ranger DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
GRANT ALL ON ranger.* TO 'rangeradmin'@'%' IDENTIFIED BY 'Cdh123456-';
CREATE DATABASE nav DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
GRANT ALL ON nav.* TO 'nav'@'%' IDENTIFIED BY 'Cdh123456-';
CREATE DATABASE navms DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
GRANT ALL ON navms.* TO 'navms'@'%' IDENTIFIED BY 'Cdh123456-';
CREATE DATABASE oozie DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
GRANT ALL ON oozie.* TO 'oozie'@'%' IDENTIFIED BY 'Cdh123456-';
FLUSH PRIVILEGES; # ...
show databases;
安装jdbc驱动
wget https://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-java-5.1.46.tar.gz
tar zxvf mysql-connector-java-5.1.46.tar.gz
for i in {
1..5}; do ssh CDH$i " mkdir -p /usr/share/java/" ; done
for i in {
1..5}; do scp /soft/mysql-connector-java-5.1.46/mysql-connector-java-5.1.46-bin.jar CDH$i:/usr/share/java/mysql-connector-java.jar; done
安装PostgreSQL(未安装)
wget https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
rpm -ivh pgdg-redhat-repo-latest.noarch.rpm
ls -lrt /etc/yum.repos.d/
yum list postgresql*
我们这里安装PostgreSQL10的数据库
sudo yum -y install postgresql10-server
安装JDK
for i in {
1..5}; do ssh CDH$i 'yum -y install java-1.8.0-openjdk.x86_64 java-1.8.0-openjdk-headless.x86_64 java-1.8.0-openjdk-devel.x86_64' ;done
CM安装
vi /etc/yum.repos.d/cm_repo.repo
新增cm_repo.repo
分发
for i in {
2..5}; do scp /etc/yum.repos.d/cm_repo.repo CDH$i:/etc/yum.repos.d/cm_repo.repo; done
安装
yum repolist
yum -y install cloudera-manager-daemons cloudera-manager-agent cloudera-manager-server
初始化数据库
语法
sudo /opt/cloudera/cm/schema/scm_prepare_database.sh [options] <databaseType> <databaseName> <databaseUser> <password>
sudo /opt/cloudera/cm/schema/scm_prepare_database.sh mysql scm scm Cdh123456-
启动Cloudera Manager Server
systemctl start cloudera-scm-server
systemctl status cloudera-scm-server
查看启动日志
sudo tail -f /var/log/cloudera-scm-server/cloudera-scm-server.log
当看到如下,准备就绪
INFO WebServerImpl:com.cloudera.server.cmf.WebServerImpl: Started Jetty server
检查端口是否监听
netstat -lnpt | grep 7180
登录CM
http://192.168.101.141:7180
admin/admin
界面
CDH集群安装
删除多余远程URL
测试链接
目录 返回
首页