DNS 部署:
主机: 192.168.1.200
系统: CentOS 7.4
CPU: 1 vCPU
Memory: 2 G
1. 安装需要的包:
$ yum -y install bind bind-utils
2. 修改配置文件:
# 仅贴出了修改的部分
$ cat /etc/named.conf options { listen-on port 53 { any; }; ...... allow-query { any; }; forwarders { 114.114.114.114; }; ...... }; zone "joshua.com" IN { type master; file "named.joshua.com"; };
3. 添加解析文件, 短域名(dns. / gluster1. / node1.)之类的仅为了操作方便, 实际环境可以不写这些条目
$ cat /var/named/named.joshua.com $TTL 1D @ IN SOA @ joshua.com. ( 0 ; serial 1D ; refresh 1H ; retry 1W ; expire 3H ) ; minimum NS dns.joshua.com. dns.joshua.com. A 192.168.1.200 dns. CNAME dns.joshua.com. ;GlusterFS gluster1.joshua.com. A 192.168.1.201 gluster1. CNAME gluster1.joshua.com. gluster2.joshua.com. A 192.168.1.202 gluster2. CNAME gluster2.joshua.com. gluster3.joshua.com. A 192.168.1.203 gluster3. CNAME gluster3.joshua.com. ;oVirt ovirt.joshua.com. A 192.168.1.50 ovirt. CNAME ovirt.joshua.com. host1.ovirt.joshua.com. A 192.168.1.51 host1. CNAME host1.ovirt.joshua.com. host2.ovirt.joshua.com. A 192.168.1.52 host2. CNAME host2.ovirt.joshua.com. ;OpenShift openshift.joshua.com. A 192.168.1.150 openshift. CNAME openshift.joshua.com. master1.openshift.joshua.com. A 192.168.1.151 master1. CNAME master1.openshift.joshua.com. master2.openshift.joshua.com. A 192.168.1.152 master2. CNAME master2.openshift.joshua.com. master3.openshift.joshua.com. A 192.168.1.153 master3. CNAME master3.openshift.joshua.com. etcd1.openshift.joshua.com. A 192.168.1.154 etcd1. CNAME etcd1.openshift.joshua.com. etcd2.openshift.joshua.com. A 192.168.1.155 etcd2. CNAME etcd2.openshift.joshua.com. etcd3.openshift.joshua.com. A 192.168.1.156 etcd3. CNAME etcd3.openshift.joshua.com. node1.openshift.joshua.com. A 192.168.1.157 node1. CNAME node1.openshift.joshua.com. node2.openshift.joshua.com. A 192.168.1.158 node2. CNAME node2.openshift.joshua.com. node3.openshift.joshua.com. A 192.168.1.159 node3. CNAME node3.openshift.joshua.com. node4.openshift.joshua.com. A 192.168.1.160 node4. CNAME node4.openshift.joshua.com. ;OpenStack openstack.joshua.com. A 192.168.1.100
4. 启动服务, 同时防火墙开通策略
$ systemctl enable named $ systemctl start named $ firewall-cmd --permanent --add-service=dns $ firewall-cmd --reload
5. 最后可以测试一下, 也是为什么会装 bind-utils 这个包, 因为这个包带了一些 DNS 测试工具
$ dig @localhost gluster1.joshua.com ; <<>> DiG 9.9.4-RedHat-9.9.4-51.el7 <<>> @localhost gluster1.joshua.com ; (2 servers found) ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 53161 ;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 2 ;; OPT PSEUDOSECTION: ; EDNS: version: 0, flags:; udp: 4096 ;; QUESTION SECTION: ;gluster1.joshua.com. IN A ;; ANSWER SECTION: gluster1.joshua.com. 86400 IN A 192.168.1.201 ;; AUTHORITY SECTION: joshua.com. 86400 IN NS dns.joshua.com. ;; ADDITIONAL SECTION: dns.joshua.com. 86400 IN A 192.168.1.99 ;; Query time: 1 msec ;; SERVER: ::1#53(::1) ;; WHEN: Mon Dec 04 13:37:54 CST 2017 ;; MSG SIZE rcvd: 98