修改主机名称
vi /etc/sysconfig/network
修改完后,reboot
IP地址映射
vi /etc/hosts 即可修改主机名与 IP 的映射关系。
免密登录
openssh-clients 服务
yum install -y openssh-clients,即可安装 openssh-clients 服务。
测试 ssh 命令
SSH 免密码登录配置
明确目标用户
首先要明确是为哪个用户创建免密码登录,比如我们为 hadoop 用户 创建 SSH 免密码登录。在 hadoop 用户下,切换到 hadoop 用户的家 目录(即/home/hadoop 目录)。
root用户
生成秘钥
ssh-keygen -t rsa 生成秘钥,然后一直按回车即可。 ssh-keygen 是 ssh 秘钥生成器,-t 是指定参数,rsa 是一种加密算法。
生成认证文件
切换到.ssh 目录下:输入 cd .ssh,然后输入“ll”命令查 看,发现有一个公钥,有一个私钥,(ssh 生成的秘钥对都是存储在.ssh 这个目录下的)
输入命令:cp id_rsa.pub authorized_keys,将公钥 copy 到认证文件。
为.ssh 赋予权限
退回到 root 的家目录,为.ssh 赋予权限
为.ssh 目录赋予 700 的权限 chmod 700 .ssh
为.ssh 目录下的所有文件赋予 600 的权限 chmod 600 .ssh/*
ssh 验证
SSH各节点免密互通
将cdh2和cdh3的公钥追加到cdh1的认证文件
cdh2和cdh3分别执行
cat ~/.ssh/id_rsa.pub | ssh root@cdh1 'cat >> ~/.ssh/authorized_keys'
执行后,查看cdh1的认证文件
将 cdh1 中的 authorized_keys 文件分发到 cdh2 和 cdh3 节点上
scp -r authorized_keys root@cdh2:~/.ssh/
scp -r authorized_keys root@cdh3:~/.ssh/
时钟同步
修改时间标准
只需要在所有节点执行命令:
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
配置 NTP 服务器
检查cdh的NTP服务是否已经安装
rpm -qa | grep ntp
如果没有安装就 yum install -y ntp
修改cdh1配置文件 ntp.conf
vi /etc/ntp.conf
- 启用 restrict,限定该机器网段 ,具体操作如下: 将restrict 192.168.74.136 mask 255.255.255.0 nomodify notrap行的注 释去掉,直接输入本机的 IP 地址
- 注释掉 server 域名配置
#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
- 在该文件中添加下边两行,让本机和本地硬件时间同步。
server 127.127.1.0
fudge 127.127.1.0 stratum 10
启动 NTP 服务
chkconfig ntpd on 这样每次机器启动时,NTP 服务自动启动
)
配置其他机器的定时时间同步
在对应机器输入命令:crontab -e ,然后在会话中输入:
0-59/5 * * * * /usr/sbin/ntpdate cdh1
表示每隔 5分做一次时钟同步
Linux配置NTP同步,出现Server dropped: no data解决
先报错:no server suitable for synchronization found
/usr/sbin/ntpdate -d cdh1
执行后发现no data
解决:
[root@cdh1 hbase]# service ntpd status
ntpd 已停
[root@cdh1 hbase]# service ntpd start
正在启动 ntpd:[确定]
[root@cdh1 hbase]# /root/tools/runRemoteCmd.sh "date" all
*******************cdh1***********************
2020年 03月 21日 星期六 17:56:48 CST
*******************cdh2***********************
2020年 03月 21日 星期六 17:56:48 CST
*******************cdh3***********************
2020年 03月 21日 星期六 17:56:48 CST