您的位置:首页 > 其它

考试总结

2017-06-15 11:39 363 查看
#1. server 主机配置 mariadb 服务如下:
- 该服务阻断所有来自网络的 tcp/ip 连接,仅支持本地连接;
- 给数据库设置密码 fentiao ;
- 新建数据库 westosinfo ,该数据库中创建表 hostinfo ;
- hostinfo 表包含的字段为 ip 和 hostname ,表中插入 3 条记录(自己随便写);
- 创建用户 redhat 对 westosinfo 数据库的所有表只能查看不能修改;
- redhat 用户的认证密码为 redhat
server:
8 yum install mariadb-server -y
9 systemctl start mariadb
10 vim /etc/my.cnf
11 systemctl start mariadb
12 mysql_secure_installation
(1)Enter current password for root (enter for none):[Enter]
(2)Set root password? [Y/n] Y ####给数据库设置密码 fentiao
New password: ###输入新密码
Re-enter new password: ###确认密码
(3)Remove anonymous users? [Y/n] Y
(4)Disallow root login remotely? [Y/n] Y
(5)Remove test database and access to it? [Y/n] Y
(6)Reload privilege tables now? [Y/n] Y
13 mysql -uroot -p
MariaDB [(none)]> create database westosinfo; 新建数据库 westosinfo
Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| westosinfo |
+--------------------+
4 rows in set (0.00 sec)

MariaDB [(none)]> use westosinfo;
MariaDB [westosinfo]> create table hostinfo(
-> ip varchar(15) not null,
-> hostname varchar(15) not null );
Query OK, 0 rows affected (0.06 sec) 数据库中创建表 hostinfo

- hostinfo 表包含的字段为 ip 和 hostname ,表中插入 3 条记录(自己随便写)
MariaDB [westosinfo]> insert into hostinfo values ('172.25.254.244','server');
Query OK, 1 row affected (0.06 sec)

MariaDB [westosinfo]> insert into hostinfo values ('172.25.254.144','desktop');
Query OK, 1 row affected (0.03 sec)

MariaDB [westosinfo]> insert into hostinfo values ('172.25.254.44','localhost');
Query OK, 1 row affected (0.36 sec)

MariaDB [westosinfo]> select * from hostinfo
-> ;
+----------------+-----------+
| ip | hostname |
+----------------+-----------+
| 172.25.254.244 | server |
| 172.25.254.144 | desktop |
| 172.25.254.44 | localhost |
+----------------+-----------+
创建用户 redhat 对 westosinfo 数据库的所有表只能查看不能修改;
- redhat 用户的认证密码为 redhat
MariaDB [(none)]> create user redhat@localhost identified by ' redhat';
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> grant select on westosinfo.hostinfo to redhat@localhost;
-> ;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> select User,Host from mysql.user;
+--------+--------------+
| User | Host |
+--------+--------------+
| redhat | % |
| root | 127.0.0.1 |
| root | ::1 |
| redhat | localhost |
| root | localhost |
| redhat | localhost; |
+--------+--------------+
14 useradd redhat
15 mysql -uredhat -predhat

#2. 配置链路聚合:
- 在 desktop 与 server 主机配置一链路,此链路使用 eth1 和 eth2;
- 此链路在一个接口失效时仍能正常工作;
- 此链路 serverx 使用 ipv6 地址 2014:ac18::10a/64;
- 此链路 desktopx 使用 ipv6 地址 2014:ac18::11b/64;
- 此链路在系统重启之后仍然保持正常状态;
server:
nmcli connection add con-name team0 ifname team0 type team config '{"runner":{"name":"activebackup"}}' ip6 X:ac18::10a/64
####添加team 运行模式为主备
nmcli connection add con-name eth2 ifname eth2type team-slave master team0 ####给team添加网卡eth0
nmcli connection add con-name eth1 ifname eth1 type team-slave master team0 ###给team添加网卡eth1

做之前必须要有两块及以上网卡。重置虚拟机.用命令nm-connection-editor删除eth0原有IP。

desktop:
nmcli connection add con-name team0 ifname team0 type team config '{"runner":{"name":"activebackup"}}' ip6 X:ac18::11b/64;
####添加team 运行模式为主备
nmcli connection add con-name eth2 ifname eth2type team-slave master team0 ####给team添加网卡eth0
nmcli connection add con-name eth1 ifname eth1 type team-slave master team0 ###给team添加网卡eth1

3. server 主机配置 dns 服务如下:
- server 主机搭建的 dns 管理的域为"westos.org";
- 根据下面 ip 与域名的对应关系实现正向解析和反向解析:
desktopx.westos.org 172.25.x.10
serverx.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 反解析到对应的域名
[root@dns-server ~]# yum install bind.x86_64 -y
[root@dns-server ~]# systemctl stop firewalld ###关闭火墙
[root@dns-server ~]# systemctl start named ###开启服务
[root@dns-server ~]# vim /etc/named.conf #编辑配置文件options { ##全局设定 listen-on port 53 { any; }; ##监听本地53端口 listen-on-v6 port 53 { ::1; }; ##关闭ipv6选项 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; }; ##允许与本地直连的网络使用[root@dns-server ~]# systemctl start named ###开启服务正向:[root@dns-server ~]# cd /var/named[root@dns-server named]# pwd/var/named[root@dns-server named]# lsdata named.ca named.localhost slavesdynamic named.empty named.loopback[root@dns-server named]# cp -p named.localhost westos.com.zone##用模板生成用模板生成dns配置配置文件[root@dns-server named]# vim westos.com.zone



[root@dns-server named]# vim /etc/named.rfc1912.zones
zone "westos.com" IN { #指定要维护的域名 type master; file "westos.com.zone"; ##指定A记录文件名 allow-update { none; }; ##没有允许更新用户};
[root@dns-server named]# systemctl restart named ###重启服务客户端 3 vim /etc/resolv.conf #编辑配置文件 4 dig dns.westos.com ##查询 5 dig www.westos.com



二 反向解析服务器 58 vim /etc/named.rfc1912.zones 48 zone "254.25.172.in-addr.arpa" IN { 49 type master; 50 file "westos.com.ptr"; 51 allow-update { none; }; 52 }; 59 cp -p named.loopback westos.com.ptr 60 vim westos.com.ptr $TTL 1D @ IN SOA dns.westos.com. root.westos.com. ( 0 ; serial 1D ; refresh 1H ; retry 1W ; expire 3H ) ; minimum NS dns.westos.com. dns A 172.25.254.244 111 PTR www.westos.com 61 systemctl restart namedyum install bind -y
vim /etc/namd.conf
cd /var/named
cp -p named.localhost westos.org.zone
vim westos.org.zone
N 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.18.10
desktop18 A 172.25.18.10
server18 A 172.25.18.11
vim /etc/named.rfc1912.zones
zone "westos.org" IN {
type master;
file "westos.org.zone";
allow-update { none;};
};
cp -p named.loopback westos.org.ptr
vim westos.org.ptr
$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.18.10
10 PTR desktop18.westos.org
11 PTR server18.westos.org
vim /etc/named.rfc1912.zones
zone "18.25.172.in-addr.arpa" IN {
type master;
file "westos.org.ptr";
allow-update { none;};
};
systemctl restart named
firewall-cmd --permanent --add-service=dns
firewall-cmd --reload
测试端
vim /etc/resolv.conf
nameserver 172.25.18.10
dig server18.westos.org @172.25.18.10
dig -x 172.25.18.11 @172.25.18.10#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 创建一虚拟主机,确保设定默认
发布目录为 /var/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 lftp -y
systemctl start httpd
systemctl enable httpd
weget http://172.25.254.254/materials/station.html mv station.html /var/www/html/index.html

vim /etc/httpd/conf.d/vhost.conf
<Virtualhost _default_:80>
DocumentRoot "/var/www/html"
ServerName server18.example.com
Cusomlog "logs/default-vhost.log" combinded
</Virtualhost>

<Virtualhost *:80>
ServerName "www18.example.com"
DocumentRoot "/var/virtual"
Customlog "logs/www18.example.com.log" combined
</Virtualhost>
<Directory "/var/virtual">
Require all granted
</Directory>

<Directory "/var/www/html/admin">
AuthUserfile "/etc/httpd/passwd"
AuthName "show passwd add username
AuthType basic
Require user admin
</Directory>

<VirtualHost *:8989>
WSGIScriptAlias / /var/www/cgi-bin/script.wsgi
ServerName wsgi.example.com
</VirtualHost>
Listen 8989

mkdir /var/virtual
semanage fcontext -a -t httpd_sys_content_t '/var/virtual(/.*)?'
restorecon RvvF /var/virtual
echo www18.example.com > /var/virtual/index.html
mkdir /var/www/html/admin
echo 'admin page' > /var/www/html/admin/index.conf
htpasswd -cm /etc/httpd/passwd admin

yum install mod_wsgi.x86_64 -y
cd /var/www/cgi-bin
wget http://172.25.254.254/materials/scripts.wsgi systemctl restart httpd
测试机 vim /etc/hosts
172.25.18.11 server18.example.com www18.example.com wsgi.example.com
进行访问测试
#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
(1)建立一个lvm设备: fdisk 用于创建与 LVM 结合使用的新分区。在要与LVM 结合使用的分区上 , 始终将
“ 类型 ” 设置为 “ 0x8e LinuxLVM”
pvcreate /dev/vdb1 ##把物理分区做成物理卷
pvs|pvdisplay ##查看物理卷
vgcreate vg0 /dev/vdb1 ##用制作好的/dev/vdb1这个物理卷制作一个物理卷组vg0
vgs|vgdisplay ##查看物理卷组
lvcreate -L 200M -n lv0 vg0 ##在vg0这个组中建立出lv0设备 -L 指定设备大小 -n 指定设备名字
lvs|lvdisplay ##对逻辑卷设备进行查看 1 fdisk /dev/vdb 2 partprobe 3 pvcreate /dev/vdb1 4 vgcreate vg0 /dev/vdb1 5 vgdisplay 6 lvctreate -l 255 -n iscsi_storage vg0 7 lvcreate -l 255 -n iscsi_storage vg0 8 lvs截图:







(2)iSCSI目标配置
安装iSCSI目标软件包:# yum install -y targetcli
启动服务:# systemctl enable target;# systemctl start target
进入iSCSI目标交互式配置模式:targetcli[root@server ~]# targetcli/> ls/> /backstores/block create server1storage /dev/vg0/iscsi_storage/> /iscsi create iqn.2016-06.com.example:strage1/> iscsi/iqn.2016-06.com.example:strage1/tpg1/luns create /backstores/block/server1storage /> iscsi/iqn.2016-06.com.example:strage1/tpg1/acls create iqn.2016-06.com.example:server1storagekey/> iscsi/iqn.2016-06.com.example:strage1/tpg1/portals create 172.25.254.244/> exit






3.访问iSCSI存储在desktop上:安装iSCSI发起端软件包:# yum install -y iscsi-initiator-utils
在/etc/iscsi/initiatorname.iscsi中设置发起端的IQN:InitiatorName=iqn.1994-05.com.redhat:9e96ff23da37----->>InitiatorName=iqn.2016-06.com.example:server1storagekey
查找iSCSI服务器所提供的iSCSI目标(目标门户)# iscsiadm -m discovery -t st -p 172.25.254.244[root@desktop ~]# iscsiadm -m discovery -t st -p 172.25.254.244iscsiadm: cannot make connection to 172.25.254.244: No route to host
[root@server ~]# systemctl status firewalldfirewalld.service - firewalld - dynamic firewall daemon Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled) Active: active (running) since Thu 2017-06-08 22:46:32 EDT; 17min ago Main PID: 484 (firewalld) CGroup: /system.slice/firewalld.service └─484 /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopid
Jun 08 22:46:32 server systemd[1]: Started firewalld - dynamic firewall daemon.[root@server ~]# systemctl stop firewalld
[root@desktop ~]# iscsiadm -m discovery -t st -p 172.25.254.244172.25.254.244:3260,1 iqn.2016-06.com.example:strage1 67 iscsiadm -m discovery -t st -p 172.25.254.244 69 iscsiadm -m discovery -t st -p 172.25.254.244 72 iscsiadm -m node -T iqn.2016-06.com.example:strage1 -p 172.25.254.244 -l 73 fdisk -l 74 fdisk /dev/sda 75 partprobe 77 mkfs.xfs /dev/sda1 78 mount /dev/sda1 /mnt/ 79 df 80 yum install tree.x86_64 -y 81 tree -c /var/lib/iscsi/














4.挂载:在/etc/fstab中永久挂载文件系统. 使用blkid确定文件系统UUID并使用UUID挂载,而不是/dev/sd*设备名称。(每次引导时显示的设备名称都不同,具体取决于iSCSI设备通过网络进行响应的顺序。如果按设备名称挂载,这会导致使用错误的设备。). 在/etc/fstab中使用_netdev作为挂载选项。(这将确保客户端不会尝试挂载文件系统,直至启用联网。否则,在引导时系统将出错。). 确保iscsi服务在引导时启动。 83 vim /etc/fstab 84 blkid 85 fg 86 mount -a 87 df




xfs文件系统只能扩大不能缩减
1)lvm扩大
lvextend —L 500M /dev/vg0/lv0 ##扩大lvm设备到500M
xfs_growfs /dev/vg0/lv0 ##扩大xfs文件系统到设备大小
fdisk /dev/vdb
partprobe
pvcreate /dev/vdb1
vgcreate iSCSI_vg /dev/vdb1
lvcreate -L 1G -n disk1_lv iSCSI_vg
yum install target -y
systemctl enable target
systemctl start target
firewall-cmd --permanent --add-port=3260/tcp
firewall-cmd --reload
targetcli
/bachstores/block create server18.disk1 /dev/iSCSI_vg/disk1_lv
/iscsi create iqn.2017-06.com.example:server18
/iscsi/iqn.2017-06.com.example:server18/tpg1/luns create /backstores/block/server18.disk1
/iscsi/iqn.2017-06.com.example:server18/tpg1/acls create iqn.2017-06.com.example:desktop18
/iscsi/iqn.2017-06.com.example:server18/tpg1/portals create 172.25.18.11
clearconfig confirm=True 清除所有记录
lvextend -L 1.5G /dev/iSCSI_vg/disk1_lv
在测试端
vim /etc/iscsi/initiatorname.iscsi
InitiatorName=iqn.2017-06.com.example:desktop18
iscsiadm -m discovery -t st -p 172.25.18.11
iscsiadm -m node -T iqn.2017-06.com.example:stragel -p 172.25.18.11 -l
fdisk /dev/sda
partprobe
mkfs.xfs /dev/sda1
mount /deb/sda1 /mnt
vim /etc/fstab
UUID=" " /mnt xfs defatults,_netdev 0 0
#6. 配 SMB 服务:
- 创建共享目录为 /smbshare ,共享名为 smbshare ,工作组为 WESTOS ,
marketing 组成员可以读写此共享,不属于 marketing 组的人只能读。
- 创建 samba-only 用户 brian 和 rob ,其中 brian 用户属于
marketing 组,用户密码都是 westos 。- 在 desktopX 上建立挂载点 /mnt/multiuser 目录,开机自动挂载
serverX 上的 smbshare 共享,激活 smb 多用户挂载支持。
34 yum install samba samba-common samba-client.x86_64 -y 35 systemctl start smb nmb ###开启服务 36 systemctl enable smb.service nmb添加samba用户:smb用户必须时本地用户smbpasswd -a studentNew SMB password:qwer#输入smb当前用户密码Retype new SMB password:qwer#确认密码
pdbedit -L#查看smb用户信息pdbedit -x smb用户#删除smb用户4.共享目录的基本设定vim /etc/samba/smb.conf[haha]共享名称comment = 对共享目录的描述path = 共享目录的绝对路径workgroup = WESTOS ####修改工作组

6.smb多用户挂载在client上vim /root/hahausername=studentpassword=qwer
chmod 600 /root/haha
yum install cifs-utils -y
mount -o credentials=/root/haha,multiuser,sec=ntlmssp //172.25.254.100/haha /mnt/#credentials=/root/haha指定挂载时所用到的用户文件
#multiuser支持多用户认证#sec=ntlmssp认证方式为标准smb认证方式#7. 配置 nfs 服务:
- serverx 主机共享本地目录/nfsshare;
- desktopX 可以读写访问此共享,并且开机自动挂载到 /mnt/nfsshare 目录上;

95 yum install nfs-utils 96 systemctl status firewalld 97 systemctl start firewalld 98 systemctl status firewalld 99 firewall-cmd --list-all 100 systemctl status nfs-server 101 systemctl start nfs-server 102 systemctl status nfs-server 103 firewall-cmd --permanent --add-service=nfs 104 firewall-cmd --permanent --add-service=rpc-bind 105 firewall-cmd --permanent --add-service=mountd 106 firewall-cmd --reload[student@localhost mnt]$ showmount -e 172.25.254.244Export list for 172.25.254.244:
2.共享目录server:systemctl start nfs-server ###开启服务mkdir /public ###建立共享目录chmod 777 /public ####给共享目录设置权限
vim /etc/exports 配置文件 ###man 5 exportfs 查看exports怎么写
exportfs -rv ###使/etc/exports文件生效#8. 在 serverX 和 desktopX 配置 postfix 服务:
- 设置服务开机自启,防护墙允许此服务。
- 将 serverX 配置为邮件空客户端,只监听本地回环接口,只允
许 127.0.0.0/8 这个网段转发邮件,从 serverX 上发出的邮件域
名都被重写为 desktopX.example.com ,所有邮件都被转发到
smtpX.example.com 主机( DNS 上已有 MX 记录,指向 desktopX ),
本地不存储邮件。
- desktopX 可以接收来自 serverX 的邮件。
6 yum install samba samba-common samba-client -y
systemctl start smb nmb
systemctl enable smb nmb
firewall-cmd --permanent --add-service=samba
firewall-cmd --permanent --add-service=samba-client
firewall-cmd --reload
groupadd marketing
useradd -s /sbin/nologin -G marketing brian
useradd -s /sbin/nologin rob
smbpasswd -a brian
smbpasswd -a rob
mkdir /smbshare
semanage fcontext -a -t samba_share_t '/smbshare(/.*)?'
restorecon -RvvF
chmod +w /smbshare
vim /etc/samba/smb.conf
[smbshare]
path = /smbshare
comment localshare
workgroup =WESTOS
write list = +marketing
在desktop18上
vim /root/haha
username=brian
password=westos
chmod 600 /root/haha
yum install cifs-utils -y
mkdir /mnt/multiuser
vim /etc/rc.d/rc.local
mount -o credentials=/root/haha,multiuser,sec=ntlmssp //172.25.18.11/smbshare /mnt/multiuser

7.
yum install nfs-untils -y
systemctl enable nfs-server
systemctl start nfs-server
firewall-cmd --permanent --add-service=nfs
firewall-cmd --permanent --add-service=mountd
firewall-cmd --permanent --add-service=rpc-bind
firewall-cmd --reload
mkdir /nfsshare
chmod 777 /nfsshare
vim /etc/exports
/nfsshare 172.25.18.10(rw,sync)
exportfs -rv
在测试端
mkdir /mnt/nfsshare
vim /etc/fstab
172.25.254.11:/nfsshare /mnt/nfsshare nfs defaults 0 0
mount -a
8.
firewall-cmd --permanent --add-service=smtp
firewall-cmd --reload
vim /etc/postfix/main.cf
76 myhostname = server18.example.com
86 mydomain = example.com
99 myorigin =desktop18.example.com
116 inet_interfaces = all
164 mydestination = $myhostname, $mydomain, localhost
264 mynetworks =127.0.0.0/8
316 relayhost = 172.25.18.10
systemctl restart postfix.service
在测试端
vim /etc/postfix/main.cf
76 myhostname = desktop18.example.com
86 mydomain = example.com
99 myorigin =desktop18.example.com
116 inet_interfaces = all
164 mydestination = $myhostname, $mydomain, localhost
进行测试mail root
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  server password current