【Centos7.6安装CDH6.1.0】第一节 基础环境准备(yum源、host域名及免密登录)

基础环境

选用Centos7.6(关于Centos操作系统版本无硬性要求):

[root@mini1 ~]# cat /etc/redhat-release
CentOS Linux release 7.6.1810 (Core)

准备三台机器:

192.168.26.11(主节点)
192.168.26.12(从节点)
192.168.26.13(从节点)

配置host域名映射

将以下host域名映射分别写入三台机器的/etc/hosts中:

192.168.26.11	mini1
192.168.26.12	mini2
192.168.26.13	mini3

关闭防火墙

root用户下,在mini1、mini2、mini3上分别命令:

# 永久关闭防火墙,并查看防火墙状态
systemctl stop firewalld
systemctl disable firewalld
systemctl status firewalld.service
#临时关闭selinux
setenforce 0    
#永久关闭selinux                                
sed -i "s/^SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config 

效果如下:

[root@mini1 ~]# systemctl stop firewalld
[root@mini1 ~]# systemctl disable firewalld
[root@mini1 ~]# systemctl status firewalld.service
● firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
   Active: inactive (dead)
     Docs: man:firewalld(1)

配置yum源(阿里镜像)

root用户下,在mini1、mini2、mini3两台机器上分别执行如下命令完成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-7.repo
yum clean all     # 清除系统所有的yum缓存
yum makecache     # 生成yum缓存
yum list

主节点到从节点免密登录(自动化脚本)

root用户下,先在在mini2、mini3两台机器上分别执行如下命令:

ssh-keygen -t rsa

在出现的提示中连续三个回车生成公钥和私钥,效果如下:

[root@mini2 ~]# ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): 
Created directory '/root/.ssh'.
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:UPAoMFlBOvjsgbd6C6dr7S/XyagvW4ZlIXKkOM2JM0w root@mini2
The key's randomart image is:
+---[RSA 2048]----+
| Eo=+....        |
|+=+=   +         |
|B+*o..o .        |
| Bo.....         |
|. =  o  S        |
| o o+            |
|. =. o+ .        |
| *.+oo +         |
|=oo=Oo           |
+----[SHA256]-----+

root用户下,在mini1创建一个名为init.sh脚本,脚本内容如下:

# 永久关闭防火墙
# 免密regist
yum -y install openssh-server
yum -y install openssh-clients
yum -y install expect
expect <<EOF
  spawn ssh-keygen -t rsa
  expect {
    "*id_rsa):" {send "\n";exp_continue}
    "*(y/n)?" {send "y\n";exp_continue}
    "*passphrase):" {send "\n";exp_continue}
    "*again:" {send "\n"}
  }
  expect eof

 spawn ssh-copy-id -p 22 -i /root/.ssh/id_rsa.pub mini1
  expect {
    "*(yes/no)?" {send "yes\n";exp_continue}
    "*password" {send "root\n"}
  }
  expect eof

 spawn ssh-copy-id -p 22 -i /root/.ssh/id_rsa.pub mini2
  expect {
    "*(yes/no)?" {send "yes\n";exp_continue}
    "*password" {send "root\n"}
  }
  expect eof

 spawn ssh-copy-id -p 22 -i /root/.ssh/id_rsa.pub mini3
  expect {
    "*(yes/no)?" {send "yes\n";exp_continue}
    "*password" {send "root\n"}
  }
  expect eof
EOF

root用户下,执行脚本:

[root@mini1 ~]# ssh init.sh

等待以来安装并自动完成配置后(机器性能不好或网络差会耗时很久),验证:

[root@mini1 ~]# ssh mini2
Last login: Fri Jan 31 16:59:19 2020 from mini1
[root@mini2 ~]# exit
登出
Connection to mini2 closed.
[root@mini1 ~]# 

主节点到从节点免密登录配置成功。

跳转

第一节 基础环境准备(host域名及免密登录)
第二节 JDK、mysql配置
第三节 Python2.7.5安装、时钟同步及CDH本地Yum源搭建
第四节 安装并启动CM组件
第五节 WebUI方式安装CDH6

发布了31 篇原创文章 · 获赞 21 · 访问量 2万+

猜你喜欢

转载自blog.csdn.net/Jack_Roy/article/details/104125751