Q1:自建yum仓库,分别为网络源和本地源
[root@CentOS7 data]# cat /etc/yum.repos.d/local.repo
[se_VM_Local]
# conf_name
name=Media DVD
# decrise
baseurl=file:///misc/cd
# path
gpgcheck=0
# gpg check 0=off 1=on
这里可以看到 其实主要就三个 一个就是名称 以及baseurl 路径 还有一个就是gpg的密钥
首先我们必须将光盘挂载在指定的路径上,在这里进行引用,gpg可以开启,开启后需要配置密钥文件,在光盘上就有。
那么网络源有分两种,一种为局域网内部的仓库服务器,另一种则为Internet上的仓库源,例如阿里云等开源服务器。
简单描述局域网内部的仓库服务器:C/S架构,需要搭建服务端以及客户端。
首先服务端,需要安装httpd服务。可利用本地源先将httpd服务安装完毕,并且systemctl start httpd 启动服务。
网站的后续对应路径都是相应在/var/www/html里面
所以 可以建立目录路径文件夹
mkdir -pv ceteros/{6,7}/os/x86_64
然后将对应光盘文件拷贝至相对应的目录下
至此服务端完毕
可通过网页访问尝试。
客户端:
脚本信息
# CentOS-Server.repo
[c6-Server]
name=CentOS-$releasever_Server
baseurl=http://192.168.17.122/centeOS/6/os/$basearch/
gpgkey=http://192.168.17.122/centeOS/6/os/$basearch/RPM-GPG-KEY-CentOS-6
这里使用的是6,当然也可以使用变量来替代版本号。
至此即可使用。
Internet 仓库源 一般都可以自己填写 或者是套用该网站提供的repo文件 下载即可使用
例如:epel可以使用阿里云的开源
https://developer.aliyun.com/mirror?spm=a2c6h.13651102.1364563.28.53322f70b5v6k2
Epel 镜像
简介
EPEL (Extra Packages for Enterprise Linux), 是由 Fedora Special Interest Group 维护的 Enterprise Linux(RHEL、CentOS)中经常用到的包。
配置方法
-
备份(如有配置其他epel源)
mv /etc/yum.repos.d/epel.repo /etc/yum.repos.d/epel.repo.backup
mv /etc/yum.repos.d/epel-testing.repo /etc/yum.repos.d/epel-testing.repo.backup -
下载新repo 到/etc/yum.repos.d/
epel(RHEL 7)wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
epel(RHEL 6)wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo
epel(RHEL 5)wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-5.repo
相关链接
下载地址:https://mirrors.aliyun.com/epel/
官方主页:https://fedoraproject.org/wiki/EPEL
Q2:编译安装http2.4,实现可以正常访问,并将编译步骤和结果提交。
首先查看该包的信息
[root@CentOS7 ~]# yum info httpd
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Installed Packages
Name : httpd
Arch : x86_64
Version : 2.4.6
Release : 67.el7.centos
Size : 9.4 M
Repo : installed
From repo : se_VM_Local
Summary : Apache HTTP Server
URL : http://httpd.apache.org/
License : ASL 2.0
Description : The Apache HTTP Server is a powerful, efficient, and extensible
: web server.
下载了一个最新版的源包
上传后并且解压
解压后 我们开始通过 ./configure 加上help 可以看到后面跟上的路径参数 以及 开启的功能参数
[root@CentOS7 httpd-2.4.41]# ./configure --help
`configure' configures this package to adapt to many kinds of systems.
Usage: ./configure [OPTION]... [VAR=VALUE]...
To assign environment variables (e.g., CC, CFLAGS...), specify them as
VAR=VALUE. See below for descriptions of some of the useful variables.
Defaults for the options are specified in brackets.
Configuration:
-h, --help display this help and exit
--help=short display options specific to this package
--help=recursive display the short help of all the included packages
-V, --version display version information and exit
-q, --quiet, --silent do not print `checking ...' messages
--cache-file=FILE cache test results in FILE [disabled]
-C, --config-cache alias for `--cache-file=config.cache'
-n, --no-create do not create output files
--srcdir=DIR find the sources in DIR [configure dir or `..']
Installation directories:
--prefix=PREFIX install architecture-independent files in PREFIX
[/usr/local/apache2]
--exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
[PREFIX]
By default, `make install' will install all the files in
`/usr/local/apache2/bin', `/usr/local/apache2/lib' etc. You can specify
an installation prefix other than `/usr/local/apache2' using `--prefix',
for instance `--prefix=$HOME'.
For better control, use the options below.
Fine tuning of the installation directories:
--bindir=DIR user executables [EPREFIX/bin]
--sbindir=DIR system admin executables [EPREFIX/sbin]
--libexecdir=DIR program executables [EPREFIX/libexec]
--sysconfdir=DIR read-only single-machine data [PREFIX/etc]
--sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
--localstatedir=DIR modifiable single-machine data [PREFIX/var]
--runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run]
--libdir=DIR object code libraries [EPREFIX/lib]
--includedir=DIR C header files [PREFIX/include]
--oldincludedir=DIR C header files for non-gcc [/usr/include]
--datarootdir=DIR read-only arch.-independent data root [PREFIX/share]
--datadir=DIR read-only architecture-independent data [DATAROOTDIR]
--infodir=DIR info documentation [DATAROOTDIR/info]
--localedir=DIR locale-dependent data [DATAROOTDIR/locale]
--mandir=DIR man documentation [DATAROOTDIR/man]
--docdir=DIR documentation root [DATAROOTDIR/doc/PACKAGE]
--htmldir=DIR html documentation [DOCDIR]
--dvidir=DIR dvi documentation [DOCDIR]
--pdfdir=DIR pdf documentation [DOCDIR]
--psdir=DIR ps documentation [DOCDIR]
./configure --prefix=/app/httpd24 --sysconfdir=/etc/httpd --enable-ssl --enable-so
路径在app/httpd24 系统配置文件路径在/etc下的httpd 开启ssl 开启so数据库
一般 在工作用途中 可能会有十几行 甚至更多 因此建议 加上斜杠
可以在文本上先输入
[root@CentOS7 httpd-2.4.41]# ./configure \
> --prefix=/apps/httpd24 \
> --sysconfdir=/etc/httpd \
> --enable-ssl \
> --enable-so
在第一次初期安装 会有缺少一些开发包或者是依赖包等 根据提示 一般我们在缺失的包名称后面以devel 就对了
[root@CentOS7 httpd-2.4.41]# ./configure \
> --prefix=/apps/httpd24 \
> --sysconfdir=/etc/httpd \
> --enable-ssl \
> --enable-so
checking for chosen layout... Apache
checking for working mkdir -p... yes
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... x86_64-pc-linux-gnu
configure:
configure: Configuring Apache Portable Runtime library...
configure:
checking for APR... no
configure: error: APR not found. Please read the documentation.
[root@CentOS7 httpd-2.4.41]# yum search apr
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
============================================== N/S matched: apr ===============================================
apr-devel.i686 : APR library development kit
apr-devel.x86_64 : APR library development kit
apr-util-devel.i686 : APR utility library development kit
apr-util-devel.x86_64 : APR utility library development kit
apr-util-ldap.x86_64 : APR utility library LDAP support
apr-util-mysql.x86_64 : APR utility library MySQL DBD driver
apr-util-nss.x86_64 : APR utility library NSS crytpo support
apr-util-odbc.x86_64 : APR utility library ODBC DBD driver
apr-util-openssl.x86_64 : APR utility library OpenSSL crytpo support
apr-util-pgsql.x86_64 : APR utility library PostgreSQL DBD driver
apr-util-sqlite.x86_64 : APR utility library SQLite DBD driver
apr.i686 : Apache Portable Runtime library
期间过程会有很多很多的error 那么 根据相对应的error 进行缺失的包安装
config.status: creating docs/conf/extra/proxy-html.conf
config.status: creating include/ap_config_layout.h
config.status: creating support/apxs
config.status: creating support/apachectl
config.status: creating support/dbmmanage
config.status: creating support/envvars-std
config.status: creating support/log_server_status
config.status: creating support/logresolve.pl
config.status: creating support/phf_abuse_log.cgi
config.status: creating support/split-logfile
config.status: creating build/rules.mk
config.status: creating build/pkg/pkginfo
config.status: creating build/config_vars.sh
config.status: creating include/ap_config_auto.h
config.status: executing default commands
configure: summary of build options:
Server Version: 2.4.41
Install prefix: /apps/httpd24
C compiler: gcc -std=gnu99
CFLAGS: -pthread
CPPFLAGS: -DLINUX -D_REENTRANT -D_GNU_SOURCE
LDFLAGS:
LIBS:
C preprocessor: gcc -E
总共需要的是 yum install gcc openssl-devel pcre-devel apr-devel apr-util-devel -y
接着 make -j 核心数 进行 make
最后 make install
Q3 创建一个2G的文件系统,块大小为2048byte,预留1%可用空间,文件系统ext4,卷标为TEST,要求此分区开机自动挂载/TEST 并且具有ACL选项。
首先使用fdisk -l 查看当前硬盘情况
[root@CentOS7 ~]# fdisk -l
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: 0x000b9cc3
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 2099199 1048576 83 Linux
/dev/sda2 2099200 211814399 104857600 83 Linux
/dev/sda3 211814400 220203007 4194304 82 Linux swap / Solaris
/dev/sda4 220203008 419430399 99613696 5 Extended
/dev/sda5 220205056 325062655 52428800 83 Linux
Disk /dev/sdb: 322.1 GB, 322122547200 bytes, 629145600 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: 0x5fd02348
Device Boot Start End Blocks Id System
/dev/sdb1 2048 8390655 4194304 82 Linux swap / Solaris
这里可以看到sdb还有余下空间,那么我们可以利用fdisk命令再次从sdb中分出一个分区
[root@CentOS7 ~]# fdisk /dev/sdb
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
Partition type:
p primary (1 primary, 0 extended, 3 free)
e extended
Select (default p): p
Partition number (2-4, default 2):
First sector (8390656-629145599, default 8390656):
Using default value 8390656
Last sector, +sectors or +size{K,M,G} (8390656-629145599, default 629145599): +2G
Partition 2 of type Linux and of size 2 GiB is set
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.
[root@CentOS7 ~]# partprobe
Warning: Unable to open /dev/sr0 read-write (Read-only file system). /dev/sr0 has been opened read-only.
Error: Invalid partition table - recursive partition on /dev/sr0.
Warning: Unable to open /dev/sr1 read-write (Read-only file system). /dev/sr1 has been opened read-only.
[root@CentOS7 ~]# fdisk -l
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: 0x000b9cc3
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 2099199 1048576 83 Linux
/dev/sda2 2099200 211814399 104857600 83 Linux
/dev/sda3 211814400 220203007 4194304 82 Linux swap / Solaris
/dev/sda4 220203008 419430399 99613696 5 Extended
/dev/sda5 220205056 325062655 52428800 83 Linux
Disk /dev/sdb: 322.1 GB, 322122547200 bytes, 629145600 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: 0x5fd02348
Device Boot Start End Blocks Id System
/dev/sdb1 2048 8390655 4194304 82 Linux swap / Solaris
/dev/sdb2 8390656 12584959 2097152 83 Linux
这里w后 可能会有分区表无法保存同步问题
可以利用partprobe命令进行同步 ,由于我的系统内有挂载了两个光盘 所以此处信息忽略
接着我们就可以开始创建文件系统了
[root@CentOS7 ~]# mkfs.ext4 -b 2048 -m 0.1 -L /TEST /dev/sdb2
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
1048 blocks (0.10%) 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
[root@CentOS7 ~]# blkid
/dev/sda1: UUID="4e7c4de8-0478-421d-aeb4-49d1c339ac5f" TYPE="xfs"
/dev/sda2: UUID="be45fdd1-e7ba-4449-a52c-fcaf90a437ef" TYPE="xfs"
/dev/sda3: UUID="a20c290f-7db9-4a25-b8e3-6fa4a956903b" TYPE="swap"
/dev/sda5: UUID="831d1f4a-7db4-4d89-b847-56039206e095" TYPE="xfs"
/dev/sr0: UUID="2017-03-28-13-24-36-00" LABEL="CentOS_6.9_Final" TYPE="iso9660" PTTYPE="dos"
/dev/sr1: UUID="2017-09-06-10-53-42-00" LABEL="CentOS 7 x86_64" TYPE="iso9660" PTTYPE="dos"
/dev/sdb1: UUID="b58f218b-e9e2-4b41-8d29-4cd50937a26b" TYPE="swap"
/dev/sdb2: LABEL="/TEST" UUID="22705dad-7dfa-467f-88bf-2c21e56a7859" TYPE="ext4"
这里就可以看到 格式化完成了
-b 代表了块大小 -m 保留的空间比 -L 卷标的意思
那么我们接下来就要添加acl选项
[root@CentOS7 ~]# tune2fs -l /dev/sdb2
tune2fs 1.42.9 (28-Dec-2013)
Filesystem volume name: /TEST
Last mounted on: <not available>
Filesystem UUID: 22705dad-7dfa-467f-88bf-2c21e56a7859
Filesystem magic number: 0xEF53
Filesystem revision #: 1 (dynamic)
Filesystem features: has_journal ext_attr resize_inode dir_index filetype extent 64bit flex_bg sparse_super huge_file uninit_bg dir_nlink extra_isize
Filesystem flags: signed_directory_hash
Default mount options: user_xattr acl
由于我们使用的是7系统 因此 默认新建的文件系统是带有ACL的 那么如果是6的系统呢
我们需要执行以下命令
tune2fs -o acl /dev/sdb2
删除就是 tune2fs -o ^acl /dev/sdb2
接着我们就要在fstab上添加上该条目 来达到开机自动挂载的动作
#
# /etc/fstab
# Created by anaconda on Thu Oct 10 10:14:46 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=be45fdd1-e7ba-4449-a52c-fcaf90a437ef / xfs defaults 0 0
UUID=4e7c4de8-0478-421d-aeb4-49d1c339ac5f /boot xfs defaults 0 0
UUID=831d1f4a-7db4-4d89-b847-56039206e095 /data xfs defaults 0 0
UUID=a20c290f-7db9-4a25-b8e3-6fa4a956903b swap swap defaults 0 0
UUID=b58f218b-e9e2-4b41-8d29-4cd50937a26b swap swap defaults 0 0
UUID=22705dad-7dfa-467f-88bf-2c21e56a7859" /TEST ext4 defaults 0 0
这里就完成了fstab的添加
Q4 创建一个至少有两个PV组成的大小为20G的名为testvg的VG;要求PE大小 为16MB, 而后在卷组中创建大小为5G的逻辑卷testlv;挂载至/users目录
首先先查看是否有空闲的块设备 接着我们需要定义至少两个块设备为PV成员
[root@CentOS7 ~]# fdisk -l
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: 0x000b9cc3
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 2099199 1048576 83 Linux
/dev/sda2 2099200 211814399 104857600 83 Linux
/dev/sda3 211814400 220203007 4194304 82 Linux swap / Solaris
/dev/sda4 220203008 419430399 99613696 5 Extended
/dev/sda5 220205056 325062655 52428800 83 Linux
Disk /dev/sdb: 322.1 GB, 322122547200 bytes, 629145600 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: 0x5fd02348
Device Boot Start End Blocks Id System
Disk /dev/sdc: 10.7 GB, 10737418240 bytes, 20971520 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 /dev/sdd: 10.7 GB, 10737418240 bytes, 20971520 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
[root@CentOS7 ~]# pvcreate /dev/sdc
Physical volume "/dev/sdc" successfully created.
[root@CentOS7 ~]# pvcreate /dev/sdd
Physical volume "/dev/sdd" successfully created.
[root@CentOS7 ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/sdc lvm2 --- 10.00g 10.00g
/dev/sdd lvm2 --- 10.00g 10.00g
这里通过pvcreate命令进行块设备的定义
[root@CentOS7 ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/sdc lvm2 --- 10.00g 10.00g
/dev/sdd lvm2 --- 10.00g 10.00g
创建VG卷组并且定义pe大小16M
[root@CentOS7 ~]# vgcreate -s 16M testvg /dev/sd{c,d}
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
[root@CentOS7 ~]# vgdiplay
bash: vgdiplay: command not found...
[root@CentOS7 ~]# vgdisplay
--- Volume group ---
VG Name testvg
System ID
Format lvm2
Metadata Areas 2
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 2
Act PV 2
VG Size <19.97 GiB
PE Size 16.00 MiB
Total PE 1278
Alloc PE / Size 0 / 0
Free PE / Size 1278 / <19.97 GiB
VG UUID uFfqfF-GzYn-n4eK-SxCl-DRo0-64Fu-Y5zfpj
创建lv逻辑卷
[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.xfs /dev/mapper/testvg-testlv
meta-data=/dev/mapper/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/sda1: UUID="4e7c4de8-0478-421d-aeb4-49d1c339ac5f" TYPE="xfs"
/dev/sda2: UUID="be45fdd1-e7ba-4449-a52c-fcaf90a437ef" TYPE="xfs"
/dev/sda3: UUID="a20c290f-7db9-4a25-b8e3-6fa4a956903b" TYPE="swap"
/dev/sda5: UUID="831d1f4a-7db4-4d89-b847-56039206e095" TYPE="xfs"
/dev/sr0: UUID="2017-03-28-13-24-36-00" LABEL="CentOS_6.9_Final" TYPE="iso9660" PTTYPE="dos"
/dev/sr1: UUID="2017-09-06-10-53-42-00" LABEL="CentOS 7 x86_64" TYPE="iso9660" PTTYPE="dos"
/dev/sdb: PTTYPE="dos"
/dev/sdc: UUID="8RBxo5-RvGh-4M4D-rIFQ-eRXk-EiK4-b0OCIK" TYPE="LVM2_member"
/dev/mapper/testvg-testlv: UUID="61591f9d-19f3-4d41-a971-58f050de8491" TYPE="xfs"
/dev/sdd: UUID="Z1DNPW-yqyE-9Tey-tfQb-RuBy-84zB-gV5Z5g" TYPE="LVM2_member"
[root@CentOS7 ~]# mount /dev/mapper/
control testvg-testlv
[root@CentOS7 ~]# mount /dev/mapper/testvg-testlv /users/
[root@CentOS7 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 100G 8.5G 92G 9% /
devtmpfs 978M 0 978M 0% /dev
tmpfs 993M 0 993M 0% /dev/shm
tmpfs 993M 9.1M 984M 1% /run
tmpfs 993M 0 993M 0% /sys/fs/cgroup
/dev/sda5 50G 218M 50G 1% /data
/dev/sda1 1014M 158M 857M 16% /boot
tmpfs 199M 12K 199M 1% /run/user/42
tmpfs 199M 0 199M 0% /run/user/0
/dev/mapper/testvg-testlv 5.0G 33M 5.0G 1% /users