yum使用,http2.4編譯安裝,磁盤分區,格式化,邏輯卷建立與掛載
一、自建yum倉庫,分別爲網絡源和本地源
操做步驟解釋: 一、將現有的RPM 包,放到同一個目錄下,使用「createrepo」 命令進行元數據建立repodata。 二、將光盤鏡像,掛載到某一目錄下,裏面自帶repodata。 三、使用http服務或者nfs,以及vsftp服務進行網絡共享。 四、客戶端配置:必須在/etc/yum.repos.d/ 目錄下,建立以 repo結尾的文件。 [base] name=base #倉庫取名字 baseurl=file:///misc/cd #共享方式及路徑,必須是有repodata所在的目錄 enabled=1 #是否開啓本yum源 gpgcheck=0 #密鑰檢查 公網的源 建議開啓,確保安全
1)、建立yum倉庫,生成repodta目錄
2)、本地yum源,以光盤爲例
[13:44:07 root@centos7 yum.repos.d]#mount /dev/sr0 /mnt
mount: /dev/sr0 is write-protected, mounting read-only
[13:44:31 root@centos7 yum.repos.d]#vim base.repo
[13:44:49 root@centos7 yum.repos.d]#cat base.repo
#本地資源,光盤鏡像共享
[base] name=base baseurl=file:///mnt enabled=1 gpgcheck=0
[13:44:54 root@centos7 yum.repos.d]#yum clean all
Loaded plugins: fastestmirror, langpacks Cleaning repos: base Cleaning up list of fastest mirrors Other repos take up 120 M of disk space (use --verbose for details)
[13:45:04 root@centos7 yum.repos.d]#yum repolist
Loaded plugins: fastestmirror, langpacks Determining fastest mirrors base | 3.6 kB 00:00:00 (1/2): base/group_gz | 166 kB 00:00:00 (2/2): base/primary_db | 3.1 MB 00:00:00 repo id repo name status base base 4,021 repolist: 4,021
3)、安裝httpd 服務,用於網絡共享資源 (必定要先用瀏覽器測試下,資源是否可用)
[13:51:53 root@centos7 dnf]#yum install httpd -y
#安裝http 服務node
[13:52:38 root@centos7 dnf]#systemctl start httpd
#開啓http 服務mysql
[13:57:09 root@centos7 yum.repos.d]#cat dnf.repo
#dnf 網絡源配置linux
[dnf] name=dnf baseurl=http://192.168.1.190/dnf/ enbaled=1 gpgcheck=0
二、編譯安裝http2.4,實現能夠正常訪問,並將編譯步驟和結果提交。
1)、http2.4.6 安裝包下載:http://httpd.apache.org/download.cgi 並上傳至服務器
2)、編譯環境安裝
[14:14:46 root@centos7 ~]#yum install pcre-devel zlib-devel openssl openssl-devel gcc -y
sql
3)、進到目錄,開始編譯安裝
[14:20:17 root@centos7 ~]#cd httpd-2.4.46/
[14:20:19 root@centos7 httpd-2.4.46]#pwd
/root/httpd-2.4.46
apache
./configure make make install
4)、默認編譯路徑及服務啓動與訪問驗證
三、建立一個2G的文件系統,塊大小爲2048byte,預留1%可用空間,文件系統 ext4,卷標爲TEST,要求此分區開機後自動掛載至/test目錄,且默認有acl掛載選項
1)、查看磁盤,將sda 進行新建立分區做爲本次測試。磁盤信息以下:
[14:51:36 root@centos7 ~]#fdisk /dev/sda
vim
Welcome to fdisk (util-linux 2.23.2). Changes will remain in memory only, until you decide to write them. Be careful before using the write command. Command (m for help): p Disk /dev/sda: 214.7 GB, 214748364800 bytes, 419430400 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk label type: dos Disk identifier: 0x0001dba8 Device Boot Start End Blocks Id System /dev/sda1 * 2048 2050047 1024000 83 Linux /dev/sda2 2050048 22530047 10240000 83 Linux /dev/sda3 22530048 24627199 1048576 83 Linux Command (m for help): n Partition type: p primary (3 primary, 0 extended, 1 free) e extended Select (default e): Using default response e Selected partition 4 First sector (24627200-419430399, default 24627200): Using default value 24627200 Last sector, +sectors or +size{K,M,G} (24627200-419430399, default 419430399): Using default value 419430399 Partition 4 of type Extended and of size 188.3 GiB is set Command (m for help): p Disk /dev/sda: 214.7 GB, 214748364800 bytes, 419430400 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk label type: dos Disk identifier: 0x0001dba8 Device Boot Start End Blocks Id System /dev/sda1 * 2048 2050047 1024000 83 Linux /dev/sda2 2050048 22530047 10240000 83 Linux /dev/sda3 22530048 24627199 1048576 83 Linux /dev/sda4 24627200 419430399 197401600 5 Extended Command (m for help): n All primary partitions are in use Adding logical partition 5 First sector (24629248-419430399, default 24629248): Using default value 24629248 Last sector, +sectors or +size{K,M,G} (24629248-419430399, default 419430399): +2G Partition 5 of type Linux and of size 2 GiB is set Command (m for help): p Disk /dev/sda: 214.7 GB, 214748364800 bytes, 419430400 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk label type: dos Disk identifier: 0x0001dba8 Device Boot Start End Blocks Id System /dev/sda1 * 2048 2050047 1024000 83 Linux /dev/sda2 2050048 22530047 10240000 83 Linux /dev/sda3 22530048 24627199 1048576 83 Linux /dev/sda4 24627200 419430399 197401600 5 Extended /dev/sda5 24629248 28823551 2097152 83 Linux Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. WARNING: Re-reading the partition table failed with error 16: Device or resource busy. The kernel still uses the old table. The new table will be used at the next reboot or after you run partprobe(8) or kpartx(8) Syncing disks.
[14:52:24 root@centos7 ~]#partprobe /dev/sda
#同步磁盤與內存中的數據一致centos
[14:52:32 root@centos7 ~]#lsblk
瀏覽器
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 200G 0 disk ├─sda1 8:1 0 1000M 0 part /boot ├─sda2 8:2 0 9.8G 0 part / ├─sda3 8:3 0 1G 0 part ├─sda4 8:4 0 1K 0 part 這是擴展分區 └─sda5 8:5 0 2G 0 part 這是邏輯分區 本次實驗以他爲主
2)、格式化文件系統爲ext4,卷標爲TEST,並指定塊大小
[14:53:28 root@centos7 ~]#mke2fs -t ext4 -b 2048 -L 'TEST' -m 1 /dev/sda5
安全
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 You have new mail in /var/spool/mail/root
[15:08:38 root@centos7 ~]#mke2fs /dev/sda5
bash
mke2fs 1.42.9 (28-Dec-2013) Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) Stride=0 blocks, Stripe width=0 blocks 131072 inodes, 524288 blocks 26214 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=536870912 16 block groups 32768 blocks per group, 32768 fragments per group 8192 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912 Allocating group tables: done Writing inode tables: done Writing superblocks and filesystem accounting information: done
3)、寫進/etc/fstab 自動掛載至/test,且默認有acl 掛載選項
[15:10:04 root@centos7 ~]#blkid
/dev/sr0: UUID="2018-11-25-23-54-16-00" LABEL="CentOS 7 x86_64" TYPE="iso9660" PTTYPE="dos" /dev/sdb1: UUID="yZ16Cg-PGpj-3oAs-vsg1-qopN-4tKs-mVYOkh" TYPE="LVM2_member" /dev/sdb2: UUID="sp1RAv-KEJq-soOc-ryfd-2u2G-kdaR-P8EpbR" TYPE="LVM2_member" /dev/sdb3: UUID="n2I2DR-IvJd-dBIV-z1vQ-QEgP-MB2p-KUBrRw" TYPE="LVM2_member" /dev/sdc: UUID="69jQYA-pOFx-CyiB-1C4d-qtH9-M20S-z48lbu" TYPE="LVM2_member" /dev/sda1: UUID="0745e236-6619-43df-929f-78cef14f3713" TYPE="xfs" /dev/sda2: UUID="296fe92a-a09a-4a43-b0bf-38302e32e228" TYPE="xfs" /dev/sda3: UUID="6eba734c-311d-4cbf-88ca-adf9312c9366" TYPE="xfs" /dev/sda5: UUID="17db2a07-e240-4816-b2e5-8cb1ccd01421" TYPE="ext2"
四、建立一個至少有兩個PV組成的大小爲20G的名爲testvg的VG;要求PE大小 爲16MB, 然後在卷組中建立大小爲5G的邏輯卷testlv;掛載至/users目錄
1)、將磁盤sda 新添加兩個分區,並更改分區屬性爲lvm 類型,做爲pv使用
[11:04:35 root@centos7 test]#fdisk /dev/sda
Welcome to fdisk (util-linux 2.23.2). Changes will remain in memory only, until you decide to write them. Be careful before using the write command. Command (m for help): n All primary partitions are in use Adding logical partition 6 First sector (28825600-419430399, default 28825600): Using default value 28825600 Last sector, +sectors or +size{K,M,G} (28825600-419430399, default 419430399): +1G Partition 6 of type Linux and of size 1 GiB is set Command (m for help): n All primary partitions are in use Adding logical partition 7 First sector (30924800-419430399, default 30924800): Using default value 30924800 Last sector, +sectors or +size{K,M,G} (30924800-419430399, default 419430399): +1G Partition 7 of type Linux and of size 1 GiB is set Command (m for help): t Partition number (1-7, default 7): 6 Hex code (type L to list all codes): L 0 Empty 24 NEC DOS 81 Minix / old Lin bf Solaris 1 FAT12 27 Hidden NTFS Win 82 Linux swap / So c1 DRDOS/sec (FAT- 2 XENIX root 39 Plan 9 83 Linux c4 DRDOS/sec (FAT- 3 XENIX usr 3c PartitionMagic 84 OS/2 hidden C: c6 DRDOS/sec (FAT- 4 FAT16 <32M 40 Venix 80286 85 Linux extended c7 Syrinx 5 Extended 41 PPC PReP Boot 86 NTFS volume set da Non-FS data 6 FAT16 42 SFS 87 NTFS volume set db CP/M / CTOS / . 7 HPFS/NTFS/exFAT 4d QNX4.x 88 Linux plaintext de Dell Utility 8 AIX 4e QNX4.x 2nd part 8e Linux LVM df BootIt 9 AIX bootable 4f QNX4.x 3rd part 93 Amoeba e1 DOS access a OS/2 Boot Manag 50 OnTrack DM 94 Amoeba BBT e3 DOS R/O b W95 FAT32 51 OnTrack DM6 Aux 9f BSD/OS e4 SpeedStor c W95 FAT32 (LBA) 52 CP/M a0 IBM Thinkpad hi eb BeOS fs e W95 FAT16 (LBA) 53 OnTrack DM6 Aux a5 FreeBSD ee GPT f W95 Ext'd (LBA) 54 OnTrackDM6 a6 OpenBSD ef EFI (FAT-12/16/ 10 OPUS 55 EZ-Drive a7 NeXTSTEP f0 Linux/PA-RISC b 11 Hidden FAT12 56 Golden Bow a8 Darwin UFS f1 SpeedStor 12 Compaq diagnost 5c Priam Edisk a9 NetBSD f4 SpeedStor 14 Hidden FAT16 <3 61 SpeedStor ab Darwin boot f2 DOS secondary 16 Hidden FAT16 63 GNU HURD or Sys af HFS / HFS+ fb VMware VMFS 17 Hidden HPFS/NTF 64 Novell Netware b7 BSDI fs fc VMware VMKCORE 18 AST SmartSleep 65 Novell Netware b8 BSDI swap fd Linux raid auto 1b Hidden W95 FAT3 70 DiskSecure Mult bb Boot Wizard hid fe LANstep 1c Hidden W95 FAT3 75 PC/IX be Solaris boot ff BBT 1e Hidden W95 FAT1 80 Old Minix Hex code (type L to list all codes): 8e Changed type of partition 'Linux' to 'Linux LVM' Command (m for help): t Partition number (1-7, default 7): 7 Hex code (type L to list all codes): 8e Changed type of partition 'Linux' to 'Linux LVM' Command (m for help): p Disk /dev/sda: 214.7 GB, 214748364800 bytes, 419430400 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk label type: dos Disk identifier: 0x0001dba8 Device Boot Start End Blocks Id System /dev/sda1 * 2048 2050047 1024000 83 Linux /dev/sda2 2050048 22530047 10240000 83 Linux /dev/sda3 22530048 24627199 1048576 83 Linux /dev/sda4 24627200 419430399 197401600 5 Extended /dev/sda5 24629248 28823551 2097152 83 Linux /dev/sda6 28825600 30922751 1048576 8e Linux LVM /dev/sda7 30924800 33021951 1048576 8e Linux LVM Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. WARNING: Re-reading the partition table failed with error 16: Device or resource busy. The kernel still uses the old table. The new table will be used at the next reboot or after you run partprobe(8) or kpartx(8) Syncing disks.
[11:07:20 root@centos7 test]#partprobe /dev/sda
[11:07:40 root@centos7 test]#lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 200G 0 disk ├─sda1 8:1 0 1000M 0 part /boot ├─sda2 8:2 0 9.8G 0 part / ├─sda3 8:3 0 1G 0 part ├─sda4 8:4 0 1K 0 part ├─sda5 8:5 0 2G 0 part /test ├─sda6 8:6 0 1G 0 part └─sda7 8:7 0 1G 0 part
[11:07:43 root@centos7 test]#fdisk /dev/sda
Welcome to fdisk (util-linux 2.23.2). Changes will remain in memory only, until you decide to write them. Be careful before using the write command. Command (m for help): n All primary partitions are in use Adding logical partition 8 First sector (33024000-419430399, default 33024000): Using default value 33024000 Last sector, +sectors or +size{K,M,G} (33024000-419430399, default 419430399): +28G Partition 8 of type Linux and of size 28 GiB is set Command (m for help): t Partition number (1-8, default 8): 8 Hex code (type L to list all codes): 8e Changed type of partition 'Linux' to 'Linux LVM' Command (m for help): p Disk /dev/sda: 214.7 GB, 214748364800 bytes, 419430400 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk label type: dos Disk identifier: 0x0001dba8 Device Boot Start End Blocks Id System /dev/sda1 * 2048 2050047 1024000 83 Linux /dev/sda2 2050048 22530047 10240000 83 Linux /dev/sda3 22530048 24627199 1048576 83 Linux /dev/sda4 24627200 419430399 197401600 5 Extended /dev/sda5 24629248 28823551 2097152 83 Linux /dev/sda6 28825600 30922751 1048576 8e Linux LVM /dev/sda7 30924800 33021951 1048576 8e Linux LVM /dev/sda8 33024000 91744255 29360128 8e Linux LVM Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. WARNING: Re-reading the partition table failed with error 16: Device or resource busy. The kernel still uses the old table. The new table will be used at the next reboot or after you run partprobe(8) or kpartx(8) Syncing disks. You have new mail in /var/spool/mail/root [11:10:18 root@centos7 test]#partprobe /dev/sda [11:10:27 root@centos7 test]#lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 200G 0 disk ├─sda1 8:1 0 1000M 0 part /boot ├─sda2 8:2 0 9.8G 0 part / ├─sda3 8:3 0 1G 0 part ├─sda4 8:4 0 1K 0 part ├─sda5 8:5 0 2G 0 part /test ├─sda6 8:6 0 1G 0 part ├─sda7 8:7 0 1G 0 part └─sda8 8:8 0 28G 0 part
2)、將sda6,sda7, sda8, 建立pv
[11:12:08 root@centos7 test]#pvcreate /dev/sda{6..8}
Physical volume "/dev/sda6" successfully created. Physical volume "/dev/sda7" successfully created. Physical volume "/dev/sda8" successfully created.
3)、建立testvg,PE爲16MB ,查看組成個數
[11:20:45 root@centos7 test]#vgcreate testvg -s 16MB /dev/sda{6..8}
Volume group "testvg" successfully created
[11:21:44 root@centos7 test]#vgdisplay
--- Volume group --- VG Name testvg System ID Format lvm2 Metadata Areas 3 Metadata Sequence No 1 VG Access read/write VG Status resizable MAX LV 0 Cur LV 0 Open LV 0 Max PV 0 Cur PV 3 Act PV 3 VG Size 29.95 GiB PE Size 16.00 MiB #此處爲PE大小 Total PE 1917 Alloc PE / Size 0 / 0 Free PE / Size 1917 / 29.95 GiB VG UUID SXDuvV-oNqk-H1Tq-q33b-jyvs-fXmB-d2TLLg
[11:24:56 root@centos7 test]#pvs PV VG Fmt Attr PSize PFree /dev/sda6 testvg lvm2 a-- 1008.00m 1008.00m /dev/sda7 testvg lvm2 a-- 1008.00m 1008.00m /dev/sda8 testvg lvm2 a-- 27.98g 27.98g
4)、建立testlv 大小爲5G
[11:29:45 root@centos7 test]#lvcreate -n testlv -L +5G testvg
Logical volume "testlv" created. You have new mail in /var/spool/mail/root
[11:31:07 root@centos7 test]#lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert testlv testvg -wi-a----- 5.00g binlog vg1 owi-a-s--- 5.00g binlog-snapshot vg1 sri-a-s--- 256.00m binlog 0.09 binlog-snapshot2 vg1 sri-a-s--- 256.00m binlog 0.02 mysql vg1 -wi-a----- 4.94g
[11:31:15 root@centos7 test]#lvdisplay
-
--- Logical volume --- LV Path /dev/testvg/testlv LV Name testlv VG Name testvg LV UUID 7sYrLA-FNam-xJav-2XfL-Pxdi-1vTR-qTkl6j LV Write Access read/write LV Creation host, time centos7, 2020-09-12 11:31:07 +0800 LV Status available # open 0 LV Size 5.00 GiB Current LE 320 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 8192 Block device 253:7
5)、格式化testlv 與掛載至 /users目錄