1、自建yum仓库,分别为网络源和本地源
一、本地源
[root@centos7 /etc/yum.repos.d]#systemctl start autofs
[root@centos7 /etc/yum.repos.d]#systemctl enabled autofs
[root@centos7 /etc/yum.repos.d]#mkdir /etc/yum.repos.d/bak
[root@centos7 /etc/yum.repos.d]#mv /etc/yum.repos.d/*.repo /etc/yum.repos.d/bak
[root@centos7 /etc/yum.repos.d]#vim /etc/yum.repos.d/base.repo
name=cdrom repo
baseurl=file:///misc/cd
gpgcheck=1
gpgkey=file:///misc/cd/RPM-GPG-KEY-CentOS-7
[epel]
name=EPEL
baseurl=http://mirrors.aliyun.com/epel/$releasever/$basearch
gpgcheck=0
enabled=0
[root@centos7 /etc/yum.repos.d]#yum clean all
[root@centos7 /etc/yum.repos.d]#yum repolist all
二、网络源
[root@centos7 /etc/yum.repos.d]#systemctl stop firewalld
[root@centos7 /etc/yum.repos.d]#systemctl disable
服务器配置
[root@centos7 /etc/yum.repos.d]#yum install httpd -y
[root@centos7 /etc/yum.repos.d]#cd /var/www/html/
[root@centos7 /var/www/html]#mkdir -pv centos/{6,7}/os/x86_64/
[root@centos7 /data]#mount -o loop /data/CentOS-6.9-x86_64-bin-DVD1.iso /var/www/html/centos/6/os/x86_64/
[root@centos7 /var/www/html]#mount /dev/sr0 centos/7/os/x86_64/
客户端配置
[root@centos6 /etc/yum.repos.d]#vim test.repo
[test]
name=base yum
baseurl=http://192.168.17.140/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=http://192.168.17.140/centos/$releasever/os/$basearch/RPM-GPG-KEY-CentOS-$releasever
[root@centos6 /etc/yum.repos.d]#yum clean all
[root@centos6 /etc/yum.repos.d]#yum repolist
Loaded plugins: fastestmirror, refresh-packagekit, security
Determining fastest mirrors
test | 4.0 kB 00:00
test/primary_db | 4.7 MB 00:00
repo id repo name status
test base yum 6,706
repolist: 6,706
2、编译安装http2.4,实现可以正常访问,并将编译步骤和结果提交。
[root@centos7 /app/httpd24]#yum install gcc openssl-devel pcre-devel apr-devel apr-util-devel -y
[root@centos7 /app/httpd24]#./configure \
--prefix=/apps/httpd24 \
--enable-ssl \
--enable-so
[root@centos7 /app/httpd24]#make
[root@centos7 /app/httpd24]#make install
[root@centos7 /app/httpd24]#./bin/apchectl start
3、创建一个2G的文件系统,块大小为2048byte,预留1%可用空间,文件系统 ext4,卷标为TEST,要求此分区开机后自动挂载至/test目录,且默认有acl挂载选项。
[root@centos6 ~]#fdisk /dev/sdb
WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
switch off the mode (command 'c') and change display units to
sectors (command 'u').
Command (m for help): n^H^H
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-2610, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-2610, default 2610): +2G
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
[root@centos6 ~]#mkfs.ext4 -b 2048 -L TEST -m 1 /dev/sdb
sdb sdb1
[root@centos6 ~]#mkfs.ext4 -b 2048 -L TEST -m 1 /dev/sdb1
mke2fs 1.41.12 (17-May-2010)
Filesystem label=TEST
OS type: Linux
Block size=2048 (log=1)
Fragment size=2048 (log=1)
Stride=0 blocks, Stripe width=0 blocks
131560 inodes, 1052240 blocks
10522 blocks (1.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=538968064
65 block groups
16384 blocks per group, 16384 fragments per group
2024 inodes per group
Superblock backups stored on blocks:
16384, 49152, 81920, 114688, 147456, 409600, 442368, 802816
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 35 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
[root@centos6 ~]#blkid /dev/sdb1
/dev/sdb1: LABEL="TEST" UUID="90b033ca-347b-4e1c-8d7c-79f4c45f4484" TYPE="ext4"
[root@centos6 ~]#mkdir /test
[root@centos6 ~]#vim /etc/fstab
#
# /etc/fstab
# Created by anaconda on Sat Nov 16 15:52:40 2019
#
# 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=ba1dfc35-a669-463f-8a6a-30d495c12066 / ext4 defaults 1 1
UUID=bfd5b98b-cf6b-41b2-a3fb-da248364dfbb /boot ext4 defaults 1 2
UUID=0fafe696-f947-4529-add7-b7e58817125c /data ext4 defaults 1 2
UUID=2ebf3929-5fd6-4033-a1fd-5b3aca7a74a6 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
UUID=90b033ca-347b-4e1c-8d7c-79f4c45f4484 /test ext4 acl 1 2
[root@centos6 ~]#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 97.7G 0 part /
├─sda3 8:3 0 48.8G 0 part /data
├─sda4 8:4 0 1K 0 part
├─sda5 8:5 0 2G 0 part [SWAP]
└─sda6 8:6 0 2G 0 part
sdb 8:16 0 20G 0 disk
└─sdb1 8:17 0 2G 0 part /test
sr0 11:0 1 3.7G 0 rom
[root@centos6 ~]#mount
/dev/sda2 on / type ext4 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
tmpfs on /dev/shm type tmpfs (rw,rootcontext="system_u:object_r:tmpfs_t:s0")
/dev/sda1 on /boot type ext4 (rw)
/dev/sda3 on /data type ext4 (rw)
/dev/sdb1 on /test type ext4 (rw,acl)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
4、创建一个至少有两个PV组成的大小为20G的名为testvg的VG;要求PE大小 为16MB, 而后在卷组中创建大小为5G的逻辑卷testlv;挂载至/users目录
[root@centos7 ~]#fdisk /dev/sdb #划分一10G大小的分区,需修改ID(8e),同时增加一个10G大小的磁盘
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 4G 0 part [SWAP]
sdb 8:16 0 200G 0 disk
├─sdb1 8:17 0 4G 0 part [SWAP]
├─sdb2 8:18 0 20G 0 part /home
└─sdb3 8:19 0 10G 0 part
sdc 8:32 0 10G 0 disk
sr0 11:0 1 3.7G 0 rom /run/media/chen/CentOS_6.9_Final
sr1 11:1 1 4.4G 0 rom /run/media/chen/CentOS 7 x86_64
[root@centos7 ~]#pvcreate /dev/sd{b3,c} #创建物理卷设备pv
Physical volume "/dev/sdb3" successfully created.
Physical volume "/dev/sdc" successfully created.
[root@centos7 ~]#pvs
PV VG Fmt Attr PSize PFree
/dev/sdb3 lvm2 --- 10.00g 10.00g
/dev/sdc lvm2 --- 10.00g 10.00g
[root@centos7 ~]#vgcreate testvg /dev/sd{b3,c} -s 16M #创建物理卷组vg,-s是指定大小
Volume group "testvg" successfully created
[root@centos7 ~]#vgdisplay
[root@centos7 ~]#lvcreate -n testlv testvg -L 5G #创建名字为testlv名字的逻辑卷,从卷组名为testvg的卷组中取大小
[root@centos7 ~]#mkfs.xfs /dev/testvg/testlv #创建文件系统
meta-data=/dev/testvg/testlv isize=512 agcount=4, agsize=327680 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0, sparse=0
data = bsize=4096 blocks=1310720, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal log bsize=4096 blocks=2560, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
[root@centos7 ~]#blkid
/dev/sda2: UUID="dc77c4ea-c483-4a79-9f71-6ef54514d36d" TYPE="xfs"
/dev/sda1: UUID="0f96f938-6ed7-438c-b8b2-bca89880f409" TYPE="xfs"
/dev/sda3: UUID="ec2d2c3f-9382-4ebe-894d-72e34866bfea" TYPE="xfs"
/dev/sda5: UUID="3912dc4c-f135-482c-a2a3-fb425bc885ca" TYPE="swap"
/dev/sr0: UUID="2017-03-28-13-24-36-00" LABEL="CentOS_6.9_Final" TYPE="iso9660" PTTYPE="dos"
/dev/sdb1: UUID="24b5f3fc-d882-46b6-b827-f613a6c2a6e3" TYPE="swap"
/dev/sdb2: UUID="328dc3ec-f221-4533-945b-2751168b6204" TYPE="xfs"
/dev/sr1: UUID="2019-09-11-18-50-31-00" LABEL="CentOS 7 x86_64" TYPE="iso9660" PTTYPE="dos"
/dev/sdb3: UUID="so7tOF-K1Br-RTKg-3Vu5-t4yc-Xr4t-YuWCvE" TYPE="LVM2_member"
/dev/sdc: UUID="OQsST7-5lj8-Anzp-LPFC-yf7D-2DX5-jPHR8N" TYPE="LVM2_member"
/dev/mapper/testvg-testlv: UUID="e16179d9-1a59-40a9-99e9-493cc255f9df" TYPE="xfs"
[root@centos7 ~]#mkdir /users
[root@centos7 ~]#mount /dev/testvg/testlv /users/ 临时挂载
[root@centos7 ~]#vim /etc/fstab 永久挂载
# /etc/fstab
# Created by anaconda on Sat Nov 16 15:29:21 2019
#
# 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=dc77c4ea-c483-4a79-9f71-6ef54514d36d / xfs defaults 0 0
UUID=0f96f938-6ed7-438c-b8b2-bca89880f409 /boot xfs defaults 0 0
UUID=ec2d2c3f-9382-4ebe-894d-72e34866bfea /data xfs defaults 0 0
UUID=3912dc4c-f135-482c-a2a3-fb425bc885ca swap swap defaults 0 0
UUID=24b5f3fc-d882-46b6-b827-f613a6c2a6e3 swap swap defaults 0 0
/swapfile swap swap defaults 0 0
UUID=328dc3ec-f221-4533-945b-2751168b6204 /home xfs defaults 0 0
UUID=e16179d9-1a59-40a9-99e9-493cc255f9df /users xfs defaults 0 0
[root@centos7 ~]#df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 895M 0 895M 0% /dev
tmpfs 910M 0 910M 0% /dev/shm
tmpfs 910M 11M 900M 2% /run
tmpfs 910M 0 910M 0% /sys/fs/cgroup
/dev/sda2 100G 6.3G 94G 7% /
/dev/sda3 50G 4.4G 46G 9% /data
/dev/sda1 1014M 179M 836M 18% /boot
tmpfs 182M 8.0K 182M 1% /run/user/42
/dev/sdb2 20G 40M 20G 1% /home
tmpfs 182M 0 182M 0% /run/user/0
tmpfs 182M 32K 182M 1% /run/user/1000
/dev/sr1 4.4G 4.4G 0 100% /run/media/chen/CentOS 7 x86_64
/dev/sr0 3.7G 3.7G 0 100% /run/media/chen/CentOS_6.9_Final
/dev/mapper/testvg-testlv 5.0G 33M 5.0G 1% /users