K8S运维知识汇总第2天2:准备服务器+安装bind9DNS服务
Posted 一片白纸
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了K8S运维知识汇总第2天2:准备服务器+安装bind9DNS服务相关的知识,希望对你有一定的参考价值。
K8S架构详解
技术架构:
部署架构:
K8S安装部署方式
Minikube链接:https://kubernetes.io/zh/docs/tutorials/hello-minikube/
K8S准备工作
虚拟机网络配置
windows本地网络配置
验证:
配置虚拟机硬件:
配置网卡:
验证是否能ping通:
复制5台并完成网卡配置的修改:
修改10.4.7.11的主机名:
[root@localhost ~]# hostnamectl set-hostname hdss7-11.com
[root@localhost ~]# hostname
hdss7-11.com
关闭防火墙和selinux
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# systemctl disable firewalld
[root@localhost ~]# setenforce 0
[root@localhost ~]# getenforce
[root@localhost ~]# sed -i s/enforcing/disabled/ /etc/selinux/config
[root@localhost ~]# cat /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# disabled - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of disabled.
# 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
安装epel-release
# 第三方rpm安装包的源
yum install -y epel-release
# 更新aliyun的yum源
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
安装必要工具
yum install wget net-tools telnet tree nmap systat lrzsz dos2unix bind-utils -y
hdss7-11的主机上安装bind9
完成docker局域网内的域名解析
[root@localhost ~]# yum install -y bind
bind9主配置文件:
[root@localhost ~]# vi /etc/named.conf
检查配置文件是否正确
[root@hdss7-11 ~]# named-checkconf
[root@hdss7-11 ~]# echo $?
0
配置区域配置文件
[root@hdss7-11 ~]# vi /etc/named.rfc1912.zones
# 最后添加
zone "host.com" IN
type master;
file "host.com.zone";
allow-update 10.4.7.11; ;
;
zone "od.com" IN
type master;
file "od.com.zone";
allow-update 10.4.7.11; ;
;
配置区域数据文件
[root@hdss7-11 ~]# vi /var/named/host.com.zone
$ORIGIN host.com.
$TTL 600 ; 10 minutes # 过期时间2019.12.09+01序号
@ IN SOA dns.host.com. dnsadmin.host.com. ( # 区域授权文件的开始,OSA记录,dnsadmin.host.com为邮箱
2020062501; serial # 安装的当天时间
10800 ; refresh (3 hours)
900 ; retry (15 minutes)
604800 ; expire (1 week)
86400 ; minimum (1 day)
)
NS dns.host.com. # NS记录
$TTL 60 ; 1 minute
dns A 10.4.7.11 # A记录
HDSS7-11 A 10.4.7.11
HDSS7-12 A 10.4.7.12
HDSS7-21 A 10.4.7.21
HDSS7-22 A 10.4.7.22
HDSS7-200 A 10.4.7.200
[root@hdss7-11 ~]# vi /var/named/od.com.zone
$ORIGIN od.com.
$TTL 600 ; 10 minutes
@ IN SOA dns.od.com. dnsadmin.od.com. (
2020062501 ; serial
10800 ; refresh (3 hours)
900 ; retry (15 minutes)
604800 ; expire (1 week)
86400 ; minimum (1 day)
)
NS dns.od.com.
$TTL 60 ; 1 minute
dns A 10.4.7.11
检查配置文件是否正确
[root@hdss7-11 ~]# named-checkconf
[root@hdss7-11 ~]# echo $?
0
检测区域数据文件
[root@localhost ~]# dig -t A hdss7-21.host.com @10.4.7.11 +short
10.4.7.21
[root@hdss7-11 named]# named-checkzone "host.com" /var/named/host.com.zone
zone host.com/IN: loaded serial 2019121001
OK
[root@hdss7-11 named]# named-checkzone "od.com" /var/named/od.com.zone
zone od.com/IN: loaded serial 2019120901
更改文件的属组,权限
[root@hdss7-11 named]# chown root:named /var/named/host.com.zone
[root@hdss7-11 named]# chown root:named /var/named/od.com.zone
[root@hdss7-11 named]# chmod 640 /var/named/host.com.zone
[root@hdss7-11 named]# chmod 640 /var/named/od.com.zone
启动named
[root@hdss7-11 named]# systemctl restart named
[root@hdss7-11 named]# systemctl enable named
查看启动端口
[root@hdss7-11 named]# netstat -luntp | grep 53
验证解析
[root@hdss7-11 named]# dig -t A hdss7-21.host.com @192.168.153.11 +short
192.168.153.21
[root@hdss7-11 named]# dig -t A hdss7-200.host.com @192.168.153.11 +short
更改客户端dns
[root@hdss7-11 named]# vi /etc/sysconfig/network-scripts/ifcfg-ens33
DNS1="10.4.7.11"
[root@hdss7-11 named]# systemctl restart network
[root@hdss7-11 named]# cat /etc/resolv.conf
# Generated by NetworkManager
search host.com
nameserver 10.4.7.11
[root@hdss7-11 named]# ping hdss7-21.host.com
添加主机域search host.com使用短域名
[root@hdss7-11 named]# cat /etc/resolv.conf
search host.com
[root@hdss7-11 named]# ping hdss7-21
更改所有主机的DNS,重启网卡
[root@hdss7-11 named]# systemctl restart network
将虚拟机的网卡DNS也改成10.4.7.11 IPV4 – 高级 – 越点改成20
将本机的网卡DNS也改成10.4.7.11 IPV4 – 高级 – 越点改成20
以上是关于K8S运维知识汇总第2天2:准备服务器+安装bind9DNS服务的主要内容,如果未能解决你的问题,请参考以下文章
第157天学习打卡(Kubernetes k8s集群部署项目)