linux學(xué)習(xí)筆記(六)

1嵌屎、自建yum倉庫推正,分別為網(wǎng)絡(luò)源和本地源

網(wǎng)絡(luò)源

## 阿里云鏡像地址為例
vi /etc/yum.repos.d/CentOS-Base.repo
[local]
name=CentOS-$releasever - Base - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/
        http://mirrors.aliyuncs.com/centos/$releasever/os/$basearch/
        http://mirrors.cloud.aliyuncs.com/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7

或者

##下載rpm文件
wget http://mirrors.aliyun.com/repo/Centos-7.repo
##安裝rpm即可直接生成repo文件
 rpm -ivh https://mirrors.aliyun.com/epel/epel-release-latest-7.noarch.rpm 

本地源

### 掛載光盤

mount /dev/sr0 /mnt/cdrom


### 編輯repo文件:

vi /etc/yum.repos.d/CentOS-Base.repo
[local]
name=localyum
baseurl=file:///mnt/cdrom/
gpgcheck=0
enabled=1

2、編譯安裝http2.4宝惰,實(shí)現(xiàn)可以正常訪問植榕,并將編譯步驟和結(jié)果提交

(1)安裝依賴包

yum -y install wget pcre-devel gcc gcc-c++ openssl-devel apr apr-util-devel

(2)下載源碼包

wget http://mirrors.tuna.tsinghua.edu.cn/apache//httpd/httpd-2.4.41.tar.gz

(3)解壓文件,編譯

tar zxvf httpd-2.4.41.tar.gz
./configure --prefix=/soft/http --enable-http --enable-proxy --enable-ssl
make
make install

(4)啟動(dòng)

/soft/http/bin/apachectl start

![http.png](https://upload-images.jianshu.io/upload_images/20338643-430a92df947ee521.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

3尼夺、創(chuàng)建一個(gè)2G的文件系統(tǒng)尊残,塊大小為2048byte炒瘸,預(yù)留1%可用空間,文件系統(tǒng) ext4,卷標(biāo)為TEST寝衫,要求此分區(qū)開機(jī)后自動(dòng)掛載至/test目錄顷扩,且默認(rèn)有acl掛載選項(xiàng)

##命令
### 劃分磁盤
fdisk /dev/sdb
(n-->p-->+1932M-->w)
### 格式化ext4文件格式
mkfs.ext4 /dev/sdb1
### 打卷標(biāo)
e2label /dev/sdb1 TEST
### 查看卷標(biāo)
 blkid
###創(chuàng)建掛載點(diǎn)目錄
 mkdir /test
### 編輯配置開機(jī)自動(dòng)掛載
 vi /etc/fstab
 
### 掛載
mount -a

#過程
[root@rac1 ~]# fdisk -l
Disk /dev/sda: 42.9 GB, 42949672960 bytes
255 heads, 63 sectors/track, 5221 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: 0x00066e7f

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          32      256000   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              32        4700    37491712   8e  Linux LVM
/dev/sda3            4700        5222     4194304   82  Linux swap / Solaris

Disk /dev/sdb: 2147 MB, 2147483648 bytes
255 heads, 63 sectors/track, 261 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: 0x00000000


Disk /dev/mapper/vg_root-LogVol00: 38.4 GB, 38390464512 bytes
255 heads, 63 sectors/track, 4667 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: 0x00000000

[root@rac1 ~]# 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 0x6fa1cdcb.
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): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-261, default 1): 1
Last cylinder, +cylinders or +size{K,M,G} (1-261, default 261): +1932M

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
[root@rac1 ~]# fdisk -l

Disk /dev/sda: 42.9 GB, 42949672960 bytes
255 heads, 63 sectors/track, 5221 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: 0x00066e7f

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          32      256000   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              32        4700    37491712   8e  Linux LVM
/dev/sda3            4700        5222     4194304   82  Linux swap / Solaris

Disk /dev/sdb: 2147 MB, 2147483648 bytes
255 heads, 63 sectors/track, 261 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: 0x6fa1cdcb

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1         247     1983996   83  Linux

Disk /dev/mapper/vg_root-LogVol00: 38.4 GB, 38390464512 bytes
255 heads, 63 sectors/track, 4667 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: 0x00000000

[root@rac1 ~]# mkfs.ext4 /dev/sdb1
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
124160 inodes, 495999 blocks
24799 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=511705088
16 block groups
32768 blocks per group, 32768 fragments per group
7760 inodes per group
Superblock backups stored on blocks: 
    32768, 98304, 163840, 229376, 294912

Writing inode tables: done                            
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 38 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.
[root@rac1 ~]# e2label /dev/sdb1 TEST
[root@rac1 ~]# blkid
/dev/mapper/vg_root-LogVol00: UUID="714741b6-8385-4647-807e-f5a4e3946276" TYPE="ext4" 
/dev/sda1: UUID="46f19ac6-907f-456c-b188-275bf3a77763" TYPE="ext4" 
/dev/sda2: UUID="t3dgsp-ogVH-zypY-v08B-fAGD-MTza-565cT2" TYPE="LVM2_member" 
/dev/sda3: UUID="62e305e8-0f56-4fe8-ad8d-957b14ad7781" TYPE="swap" 
/dev/sdb1: LABEL="TEST" UUID="81e4fa94-9024-484f-9b28-d489529465ed" TYPE="ext4" 
[root@rac1 ~]# mkdir /test
[root@rac1 ~]# vi /etc/fstab
[root@rac1 ~]# cat /etc/fstab 

#
# /etc/fstab
# Created by anaconda on Fri Jul  5 09:58:50 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
#
/dev/mapper/vg_root-LogVol00 /                       ext4    defaults        1 1
UUID=46f19ac6-907f-456c-b188-275bf3a77763 /boot                   ext4    defaults        1 2
UUID=62e305e8-0f56-4fe8-ad8d-957b14ad7781 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
/dev/sdb1   /test   ext4    acl 0 0
[root@rac1 ~]# mount -a
[root@rac1 ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/vg_root-LogVol00
                       36G  1.6G   32G   5% /
tmpfs                 932M     0  932M   0% /dev/shm
/dev/sda1             243M   33M  198M  14% /boot
/dev/sdb1             1.9G   35M  1.8G   2% /test

4、創(chuàng)建一個(gè)至少有兩個(gè)PV組成的大小為20G的名為testvg的VG;要求PE大小 為16MB, 而后在卷組中創(chuàng)建大小為5G的邏輯卷testlv;掛載至/users目錄

#查看磁盤
 lsblk
#劃分第一塊盤
 fdisk /dev/sdc
#劃分第二塊盤 
fdisk /dev/sdd
#創(chuàng)建pv
 pvcreate /dev/sdc1
 pvcreate /dev/sdd1
#創(chuàng)建vg
 vgcreate -s 16M testvg /dev/sdc1 /dev/sdd1
#查看vg
 vgs
#創(chuàng)建lv卷組
 lvcreate -n testlv -L 5G testvg
#查看lv信息
 lvs                                 
#格式化
 mkfs.ext4 /dev/testvg/testlv
#查看磁盤信息uuid
 blkid
#添加自動(dòng)掛載
 vi /etc/fstab
#掛載
 mkdir /users
 mount -a



[root@rac1 ~]# lsblk
NAME                        MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sr0                          11:0    1  1024M  0 rom  
sdb                           8:16   0     2G  0 disk 
└─sdb1                        8:17   0   1.9G  0 part /test
sda                           8:0    0    40G  0 disk 
├─sda1                        8:1    0   250M  0 part /boot
├─sda2                        8:2    0  35.8G  0 part 
│ └─vg_root-LogVol00 (dm-0) 253:0    0  35.8G  0 lvm  /
└─sda3                        8:3    0     4G  0 part [SWAP]
sdc                           8:32   0    10G  0 disk 
sdd                           8:48   0    10G  0 disk 
[root@rac1 ~]# fdisk /dev/sdc
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x9f177076.
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): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-1305, default 1): 
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-1305, default 1305): +10G
Value out of range.
Last cylinder, +cylinders or +size{K,M,G} (1-1305, default 1305): 
Using default value 1305

Command (m for help): p

Disk /dev/sdc: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 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: 0x9f177076

   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1               1        1305    10482381   83  Linux

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
[root@rac1 ~]# fdisk /dev/sdd
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0xf23a4da4.
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): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-1305, default 1): 
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-1305, default 1305): 
Using default value 1305

Command (m for help): p

Disk /dev/sdd: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 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: 0xf23a4da4

   Device Boot      Start         End      Blocks   Id  System
/dev/sdd1               1        1305    10482381   83  Linux

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
[root@rac1 ~]# pvcreate /dev/sdc1
  Writing physical volume data to disk "/dev/sdc1"
  Physical volume "/dev/sdc1" successfully created
[root@rac1 ~]# pvcreate /dev/sdd1
  Writing physical volume data to disk "/dev/sdd1"
  Physical volume "/dev/sdd1" successfully created
[root@rac1 ~]# vgcreate -s 16M testvg /dev/sdc1 /dev/sdd1
  Volume group "testvg" successfully created
[root@rac1 ~]# vgs
  VG      #PV #LV #SN Attr   VSize  VFree 
  testvg    2   0   0 wz--n- 19.97g 19.97g
  vg_root   1   1   0 wz--n- 35.75g     0 
[root@rac1 ~]# lvcreate -n testlv -L 5G testvg
  Logical volume "testlv" created
[root@rac1 ~]# lvs
  LV       VG      Attr     LSize  Pool Origin Data%  Move Log Copy%  Convert
  testlv   testvg  -wi-a---  5.00g                                           
  LogVol00 vg_root -wi-ao-- 35.75g                                           
[root@rac1 ~]# #mkfs.ext4 /dev/testvg/testlv
[root@rac1 ~]# mkfs.ext4 /dev/testvg/testlv
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
327680 inodes, 1310720 blocks
65536 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=1342177280
40 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks: 
    32768, 98304, 163840, 229376, 294912, 819200, 884736

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

This filesystem will be automatically checked every 30 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.
[root@rac1 ~]# blkid
/dev/mapper/vg_root-LogVol00: UUID="714741b6-8385-4647-807e-f5a4e3946276" TYPE="ext4" 
/dev/sda1: UUID="46f19ac6-907f-456c-b188-275bf3a77763" TYPE="ext4" 
/dev/sda2: UUID="t3dgsp-ogVH-zypY-v08B-fAGD-MTza-565cT2" TYPE="LVM2_member" 
/dev/sda3: UUID="62e305e8-0f56-4fe8-ad8d-957b14ad7781" TYPE="swap" 
/dev/sdb1: LABEL="TEST" UUID="81e4fa94-9024-484f-9b28-d489529465ed" TYPE="ext4" 
/dev/sdc1: UUID="b0GWgB-CI8s-slT7-M835-jaa7-TmfL-Jv8I6l" TYPE="LVM2_member" 
/dev/sdd1: UUID="j268OB-EvOU-F4iA-hpdJ-E4Hv-4m0F-ZdKdwp" TYPE="LVM2_member" 
/dev/mapper/testvg-testlv: UUID="82f9cd59-eb74-4dd4-af87-3fc8464649ab" TYPE="ext4" 
[root@rac1 ~]# vi /etc/fstab
[root@rac1 ~]# mkdir /users
[root@rac1 ~]# mount -a
[root@rac1 ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/vg_root-LogVol00
                       36G  1.6G   32G   5% /
tmpfs                 932M     0  932M   0% /dev/shm
/dev/sda1             243M   33M  198M  14% /boot
/dev/sdb1             1.9G   35M  1.8G   2% /test
/dev/mapper/testvg-testlv
                      5.0G  138M  4.6G   3% /users


?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末慰毅,一起剝皮案震驚了整個(gè)濱河市屎即,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌事富,老刑警劉巖,帶你破解...
    沈念sama閱讀 211,265評(píng)論 6 490
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件乘陪,死亡現(xiàn)場(chǎng)離奇詭異统台,居然都是意外死亡,警方通過查閱死者的電腦和手機(jī)啡邑,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 90,078評(píng)論 2 385
  • 文/潘曉璐 我一進(jìn)店門贱勃,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人谤逼,你說我怎么就攤上這事贵扰。” “怎么了流部?”我有些...
    開封第一講書人閱讀 156,852評(píng)論 0 347
  • 文/不壞的土叔 我叫張陵戚绕,是天一觀的道長(zhǎng)。 經(jīng)常有香客問我枝冀,道長(zhǎng)舞丛,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 56,408評(píng)論 1 283
  • 正文 為了忘掉前任果漾,我火速辦了婚禮球切,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘绒障。我一直安慰自己吨凑,他們只是感情好,可當(dāng)我...
    茶點(diǎn)故事閱讀 65,445評(píng)論 5 384
  • 文/花漫 我一把揭開白布户辱。 她就那樣靜靜地躺著鸵钝,像睡著了一般。 火紅的嫁衣襯著肌膚如雪焕妙。 梳的紋絲不亂的頭發(fā)上蒋伦,一...
    開封第一講書人閱讀 49,772評(píng)論 1 290
  • 那天,我揣著相機(jī)與錄音焚鹊,去河邊找鬼痕届。 笑死韧献,一個(gè)胖子當(dāng)著我的面吹牛,可吹牛的內(nèi)容都是我干的研叫。 我是一名探鬼主播锤窑,決...
    沈念sama閱讀 38,921評(píng)論 3 406
  • 文/蒼蘭香墨 我猛地睜開眼,長(zhǎng)吁一口氣:“原來是場(chǎng)噩夢(mèng)啊……” “哼嚷炉!你這毒婦竟也來了渊啰?” 一聲冷哼從身側(cè)響起,我...
    開封第一講書人閱讀 37,688評(píng)論 0 266
  • 序言:老撾萬榮一對(duì)情侶失蹤申屹,失蹤者是張志新(化名)和其女友劉穎绘证,沒想到半個(gè)月后,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體哗讥,經(jīng)...
    沈念sama閱讀 44,130評(píng)論 1 303
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡嚷那,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 36,467評(píng)論 2 325
  • 正文 我和宋清朗相戀三年,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了杆煞。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片魏宽。...
    茶點(diǎn)故事閱讀 38,617評(píng)論 1 340
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡,死狀恐怖决乎,靈堂內(nèi)的尸體忽然破棺而出队询,到底是詐尸還是另有隱情,我是刑警寧澤构诚,帶...
    沈念sama閱讀 34,276評(píng)論 4 329
  • 正文 年R本政府宣布蚌斩,位于F島的核電站,受9級(jí)特大地震影響范嘱,放射性物質(zhì)發(fā)生泄漏凳寺。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 39,882評(píng)論 3 312
  • 文/蒙蒙 一彤侍、第九天 我趴在偏房一處隱蔽的房頂上張望肠缨。 院中可真熱鬧,春花似錦盏阶、人聲如沸晒奕。這莊子的主人今日做“春日...
    開封第一講書人閱讀 30,740評(píng)論 0 21
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽脑慧。三九已至,卻和暖如春砰盐,著一層夾襖步出監(jiān)牢的瞬間闷袒,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 31,967評(píng)論 1 265
  • 我被黑心中介騙來泰國打工岩梳, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留囊骤,地道東北人晃择。 一個(gè)月前我還...
    沈念sama閱讀 46,315評(píng)論 2 360
  • 正文 我出身青樓,卻偏偏與公主長(zhǎng)得像也物,于是被迫代替她去往敵國和親宫屠。 傳聞我的和親對(duì)象是個(gè)殘疾皇子,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 43,486評(píng)論 2 348

推薦閱讀更多精彩內(nèi)容