linux学习笔记(六)

1、自建yum仓库,分别为网络源和本地源

网络源

## 阿里云镜像地址为例
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,实现可以正常访问,并将编译步骤和结果提交

(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)启动

/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、创建一个2G的文件系统,块大小为2048byte,预留1%可用空间,文件系统 ext4,卷标为TEST,要求此分区开机后自动挂载至/test目录,且默认有acl挂载选项

##命令
### 划分磁盘
fdisk /dev/sdb
(n-->p-->+1932M-->w)
### 格式化ext4文件格式
mkfs.ext4 /dev/sdb1
### 打卷标
e2label /dev/sdb1 TEST
### 查看卷标
 blkid
###创建挂载点目录
 mkdir /test
### 编辑配置开机自动挂载
 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、创建一个至少有两个PV组成的大小为20G的名为testvg的VG;要求PE大小 为16MB, 而后在卷组中创建大小为5G的逻辑卷testlv;挂载至/users目录

#查看磁盘
 lsblk
#划分第一块盘
 fdisk /dev/sdc
#划分第二块盘 
fdisk /dev/sdd
#创建pv
 pvcreate /dev/sdc1
 pvcreate /dev/sdd1
#创建vg
 vgcreate -s 16M testvg /dev/sdc1 /dev/sdd1
#查看vg
 vgs
#创建lv卷组
 lvcreate -n testlv -L 5G testvg
#查看lv信息
 lvs                                 
#格式化
 mkfs.ext4 /dev/testvg/testlv
#查看磁盘信息uuid
 blkid
#添加自动挂载
 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


©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 204,445评论 6 478
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 85,889评论 2 381
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 151,047评论 0 337
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 54,760评论 1 276
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 63,745评论 5 367
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,638评论 1 281
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 38,011评论 3 398
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,669评论 0 258
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 40,923评论 1 299
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,655评论 2 321
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,740评论 1 330
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,406评论 4 320
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 38,995评论 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,961评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,197评论 1 260
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 45,023评论 2 350
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,483评论 2 342

推荐阅读更多精彩内容