CDH安装宝典之前言

设置 hostname

hostnamectl set-hostname 主机名
hostnamectl set-hostname node1

vi /etc/hostname
node1

设置 hosts 文件

vim /etc/hosts
192.168.166.30 node1
192.168.166.31 node2
192.168.166.32 node3

#下面得先配置免密登录先
scp -r /etc/hosts root@node2:/etc
scp -r /etc/hosts root@node3:/etc

设置免密登录

每个节点都需要拷贝秘钥然后分发给别的linux,执行命令后然后输入yes,然后最终输入密码

ssh-keygen 
#一般执行完这个命令公钥和私钥会生成到 .ssh 的隐藏目录,在执行这个命令之前我们先检查一下这个目录是否存在,因为有些linux如果没有这个目录的话是不会生成key的
ls -la
ssh-keygen -t rsa    #直接回车回车就OK
cd .ssh #可免
ssh-copy-id node2
ssh-copy-id node3

ssh node3

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-CluZ7ox8-1641781522910)(…/…/…/图床/安装搭建/免密登录.png)]

禁用 防火墙 ,重启生效 ,

关闭  systemctl stop firewalld
开机禁用 systemctl disable firewalld
查看状态 systemctl status firewalld

禁用 SELINUX

1.临时关闭SELINUX
setenforce 0
2.永久关闭SELINUX
修改配置文件 vim /etc/selinux/config  (重启生效)SELINUX=enforcing 改为 SELINUX=disabled 
3.查看SELINUX状态 sestatus
reboot 重启机器后 执行 sestatus 显示 SELinux status:  disabled

#一键替换
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config

配置时钟同步

如果多个节点之间的NTP服务没有成功同步时间的话,多个组件都无法使用,并且CM页面上会显示 ,时钟偏差不良 ,并报错信息:
The health test result for HOST_CLOCK_OFFSET has become bad: The host’s NTP service is not synchronized to any remote server
注意:ntpd服务启动后,主节点一般需要15分钟才能同步上外部的授时中心,其他子节点同样可能需要15分钟才同步上主节点时钟

安装

先安装 ntp 再使用命令同步外部授时中心: ntpdate -u cn.pool.ntp.org 或 ntpdate -u ntp6.aliyun.com
安装 yum install ntp 
启动服务 systemctl start ntpd 
查看是否启动 ps -ef | grep ntpd
开机启动 systemctl enable ntpd.service    
查看当前时间 date
查看当前时间和NTP服务的同步状态 timedatectl

node1作为NTP Server,node2和node3作为NTP Client,node2和node3要跟node1同步时间,node1要去外部授时中心同步时间

备份 /etc/ntp.conf 到 /etc/ntp.conf.bak20200105
cp /etc/ntp.conf /etc/ntp.conf.bak20200105


配置 ,服务端 ,node1

配置前先使用命令同步外部授时中心(可免)
ntpdate -u cn.pool.ntp.org
ntpdate -u ntp6.aliyun.com

vim /etc/ntp.conf
----------------------------------------------------------------------------------------------------
注释以下配置
#server 0.centos.pool.ntp.org iburst
#server 1.centos.pool.ntp.org iburst
#server 2.centos.pool.ntp.org iburst
#server 3.centos.pool.ntp.org iburst

driftfile /var/lib/ntp/drift
restrict default nomodify notrap nopeer noquery
restrict 127.0.0.1 
restrict ::1
# 允许内网其他机器同步时间,如果不添加该约束默认允许所有IP访问本机同步服务.192.168.166.0 为本局域网内的子网IP
restrict 192.168.166.0 mask 255.255.255.0 nomodify notrap
# 配置和上游标准时间同步
server 210.72.145.44  # 中国国家授时中心
server 133.100.11.8  #日本[福冈大学]
server 0.cn.pool.ntp.org
server 1.cn.pool.ntp.org
server 2.cn.pool.ntp.org
server 3.cn.pool.ntp.org

# 配置允许上游时间服务器主动修改本机(内网ntp Server)的时间
restrict 210.72.145.44 nomodify notrap noquery
restrict 133.100.11.8 nomodify notrap noquery
restrict 0.cn.pool.ntp.org nomodify notrap noquery
restrict 1.cn.pool.ntp.org nomodify notrap noquery
restrict 2.cn.pool.ntp.org nomodify notrap noquery
restrict 3.cn.pool.ntp.org nomodify notrap noquery

# 确保localhost有足够权限,使用没有任何限制关键词的语法.
# 外部时间服务器不可用时,以本地时间作为时间服务.
# 注意:这里不能改,必须使用127.127.1.0,否则会导致无法
#在ntp客户端运行ntpdate serverIP,出现no server suitable for synchronization found的错误.
#在ntp客户端用ntpdate –d serverIP查看,发现有 ,Server dropped: strata too high ,的错误,并且显示 ,stratum 16 ,.而正常情况下stratum这个值得范围是 ,0~15 ,.
#这是因为NTP server还没有和其自身或者它的server同步上.
#以下的定义是让NTP Server和其自身保持同步,如果在ntp.conf中定义的server都不可用时,将使用local时间作为ntp服务提供给ntp客户端.
#下面这个配置,建议NTP Client关闭,建议NTP Server打开.因为Client如果打开,可能导致NTP自动选择合适的最近的NTP Server ,也就有可能选择了LOCAL作为Server进行同步,而不与远程Server进行同步.

server 127.127.1.0
fudge 127.127.1.0  stratum 10

includefile /etc/ntp/crypto/pw
keys /etc/ntp/keys
disable monitor
----------------------------------------------------------------------------------------------------

#美宜佳大数据配置
driftfile /var/lib/ntp/drift
restrict default nomodify notrap nopeer noquery
restrict 127.0.0.1
restrict ::1
server 192.168.0.1
restrict 192.168.0.1 nomodify notrap noquery
server 127.0.0.1
fudge 127.0.0.1 stratum 10
includefile /etc/ntp/crypto/pw
keys /etc/ntp/keys
disable monitor





查看时间同步状态

systemctl restart ntpd #重启服务端ntpd服务
ntpq -p #查看网络中的NTP服务器,同时显示客户端和每个服务器的关系
ntpstat #查看时间同步状态
1. 正在尝试同步的话,执行ntpstat会显示 synchronised to local net at stratum 11
主节点一般需要1~5分钟才能同步上外部的授时中心.所以,服务器启动后需要稍等下
2. 没有同步成功的话,执行ntpstat会显示unsynchronised
3. 同步成功以后,node1会显示 synchronised to NTP server (119.28.183.184) at stratum 3

ntpdate -u ntp6.aliyun.com 同步阿里云时间
timedatectl 查看当前时间和NTP服务的同步状态:必须保证所有节点下的时间都是一致,并且NTP服务同步成功,那么才能作为CDH启动成功的保证

node2\node3 都可以手动执行 
ntpdate -u node1 同步主节点的时间
timedatectl  set-ntp  yes    //启用NTP同步

配置 ,客户端 ,node2 ,node3

vim /etc/ntp.conf
注释以下配置
#server 0.centos.pool.ntp.org iburst
#server 1.centos.pool.ntp.org iburst
#server 2.centos.pool.ntp.org iburst
#server 3.centos.pool.ntp.org iburst
增加如下配置:
#配置上游时间服务器为本地的ntpd Server服务器
server 192.168.166.30

# 配置允许上游时间服务器主动修改本机的时间
restrict 192.168.166.30 nomodify notrap noquery

CDH之优化Linux底层

关闭透明大页

禁用透明重复页面 ,THP ,
CDH支持的大多数Linux平台都包含一个名为transparent hugepages的功能,该功能与Hadoop工作负载交互不良,并且可能严重降低性能.

1.执行 cat /sys/kernel/mm/transparent_hugepage/enabled
  显示为 [always] madvise never 表示启用
  默认情况下,状态为always,需要调整为never
2.vim /etc/default/grub
    把第六行的 GRUB_CMDLINE_LINUX="crashkernel=auto rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb quiet"
    修改为 GRUB_CMDLINE_LINUX="rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb quiet transparent_hugepage=never"
3.grub2-mkconfig -o /boot/grub2/grub.cfg
4.reboot    
5.重启后 重新执行 cat /sys/kernel/mm/transparent_hugepage/enabled 显示 always madvise [never] 表示禁用
6.在安装CDH如果还提示没有禁用成功的话,请进行如下设置进行禁用:
  已启用透明大页面压缩,可能会导致重大性能问题,需要禁用此设置.
  请运行
echo never > /sys/kernel/mm/transparent_hugepage/defrag
echo never > /sys/kernel/mm/transparent_hugepage/enabled
  可以暂时生效
  永久生效:将上述两个命令然 添加到/etc/rc.local等初始化脚本中,以便在系统重启时予以设置. 
vim /etc/rc.local
echo never > /sys/kernel/mm/transparent_hugepage/defrag
echo never > /sys/kernel/mm/transparent_hugepage/enabled

scp -r /etc/rc.local root@node2:/etc/
scp -r /etc/rc.local root@node3:/etc/

设置vm.swappiness Linux内核参数

Linux内核参数 , vm.swappiness ,是一个0-100的值 ,用于控制应用程序数据 ,作为匿名页面 ,从物理内存到磁盘上的虚拟内存的交换 ,
值越高 ,从物理内存中交换出更积极的非活动进程 ,值越小 ,交换的次数越少 ,强制清空文件系统缓冲区 ,
在大多数系统上 , vm.swappiness默认设置为60 ,这不适用于Hadoop集群 ,因为即使有足够的可用内存 ,有时也会交换进程 ,
这可能会导致重要系统守护程序的冗长垃圾收集暂停 ,从而影响稳定性和性能 ,
Cloudera建议您设置 vm.swappiness对于最小交换 ,值为1到10 ,优选为1 ,

1.vim /etc/sysctl.conf 添加 vm.swappiness=1
2.执行激活 sysctl -p 显示 vm.swappiness = 1
  查看 cat /proc/sys/vm/swappiness 显示值为 1
3.reboot 重启后 重新查看

MYJ配置
echo vm.swappiness = 0 >> /etc/sysctl.conf
sysctl -p

禁用已调优的服务

1.无需执行 ,确保已启动调优服务 ,systemctl start tuned
2.关闭调优服务 ,tuned-adm off
3.确保没有活动的配置文件 ,tuned-adm list 最后一行显示为 No current active profile ,无当前活动配置文件 ,
4.关闭并禁用调优服务 ,
    systemctl stop tuned
    systemctl disable tuned

修改打开文件数 ulimit -n 65535

安装基础工具

yum groupinstall "Development Tools"  -y

yum install -y wget vim net-tools git make automake autoconf libtool pcre \
    pcre-devel zlib zlib-devel openssl openssl-devel python-devel libevent-devel \
    python-pip gcc gcc-c++ xz-devel readline-devel sqlite-devel bzip2-devel

检查默认创建权限umask

umask #查看创建权限 默认是0022

echo umask 0022 >> /etc/profile #修改

Mysql(元数据)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值