腳本又見腳本,作業又是作業_第七周

1、創建一個10G分區,并格式為ext4文件系統;

(1) 要求其block大小為2048, 預留空間百分比為2, 卷標為MYDATA, 默認掛載屬性包含acl;

(2) 掛載至/data/mydata目錄,要求掛載時禁止程序自動運行,且不更新文件的訪問時間戳;

[root@centos ~]# fdisk -l   #馬哥說不寫注釋的都是耍流氓

Disk /dev/sda: 171.8 GB, 171798691840 bytes
255 heads, 63 sectors/track, 20886 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: 0x00098b32

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          64      512000   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              64       20887   167259136   8e  Linux LVM

Disk /dev/sdb: 10.7 GB, 10737418240 bytes   #創建一個10G分區
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: 0x00000000


Disk /dev/mapper/vg_centos-lv_root: 170.2 GB, 170196467712 bytes
255 heads, 63 sectors/track, 20691 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_centos-lv_swap: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 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@centos ~]# 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 0x248136bc.
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): wq
The partition table has been altered!

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

Disk /dev/sda: 171.8 GB, 171798691840 bytes
255 heads, 63 sectors/track, 20886 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: 0x00098b32

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          64      512000   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              64       20887   167259136   8e  Linux LVM

Disk /dev/sdb: 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: 0x248136bc

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

Disk /dev/mapper/vg_centos-lv_root: 170.2 GB, 170196467712 bytes
255 heads, 63 sectors/track, 20691 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_centos-lv_swap: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 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@centos ~]# mkfs -b 2048 -t ext4 -L MYDATA -m 2 /dev/sdb1  #格式為ext4文件系統,其block大小為2048, 預留空間百分比為2, 卷標為MYDATA
mke2fs 1.41.12 (17-May-2010)
文件系統標簽=MYDATA
操作系統:Linux
塊大小=2048 (log=1)
分塊大小=2048 (log=1)
Stride=0 blocks, Stripe width=0 blocks
655360 inodes, 5241190 blocks
262059 blocks (5.00%) reserved for the super user
第一個數據塊=0
Maximum filesystem blocks=542113792
320 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, 1327104, 
    2048000, 3981312

正在寫入inode表: 完成                            
Creating journal (32768 blocks): 完成
Writing superblocks and filesystem accounting information: 完成

This filesystem will be automatically checked every 20 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.

[root@centos ~]# tune2fs -o acl /dev/sdb1  #默認掛載屬性包含acl
tune2fs 1.41.12 (17-May-2010)
[root@centos ~]# mkdir -p /data/mydata && mount -o noexec,noatime /dev/sdb1 /data/mydata #掛載至/data/mydata目錄,要求掛載時禁止程序自動運行,且不更新文件的訪問時間戳
[root@centos ~]# echo $? 
0
[root@centos ~]# cd /data/
[root@centos data]# ll
總用量 2
drwxr-xr-x 3 root root 2048 12月 26 17:36 mydata
[root@centos data]# cd mydata/
[root@centos mydata]# ll
總用量 16
drwx------ 2 root root 16384 12月 26 17:36 lost+found
[root@centos mydata]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/vg_centos-lv_root
                      156G  3.8G  145G   3% /
tmpfs                 1.9G   72K  1.9G   1% /dev/shm
/dev/sda1             477M  160M  292M  36% /boot
/dev/sdb1             9.8G   13M  9.3G   1% /data/mydata
[root@centos mydata]#

2、創建一個大小為1G的swap分區,并創建好文件系統,并啟用之;

[root@centos ~]# 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 0x70af3aab.
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)

Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-130, default 1): 
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-130, default 130): 
Using default value 130

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

Calling ioctl() to re-read partition table.
Syncing disks.

[root@centos ~]# mkswap /dev/sdb1
Setting up swapspace version 1, size = 1044188 KiB
no label, UUID=85de9eea-a86d-48f4-a24d-00615a9812f8
[root@centos ~]# swapon /dev/sdb1 
[root@centos ~]# free -m
             total       used       free     shared    buffers     cached
Mem:          3816        517       3299          1         27        289
-/+ buffers/cache:        200       3615
Swap:         1019          0       1019
[root@centos ~]# echo "/dev/sdb1 swap swap defaults 0 0" >> /etc/fstab #swap現已加入開機掛載全家桶!

3、寫一個腳本

(1)、獲取并列出當前系統上的所有磁盤設備;(2)、顯示每個磁盤設備上每個分區相關的空間使用信息;

[root@centos gogogogogogogogoo]# cat DiskInfo_Jerry.sh  #馬哥說過,腳本就是命令的拼湊,所以,命令學好,腳本風騷。
#!/bin/bash
#Author: Jerry
lsblk
df -ahT

[root@centos gogogogogogogogoo]# bash DiskInfo_Jerry.sh 
NAME                          MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda                             8:0    0   160G  0 disk 
├─sda1                          8:1    0   500M  0 part /boot
└─sda2                          8:2    0 159.5G  0 part 
  ├─vg_centos-lv_root (dm-0)  253:0    0 158.5G  0 lvm  /
  └─vg_centos-lv_swap (dm-1)  253:1    0     1G  0 lvm  
sdb                             8:16   0    10G  0 disk 
└─sdb1                          8:17   0    10G  0 part 
  ├─vg_mage-mylv1-real (dm-3) 253:3    0     5G  0 lvm  
  │ ├─vg_mage-mylv1 (dm-2)    253:2    0     5G  0 lvm  
  │ └─vg_mage-snvg1 (dm-5)    253:5    0     5G  1 lvm  
  └─vg_mage-snvg1-cow (dm-4)  253:4    0   160M  1 lvm  
    └─vg_mage-snvg1 (dm-5)    253:5    0     5G  1 lvm  
sdc                             8:32   0    60G  0 disk 
└─sdc1                          8:33   0    60G  0 part 

Filesystem           Type                 Size  Used Avail Use% Mounted on
/dev/mapper/vg_centos-lv_root
                     ext4                 156G  3.4G  145G   3% /
proc                 proc                    0     0     0    - /proc
sysfs                sysfs                   0     0     0    - /sys
devpts               devpts                  0     0     0    - /dev/pts
tmpfs                tmpfs                1.9G   68K  1.9G   1% /dev/shm
/dev/sda1            ext4                 477M   35M  418M   8% /boot
/dev/mapper/vg_mage-mylv1
                     ext4                 4.8G   10M  4.6G   1% /users
none                 binfmt_misc             0     0     0    - /proc/sys/fs/binfmt_misc
vmware-vmblock       fuse.vmware-vmblock     0     0     0    - /var/run/vmblock-fuse

[root@centos gogogogogogogogoo]#

4、總結RAID的各個級別及其組合方式和性能的不同;

    RAID-0: 
        讀、寫性能提升;
        可用空間:N*min(S1,S2,...)
        無容錯能力
        最少磁盤數:2, 2+

    RAID-1:
        讀性能提升、寫性能略有下降;
        可用空間:1*min(S1,S2,...)
        有冗余能力
        最少磁盤數:2, 2+

    RAID-4:
        1101, 0110, 1011

    RAID-5:
        讀、寫性能提升
        可用空間:(N-1)*min(S1,S2,...)
        有容錯能力:1塊磁盤
        最少磁盤數:3, 3+

    RAID-6:
        讀、寫性能提升
        可用空間:(N-2)*min(S1,S2,...)
        有容錯能力:2塊磁盤
        最少磁盤數:4, 4+


    混合類型
        RAID-10:
            讀、寫性能提升
            可用空間:N*min(S1,S2,...)/2
            有容錯能力:每組鏡像最多只能壞一塊;
            最少磁盤數:4, 4+

5、創建一個大小為10G的RAID1,要求有一個空閑盤,而且CHUNK大小為128k;

生產環境都是用服務器自帶的磁盤陣列卡來做raid,具體詳見各廠商的操作文檔,此題我就跳過了,請老濕原諒我的直接。

6、創建一個大小為4G的RAID5設備,chunk大小為256k,格式化ext4文件系統,要求可開機自動掛載至/backup目錄,而且不更新訪問時間戳,且支持acl功能;

生產環境都是用服務器自帶的磁盤陣列卡來做raid,具體詳見各廠商的操作文檔,此題我就跳過了,請老濕原諒我的直接。
更新訪問時間戳我要說一下,生產環境一般都是要更新訪問時間戳的

7、寫一個腳本,(1) 接受一個以上文件路徑作為參數;(2) 顯示每個文件擁有的行數;(3) 總結說明本次共為幾個文件統計了其行數;

[root@centos gogogogogogogogoo]# bash Sum_wc-l.sh /etc/ssh/sshd_config /etc/fstab /etc/rc.local 
Number of rows in /etc/ssh/sshd_config is 138
Number of rows in /etc/fstab is 16
Number of rows in /etc/rc.local is 7
total of 3  files
[root@centos gogogogogogogogoo]# cat Sum_wc-l.sh 
#!/bin/bash
#
if [ $# -lt 1 ];then
    echo "At least one filesname "
    exit 2
fi

    for i in $*;do
       line=$(cat $i | wc -l)
       echo "Number of rows in $i is $line"
    done 

echo "total of $#  files"
[root@centos gogogogogogogogoo]#

8、寫一個腳本 (1) 傳遞兩個以上字符串當作用戶名;(2) 創建這些用戶;且密碼同用戶名;(3) 總結說明共創建了幾個用戶;

[root@centos gogogogogogogogoo]# bash Creat_user.sh 
At least two username 
[root@centos gogogogogogogogoo]# bash Creat_user.sh abb1 abb2 abb3 abb4
Add user abb1 finished
Add user abb2 finished
Add user abb3 finished
Add user abb4 finished
total of Create 4 users
[root@centos gogogogogogogogoo]# cat Creat_user.sh 
#!/bin/bash

if [ $# -lt 2 ];then
    echo "At least two username "
    exit 2
fi    

    for i in $*;do
        if grep "^$i\>" /etc/passwd &> /dev/null;then

            echo "User $i exists"
    else
        useradd $i
            echo $i | passwd --stdin $i &> /dev/null
            echo "Add user $i finished"
        fi

    done 

echo "total of Create $# users"
[root@centos gogogogogogogogoo]#

9、寫一個腳本,新建20個用戶,visitor1-visitor20;計算他們的ID之和;

[root@centos gogogogogogogogoo]# bash sum_userid.sh 
The users ID sum is: 10330
[root@centos gogogogogogogogoo]# cat sum_userid.sh 
#!/bin/bash

num=0

for i in {1..20};do
    if id visitor$i &> /dev/null;then
    echo "visitor$i exists"
        else
            useradd visitor$i
        id=$(grep "^visitor$i\>" /etc/passwd | cut -d: -f 3)
        let num+=$id
    fi
done

echo "The users ID sum is: $num"
[root@centos gogogogogogogogoo]#

10、寫一腳本,分別統計/etc/rc.d/rc.sysinit、/etc/rc.d/init.d/functions和/etc/fstab文件中以#號開頭的行數之和,以及總的空白行數;

[root@centos jerry_go]# cat title10-2.sh 
#!/bin/bash
#Author:Jerry
#Description
#
#

    if [ -e $1 ]; then
        jinghao1=$(grep "^#" $1 | wc -l)
        blank_line1=$(grep "^$" $1 | wc -l)
        echo "The file $1 Jinghao_lines:$jinghao1    Blank_lines:$blank_line1  " 
    else
        echo "The file $1 no exist"
        exit 2
    fi


    if [ -e $2 ]; then
        jinghao2=$(grep "^#" $2 | wc -l)
        blank_line2=$(grep "^$" $2 | wc -l)
        echo "The file $2 Jinghao_lines:$jinghao2    Blank_lines:$blank_line2  " 
    else
        echo "The file $2 no exist"
        exit 2
   fi


    if [ -e $3 ]; then
        jinghao3=$(grep "^#" $3 | wc -l)
        blank_line3=$(grep "^$" $3 | wc -l)
        echo "The file $3 Jinghao_lines:$jinghao3    Blank_lines:$blank_line3  "  
    else
        echo "The file $3 no exist"
        exit 2
    fi

    echo "Total jinghao lines: $[$jinghao1+$jinghao2+$jinghao3]"   
    echo "Total blank lines: $[$blank_line1+$blank_line2+$blank_line3]" && exit 0  

走一個!come on baby!
[root@centos jerry_go]# bash title10-2.sh /etc/rc.d/rc.sysinit /etc/rc.d/init.d/functions /etc/fstab 
The file /etc/rc.d/rc.sysinit Jinghao_lines:44    Blank_lines:100  
The file /etc/rc.d/init.d/functions Jinghao_lines:43    Blank_lines:105  
The file /etc/fstab Jinghao_lines:8    Blank_lines:1  
Total jinghao lines: 95
Total blank lines: 206
[root@centos jerry_go]# 

異常的走一個! 歐耶!
[root@centos jerry_go]# bash title10-2.sh /etc/rc.d/rc.sysinit /etc/rc.d/init.d/funct234ions /etc/fstab 
The file /etc/rc.d/rc.sysinit Jinghao_lines:44    Blank_lines:100  
The file /etc/rc.d/init.d/funct234ions no exist
[root@centos jerry_go]#

異常的再走一個!    
[root@centos jerry_go]# bash title10-2.sh /etc/rc.d/rc.sysinit /etc/rc.d/init.d/functions /etc/fst123ab 
The file /etc/rc.d/rc.sysinit Jinghao_lines:44    Blank_lines:100  
The file /etc/rc.d/init.d/functions Jinghao_lines:43    Blank_lines:105  
The file /etc/fst123ab no exist
[root@centos jerry_go]# 

最后發現井號的英文是well number , 腳本里面用拼音實在是很low,不過我是剛開始嘛,who care......

11、寫一個腳本,顯示當前系統上所有默認shell為bash的用戶的用戶名、UID以及此類所有用戶的UID之和;

[root@centos jerry_go]# cat week7_title11.sh
#!/bin/bash
#Author:Jerry
#Description
#
#

grep "bin/bash$" /etc/passwd  |cut -d":" -f1,3

for i in `grep "bin/bash$" /etc/passwd  |awk -F ":" '{print $3}'`;do
    let sum+=$i
done

 echo "Users ID sum is:$sum"

[root@centos jerry_go]# bash week7_title11.sh 
root:0
magedu:500
mamamamam:501
magedu1:502
abb1:503
abb2:504
abb3:505
abb4:506
visitor1:507
visitor2:508
visitor3:509
visitor4:510
visitor5:511
visitor6:512
visitor7:513
visitor8:514
visitor9:515
visitor10:516
visitor11:517
visitor12:518
visitor13:519
visitor14:520
visitor15:521
visitor16:522
visitor17:523
visitor18:524
visitor19:525
visitor20:526
Users ID sum is:13851

12、寫一個腳本,顯示當前系統上所有,擁有附加組的用戶的用戶名;并說明共有多少個此類用戶;

[root@centos jerry_go]# bash week7_title12.sh 
bin
daemon
sys
adm
lp
mail
haldaemon
This users has 7.

[root@centos jerry_go]# cat week7_title12.sh 
#!/bin/bash
#Author:Jerry
#Description
#

grep -v ":$" /etc/group |awk -F ":" '{print $1}'
echo "This users has $(grep -v ":$" /etc/group |awk -F ":" '{print $1}'|wc -l)."
[root@centos jerry_go]#

13、創建一個由至少兩個物理卷組成的大小為20G的卷組;要求,PE大小為8M;而在卷組中創建一個大小為5G的邏輯卷mylv1,格式化為ext4文件系統,開機自動掛載至/users目錄,支持acl;

[root@centos ~]# pvdisplay   #先看看環境
  --- Physical volume ---
  PV Name               /dev/sda2
  VG Name               vg_centos
  PV Size               159.51 GiB / not usable 3.00 MiB
  Allocatable           yes (but full)
  PE Size               4.00 MiB
  Total PE              40834
  Free PE               0
  Allocated PE          40834
  PV UUID               1O2YO5-7puR-3Pfu-nR15-tqCc-JjPN-giIZeh

  "/dev/sdb1" is a new physical volume of "10.00 GiB"
  --- NEW Physical volume ---
  PV Name               /dev/sdb1
  VG Name               
  PV Size               10.00 GiB
  Allocatable           NO
  PE Size               0   
  Total PE              0
  Free PE               0
  Allocated PE          0
  PV UUID               dmUkps-1j6e-q50O-yOh8-nBlT-lw6t-nGKnat

  "/dev/sdc1" is a new physical volume of "60.00 GiB"
  --- NEW Physical volume ---
  PV Name               /dev/sdc1
  VG Name               
  PV Size               60.00 GiB
  Allocatable           NO
  PE Size               0   
  Total PE              0
  Free PE               0
  Allocated PE          0
  PV UUID               WfoY2H-efkl-qx0z-Yetm-wyV0-3lUU-u815Aq

[root@centos ~]# vgcreate -s 8m vg_mage /dev/sdb1 /dev/sdc1  #創建一個由至少兩個物理卷組成的大小為20G的卷組,我這里不止了,無傷大雅。
  Volume group "vg_mage" successfully created
[root@centos ~]# lvcreate -L 5G -n mylv1 vg_mage && mkfs.ext4 /dev/vg_mage/mylv1 #在卷組中創建一個大小為5G的邏輯卷mylv1,格式化為ext4文件系統
[root@centos ~]# mkdir /users && echo "/dev/vg_mage/mylv1 /users ext4 defaults,acl 0 0" >> /etc/fstab  #自動掛載至/users目錄,支持acl
[root@centos ~]# cat /etc/fstab 

#
# /etc/fstab
# Created by anaconda on Thu Jun 23 18:40:21 2016
#
# 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_centos-lv_root /                       ext4    defaults        1 1
UUID=7b714956-acd7-44cb-af53-4eacde793fd9 /boot                   ext4    defaults        1 2
#/dev/mapper/vg_centos-lv_swap 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/vg_mage/mylv1 /users ext4 defaults,acl 0 0

 [root@centos ~]#

14、新建用戶magedu;其家目錄為/users/magedu,而后su切換至此用戶,復制多個文件至家目錄;

[root@centos ~]# useradd magedu -d /users/magedu
[root@centos ~]# su - magedu
[magedu@centos ~]$ cp /etc/*.conf ~
[magedu@centos ~]$ ls -al
總用量 188
drwx------  4 magedu magedu  4096 12月 27 12:52 .
drwxr-xr-x. 4 root   root    4096 12月 27 12:48 ..
-rw-r--r--  1 magedu magedu   148 12月 27 12:52 asound.conf
-rw-r--r--  1 magedu magedu    18 5月  11 2016 .bash_logout
-rw-r--r--  1 magedu magedu   176 5月  11 2016 .bash_profile
-rw-r--r--  1 magedu magedu   124 5月  11 2016 .bashrc
-rw-r--r--  1 magedu magedu  1780 12月 27 12:52 cas.conf
-rw-r--r--  1 magedu magedu 21214 12月 27 12:52 dnsmasq.conf
-rw-r--r--  1 magedu magedu   519 12月 27 12:52 dracut.conf
-rw-r--r--  1 magedu magedu    20 12月 27 12:52 fprintd.conf
-rw-r--r--  1 magedu magedu     0 12月 27 12:52 gai.conf
drwxr-xr-x  2 magedu magedu  4096 11月 12 2010 .gnome2
-rw-r--r--  1 magedu magedu     9 12月 27 12:52 host.conf
-rw-r--r--  1 magedu magedu     0 12月 27 12:52 init.conf
-rw-r--r--  1 magedu magedu  8120 12月 27 12:52 kdump.conf
-rw-r--r--  1 magedu magedu   449 12月 27 12:52 krb5.conf
-rw-r--r--  1 magedu magedu  1662 12月 27 12:52 latrace.conf
-rw-r--r--  1 magedu magedu    47 12月 27 12:52 ld.so.conf
-rw-r--r--  1 magedu magedu  2293 12月 27 12:52 libuser.conf
-rw-r--r--  1 magedu magedu   662 12月 27 12:52 logrotate.conf
-rw-r--r--  1 magedu magedu 10814 12月 27 12:52 ltrace.conf
-rw-r--r--  1 magedu magedu   827 12月 27 12:52 mke2fs.conf
drwxr-xr-x  4 magedu magedu  4096 6月  23 2016 .mozilla
-rw-r--r--  1 magedu magedu  2620 12月 27 12:52 mtools.conf
-rw-r--r--  1 magedu magedu  1688 12月 27 12:52 nsswitch.conf
-rw-r--r--  1 magedu magedu  1698 12月 27 12:52 ntp.conf
-rw-r--r--  1 magedu magedu   370 12月 27 12:52 pm-utils-hd-apm-restore.conf
-rw-r--r--  1 magedu magedu   789 12月 27 12:52 prelink.conf
-rw-r--r--  1 magedu magedu   966 12月 27 12:52 readahead.conf
-rw-r--r--  1 magedu magedu    81 12月 27 12:52 resolv.conf
-rw-r--r--  1 magedu magedu  2875 12月 27 12:52 rsyslog.conf
-rw-r--r--  1 magedu magedu   216 12月 27 12:52 sestatus.conf
-rw-r--r--  1 magedu magedu  6717 12月 27 12:52 smartd.conf
-rw-r--r--  1 magedu magedu   256 12月 27 12:52 sos.conf
-rw-r--r--  1 magedu magedu  1800 12月 27 12:52 sysctl.conf
-rw-r--r--  1 magedu magedu  1309 12月 27 12:52 tpvmlp.conf
-rw-r--r--  1 magedu magedu    45 12月 27 12:52 Trolltech.conf
-rw-r--r--  1 magedu magedu   485 12月 27 12:52 updatedb.conf
-rw-r--r--  1 magedu magedu  3008 12月 27 12:52 warnquota.conf
-rw-r--r--  1 magedu magedu   969 12月 27 12:52 yum.conf
[magedu@centos ~]$

15、擴展mylv1至9G,確保擴展完成后原有數據完全可用;

lvextend -L +4G /dev/mapper/myvg-mylv1 
resize2fs /dev/mapper/myvg-mylv1

16、縮減mylv1至7G,確??s減完成后原有數據完全可用;

# umount /dev/vg_mage/mylv1
# e2fsck -f /dev/vg_mage/mylv1
# resize2fs /dev/vg_mage/mylv11 7G
# lvreduce -L 7G /dev/vg_mage/mylv1
# mount /dev/vg_mage/mylv1 /users/

17、對mylv1創建快照,并通過備份數據;要求保留原有的屬主屬組等信息;

[root@centos users]# lvcreate -s -l 20 -n snvg1 -p r /dev/vg_mage/mylv1
Logical volume "snvg1" created.

原創文章,作者:N24_Jerry,如若轉載,請注明出處:http://www.www58058.com/65351

(0)
N24_JerryN24_Jerry
上一篇 2016-12-30 15:50
下一篇 2016-12-30 17:46

相關推薦

  • 第七周

    第七周 1 創建一個10G分區,并格式為ext4文件系統;    (1) 要求其block大小為2048, 預留空間百分比為2, 卷標為MYDATA, 默認掛載屬性包含acl;    (2) 掛載至/data/mydata目錄,要求掛載時禁止程序自動…

    Linux干貨 2017-02-20
  • CentOS 7 RPM包方式安裝LAMP

    細節要求: (1) 三者分離于兩臺主機; (2) 一個虛擬主機用于提供phpMyAdmin;另一個虛擬主機用于提供wordpress; (3) 提供xcache加速; (4) 為phpMyAdmin提供https虛擬主機; 一、準備CentOS 7主機環境以及Repo倉庫提供基于rpm安裝包方式的程序包安裝源 安裝主機程序包規劃: 主機1:web-serve…

    Linux干貨 2017-02-16
  • heartbeat2+crm+hb_gui接口,配置高可用httpd,mysql,lvs-director

    heartbeat2使用crm借助gui界面配置httpd服務     1. 服務大體資源構架:          1) 兩臺httpd服務,外加一臺nfs共享存儲服務。     &nbsp…

    Linux干貨 2016-01-13
  • 集群-基礎知識(2)

    負載均衡集群實現方法: 1、硬件方式 F5,CITRX,NETSCALER,A10(價格逐漸降低,由于為了防止調度器成為單點故障,所以要配置一臺備用設備,所以造價更高了) 2、軟件方式 四層:LVS(根據請求的ip和端口來分發),性能好,但對高級特性支持不好。 七層(反向代理):Nginx(http,smtp,pop3,imap),Haproxy(主要是ht…

    Linux干貨 2015-11-26
  • linux學習的環境構建

    俗話說磨刀不誤砍柴工,所以在加入馬哥linux培訓班后第一件事情就是構建學習環境。在這里把一些心得分享給大家。 1:通過測試比較服務器選擇運行ESXI6.0的虛擬機。剛開始準備采用微軟的Hyper-v的,但是管理Hyper-v需要域環境(工作組環境下雖然也可以管理,但是配置復雜和安全性很低),額外的增加了系統開銷所以果斷放棄。 2:通過網絡獲得Esxi6.0…

    Linux干貨 2016-02-28
  • 從Linux小白到大牛——與狼共舞的日子2

    馬哥教育網絡班21期+第2周課程練習 1、Linux上的文件管理類命令都有哪些,其常用的使用方法及其相關示例演示。 cp:copy,復制文件 cp SRC DEST   SRC為文件     如果目錄不存在:新建DEST,并將SRC中內容填充至DEST中     如果目…

    Linux干貨 2016-07-17

評論列表(2條)

  • 馬哥教育
    馬哥教育 2017-01-04 16:17

    寫的很棒,排版也很棒,為什么下面的沒有注釋了那?

    • N24_Jerry
      N24_Jerry 2017-01-04 16:19

      @馬哥教育(⊙o⊙)……. 開始耍流氓了

欧美性久久久久