一、自建yum倉庫,分別爲網絡源和本地源html
在centos7安裝yum源:node
(1)本地自建yum倉庫:首先須要啓動神奇目錄ls /misc/cd,用來掛載光盤,linux
一、 安裝autofs軟件,並啓動。apache
二、 [root@centos7-2 ~]# yum install autofs 安裝autofsvim
三、 [root@centos7-2 ~]# systemctl start autofs 啓動autofscentos
四、 [root@centos7-2 ~]# systemctl enable autofs 下次開機啓動autofsbash
五、 [root@centos7-2 yum.repos.d]# rm -rf repo.* 刪除yum源多餘的文件網絡
[root@centos7-2 yum.repos.d]#vim development.repo 建立Yum倉庫
[development] baseurl=file:///misc/cd #gpgcheck=0 gpgcheck=file:///misc/cd/RPM-GPG-KEY-CenstOS-7 enable=1
六、yum repolist 加載當前的yum源倉庫 app
(2)光盤掛載到httpd服務上的yum源倉庫ide
一、[root@centos7-2 yum.repos.d]#mkdir -pv /var/www/html/centos/6/os/x86_64/ 新建一個相似光盤的路徑目錄
二、[root@centos7-2 yum.repos.d]#yum install httpd -y 安裝httpd服務
三、[root@centos7-2 yum.repos.d]#systemctl start httpd 啓動httpd服務
四、[root@centos7-2 yum.repos.d]#mount /dev/sr0 /var/www/html/centos/6/os/x86_64 將本地光盤掛載到httpd網上
[root@centos7-2 yum.repos.d]#vim base.repo 開始建立yum倉庫 [base] baseurl=http://192.168.34.101/CentOS/$releasever/os/$basearch gpgcheck= 0 enable=1
五、 yum repolist 加載當前的Yum源倉庫
(3) 建立網絡yum源倉庫(ELPL源):
一、[root@centos7-2 yum.repos.d]#cd /etc/yum.repos.d/
直接在阿里官網找到elpl源倉庫,將repodata上級全部目錄都複製出來,放到baseurl指定的目錄便可:
[root@centos7-2 yum.repos.d]#vim elpl.repo [elpl] baseurl= https://mirrors.aliyun.com/epel/$releasever/x86_64 gpgcheck=0 enable=1
二、yum repolist 加載當前的yum源倉庫
二、編譯安裝http2.4,實現能夠正常訪問,並將編譯步驟和結果提交。
在官網上下載httpd源碼包http://httpd.apache.org,也能夠在linux中輸入rpm -qi httpd查看到當前下載源碼httpd的網址
下載到linux的data目錄下,而後進行解壓:
1
2
3
|
[root@ansibledata]
#rz
[root@ansibledata]
#tar xf httpd-2.4.39
|
注意:必定要在解壓後的httpd目錄下安裝,下面的編譯須要用到httdp目錄下的腳本,因此我用cd httpd把目錄切換到httpd中去進入cd httpd-2.4.27/
查詢 cat INSTALL,裏邊有簡單的安裝過程,和一些例子
查詢 cat README,(what is it ?)裏邊有一些Apache 的功能介紹
(1)./configure --help 查詢這個腳本的用法,
--prefix=PREFIX 指定默認安裝總目錄, 默認爲/usr/local/
--sysconfdir=/PATH 配置文件安裝位置,默認就安裝到指定安裝總目錄的下面
Optional Features: 須要什麼功能
--disable-FEATURE 關閉某些功能
--enable-FEATURE 開啓某些功能
下面咱們就來執行這個腳本,添加一些簡單的設置
手工建立帳號:
1
|
[root@ansiblehttpd-2.4.39]
#useradd -r -u 80 -d /var/www -s /sbin/nologin httpd
|
(1)首先安裝development-tools包,由於沒有C編譯工具,缺乏gcc,這時候,咱們須要下一個包組development tools
yum -y groupinstall "Development Tools"
1
|
[root@ansiblehttpd-2.4.39]
#yum groupinstall "development tools"
|
(2)首次安裝包,會有一些提示錯誤,第一次安裝沒有一些準備好的包,能夠根據提示錯誤進行安裝:
1
|
[root@ansiblehttpd-2.4.39]
#./configure --prefix=/app/httpd --sysconfdir=/etc/httpd24 --enable-ssl --disable-status
|
(3)咱們只需按照提示的錯誤,把須要的都安裝上去(直到沒有提示錯誤)
先查詢缺乏的 yum search apr-devel(通常關於開發的都叫 devel)
再安裝 yum -y install apr-devel
1
|
[root@ansiblehttpd-2.4.39]
#yum install apr-devel
|
(4)此時缺乏apr-util包,按照提示錯誤來進行下一步安裝:
1
|
[root@ansiblehttpd-2.4.39]
#yum install apr-util-devel
|
1
|
[root@ansiblehttpd-2.4.39]
#./configure --prefix=/app/httpd --sysconfdir=/etc/httpd24 --enable-ssl --disable-status
|
(5)根據提示錯誤繼續往下安裝,此時缺乏pcre包,安裝pcre-devel包
1
|
[root@ansiblehttpd-2.4.39]
#yum install pcre-devel
|
繼續執行指定路徑的包安裝
1
|
[root@ansiblehttpd-2.4.39]
#./configure --prefix=/app/httpd --sysconfdir=/etc/httpd24 --enable-ssl --disable-status
|
(6)根據提示的錯誤,安裝openssl-devel包:
1
|
[root@ansiblehttpd-2.4.39]
#yum install openssl-devel
|
(7)再執行指定路徑的包安裝,此時就已經完成指定路徑包的安裝。
1
|
[root@ansiblehttpd-2.4.39]
#./configure --prefix=/app/httpd --sysconfdir=/etc/httpd24 --enable-ssl --disable-status
|
(8)configure腳本徹底執行成功(多了一個Makefile)沒有Makefile
(1)進行make編譯,make 編譯後,多了不少.o .lo 文件 (二進制文件),在此以前的工做,任何用戶都能作,而且都在httpd-2.4.27 這個目錄下進行
1
|
[root@ansiblehttpd-2.4.39]
#make
|
(2)make install 安裝到指定位置,只有root 能作,此時httpd的編譯完成。
1
|
[root@ansiblehttpd]
#make install
|
(3)切換到/app/httpd/bin執行程序目錄下,此時去執行服務啓動,都必須是./apachectl start,不太方便,咱們能夠指定變量路徑
1
2
3
4
5
|
[root@ansiblehttpd]
#cd /app/httpd/bin
[root@ansiblebin]
#pwd
/app/httpd/bin
[root@ansiblebin]
#echo 'PATH=/app/httpd/bin:$PATH' > /etc/profile.d/httpd.sh 定義一個/app/httpd/bin的配置文件路徑
[root@ansiblebin]
#apachectl start 啓動當前編譯的httpd服務
|
此時在網上輸入本機的IP地址就能夠訪問信息:
導入幫助手冊man
vim /etc/man_db.conf
加入一行 MANDATORY_MANPATH /app/httpd/man
三、建立一個2G的文件系統,塊大小爲2048byte,預留1%可用空間,文件系統 ext4,卷標爲TEST,要求此分區開機後自動掛載至/test目錄,且默認有acl掛載選項
(1)先在/dev/sdb磁盤上建立一個2G的分區
[root@centos6~]#fdisk /dev/sdb Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel Building a new DOS disklabel with disk identifier 0xef64b475. Changes will remain in memory only, until you decide to write them. After that, of course, the previous content won't be recoverable. Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite) 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): m Command action a toggle a bootable flag b edit bsd disklabel c toggle the dos compatibility flag d delete a partition l list known partition types m print this menu n add a new partition o create a new empty DOS partition table p print the partition table q quit without saving changes s create a new empty Sun disklabel t change a partition's system id u change display/entry units v verify the partition table w write table to disk and exit x extra functionality (experts only) Command (m for help): p Disk /dev/sdb: 214.7 GB, 214748364800 bytes 255 heads, 63 sectors/track, 26108 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0xef64b475 Device Boot Start End Blocks Id System Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 1 First cylinder (1-26108, default 1): 1 Last cylinder, +cylinders or +size{K,M,G} (1-26108, default 26108): +2G Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks.
查看此時的/dev/sdb的分區大小是2G
[root@centos6~]#lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sr0 11:0 1 3.7G 0 rom 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] sdb 8:16 0 200G 0 disk └─sdb1 8:17 0 15.7M 0 part
(2)指定磁盤空間及系統標記:塊大小爲2048byte,預留1%可用空間,文件系統 ext4,卷標爲TEST
[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 22 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override.
查看指定後的分區信息:
lsblk /dev/sdb1
[root@centos6~]#blkid /dev/sdb1 /dev/sdb1: LABEL="TEST" UUID="9250f7d0-977b-4c0b-bba8-7dfca23c3dcd" TYPE="ext4"
查看文件系統的ACL功能:
tune2fs -l /dev/sdb1
[root@centos6~]#tune2fs -l /dev/sdb1
tune2fs 1.41.12 (17-May-2010)
Filesystem volume name: TEST
Last mounted on: <not available>
Filesystem UUID: 9250f7d0-977b-4c0b-bba8-7dfca23c3dcd
Filesystem magic number: 0xEF53
Filesystem revision #: 1 (dynamic)
Filesystem features: has_journal ext_attr resize_inode dir_index filetype extent flex_bg sparse_super huge_file uninit_bg dir_nlink extra_isize
Filesystem flags: signed_directory_hash
Default mount options: acl
Filesystem state: clean
Errors behavior: Continue
Filesystem OS type: Linux
Inode count: 131560
Block count: 1052240
Reserved block count: 10522
Free blocks: 998252
Free inodes: 131549
First block: 0
Block size: 2048
Fragment size: 2048
Reserved GDT blocks: 512
Blocks per group: 16384
Fragments per group: 16384
Inodes per group: 2024
Inode blocks per group: 253
Flex block group size: 16
Filesystem created: Sun Nov 10 09:17:32 2019
Last mount time: n/a
Last write time: Sun Nov 10 09:21:25 2019
Mount count: 0
Maximum mount count: 22
Last checked: Sun Nov 10 09:17:32 2019
Check interval: 15552000 (6 months)
Next check after: Fri May 8 09:17:32 2020
Lifetime writes: 97 MB
Reserved blocks uid: 0 (user root)
Reserved blocks gid: 0 (group root)
First inode: 11
Inode size: 256
Required extra isize: 28
Desired extra isize: 28
Journal inode: 8
Default directory hash: half_md4
Directory Hash Seed: 840447d7-3f85-4ff3-bec5-89fb0e95a853
Journal backup: inode block
(3)開機掛載/dev/sdb1磁盤:
vim /dev/fstab 將文件UUID寫入到配置文件中便可:
[root@centos6~]#cat /etc/fstab # # /etc/fstab # Created by anaconda on Thu Aug 22 15:06:16 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=26a9ab70-c62f-471f-bdf2-bb38c350526a / ext4 defaults 1 1 UUID=e1f6dde3-d380-4e79-80cc-b41fbf93f404 /boot ext4 defaults 1 2 UUID=7f570fd9-b234-46a1-9bc5-c8cf3942d9ca /data ext4 defaults 1 2 UUID=be5f6d9c-1887-4895-ac3f-c795f2eaafac swap swap defaults 0 0 UUID=9250f7d0-977b-4c0b-bba8-7dfca23c3dcd /mnt/sdb1 ext4 defaults 0 0
四、建立一個至少有兩個PV組成的大小爲20G的名爲testvg的VG;要求PE大小 爲16MB, 然後在卷組中建立大小爲5G的邏輯卷testlv;掛載至/users目錄
(1)虛擬機上安上兩個10G的虛擬硬盤,而後組合PV物理組:
[root@ansiblehttpd]#pvcreate /dev/{sdc,sdd} Physical volume "/dev/sdc" successfully created. Physical volume "/dev/sdd" successfully created.
(2)建立PE爲16MB的VG組
[root@ansiblehttpd]#vgcreate -s 16m vg0 /dev/sd{c,d} Volume group "vg0" successfully created
(3)將卷組建立成5G邏輯卷
[root@ansiblehttpd]#lvcreate -n testly -L 5G vg0 Logical Volume "testly" already exists in volume group "vg0"
(4)格式化當前的卷組
[root@ansiblehttpd]#mkfs.ext4 /dev/vg0/testly mke2fs 1.42.9 (28-Dec-2013) Filesystem label= OS type: Linux Block size=1024 (log=0) Fragment size=1024 (log=0) Stride=0 blocks, Stripe width=0 blocks 16384 inodes, 65536 blocks 3276 blocks (5.00%) reserved for the super user First data block=1 Maximum filesystem blocks=33685504 8 block groups 8192 blocks per group, 8192 fragments per group 2048 inodes per group Superblock backups stored on blocks: 8193, 24577, 40961, 57345 Allocating group tables: done Writing inode tables: done Creating journal (4096 blocks): done Writing superblocks and filesystem accounting information: done
查看當前的卷組信息:
[root@ansible~]#pvdisplay --- Physical volume --- PV Name /dev/sdc VG Name vg0 PV Size 10.00 GiB / not usable 16.00 MiB Allocatable yes PE Size 16.00 MiB Total PE 639 Free PE 635 Allocated PE 4 PV UUID AYecKo-37eD-N6sC-jL33-kCrb-ACAV-ez47oc --- Physical volume --- PV Name /dev/sdd VG Name vg0 PV Size 10.00 GiB / not usable 16.00 MiB Allocatable yes PE Size 16.00 MiB Total PE 639 Free PE 639 Allocated PE 0 PV UUID JMGIQr-CS6e-XpUb-1MNu-J4fW-faeW-twAMni
(5)掛載卷組
[root@ansiblehttpd]#mount /dev/vg0/testly /users