一、简述DNS服务器原理,并搭建主-辅服务器。 主服务器如下配置,加了如下内容(红色): [root@centos8 /var/named]#cat /var/named/magedu.org.zone $TTL 1D @ IN SOA ns1 admin.magedu.org. ( 20200530 ; serial 1D ; refresh 1H ; retry 1W ; expire 3H ) ; minimum @ NS ns1 @ NS ns2 ns1 A 172.16.0.152 ns2 A 172.16.0.151 www CNAME websrv websrv A 172.16.0.77 websrv A 172.16.0.77

  •       A   172.16.0.151
    

@ MX 10 mailsrv @ MX 20 mailsrv2 mailsrv A 172.16.0.151 mailsrv2 A 172.16.0.152 [root@centos8 /var/named]#

DNS从服务器 用虚拟机的配置:172.20.4.108 #hostnamectl set-hostname slave

[root@centos7 ~]#yum -y install bind

[root@centos7 ~]#systemctl enable --now named vim /etc/named.conf

vim /etc/named.conf // listen-on port 53 { 127.0.0.1; }; // allow-query { localhost; };

vim /etc/named.rfc1912.zones

指向主服务器 zone "magedu.org" IN { type slave; masters {172.16.0.152;}; 这里有两个分号,同时是masters file "slaves/magedu.org.zone.slave"; };

如下文件夹是空的: [root@centos7 ~]#ls /var/named/slaves/ [root@centos7 ~]# 验证: 图3 图3.png 图4 图4.png 总结:1、从服务器搭建完后需要重启服务,是可以从主服务器得到数据。 2、主服务器在更新后,需要变更版本号,同时建一个NS,这样才知道推送给谁。

二、搭建并实现智能DNS。

dns server : centos 8 172.16.0.152

客户端 centos 7 172.16.0.151 上海 客户端 Centos 6 172.16.0.31 北京

yum -y install bind;systemctl enable --now named

vim /etc/named.conf

acl beijingnet { 172.16.0.31/32; };

acl shanghainet { 172.16.0.151/32; };

acl othernet { any; };

删除include "/etc/named.rfc1912.zones";

view beijingview { match-clients { beijingnet;}; include "/etc/named.rfc1912.zones.bj"; }; view shanghaiview { match-clients { shanghainet;}; include "/etc/named.rfc1912.zones.sh"; }; view otherview { match-clients { othernet;}; include "/etc/named.rfc1912.zones.other"; }; include "/etc/named.root.key";

区域文件: [root@centos8 etc]# pwd /etc [root@centos8 etc]# ls named* named.conf named.rfc1912.zones.bj named.rfc1912.zones.sh named.rfc1912.zones named.rfc1912.zones.other named.root.key

named: [root@centos8 etc]#

cp named.rfc1912.zones named.rfc1912.zones.bj vim named.rfc1912.zones.bj zone "magedu.org" IN { type master; file "magedu.org.zone.bj"; };

cp named.rfc1912.zones.bj named.rfc1912.zones.sh

zone "magedu.org" IN { type master; file "magedu.org.zone.sh"; }; cp named.rfc1912.zones.bj named.rfc1912.zones.other zone "magedu.org" IN { type master; file "magedu.org.zone.other"; };

创建数据库: cd /var/named/ [root@centos8 named]# cat magedu.org.zone.bj $TTL 1D @ IN SOA ns1 admin ( 1 1D 1H 1W 2H ) NS ns1 ns1 A 172.16.0.152 自己的服务器 www A 172.16.0.31 北京来时访问这个网站

[root@centos8 named]#

[root@centos8 named]# cat magedu.org.zone.sh $TTL 1D @ IN SOA ns1 admin ( 1 1D 1H 1W 2H ) NS ns1 ns1 A 172.16.0.152 www A 172.16.0.151

[root@centos8 named]# cat magedu.org.zone.other $TTL 1D @ IN SOA ns1 admin ( 1 1D 1H 1W 2H ) NS ns1 ns1 A 172.16.0.152 www A 127.0.0.1

[root@centos8 named]#

修改权限:

[root@centos8 etc]# chgrp named /etc/named.rfc1912.* [root@centos8 etc]# systemctl restart named [root@centos8 etc]#

验证结果: 图1 图1.png 图2 图2.png 三、通过编译、二进制安装MySQL5.7多实例 环境:centos 7 上传如下包: mysql-5.7.29-linux-glibc2.12-x86_64.tar

1、安装包 yum -y install libaio numactl-libs

2、用户和组 groupadd mysql useradd -r -g mysql -s /bin/false mysql

3、准备程序文件

tar xf mysql-5.7.29-linux-glibc2.12-x86_64.tar.gz –C /usr/local cd /usr/local/ ln -s mysql-5.7.29-linux-glibc2.12-x86_64/ mysql chown -R root.root /usr/local/mysql/ 最后那个斜杠一下要加上,这里也踩过坑

4、准备环境变量

[root@centos7 bin]# echo 'PATH=/usr/local/mysql/bin:$PATH' > /etc/profile.d/mysql.sh [root@centos7 bin]# . /etc/profile.d/mysql.sh [root@centos7 bin]#

5、生成配置文件

cp /etc/my.cnf{,.bak} 先备份

[root@centos7 etc]# cat my.cnf [mysqld] datadir=/data/mysql skip_name_resolve=1 socket=/data/mysql/mysql.sock
log-error=/data/mysql/mysql.log pid-file=/data/mysql/mysql.pid [client] socket=/data/mysql/mysql.sock

This group is read both by the client and the server

use it for options that affect everything

include *.cnf from the config directory

[root@centos7 etc]#

6、 生成数据库文件,并提取root密码 (新开一个窗口) [root@centos7 ~]# mysqld --initialize --user=mysql --datadir=/data/mysql [root@centos7 ~]#

查看临时性口令:cat /data/mysql/mysql.log .e2i;He2y!wu

7、准备服务的脚本

[root@centos7 ~]# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld

[root@centos7 ~]# chkconfig --add mysqld [root@centos7 ~]#

启动服务 [root@centos7 ~]# systemctl start mysqld

[root@centos7 ~]# mysql -uroot -p'.e2i;He2y!wu' 此时能登陆,但是任何操作不能做

改密码 [root@centos7 ~]# mysqladmin -uroot -p'.e2i;He2y!wu' password magedu

多实例部分 root@centos7 ~]# cp /mysql/3306/bin/mysqld /mysql/3307/bin/mysqld [root@centos7 ~]# cp /mysql/3306/bin/mysqld /mysql/3308/bin/mysqld

复制后port=3306 要改 [root@centos7 ~]# /mysql/3306/bin/mysqld start Starting MySQL... [root@centos7 ~]# /mysql/3307/bin/mysqld start Starting MySQL... [root@centos7 ~]# /mysql/3308/bin/mysqld start Starting MySQL...

mysql用的是安全管理来改密码

四、整理MySQL数据类型

图5 图5.png

图6.png 图7.png

图8.png