文章主要是用来安装大数据组件前的环境准备,没有过多的参数配置,简单的环境准备步骤,安装apache和cdh都没问题
本次测试3台集群(node1(192.168.1.2),node2(192.168.1.4),node3(192.168.1.6)),所有的主服务都安装在node1节点,操作系统为CentOS7.6
1.设置语言和时区
(1)设置默认语言
每个节点都要设置
echo $LANG
默认语言为en_US.UTF-8,则跳过。
默认语言非en_US.UTF-8,则执行以下步骤:
echo 'export LANG=en_US.UTF-8' >> ~/.bashrc
重新登录当前会话。
(2)设置操作系统时区
每个节点都要设置
默认设置为(Asia /Shanghai)
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
重新登录当前会话。
2.设置主机名
(1)修改主机名
每个节点都要设置,将节点的主机名分别修改为node1,node2和node3
hostnamectl set-hostname node1 --static
hostnamectl set-hostname node2 --static
hostnamectl set-hostname node3 --static
(2)修改/etc/hosts
每个节点都要设置,在/etc/hosts文件中添加集群所有节点的映射关系
vim /etc/hosts
192.168.1.2 node1
192.168.1.4 node2
192.168.1.6 node3
3.禁用防火墙和关闭SELinux
(1)关闭禁用防火墙
每个节点都要设置
systemctl disable firewalld
systemctl stop firewalld
(2)关闭SELinux
每个节点都要设置
# 先更改SELinux为宽容模式
setenforce 0
# 修改/etc/selinux/config文件,永久禁止SELinux
vi /etc/selinux/config
修改为disabled
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of three values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
4.配置limits参数
每个节点都要设置,编辑limits.conf文件
vi /etc/security/limits.conf
在最后添加以下几行
* hard nproc 65535
* soft nproc 65535
* hard nofile 65535
* soft nofile 65535
5.设置节点互信
每个节点都要设置,配置SSH免密登录
# 执行如下命令,生成密钥,遇到提示时,按回车
ssh-keygen -t rsa
配置SSH免密登录(包括配置自身节点的免密)
ssh-copy-id -i ~/.ssh/id_rsa.pub root@所有节点IP
例子:
# 在node1下生产密钥
ssh-keygen -t rsa
# 配置免密 需要输入密码
ssh-copy-id -i ~/.ssh/id_rsa.pub root@node1
ssh-copy-id -i ~/.ssh/id_rsa.pub root@node2
ssh-copy-id -i ~/.ssh/id_rsa.pub root@node3
6.配置OS的yum源
每个节点都要设置,配置SSH免密登录
参考博客:https://blog.csdn.net/qq_35260875/article/details/106148473
(1)挂载镜像源
# 需要先下载操作系统的iso,我这里用的是CentOS7.6的
mount CentOS-7-x86_64-DVD-1810.iso /media/ -o loop
(2)配置yum源
#备份原始repo文件
cd /etc/yum.repos.d
mkdir -p /etc/yum.repos.d/bak
mv *.repo bak
# 创建并编辑local.repo文件
cd /etc/yum.repos.d
vi local.repo
在local.repo文件中添加如下内容:
[local]
name=local repo
baseurl=file:///media
enabled=1
gpgcheck=0
(3)本地源生效
yum clean all
yum makecache
7.安装配置JDK
每个节点都要设置,使用yum源安装jdk1.8
yum install java-1.8.0-openjdk*
8.时钟同步ntp设置
(1)安装ntp
每个节点都要执行
yum install ntp -y
(2)设置时钟同步开机自启
每个节点都要执行
system enable ntpd
(3)配置ntp 服务端
设置node1作为ntp服务端,其他两台的时间会以这台作为同步
vi /etc/ntp.conf
# 修改内容为如下
# Hosts on local network are less restricted.
restrict 128.5.128.1 mask 255.255.224.0 nomodify notrap
#允许内网其他机器同步时间,192.168.1.1为当前网关,255.255.224.0为子网掩码
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
#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
#设置node1为时钟服务器
server 127.127.1.0
Fudge 127.127.1.0 stratum 10
# 重启ntp
systemctl restart ntpd.service
(4)配置ntp 客户端
node2和node3作为ntp客户端
vi /etc/ntp.conf
# 修改内容为如下
# Hosts on local network are less restricted.
restrict 128.5.128.1 mask 255.255.224.0 nomodify notrap
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
#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
#设置为node1的ip
server 192.168.1.2 prefer
fudge 192.168.1.2 stratum 10
# 重启ntp
systemctl restart ntpd.service
(5)验证ntp时钟同步
每个节点都要执行
ntpstat
# ntp 服务端信息如下:
synchronised to local net at stratum 6
time correct to within 12 ms
polling server every 64 s
# ntp 客户端信息如下:
synchronised to NTP server (192.168.1.2) at stratum 7
time correct to within 41 ms
polling server every 1024 s