Engineer-Exec03-参考解析

案例1:在在 server0、desktop0 上操作

– 将防火墙默认区域设置为trusted
[root@server0 ~]# firewall-cmd --get-default-zone #查看默认区域
public
[root@server0 ~]# firewall-cmd --set-default-zone=trusted #修改默认区域为trusted
success

案例2:指定yum软件源
为 server0 指定可用的 yum 软件源
– YUM软件库的地址为 http://classroom.example.com/content/rhel7.0/x86_64/dvd
– 将此配置为虚拟机 server0 的默认软件仓库
[root@server0 ~]# rm -rf /etc/yum.repos.d/*
[root@server0 ~]# vim /etc/yum.repos.d/shlss.repo
[saohuoliushishi]
name=jianrenliushishi
baseurl=http://classroom.example.com/content/rhel7.0/x86_64/dvd
enabled=1
gpgcheck=0

– 确认可用的仓库列表 [root@server0 ~]# yum rrpolist
– 利用yum仓库安装system-config-kickstart
[root@server0 ~]# yum -y install system-config-kickstart

案例3:tar制作/释放归档压缩包(zcf、ztf、zxf、jcf、jtf、jxf、cf、tf)
首先创建/root/boothome/与/root/usrsbin/目录
[root@server0 ~]# mkdir /root/boothome /root/usrsbin/
1)备份/boot、/home这两个文件夹,保存为boothome.tar.gz文件
[root@server0 ~]# tar -zcf /boothome.tar.gz /boot /home

2)查看boothome.tar.gz文件内包含哪些内容 

[root@server0 ~]# tar -tf /boothome.tar.gz

3)将boothome.tar.gz释放到文件夹/root/boothome/下

[root@server0 ~]# tar -xf /boothome.tar.gz -C /root/boothome/

4)备份/usr/sbin目录,保存为usrsbin.tar.bz2文件

[root@server0 ~]# tar -jcf /usrsbin.tar.bz2 /usr/sbin

5)查看usrsbin.tar.bz2文件内包含哪些内容

[root@server0 ~]# tar -tf /usrsbin.tar.bz2

6)将usrsbin.tar.bz2释放到/root/usrsbin/文件夹下

[root@server0 ~]# tar -xf /usrsbin.tar.bz2 -C /root/usrsbin/

案例4:在server上操作,搭建mariadb数据库系统

  1. 在 server0 上安装 MariaDB 数据库系统
    1)安装 mariadb-server软件包
    [root@server0 ~]# yum -y install mariadb-server
    2)启动 mariadb 服务
    [root@server0 ~]# systemctl restart mariadb
    [root@server0 ~]# systemctl enable mariadb

案例5:在server上操作,配置一个数据库
– 为mariadb数据库root设置登陆密码为 haxi
[root@server0 ~]# mysqladmin -u root password ‘haxi’
– 新建一个数据库名为 nsd
[root@server0 ~]# mysql -u root -phaxi #进入数据库
MariaDB [(none)]> create database nsd; #创建nsd库
– 除了 root 用户,此数据库只能被用户 lisi 查询,此用户的密码为 123(用户的授权)
MariaDB [(none)]> grant select on nsd.* to lisi@localhost identified by ‘123’;
– 数据库 nsd 中应该包含来自数据库复制的内容,(数据库导入数据)
数据库文件的 URL为:http://classroom/pub/materials/users.sql
[root@server0 ~]# wget http://classroom/pub/materials/users.sql
[root@server0 ~]# mysql -u root -phaxi nsd < /root/users.sql
案例6:在server上操作,使用数据库查询
1)查询base表所有内容
MariaDB [nsd]> select * from nsd.base;
2)查询location表所有内容
MariaDB [nsd]> select * from nsd.location;
3)查询base表的结构
MariaDB [nsd]> desc base;
4)查询location表的结构
MariaDB [nsd]> desc location;
5)查询base表内容,只显示name字段
MariaDB [nsd]> select name from nsd.base;
6)查询mysql表内容,只显示user,host,password字段
MariaDB [mysql]> select user,host,password from mysql.user;
7)密码是 solicitous 的人的名字?
MariaDB [mysql]> select * from nsd.base where password=‘solicitous’;
8)有多少人的姓名是 Barbara 同时居住在 Sunnyvale?
MariaDB [nsd]> select count() from base,location where base.name=‘Barbara’ and location.city=‘Sunnyvale’ and base.id=location.id;
±---------+
| count(
) |
±---------+
| 1 |
±---------+

扫描二维码关注公众号,回复: 9117888 查看本文章

9)在base表中追加记录 id为6,name为Barbara,password为900
MariaDB [nsd]> insert base values(‘6’,‘Barbara’,‘900’);
10)在location表中追加记录 id为6,city为Sunnyvale
MariaDB [nsd]> insert location values(‘6’,‘Sunnyvale’);
11)再次查询有多少人的姓名是 Barbara 同时居住在 Sunnyvale?
MariaDB [nsd]> select count() from base,location where base.name=‘Barbara’ and location.city=‘Sunnyvale’ and base.id=location.id;
±---------+
| count(
) |
±---------+
| 2 |
±---------+

案例7:虚拟机 server0操作, /dev/vdb 上按以下要求建立分区:
采用默认的 msdos 分区模式
– 第1个分区 /dev/vdb1 的大小为 3G
– 第2个分区 /dev/vdb2 的大小为 200M
– 第3个分区 /dev/vdb3 的大小为 100M
– 第4个分区 /dev/vdb4为扩展分区
– 在划分二个分区逻辑分区/dev/vdb[5-6],
– 分区大小依次为500M、2000M
[root@server0 ~]# fdisk /dev/vdb

案例8:发布iSCSI网络磁盘
1)配置 server0 提供 iSCSI 服务,要求如下:
[root@server0 ~]# rpm -q targetcli
未安装软件包 targetcli
[root@server0 ~]# yum -y install targetcli

2)磁盘名为iqn.2016-02.com.example:server0(target磁盘组名字)
[root@server0 ~]# targetcli
3)服务端口为 3260
4)使用 iscsi_store(后端存储的名称) 作其后端卷,其大小为 3GiB
/> backstores/block create dev=/dev/vdb1 name=target
/> iscsi/ create iqn.2016-02.com.example:server0 #打包一
/> iscsi/iqn.2016-02.com.example:server0/tpg1/ #打包二
/> iscsi/iqn.2016-02.com.example:server0/tpg1/luns create /backstores/block/target #luns关联

5)此磁盘服务只能被 desktop0.example.com 访问,在Server0上配置客户端ACL为iqn.2016-02.com.example:desktop0
/> iscsi/iqn.2016-02.com.example:server0/tpg1/acls create iqn.2016-02.com.example:desktop
/> iscsi/iqn.2016-02.com.example:server0/tpg1/portals create 0.0.0.0 #设置监听IP地址与端口(所有)
[root@server0 ~]# systemctl restart target #重启服务
[root@server0 ~]# systemctl enable target #开机启用

6)配置虚拟机desktop0 使用 虚拟机server0 提供 iSCSI 服务
[root@desktop0 ~]# rpm -q iscsi-initiator-utils #查询iscsi-initiator-utils是否安装
[root@desktop0 ~]# vim /etc/iscsi/initiatorname.iscsi #修改配置文件,指定客户端声称名字
InitiatorName=iqn.2016-02.com.example:desktop
[root@desktop0 ~]# systemctl restart iscsid #重起iscsid专门用于刷新客户端声称的名字
[root@desktop0 ~]# iscsiadm --mode discoverydb --type sendtargets --portal 172.25.0.11 --discover
#寻找服务端访问共享存储
172.25.0.11:3260,1 iqn.2016-02.com.example:server0
[root@desktop0 ~]# systemctl restart iscsi #重启iscsi服务
[root@desktop0 ~]# lsblk #
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 3G 0 disk
vda 253:0 0 10G 0 disk
└─vda1 253:1 0 10G 0 part /
vdb 253:16 0 10G 0 disk

发布了55 篇原创文章 · 获赞 0 · 访问量 438

猜你喜欢

转载自blog.csdn.net/weixin_45533230/article/details/103704292