CDH6.2.0安装(二)
虚拟机设置
Step1: 安装虚拟机
略
Step2: 设置网络
- 进入/etc/sysconfig/network-scripts/目录,编辑ifcfg-enp0s3文件(名称可能不一样)
TYPE="Ethernet"
PROXY_METHOD="none"
BROWSER_ONLY="no"
############改动部分开始############
#动态IP
#BOOTPROTO="dhcp"
#静态IP
BOOTPROTO="static"
IPADDR=192.168.0.222
NETMASK=255.255.255.0
GATEWAY=192.168.0.1
DNS1=114.114.114.114
############改动部分结束############
DEFROUTE="yes"
IPV4_FAILURE_FATAL="no"
IPV6INIT="yes"
IPV6_AUTOCONF="yes"
IPV6_DEFROUTE="yes"
IPV6_FAILURE_FATAL="no"
IPV6_ADDR_GEN_MODE="stable-privacy"
NAME="enp0s3"
UUID="73ab5a69-9070-4c5a-a0b9-c5a6250af943"
DEVICE="enp0s3"
ONBOOT="yes
- 修改文件后保存退出,使用命令 service network restart 重启网卡服务,即可
Step3:设置hosts(后续操作均以root用户执行)
-
确定各节点hostname 正确设置:
vi /etc/hostname
-
设置hosts:
vi /etc/hosts: 192.168.31.110 master 192.168.31.111 slave1 192.168.31.112 slave2
Step4:关闭SELinux及防火墙
- 关闭SELinux:
vi /etc/selinux/config ,修改如下:
SELINUX=disabled
- 关闭防火墙:
systemctl stop firewalld
systemctl disable firewalld
Step5: 设置ssh免密登录
- 生成密钥:
ssh-keygen -t rsa(默认位于 ~/.ssh/)
- 拷贝公钥到所有机器:
ssh-copy-id root@master
ssh-copy-id root@slave1
ssh-copy-id root@slave2
- 测试免密登录:
ssh master
ssh slave01
ssh slave02
Step6: 设置yum源为阿里云的源
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
yum clean all
yum makecache
Step7: 设置ntp时间同步服务
- 安装 ntp
yum –y install ntp
- 启动并设置NTP服务开机启动
systemctl start ntpd
systemctl enable ntpd
Step8: 设置ntp时间同步服务
- vi /etc/ntp.conf,内容如下:
driftfile /var/lib/ntp/ntp.drift #草稿文件
# 允许内网其他机器同步时间(192.168.137.0 修改为自己的ip掩码)
restrict 192.168.137.0 mask 255.255.255.0 nomodify notrap
# Use public servers from the pool.ntp.org project.
# 中国这边最活跃的时间服务器 : [http://www.pool.ntp.org/zone/cn](http://www.pool.ntp.org/zone/cn)
server 210.72.145.44 perfer # 中国国家受时中心
server 202.112.10.36 # 1.cn.pool.ntp.org
server 59.124.196.83 # 0.asia.pool.ntp.org
# allow update time by the upper server
# 允许上层时间服务器主动修改本机时间
restrict 210.72.145.44 nomodify notrap noquery
restrict 202.112.10.36 nomodify notrap noquery
restrict 59.124.196.83 nomodify notrap noquery
#外部时间服务器不可用时,以本地时间作为时间服务
server 127.127.1.0 # local clock
fudge 127.127.1.0 stratum 10
2.重启服务:
service ntpd restart
3.查看同步状态:
netstat -tlunp | grep ntp
Step9: 设置ntp时间同步服务
设置slave到master 的同步(在slave节点操作):
- vi /etc/ntp.conf,内容如下:
driftfile /var/lib/ntp/ntp.drift # 草稿文件
statsdir /var/log/ntpstats/
statistics loopstats peerstats clockstats
filegen loopstats file loopstats type day enable
filegen peerstats file peerstats type day enable
filegen clockstats file clockstats type day enable
# 让NTP Server为内网的ntp服务器( 192.168.31.110修改为master节点ip)
server 192.168.31.110
fudge 192.168.31.110 stratum 5
# 不允许来自公网上ipv4和ipv6客户端的访问
restrict -4 default kod notrap nomodify nopeer noquery
restrict -6 default kod notrap nomodify nopeer noquery
# Local users may interrogate the ntp server more closely.
restrict 127.0.0.1
restrict ::1
- 重启服务:
service ntpd restart
- 手动同步:
ntpdate -u 192.168.31.110