Linux--RH254---rh254exam
来源:互联网 发布:java标识符 编辑:程序博客网 时间:2024/06/09 20:28
静态配置ip如下:
server:
ip=172.25.x.11,gateway=172.25.x.254,dns1=172.25.254.254
desktop:
ip=172.25.x.10,gateway=172.25.x.254,dns1=172.25.254.254
desktop与server主机防火墙开启;
desktop与server主机selinux=enforcing;
desktop和server的yum源为http://172.25.254.254/rhel7.0/x86_64/dvd
确保以下操作在 desktop 和 server 主机重启后依然生效;
nm-connection-editor ##进入图形界面,设置网络
systemctl status firewalld ##查看防火墙状态
getenforce ##查看selinux状态
vim /etc/sysconfig/selinux ##selinux配置文件
reboot
vim /etc/yum.repos.d/rhel_dvd.repo
yum clean all
#1. server主机配置mariadb服务如下:
- 该服务阻断所有来自网络的tcp/ip连接,仅支持本地连接;
- 给数据库设置密码 fentiao ;
- 新建数据库 westosinfo ,该数据库中创建表 hostinfo ;
- hostinfo 表包含的字段为 ip 和 hostname ,表中插入3条记录(自己随便写);
- 创建用户 redhat 对 westosinfo 数据库的所有表只能查看不能修改;
yum reinstall mariadb-server -y
systemctl start mariadb
systemctl enable mariadb
vim /etc/my.cnf
skip-networking=1 ###阻断监听
systemctl restart mariadb
netstat -antlpe | grep mysql
mysql_secure_installation ##第一次安装mysql以后通过这条命令可以对mysql进行设置
Enter current password for root (enter for none) 按Enter
Set root password? [Y/n] y
New password: fentiao
Re-enter new password:
Remove anonymous users? [Y/n] y
Disallow root login remotely? [Y/n] y
Remove test database and access to it? [Y/n] y
Reload privilege tables now? [Y/n] y
mysql -uroot -p
Enter password:fentiao
MariaDB [(none)]> create database westosinfo;
MariaDB [(none)]> use westosinfo;
MariaDB [westosinfo]> create table hostinfo (
-> ip varchar(20) not null,
-> hostname varchar(50) not null);
MariaDB [westosinfo]> insert into hostinfo values('172.25.31.1','server1.example.com');
MariaDB [westosinfo]> insert into hostinfo values('172.25.31.2','server2.example.com');
MariaDB [westosinfo]> insert into hostinfo values('172.25.31.3','server3.example.com');
MariaDB [westosinfo]> select * from hostinfo;
MariaDB [westosinfo]> create user redhat@localhost identified by "redhat";
MariaDB [westosinfo]> grant select on westosinfo.* to redhat@localhost;
mysql -uredhat -predhat -h localhost
#2. 配置链路聚合:
- 在desktop与server主机配置一链路,此链路使用 eth1 和 eth2;
- 此链路在一个接口失效时仍能正常工作;
- 此链路 serverx 使用ipv6地址 x:ac18::10a/64;
- 此链路 desktopx 使用ipv6地址 x:ac18::11b/64;
- 此链路在系统重启之后仍然保持正常状态。
[root@server31 ~]# nmcli connection add con-name team0 ifname team0 type team config '{"runner":{"name":"activebackup"}}' ip6 31:ac18::10a/64
[root@server31 ~]# nmcli connection add con-name eth1 ifname eth1 type team-slave master team0
[root@server31 ~]# nmcli connection add con-name eth2 ifname eth2 type team-slave master team0
[root@server31 ~]# teamdctl team0 stat
setup:
runner: activebackup
ports:
eth1
link watches:
link summary: up
instance[link_watch_0]:
name: ethtool
link: up
eth2
link watches:
link summary: up
instance[link_watch_0]:
name: ethtool
link: up
runner:
active port: eth1
[root@desktop31 ~]# nmcli connection add con-name team0 ifname team0 type team config '{"runner":{"name":"activebackup"}}' ip6 31:ac18::11b/64
[root@desktop31 ~]# nmcli connection add con-name eth1 ifname eth1 type team-slave master team0
[root@desktop31 ~]# nmcli connection add con-name eth2 ifname eth2 type team-slave master team0
[root@desktop31 ~]# teamdctl team0 stat
setup:
runner: activebackup
ports:
eth2
link watches:
link summary: up
instance[link_watch_0]:
name: ethtool
link: up
eth1
link watches:
link summary: up
instance[link_watch_0]:
name: ethtool
link: up
runner:
active port: eth1
#3. server主机配置dns服务如下:
- server主机搭建的dns管理的域为"westos.org";
- 根据下面ip与域名的对应关系实现正向解析和反向解析:
desktop.westos.org 172.25.x.10
server.westos.org 172.25.x.11
desktop 主机可执行命令
dig serverx.westos.org @172.25.x.11 //根据域名解析到 对应的 ip
dig -x 172.25.0.11 @172.25.0.11 //根据 ip 反解析到对应的域名
yum install bind.x86_64 -y
vim /etc/named.conf
11 listen-on port 53 { any; };
17 allow-query { any; };
31 dnssec-enable no;
vim /etc/named.rfc1912.zones
zone "westos.org" IN {
type master;
file "westos.org.zone";
allow-update { none; };
};
zone "31.25.172.in-addr.arpa" IN {
type master;
file "westos.org.ptr";
allow-update { none; };
};
cd /var/named/
cp -p named.localhost westos.org.zone
vim westos.org.zone
$TTL 1D
@ IN SOA dns.westos.org. root.westos.org. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
NS dns.westos.org.
dns A 172.25.31.11
desktop31 A 172.25.31.10
server31 A 172.25.31.11
cp -p named.empty westos.org.ptr
vim westos.org.ptr
$TTL 3H
@ IN SOA dns.westos.org. root.westos.org. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
NS dns.westos.org.
dns.westos.org. A 172.25.31.11
10 PTR desktop31.westos.org.
11 PTR server31.westos.org.
firewall-cmd --add-service=dns --permanent --zone=public
firewall-cmd --reload
systemctl start named
systemctl enable named
desktop测试:
dig server31.westos.org @172.25.31.11 ##根据域名解析到对应的ip
dig -x 172.25.31.11 @172.25.31.11 ##根据ip反解析到对应的域名
#4. server主机配置web服务如下:
- 下载 http://172.25.254.254/materials/station.html 到 apache 默认发布目录并重命名为
index.html,
确保 http://serverx.example.com 可访问,日志位置在 logs/default- vhost.log ,日志格
式为 combined;
- 拓展web主机站点 http://wwwx.example.com 创建一虚拟主机,确保设定默认
发布目录为 /www/virtual ,访问内容为 "wwwx.example.com" ,日志存储在
logs/wwwX.example.com.log ,日志格式为 combined;
- 在默认发布目录下创建一个名为 admin 的目录,访问该目录的页面内容为
admin page ,实现apache基于用户认证功能的实现,只有admin用户可通过
密码 fentiao 登陆浏览页面内容;
- 实现动态 web 内容,动态内容下载地址为 http://172.25.254.254/materials/script.wsgi,
虚拟主机监听端口:8989,desktop 主机访问 http://wsgi.example.com:8989 可看动态网页。
yum install httpd -y
firewall-cmd --permanent --add-service=http
firewall-cmd --reload
systemctl start httpd
systemctl enable httpd
wget http://172.25.254.254/materials/station.html -O /var/www/html/index.html
mkdir /www/virtual -p
echo "www31.example.com" >/www/virtual/index.html
semanage fcontext -a -t 'httpd_sys_content_t' '/www/virtual(/.*)?'
restorecon -FvvR /www/virtual/
mkdir /var/www/html/admin
echo 'admin page' > /var/www/html/admin/index.html
htpasswd -cm /etc/httpd/accessuser admin
New password: fentiao
Re-type new password: fentiao
Adding password for user admin
vim /etc/httpd/conf.d/default.conf
<Virtualhost _default_:80>
DocumentRoot "/var/www/html"
ServerName "server31.example.com"
CustomLog "logs/default-vhost.log" combined
</Virtualhost>
vim /etc/httpd/conf.d/www.conf
<Virtualhost *:80>
DocumentRoot "/www/virtual"
ServerName "www31.example.com"
CustomLog "logs/www31.example.com.log" combined
</Virtualhost>
<Directory "/www/virtual">
Require all granted
</Directory>
vim /etc/httpd/conf/httpd.conf
124 <Directory "/var/www/html/admin">
125 AuthUserFile /etc/httpd/accessuser
126 AuthName "please input your name and password!!"
127 AuthType basic
128 Require user admin
129 </Directory>
yum install mod_wsgi.x86_64 -y
cd /var/www/cgi-bin
wget http://172.25.254.254/materials/script.wsgi
vim /etc/httpd/conf.d/www.conf
<Virtualhost *:8989>
WSGIScriptAlias / /var/www/cgi-bin/script.wsgi
ServerName wsgi.example.com
</Virtualhost>
Listen 8989
systemctl restart httpd
在desktop中添加解析
vim /etc/hosts
172.25.31.11 www31.example.com server31.example.com wsgi.example.com
访问server31.example.com时,访问结果的内容是http://172.25.254.254/materials/station.html下的内容
访问www31.example.com时,访问结果的内容是/www/virtual/index.html下的内容
当访问172.25.31.11/admin时,需填写用户认证信息,访问结果的内容是/var/www/html/admin/index.html下的内容
#5. server主机配置 iSCSI 服务:
- 在 vdb 磁盘上分一个 2G 大小的 LVM 分区,用以创建逻辑卷组
iSCSI_vg 和一个 1G 大小的逻辑卷 disk1_lv;
- 使用 disk1_lv 作为 iSCSI 的后端存储名称为 serverX.disk1;
- 定义 IQN 为 iqn.2017-06.com.example:serverX;
- 设置 ACL 允许 initiator name 为 iqn.2017-06.com.example:desktopX
的客户端可以连接。程序监听172.25.X.11 的 3260 端口;
desktopX 安装客户端程序,连接 serverX 的 iSCSI 目标资源到本地,用以创建一个
xfs 文件系统,并开机自动挂载到 /iscsidisk.
拓展:扩展共享的设备到1.5G
yum install targetcli -y
systemctl start target
systemctl enable target
firewall-cmd --permanent --add-port=3260/tcp
fdisk /dev/vdb (t:8e)
partprobe
pvcreate /dev/vdb1
vgcreate iSCSI_vg /dev/vdb1
lvcreate -L 1G -n disk1_lv iSCSI_vg
targetcli
/backstores/block create server31.disk1 /dev/iSCSI_vg/disk1_lv
/iscsi create iqn.2017-06.com.example:server31
/iscsi/iqn.2017-06.com.example:server31/tpg1/luns create /backstores/block/server31.disk1
/iscsi/iqn.2017-06.com.example:server31/tpg1/portals create 172.25.31.11
/iscsi/iqn.2017-06.com.example:server31/tpg1/acls create iqn.2017-06.com.example:desktop31
exit
在desktop上
vim /etc/iscsi/initiatorname.iscsi
InitiatorName=iqn.2017-06.com.example:desktop31
systemctl restart iscsi
iscsiadm -m discovery -t st -p 172.25.31.11
iscsiadm -m node -T iqn.2017-06.com.example:strage1 -p 172.25.31.11 -l
fdisk /dev/sda
n--wq
partprobe
mkfs.xfs /dev/sda1
mount /dev/sda1 /mnt/
yum install tree -y
tree -C /var/lib/iscsi/
blkid
/dev/sda1: UUID="24875c42-c94c-4f52-8ac9-452df9417264" TYPE="xfs"
vim /etc/fstab ##开机自挂起(_netdev作为挂载选项,启用联网)
UUID="24875c42-c94c-4f52-8ac9-452df9417264" /iscsidisk xfs defaults,_netdev 0 0
#6. 配 SMB 服务:
- 创建共享目录为 /smbshare ,共享名为 smbshare ,工作组为WESTOS ,
marketing 组成员可以读写此共享,不属于marketing 组的人只能读。
- 创建 samba-only 用户 brian 和 rob ,其中 brian 用户属于
marketing 组,用户密码都是 westos 。
- 在 desktopX 上建立挂载点 /mnt/multiuser 目录,开机自动挂载
serverX 上的 smbshare 共享,激活 smb 多用户挂载支持。
server端:
yum install samba samba-common samba-client -y
firewall-cmd --permanent --add-service=samba
firewall-cmd --permanent --add-service=samba-client
systemctl start smb nmb ##开启服务
systemctl enable smb nmb ##自启动
mkdir /smbshare ##建立目录
vim /etc/samba/smb.conf
[westos]
comment = local directory
path = /smbshare
workgroup = WESTOS
writable = no
write list = +marketing
systemctl restart smb.service ##重启服务
semanage fcontext -a -t samba_share_t '/smbshare(/.*)?' ##安全上下文
restorecon -RvvF /smbshare ##刷新
setsebool -P samba_export_all_rw on ##读写共享
useradd -s /sbin/nologin brian
useradd -s /sbin/nologin rob
semanage fcontext -a -t samba_share_t '/smbshare(/.*)?'
restorecon -RvvF /smbshare
groupadd marketing
usermod -G marketing brian
smbpasswd -a brian
smbpasswd -a rob
setsebool -P samba_enable_home_dirs on
desktop端:
mkdir /mnt/multiuser
vim /etc/fstab
/172.25.31.11/westos /mnt/multiuser cifs defaults,credentials=/root/smbuser 0 0
#7. 配置nfs服务:
- serverx主机共享本地目录/nfsshare;
- desktopX 可以读写访问此共享,并且开机自动挂载到 /mnt/nfsshare 目录上。
server端:
yum install nfs-utils -y
systemctl start nfs-server
systemctl enable nfs-server
firewall-cmd --permanent --add-service=nfs
firewall-cmd --permanent --add-service=rpc-bind
firewall-cmd --permanent --add-service=mountd
firewall-cmd --reload
mkdir /nfsshare
chmod 777 /nfsshare/
vim /etc/exports
/nfsshare 172.25.31.10(rw,sync)
exportfs -rv
desktop端:
mkdir /mnt/nfsshare
vim /etc/fstab
172.25.31.11:/nfsshare /mnt/nfsshare nfs defaults 0 0
#8. 在 serverX 和 desktopX 配置 postfix 服务:
- 设置服务开机自启,防护墙允许此服务。
- 将 serverX 配置为邮件空客户端,只监听本地回环接口,只允
许 127.0.0.0/8 这个网段转发邮件,从 serverX 上发出的邮件域
名都被重写为 desktopX.example.com ,所有邮件都被转发到
smtpX.example.com 主机( DNS 上已有 MX 记录,指向desktopX ),
本地不存储邮件。
- desktopX 可以接收来自 serverX 的邮件。
yum install bind -y
systemctl start named
systemctl enable named
firewall-cmd --permanent --add-service=smtp
server端:
vim /etc/postfix/main.cf
76 myhostname = server31.example.com
83 mydomain = example.com
99 myorigin = desktop31.example.com
116 inet_interfaces = localhost
164 mydestination = $myhostname, $mydomain, localhost
264 mynetworks = 127.0.0.0/8
316 relayhost = 172.25.31.10
systemctl restart postfix.service
desktop端:
vim /etc/postfix/main.cf
76 myhostname = desktop31.example.com
83 mydomain = example.com
99 myorigin = desktop31.example.com
116 inet_interfaces = all
164 mydestination = $myhostname, $mydomain, localhost
systemctl restart postfix.service
server:
ip=172.25.x.11,gateway=172.25.x.254,dns1=172.25.254.254
desktop:
ip=172.25.x.10,gateway=172.25.x.254,dns1=172.25.254.254
desktop与server主机防火墙开启;
desktop与server主机selinux=enforcing;
desktop和server的yum源为http://172.25.254.254/rhel7.0/x86_64/dvd
确保以下操作在 desktop 和 server 主机重启后依然生效;
nm-connection-editor ##进入图形界面,设置网络
systemctl status firewalld ##查看防火墙状态
getenforce ##查看selinux状态
vim /etc/sysconfig/selinux ##selinux配置文件
reboot
vim /etc/yum.repos.d/rhel_dvd.repo
yum clean all
#1. server主机配置mariadb服务如下:
- 该服务阻断所有来自网络的tcp/ip连接,仅支持本地连接;
- 给数据库设置密码 fentiao ;
- 新建数据库 westosinfo ,该数据库中创建表 hostinfo ;
- hostinfo 表包含的字段为 ip 和 hostname ,表中插入3条记录(自己随便写);
- 创建用户 redhat 对 westosinfo 数据库的所有表只能查看不能修改;
- redhat 用户的认证密码为 redhat
yum reinstall mariadb-server -y
systemctl start mariadb
systemctl enable mariadb
vim /etc/my.cnf
skip-networking=1 ###阻断监听
systemctl restart mariadb
netstat -antlpe | grep mysql
mysql_secure_installation ##第一次安装mysql以后通过这条命令可以对mysql进行设置
Enter current password for root (enter for none) 按Enter
Set root password? [Y/n] y
New password: fentiao
Re-enter new password:
Remove anonymous users? [Y/n] y
Disallow root login remotely? [Y/n] y
Remove test database and access to it? [Y/n] y
Reload privilege tables now? [Y/n] y
mysql -uroot -p
Enter password:fentiao
MariaDB [(none)]> create database westosinfo;
MariaDB [(none)]> use westosinfo;
MariaDB [westosinfo]> create table hostinfo (
-> ip varchar(20) not null,
-> hostname varchar(50) not null);
MariaDB [westosinfo]> insert into hostinfo values('172.25.31.1','server1.example.com');
MariaDB [westosinfo]> insert into hostinfo values('172.25.31.2','server2.example.com');
MariaDB [westosinfo]> insert into hostinfo values('172.25.31.3','server3.example.com');
MariaDB [westosinfo]> select * from hostinfo;
MariaDB [westosinfo]> create user redhat@localhost identified by "redhat";
MariaDB [westosinfo]> grant select on westosinfo.* to redhat@localhost;
mysql -uredhat -predhat -h localhost
#2. 配置链路聚合:
- 在desktop与server主机配置一链路,此链路使用 eth1 和 eth2;
- 此链路在一个接口失效时仍能正常工作;
- 此链路 serverx 使用ipv6地址 x:ac18::10a/64;
- 此链路 desktopx 使用ipv6地址 x:ac18::11b/64;
- 此链路在系统重启之后仍然保持正常状态。
[root@server31 ~]# nmcli connection add con-name team0 ifname team0 type team config '{"runner":{"name":"activebackup"}}' ip6 31:ac18::10a/64
[root@server31 ~]# nmcli connection add con-name eth1 ifname eth1 type team-slave master team0
[root@server31 ~]# nmcli connection add con-name eth2 ifname eth2 type team-slave master team0
[root@server31 ~]# teamdctl team0 stat
setup:
runner: activebackup
ports:
eth1
link watches:
link summary: up
instance[link_watch_0]:
name: ethtool
link: up
eth2
link watches:
link summary: up
instance[link_watch_0]:
name: ethtool
link: up
runner:
active port: eth1
[root@desktop31 ~]# nmcli connection add con-name team0 ifname team0 type team config '{"runner":{"name":"activebackup"}}' ip6 31:ac18::11b/64
[root@desktop31 ~]# nmcli connection add con-name eth1 ifname eth1 type team-slave master team0
[root@desktop31 ~]# nmcli connection add con-name eth2 ifname eth2 type team-slave master team0
[root@desktop31 ~]# teamdctl team0 stat
setup:
runner: activebackup
ports:
eth2
link watches:
link summary: up
instance[link_watch_0]:
name: ethtool
link: up
eth1
link watches:
link summary: up
instance[link_watch_0]:
name: ethtool
link: up
runner:
active port: eth1
#3. server主机配置dns服务如下:
- server主机搭建的dns管理的域为"westos.org";
- 根据下面ip与域名的对应关系实现正向解析和反向解析:
desktop.westos.org 172.25.x.10
server.westos.org 172.25.x.11
desktop 主机可执行命令
dig serverx.westos.org @172.25.x.11 //根据域名解析到 对应的 ip
dig -x 172.25.0.11 @172.25.0.11 //根据 ip 反解析到对应的域名
yum install bind.x86_64 -y
vim /etc/named.conf
11 listen-on port 53 { any; };
17 allow-query { any; };
31 dnssec-enable no;
vim /etc/named.rfc1912.zones
zone "westos.org" IN {
type master;
file "westos.org.zone";
allow-update { none; };
};
zone "31.25.172.in-addr.arpa" IN {
type master;
file "westos.org.ptr";
allow-update { none; };
};
cd /var/named/
cp -p named.localhost westos.org.zone
vim westos.org.zone
$TTL 1D
@ IN SOA dns.westos.org. root.westos.org. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
NS dns.westos.org.
dns A 172.25.31.11
desktop31 A 172.25.31.10
server31 A 172.25.31.11
cp -p named.empty westos.org.ptr
vim westos.org.ptr
$TTL 3H
@ IN SOA dns.westos.org. root.westos.org. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
NS dns.westos.org.
dns.westos.org. A 172.25.31.11
10 PTR desktop31.westos.org.
11 PTR server31.westos.org.
firewall-cmd --add-service=dns --permanent --zone=public
firewall-cmd --reload
systemctl start named
systemctl enable named
desktop测试:
dig server31.westos.org @172.25.31.11 ##根据域名解析到对应的ip
dig -x 172.25.31.11 @172.25.31.11 ##根据ip反解析到对应的域名
#4. server主机配置web服务如下:
- 下载 http://172.25.254.254/materials/station.html 到 apache 默认发布目录并重命名为
index.html,
确保 http://serverx.example.com 可访问,日志位置在 logs/default- vhost.log ,日志格
式为 combined;
- 拓展web主机站点 http://wwwx.example.com 创建一虚拟主机,确保设定默认
发布目录为 /www/virtual ,访问内容为 "wwwx.example.com" ,日志存储在
logs/wwwX.example.com.log ,日志格式为 combined;
- 在默认发布目录下创建一个名为 admin 的目录,访问该目录的页面内容为
admin page ,实现apache基于用户认证功能的实现,只有admin用户可通过
密码 fentiao 登陆浏览页面内容;
- 实现动态 web 内容,动态内容下载地址为 http://172.25.254.254/materials/script.wsgi,
虚拟主机监听端口:8989,desktop 主机访问 http://wsgi.example.com:8989 可看动态网页。
yum install httpd -y
firewall-cmd --permanent --add-service=http
firewall-cmd --reload
systemctl start httpd
systemctl enable httpd
wget http://172.25.254.254/materials/station.html -O /var/www/html/index.html
mkdir /www/virtual -p
echo "www31.example.com" >/www/virtual/index.html
semanage fcontext -a -t 'httpd_sys_content_t' '/www/virtual(/.*)?'
restorecon -FvvR /www/virtual/
mkdir /var/www/html/admin
echo 'admin page' > /var/www/html/admin/index.html
htpasswd -cm /etc/httpd/accessuser admin
New password: fentiao
Re-type new password: fentiao
Adding password for user admin
vim /etc/httpd/conf.d/default.conf
<Virtualhost _default_:80>
DocumentRoot "/var/www/html"
ServerName "server31.example.com"
CustomLog "logs/default-vhost.log" combined
</Virtualhost>
vim /etc/httpd/conf.d/www.conf
<Virtualhost *:80>
DocumentRoot "/www/virtual"
ServerName "www31.example.com"
CustomLog "logs/www31.example.com.log" combined
</Virtualhost>
<Directory "/www/virtual">
Require all granted
</Directory>
vim /etc/httpd/conf/httpd.conf
124 <Directory "/var/www/html/admin">
125 AuthUserFile /etc/httpd/accessuser
126 AuthName "please input your name and password!!"
127 AuthType basic
128 Require user admin
129 </Directory>
yum install mod_wsgi.x86_64 -y
cd /var/www/cgi-bin
wget http://172.25.254.254/materials/script.wsgi
vim /etc/httpd/conf.d/www.conf
<Virtualhost *:8989>
WSGIScriptAlias / /var/www/cgi-bin/script.wsgi
ServerName wsgi.example.com
</Virtualhost>
Listen 8989
systemctl restart httpd
在desktop中添加解析
vim /etc/hosts
172.25.31.11 www31.example.com server31.example.com wsgi.example.com
访问server31.example.com时,访问结果的内容是http://172.25.254.254/materials/station.html下的内容
访问www31.example.com时,访问结果的内容是/www/virtual/index.html下的内容
当访问172.25.31.11/admin时,需填写用户认证信息,访问结果的内容是/var/www/html/admin/index.html下的内容
#5. server主机配置 iSCSI 服务:
- 在 vdb 磁盘上分一个 2G 大小的 LVM 分区,用以创建逻辑卷组
iSCSI_vg 和一个 1G 大小的逻辑卷 disk1_lv;
- 使用 disk1_lv 作为 iSCSI 的后端存储名称为 serverX.disk1;
- 定义 IQN 为 iqn.2017-06.com.example:serverX;
- 设置 ACL 允许 initiator name 为 iqn.2017-06.com.example:desktopX
的客户端可以连接。程序监听172.25.X.11 的 3260 端口;
desktopX 安装客户端程序,连接 serverX 的 iSCSI 目标资源到本地,用以创建一个
xfs 文件系统,并开机自动挂载到 /iscsidisk.
拓展:扩展共享的设备到1.5G
yum install targetcli -y
systemctl start target
systemctl enable target
firewall-cmd --permanent --add-port=3260/tcp
fdisk /dev/vdb (t:8e)
partprobe
pvcreate /dev/vdb1
vgcreate iSCSI_vg /dev/vdb1
lvcreate -L 1G -n disk1_lv iSCSI_vg
targetcli
/backstores/block create server31.disk1 /dev/iSCSI_vg/disk1_lv
/iscsi create iqn.2017-06.com.example:server31
/iscsi/iqn.2017-06.com.example:server31/tpg1/luns create /backstores/block/server31.disk1
/iscsi/iqn.2017-06.com.example:server31/tpg1/portals create 172.25.31.11
/iscsi/iqn.2017-06.com.example:server31/tpg1/acls create iqn.2017-06.com.example:desktop31
exit
在desktop上
vim /etc/iscsi/initiatorname.iscsi
InitiatorName=iqn.2017-06.com.example:desktop31
systemctl restart iscsi
iscsiadm -m discovery -t st -p 172.25.31.11
iscsiadm -m node -T iqn.2017-06.com.example:strage1 -p 172.25.31.11 -l
fdisk /dev/sda
n--wq
partprobe
mkfs.xfs /dev/sda1
mount /dev/sda1 /mnt/
yum install tree -y
tree -C /var/lib/iscsi/
blkid
/dev/sda1: UUID="24875c42-c94c-4f52-8ac9-452df9417264" TYPE="xfs"
vim /etc/fstab ##开机自挂起(_netdev作为挂载选项,启用联网)
UUID="24875c42-c94c-4f52-8ac9-452df9417264" /iscsidisk xfs defaults,_netdev 0 0
#6. 配 SMB 服务:
- 创建共享目录为 /smbshare ,共享名为 smbshare ,工作组为WESTOS ,
marketing 组成员可以读写此共享,不属于marketing 组的人只能读。
- 创建 samba-only 用户 brian 和 rob ,其中 brian 用户属于
marketing 组,用户密码都是 westos 。
- 在 desktopX 上建立挂载点 /mnt/multiuser 目录,开机自动挂载
serverX 上的 smbshare 共享,激活 smb 多用户挂载支持。
server端:
yum install samba samba-common samba-client -y
firewall-cmd --permanent --add-service=samba
firewall-cmd --permanent --add-service=samba-client
systemctl start smb nmb ##开启服务
systemctl enable smb nmb ##自启动
mkdir /smbshare ##建立目录
vim /etc/samba/smb.conf
[westos]
comment = local directory
path = /smbshare
workgroup = WESTOS
writable = no
write list = +marketing
systemctl restart smb.service ##重启服务
semanage fcontext -a -t samba_share_t '/smbshare(/.*)?' ##安全上下文
restorecon -RvvF /smbshare ##刷新
setsebool -P samba_export_all_rw on ##读写共享
useradd -s /sbin/nologin brian
useradd -s /sbin/nologin rob
semanage fcontext -a -t samba_share_t '/smbshare(/.*)?'
restorecon -RvvF /smbshare
groupadd marketing
usermod -G marketing brian
smbpasswd -a brian
smbpasswd -a rob
setsebool -P samba_enable_home_dirs on
desktop端:
mkdir /mnt/multiuser
vim /etc/fstab
/172.25.31.11/westos /mnt/multiuser cifs defaults,credentials=/root/smbuser 0 0
#7. 配置nfs服务:
- serverx主机共享本地目录/nfsshare;
- desktopX 可以读写访问此共享,并且开机自动挂载到 /mnt/nfsshare 目录上。
server端:
yum install nfs-utils -y
systemctl start nfs-server
systemctl enable nfs-server
firewall-cmd --permanent --add-service=nfs
firewall-cmd --permanent --add-service=rpc-bind
firewall-cmd --permanent --add-service=mountd
firewall-cmd --reload
mkdir /nfsshare
chmod 777 /nfsshare/
vim /etc/exports
/nfsshare 172.25.31.10(rw,sync)
exportfs -rv
desktop端:
mkdir /mnt/nfsshare
vim /etc/fstab
172.25.31.11:/nfsshare /mnt/nfsshare nfs defaults 0 0
#8. 在 serverX 和 desktopX 配置 postfix 服务:
- 设置服务开机自启,防护墙允许此服务。
- 将 serverX 配置为邮件空客户端,只监听本地回环接口,只允
许 127.0.0.0/8 这个网段转发邮件,从 serverX 上发出的邮件域
名都被重写为 desktopX.example.com ,所有邮件都被转发到
smtpX.example.com 主机( DNS 上已有 MX 记录,指向desktopX ),
本地不存储邮件。
- desktopX 可以接收来自 serverX 的邮件。
yum install bind -y
systemctl start named
systemctl enable named
firewall-cmd --permanent --add-service=smtp
server端:
vim /etc/postfix/main.cf
76 myhostname = server31.example.com
83 mydomain = example.com
99 myorigin = desktop31.example.com
116 inet_interfaces = localhost
164 mydestination = $myhostname, $mydomain, localhost
264 mynetworks = 127.0.0.0/8
316 relayhost = 172.25.31.10
systemctl restart postfix.service
desktop端:
vim /etc/postfix/main.cf
76 myhostname = desktop31.example.com
83 mydomain = example.com
99 myorigin = desktop31.example.com
116 inet_interfaces = all
164 mydestination = $myhostname, $mydomain, localhost
systemctl restart postfix.service
阅读全文
0 0
- Linux--RH254---rh254exam
- Linux--RH254---unit4 postfix2
- Linux--RH254---PXE
- Linux--RH254---脚本作业
- Linux--RH254---unit4 postfix电子邮件
- Linux--RH254---unit 10 iptables
- Linux--RH254---unit 10 firewalld
- Linux--RH254---unit 7 Samba
- Linux---RH254---unit 6 NFS
- Linux--RH254---unit 5 ISCSI
- Linux--RH254---uint 11 Bash
- Linux--RH254---unit 3 高速缓存DNS
- Linux--RH254---unit 8 mariadb数据库
- Linux--RH254---unit 2 高级网络配置
- Linux--RH254---unit 9 apache web服务
- Linux--RH254---unit 11 bash 2
- Linux--RH254---unit 1 ipv6网络的管理
- rh254复习题
- Java设计模式之创建型模式--建造者模式
- vuejs第二天1
- spring的面试题库
- Android最快捷集成Sharesdk短信验证码功能(干货)
- C语言二维字符数组的运用—模拟对话
- Linux--RH254---rh254exam
- if语句、三元运算 、switch
- 回文算法挑战
- qt QTableWidget&&QTableView 导出数据到excel
- go 守护进程部署
- Maven配置阿里云镜像
- PHP Composer 依赖管理器
- AlphaGo围棋论文中文翻译
- Golang开发入门(Linux)