日萌社
人工智能AI:Keras PyTorch MXNet TensorFlow PaddlePaddle 深度学习实战(不定时更新)
总帖:CDH 6系列(CDH 6.0、CHD6.1等)安装和使用
------------------------------------------------------------------------------------------------------------------------------------------------
1.查看IP地址:ip addr
2.配置网卡信息
1.vi /etc/sysconfig/network-scripts/ifcfg-ens33
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=none
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=ens33
UUID=1945a1d8-e6a6-4d0d-828e-60dc0320edb4
DEVICE=ens33
ONBOOT=yes 修改完这个然后重启网络后就可以ping通外界网络了
IPADDR=192.168.88.100
PREFIX=24
GATEWAY=192.168.88.2
DNS1=192.168.88.2
IPV6_PRIVACY=no
3.重启网络:service network restart
4.ping baidu.com
5.yum install vim
6.vim添加行号
vim /etc/vimrc
最后一行添加内容 :set number
3.设置 hostname,reboot重启之后即能显示(注意:不使用大写字符作为主机名,否则在CDH中无法正常通过Kerberos进行身份验证)
hostnamectl set-hostname 主机名
vim /etc/hostname 设置主机名
4.设置 hosts 文件
vim /etc/hosts
192.168.88.100 node1
192.168.88.101 node2
192.168.88.102 node3
scp -r /etc/hosts root@node2:/etc
scp -r /etc/hosts root@node3:/etc
5.禁用 防火墙(重启生效)
关闭 systemctl stop firewalld
开机禁用 systemctl disable firewalld
查看状态 systemctl status firewalld
6.禁用 SELINUX
1.临时关闭SELINUX
setenforce 0
2.永久关闭SELINUX
修改配置文件 vim /etc/selinux/config(重启生效)
将 SELINUX=enforcing 改为 SELINUX=disabled
3.查看SELINUX状态 sestatus
reboot 重启机器后 执行 sestatus 显示 SELinux status: disabled
------------------------------------------------------------------------------------------------------------------------------------------------
非对称加密的方式基于私钥登陆的方式:(ssh连接时无需输入用户密码)
1.ssh-keygen -t rsa 然后四下回车
2./root/.ssh目录下:
私钥:id_rsa
公钥:id_rsa.pub
3.ssh-copy-id linux的IP
每个节点都需要拷贝秘钥然后分发给别的linux,执行命令后然后输入yes,然后最终输入密码
ssh-copy-id node1
ssh-copy-id node2
ssh-copy-id node3
4.ssh linux的用户名@别的linux的IP
现在无需输入别的linux的用户密码即能登录到别的linux中
5.ssh root@node1
exit
ssh root@node2
exit
ssh root@node3
exit
------------------------------------------------------------------------------------------------------------------------------------------------
7.配置时间同步
如果多个节点之间的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服务启动后,主节点一般需要1~5分钟才能同步上外部的授时中心,其他子节点同样可能需要1~5分钟才同步上主节点时钟
1.方案一(推荐使用方案二,不建议使用方案一)
安装 yum install ntpdate
根据aliyun提供的服务进行 时间同步:ntpdate ntp6.aliyun.com
查看当前时间:date 或 timedatectl
2.方案二(推荐使用方案二,不建议使用方案一)
先安装 ntp 再使用命令同步外部授时中心:ntpdate -u cn.pool.ntp.org 或 ntpdate -u ntp6.aliyun.com
1.ntp
安装 yum install ntp
启动服务 systemctl start ntpd
查看是否启动 ps -ef | grep ntpd
开机启动 systemctl enable ntpd.service
查看当前时间 date
查看当前时间和NTP服务的同步状态 timedatectl
2.node1作为NTP Server,node2和node3作为NTP Client,node2和node3要跟node1同步时间,node1要去外部授时中心同步时间
1.配置 node1:
1.配置前先使用命令同步外部授时中心:ntpdate -u cn.pool.ntp.org 或 ntpdate -u ntp6.aliyun.com
2.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
增加如下配置:
# 允许内网其他机器同步时间,如果不添加该约束默认允许所有IP访问本机同步服务。192.168.88.0为本局域网内的子网IP
restrict 192.168.88.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 # local clock
fudge 127.127.1.0 stratum 10
3.systemctl restart ntpd 重启服务端ntpd服务
4.ntpq -p 查看网络中的NTP服务器,同时显示客户端和每个服务器的关系
5.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
6.也可以使用 ntpdate -u ntp6.aliyun.com 同步阿里云时间
timedatectl 查看当前时间和NTP服务的同步状态:必须保证所有节点下的时间都是一致,并且NTP服务同步成功,那么才能作为CDH启动成功的保证
2.配置 node2、node3:
1.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.88.100
# 配置允许上游时间服务器主动修改本机的时间
restrict 192.168.88.100 nomodify notrap noquery
2.systemctl restart ntpd 重启服务端ntpd服务
3.ntpq -p 查看网络中的NTP服务器,同时显示客户端和每个服务器的关系
4.ntpstat 查看时间同步状态
其他子节点同样可能需要1~5分钟才同步上主节点时钟
同步还没有成功时,node2、node3会显示 synchronised to unspecified at stratum 3
同步成功以后,node2、node3会显示 synchronised to NTP server (主节点IP)at stratum 3
3.node2、node3 都可以手动执行 ntpdate -u node1 同步主节点的时间
timedatectl 查看当前时间和NTP服务的同步状态 timedatectl:必须保证所有节点下的时间都是一致,并且NTP服务同步成功,那么才能作为CDH启动成功的保证
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
安装 JDK(此处不自己安装JDK,后面的文章 Cloudera Manager安装(只需要在NODE1做) 中会介绍如何安装JDK)
CDH6 官方提供的多个包中 已经包含 JDK,因此就不要自己另外装JDK了,装CM6 时,请装官方提供的JDK:oracle-j2sdk1.8-1.8.0+update141-1.x86_64.rpm
Cloudera Manager的rpm安装包由之前的7个变成了5个,去掉了之前的JDK6的包,然后自带JDK1.8.0_141,将不再支持JDK1.7,因此可以不需要自己手动安装JDK
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
9.CDH之优化Linux底层:
https://www.cloudera.com/documentation/enterprise/latest/topics/cdh_admin_performance.html#cdh_performance__section_nt5_sdf_jq
1.关闭透明大页
禁用透明重复页面(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/
2.设置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 重启后 重新查看
3.禁用已调优的服务
1.(无需执行)确保已启动调优服务:systemctl start tuned
2.关闭调优服务:tuned-adm off
3.确保没有活动的配置文件:tuned-adm list 最后一行显示为 No current active profile(无当前活动配置文件)
4.关闭并禁用调优服务:
systemctl stop tuned
systemctl disable tuned