setenforce 0
systemctl stop firewall
mkdir /mnt/cdrom
mount /dev/cdrom /mnt/cdrom/
cd /etc/yum.repos.d/
cp CentOS-Base.repo iso.repo
rm -rf C*
vim iso.repo
[iso]
name=iso
baseurl=file:///mnt/cdrom/ #挂载的目录
gpgcheck=1
enabled=1 #1表示启用源文件
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
#懒得背命令就复制原有的Yum源文件当作模板,注释前面所有文字修改后四行即可
yum clean all
1.在此服务器中安装配置DNS服务,负责区域chinaskills.net
内主机解析,六台主机分别为dns.chinaskills.net
、mail.chinaskills.net
、www1.chinaskills.net
、www2.chinaskills.net
、ssm.chinaskills.net
、ha.chinaskills.net
,做好正反向DNS服务解析
yum install -y bind
vim /etc/named.conf
options {
listen-on port 53 { any; }; #any监听所有端口
listen-on-v6 port 53 { ::1; };
directory "/var/named";
dump-file "/var/named/data/cache_dump.db";
statistics-file "/var/named/data/named_stats.txt";
memstatistics-file "/var/named/data/named_mem_stats.txt";
allow-query { any; }; #any允许所有人查询
vim /etc/named.rfc1912.zones
zone "chinaskills.net"IN{
type master;
file "chinaskills.net.zone";
};
zone "70.168.172.in-addr.arpa" IN{
type master;
file "172.168.70.arpa";
};
cp /var/named/named.localhost /var/named/chinaskills.net.zone
cp /var/named/named.loopback /var/named/172.168.70.arpa
#正向解析
chinaskills.net. rname.invalid. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
IN NS dns.chinaskills.net.
dns IN A 172.168.70.176
www1 IN A 172.168.70.177
www2 IN A 172.168.70.178
ssm IN A 172.168.70.179
mail IN A 172.168.70.180
ha IN A 172.168.70.169
#反向解析
$TTL 1D
@ IN SOA chinaskills.net rname.invalid. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
IN NS dns.chinaskills.net.
176 IN PTR dns.chinaskills.net.
177 IN PTR www1.chinaskills.net.
178 IN PTR www2.chinaskills.net.
179 IN PTR ssm.chinaskills.net.
180 IN PTR mail.chinaskills.net.
169 IN PTR ha.chinaskills.net.
检查主配置文件和区域解析文件错误
named-checkconf /etc/named.conf
named-checkzone chinaskills.net /var/named/chinaskills.net.zone
named-checkzone 172.168.70 /var/named/172.168.70.arpa
nslookup dns.chinaskills.net
nslookup 172.168.70.176
我们在用root用户复制完区域解析文件后,两个文件默认权限是root用户,无法解析文件,这时候我们需要更改文件夹权限
chown named:named /var/named
或者复制的时候使用cp -p
命令
创建三个用户user1, user2,user3。建立共享目录/opt/finance_share,要求共享名为archive,user1和user2用户可以通过虚拟用户admin1和admin2(用户名和密码相同)输入用户名和密码登录并上传文件
限制user3用户在共享目录中最多创建3个文件
yum install -y samba
useradd user1 useradd user2 useradd user3
mkdir /opt/finance_share
chmod 777 /opt/finance_share
vim /etc/samba/sambusers
user1=admin1 admin2
user2=admin1 admin2
vim /etc/samba/smb.conf
#在全局中添加虚拟用户登录
username map = /etc/samba/smbusers
[archice]
comment = samba
path = /opt/finance_share
browseable = yes
public = yes
writable = yes
valid users = user1,user2,user3
write list = user1,user2,user3
在此服务器中安装Apache服务,建立虚拟主机站点www1.chinaskills.net:
主页名字为 2019dcn.html,首页内容为“Welcome chinaskills website1” 。配置访问日志路径和名称为/var/log/httpd/www1.chinaskills.net-access_log,日志记录格式为普通型
yum install -y httpd
mkdir /www/8080
echo "Welcome chinaskills website1" > /www/8080/2019dcb.html
vim /etc/httpd/conf/httpd.conf
# 数字是行号
......
42 Listen 8080 #监听端口
......
86 ServerAdmin root@localhost #管理员邮箱地址
......
95 ServerName www1.chinaskills.net #网站服务器域名
......
119 DocumentRoot "/www/8080" #网站数据目录
......
124 <Directory "/www/8080"> #网站数据目录权限
125 AllowOverride None
126 # Allow open access:
127 Require all granted
128 </Directory>
......
163 <IfModule dir_module>
164 DirectoryIndex index.html 2019dcn.html #默认网站索引页面
165 </IfModule>
......
211 Customlog "/var/log/httpd/www1.chinaskills.net-access_log" common #访问日志路径 common为普通
.....
httpd -t
vim /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
172.168.70.177 `www1.chinaskills.net ip #网站指向你的网站
systemctl restart httpd
配置系统防火墙firewall,关闭除提供系统服务(80、443、25、22、110、53)以外的端口,在此服务器上实现网络时间服务Chrony的配置,使得172.20.30.0/24网络中的其它计算机通过此服务器进行网络校时
firewall-cmd --zone=public --add-port=80/tcp --permanent
firewall-cmd --zone=public --add-port=443/tcp --permanent
firewall-cmd --zone=public --add-port=25/tcp --permanent
firewall-cmd --zone=public --add-port=22/tcp --permanent
firewall-cmd --zone=public --add-port=110/tcp --permanent
firewall-cmd --zone=public --add-port=53/tcp --permanent
firewall-cmd --reload
firewall-cmd --zone=public --list-ports
yum install -y Chrony
vim /etc/chrony
27 allow 172.168.70.0/24
29 local stratum 10
其他云主机
vim /etc/chrony
server 172.168.70.177 iburst
在此服务器中安装Apache服务,建立虚拟主机站点www2.chinaskills.net
主页名字为 2019dcn.html,首页内容为Welcome chinaskills website2
配置访问日志路径和名称为/var/log/httpd/www2.chinaskills.net-access_log,日志记录格式为复合型
yum install -y httpd
mkdir /www/8080
echo "Welcome chinaskills website2" > /www/8080/2019dcb.html
vim /etc/httpd/conf/httpd.conf
# 数字是行号
......
42 Listen 8080 #监听端口
......
86 ServerAdmin root@localhost #管理员邮箱地址
......
95 ServerName www1.chinaskills.net #网站服务器域名
......
119 DocumentRoot "/www/8080" #网站数据目录
......
124 <Directory "/www/8080"> #网站数据目录权限
125 AllowOverride None
126 # Allow open access:
127 Require all granted
128 </Directory>
......
163 <IfModule dir_module>
164 DirectoryIndex index.html 2019dcn.html #默认网站索引页面
165 </IfModule>
......
211 Customlog "/var/log/httpd/www2.chinaskills.net-access_log" common #访问日志路径 common为普通
.....
httpd -t
vim /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
172.168.70.178 `www2.chinaskills.net ip #网站指向你的网站
systemctl restart httpd
将此服务器配置为数据库服务器,创建数据库为School,在库中创建表为Score,在表中创建2个用户,分别为(1,suser1,1999-6-1,female),(2,suser2,2000-9-1,male),口令与用户名相同,表结构如下
字段名 | 数据类型 | 主键 |
---|---|---|
ID | Int | 是 |
Name | varchar(20) | 否 |
Birthday | Datetime | 否 |
Sex | char(10) | 否 |
Password | char(64) | 否 |
yum install -y mariadb-server
mysql_secure_installation
Enter current password for root (enter for none): # 输入数据库超级管理员root的密码,没有直接回车
Set root password? [Y/n] # 设置密码,y
New password: 687145 # 新密码
Re-enter new password: 687145 # 再次输入密码
Remove anonymous users? [Y/n] y # 移除匿名用户
Disallow root login remotely? [Y/n] y # 拒绝root远程登录
Remove test database and access to it? [Y/n] y # 删除test数据库
Reload privilege tables now? [Y/n] y # 重新加载权限表
mysql -u root -p
Create database School;
use School;
mysql
MariaDB [School]> create table Score(
-> ID Int primary key, #primary key为主键
-> Name varchar(10),
-> Birthday Datetime,
-> Sex char(10),
-> Password char(64)
-> );
desc Score;
mysql
MariaDB [School]> insert into Score values(
1,
'suser1',
'1999-6-1',
'female',
'suser1'
);
mysql
MariaDB [School]> insert into Score values(
2,
'suser2',
'2000-9-1',
'male',
'suser2'
);
select * from Score;
vim /etc/my.cnf
slow_query_log=1
slow_query_log_file=ar/log/mariadb/mariadb.log