2020-06-01

1、自建yum仓库,分别为网络源和本地源
1.1 创建本地源

# 把原有的yum源配置文件移动到备份文件夹
[root@centos7 cd]# cd /etc/yum.repos.d/
[root@centos7 yum.repos.d]# ls
CentOS-Base.repo       CentOS-fasttrack.repo  CentOS-Vault.repo
CentOS-CR.repo         CentOS-Media.repo      CentOS-x86_64-kernel.repo
CentOS-Debuginfo.repo  CentOS-Sources.repo

[root@centos7 yum.repos.d]# mkdir backup
[root@centos7 yum.repos.d]# mv CentOS-* backup

# 挂载光盘到/misc/cd目录下,也可以是其他目录
[root@centos7 yum.repos.d]# cd /misc/cd
[root@centos7 cd]# ls
CentOS_BuildTag  GPL       LiveOS    RPM-GPG-KEY-CentOS-7
EFI              images    Packages  RPM-GPG-KEY-CentOS-Testing-7
EULA             isolinux  repodata  TRANS.TBL

# 创建指向本地yum源的配置文件,必须是.repo结尾
[root@centos7 yum.repos.d]# cat base.repo
[base]                        # 为yum源起一个名字,也可以是其他名字,但是参考原有的配置文件还是叫base
name=local_iso                # yum源的描述信息,也可以不写
baseurl=file:///misc/cd       # yum源的路径,指向光盘中repodata目录所在的路径
gpgcheck=0                    # 是否开启校验,0是不校验,默认为1

# 清除原有yum源缓存,这一步必须做,否则会出错
[root@centos7 ~]# yum clean all
Loaded plugins: fastestmirror, langpacks
Cleaning repos: base
Cleaning up list of fastest mirrors
Other repos take up 38 M of disk space (use --verbose for details)


# 生成现有yum源的元数据缓存,可以不执行,如果不执行,在安装数据包时,会自动下载缓存
[root@centos7 ~]# yum makecache
Loaded plugins: fastestmirror, langpacks
Determining fastest mirrors
base                                                                    | 4.0 kB  00:00:00     
(1/4): base/group_gz                                                    | 242 kB  00:00:00     
(2/4): base/primary_db                                                  | 4.7 MB  00:00:00     
(3/4): base/other_db                                                    | 2.8 MB  00:00:00     
(4/4): base/filelists_db                                                | 6.3 MB  00:00:00     
Metadata Cache Created

# 列出yum源
[root@centos7 ~]# yum repolist
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
repo id                                    repo name                                     status
base                                       local_iso                                     6,713
repolist: 6,713

1.2 创建网络源

# 先查看httpd包是否安装,如果没有安装通过yum安装,http服务器地址192.168.227.128
[root@centos7 ~]# rpm -q httpd
httpd-2.4.6-90.el7.centos.x86_64

# 启动httpd服务
[root@centos7 ~]# systemctl start httpd
[root@centos7 ~]# systemctl status httpd
● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
   Active: active (running) since Sat 2020-05-30 23:12:58 CST; 110ms ago
     Docs: man:httpd(8)
           man:apachectl(8)
           
# 模仿aliyun的yum源路径,在httpd主目录下创建子目录
[root@centos7 ~]# mkdir -p /var/www/html/centos/{6,7}/os/x86_64
[root@centos7 ~]# tree /var/www/html/centos
/var/www/html/centos
├── 6
│   └── os
│       └── x86_64
└── 7
    └── os
        └── x86_64

# 分别挂载CentOS6和CentOS7的光盘到相应文件夹
[root@centos7 ~]# mount /dev/sr0 /var/www/html/centos/6/os/x86_64/
mount: /dev/sr0 is write-protected, mounting read-only
[root@centos7 ~]# mount /dev/sr1 /var/www/html/centos/7/os/x86_64/
mount: /dev/sr1 is write-protected, mounting read-only

# CentOS6上修改客户端的配置文件
[root@CentOS6 yum.repos.d]#cat base.repo
[base]
name=http_yum
baseurl=http://192.168.227.128/centos/$releasever/os/$basearch/
gpgcheck=0

[root@CentOS6 yum.repos.d]#yum clean all
Loaded plugins: fastestmirror, refresh-packagekit, security
Cleaning repos: base
Cleaning up Everything
Cleaning up list of fastest mirrors

[root@CentOS6 yum.repos.d]#yum makecache
Loaded plugins: fastestmirror, refresh-packagekit, security
Determining fastest mirrors
base                                                                    | 4.0 kB     00:00     
base/group_gz                                                           | 242 kB     00:00     
base/filelists_db                                                       | 6.3 MB     00:00     
base/primary_db                                                         | 4.7 MB     00:00     
base/other_db                                                           | 2.8 MB     00:00     
Metadata Cache Created

[root@CentOS6 yum.repos.d]#yum repolist
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
repo id                                     repo name                                    status
base                                        http_yum                                     6713
repolist: 6713


# 在CentOS7上修改客户端配置文件
[root@centos7 yum.repos.d]#cat base.repo
[base]
name=http_yum
baseurl=http://192.168.227.128/centos/$releasever/os/$basearch/
gpgcheck=0

[root@centos7 yum.repos.d]#yum clean all
Loaded plugins: fastestmirror, langpacks
Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast
Cleaning repos: base
Cleaning up list of fastest mirrors
Other repos take up 56 M of disk space (use --verbose for details)


[root@centos7 yum.repos.d]#yum makecache
Loaded plugins: fastestmirror, langpacks
Determining fastest mirrors
base                                                                    | 3.6 kB  00:00:00     
(1/4): base/7/x86_64/group_gz                                           | 165 kB  00:00:00     
(2/4): base/7/x86_64/filelists_db                                       | 3.3 MB  00:00:00     
(3/4): base/7/x86_64/primary_db                                         | 3.2 MB  00:00:00     
(4/4): base/7/x86_64/other_db                                           | 1.3 MB  00:00:00     
Metadata Cache Created

[root@centos7 yum.repos.d]#yum repolist
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
repo id                                        repo name                                 status
base/7/x86_64                                  http_yum                                  4,067
repolist: 4,067

2、编译安装http2.4,实现可以正常访问,并将编译步骤和结果提交。

# 解压httpd软件包

[root@centos7 data]# tar xf httpd-2.4.39.tar.bz2

# 进入到目录中,可以先看一下INSTALL和README文件,里面写了安装方法

[root@centos7 data]# cd httpd-2.4.39/# 在安装之前,先把需要的软件包装上,如果没有提前装,在执行configure时会提示,也可以根据提示安装;也可以直接安装“Development Tools”开发包组

[root@centos7 httpd-2.4.39]#yum install gcc apr-devel apr-util-devel pcre-devel openssl-devel -y

# 执行configure开启特性和检测安装环境,可以使用./configure --help来查看选项,这里只指定了安装目录为/app/httpd2.4.39,开启了ssl加密功能,在执行完毕之后可以使用echo $?查看执行结果

[root@centos7 httpd-2.4.39]# ./configure --prefix=/app/httpd2.4.39 --enable-ssl

# 执行make命令编译,可以跟-j选项指定编译的核心个数,个数越多编译越快,我只有单核的处理器,就不指定了,过程可能会比较长,执行完毕之后使用echo $?查看结果

[root@centos7 httpd-2.4.39]# make

# 执行make install安装

[root@centos7 httpd-2.4.39]# make install

# 修改环境变量,我这里是临时修改,要永久修改可以写到配置文件中

[root@centos7 bin]# PATH="/app/httpd2.4.39/bin:$PATH"

[root@centos7 bin]# which apachectl /app/httpd2.4.39/bin/apachectl

# 启动服务,启动时可能会报域名错误,找到配置文件中ServerName一行,去掉前面的#即可

[root@centos7 bin]# apachectl start

# 访问测试,通过CentOS6客户端访问成功

[root@CentOS6 ~]#curl 192.168.227.128

<html><body><h1>It works!</h1></body></html>

3、创建一个2G的文件系统,块大小为2048byte,预留1%可用空间,文件系统 ext4,卷标为TEST,要求此分区开机后自动挂载至/test目录,且默认有acl挂载选项

# 先通过fdisk分出来一个2G的分区/dev/sda8
[root@centos7 ~]# lsblk
NAME              MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda                 8:0    0  200G  0 disk 
├─sda1              8:1    0    1G  0 part /boot
├─sda2              8:2    0  100G  0 part /
├─sda3              8:3    0   50G  0 part /data
├─sda4              8:4    0    1K  0 part 
├─sda5              8:5    0    2G  0 part [SWAP]
├─sda6              8:6    0   10G  0 part 
├─sda7              8:7    0   10G  0 part 
│ └─testvg-testlv 253:0    0    4G  0 lvm  
└─sda8              8:8    0    2G  0 part 
sdb                 8:16   0   20G  0 disk 
└─sdb1              8:17   0   10G  0 part 
sr0                11:0    1  3.7G  0 rom  
sr1                11:1    1  4.4G  0 rom 

# 创建文件系统
[root@centos7 ~]# mkfs.ext4 -b 2048 -L 'TEST' -m 1 /dev/sda8
mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=TEST
OS type: Linux
Block size=2048 (log=1)
Fragment size=2048 (log=1)
Stride=0 blocks, Stripe width=0 blocks
131072 inodes, 1048576 blocks
10485 blocks (1.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=269484032
64 block groups
16384 blocks per group, 16384 fragments per group
2048 inodes per group
Superblock backups stored on blocks: 
    16384, 49152, 81920, 114688, 147456, 409600, 442368, 802816

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done 

# 把挂载信息写入/etc/fstab文件中,实现开机自动挂载,在CentOS7上默认就支持acl权限,所以权限写defaults即可,这里的/dev/sda8也可以写成UUID,UUID可以通过blkid命令查
[root@centos7 ~]# cat /etc/fstab

#
# /etc/fstab
# Created by anaconda on Thu Apr 16 12:30:24 2020
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=6d9afe5c-50af-4d28-9855-2292ba1ef3c0 /                       xfs     defaults        0 0
UUID=7a87851a-947b-41a6-96e0-a0f6a1a20069 /boot                   xfs     defaults        0 0
UUID=87c89478-a67c-4f92-9d99-3924cce70351 /data                   xfs     defaults        0 0
UUID=131563e5-7253-495b-bb20-c7873c76cdb9 swap                    swap    defaults        0 0
/dev/sda8                                 /test                   ext4    defaults        0 0

# 在CentOS6上默认挂载权限不包括acl,需要指定acl权限挂载
[root@CentOS6 ~]#cat /etc/fstab
#
# /etc/fstab
# Created by anaconda on Sun Dec 11 11:13:37 2016
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=2bb39d88-9d3d-4675-b842-213ad94b1f30 /                       ext4    defaults        1 1
UUID=347e9532-1408-47a0-bb6a-b4d2bf886e31 /boot                   ext4    defaults        1 2
/dev/sdb3                                 /test                   ext4    acl             1 2
UUID=31bf342f-8f6e-4e13-959c-4ee6e4bd1110 swap                    swap    defaults        0 0
tmpfs                   /dev/shm                tmpfs   defaults        0 0
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                   /sys                    sysfs   defaults        0 0
proc                    /proc                   proc    defaults        0 0

4、创建一个至少有两个PV组成的大小为20G的名为testvg的VG;要求PE大小 为16MB, 而后在卷组中创建大小为5G的逻辑卷testlv;挂载至/users目录;

# 先划分出来/dev/sda7和/dev/sdb1两个分区,大小都为10G
[root@centos7 ~]# lsblk /dev/sda7
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda7   8:7    0  10G  0 part 
[root@centos7 ~]# lsblk /dev/sdb1
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sdb1   8:17   0  10G  0 part 

# 创建pv
[root@centos7 ~]# pvcreate /dev/sda7 /dev/sdb1
  Physical volume "/dev/sda7" successfully created.
  Physical volume "/dev/sdb1" successfully created.
[root@centos7 ~]# pvs
  PV         VG Fmt  Attr PSize  PFree 
  /dev/sda7     lvm2 ---  10.00g 10.00g
  /dev/sdb1     lvm2 ---  10.00g 10.00g
  
# 创建testvg,指定PE为16M
[root@centos7 ~]# vgcreate -s 16M testvg /dev/sda7 /dev/sdb1
  Volume group "testvg" successfully created
[root@centos7 ~]# vgs
  VG     #PV #LV #SN Attr   VSize   VFree  
  testvg   2   0   0 wz--n- <19.97g <19.97g
  
# 创建testlv,大小为5G
[root@centos7 ~]# lvcreate -n testlv -L 5G testvg
  Logical volume "testlv" created.
[root@centos7 ~]# lvs
  LV     VG     Attr       LSize Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  testlv testvg -wi-a----- 5.00g
  
# 创建文件系统
[root@centos7 ~]# mkfs.ext4 /dev/testvg/testlv 
[root@centos7 ~]# blkid /dev/testvg/testlv
/dev/testvg/testlv: UUID="847705c0-a8b1-432b-a89e-2d8feec446cd" TYPE="ext4"

# 挂载至/user目录
[root@centos7 ~]# mkdir /users
[root@centos7 ~]# mount /dev/testvg/testlv /users
[root@centos7 ~]# df /users
Filesystem                 Size  Used Avail Use% Mounted on
/dev/mapper/testvg-testlv  4.8G   20M  4.6G   1% /users
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 219,539评论 6 508
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 93,594评论 3 396
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 165,871评论 0 356
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 58,963评论 1 295
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 67,984评论 6 393
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 51,763评论 1 307
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 40,468评论 3 420
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 39,357评论 0 276
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 45,850评论 1 317
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 38,002评论 3 338
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 40,144评论 1 351
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 35,823评论 5 346
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 41,483评论 3 331
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 32,026评论 0 22
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 33,150评论 1 272
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 48,415评论 3 373
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 45,092评论 2 355