标签 分区 下的文章

AWS上快速创建LVM

名词解释:
PV(Physical Volume) - 物理卷
物理卷在逻辑卷管理中处于最底层,它可以是实际物理硬盘上的分区,也可以是整个物理硬盘,也可以是raid设备

VG(Volume Group) - 卷组
卷组建立在物理卷之上,一个卷组中至少要包括一个物理卷,在卷组建立之后可动态添加物理卷到卷组中。一个逻辑卷管理系统工程中可以只有一个卷组,也可以拥有多个卷组

LV(Logical Volume) - 逻辑卷
逻辑卷建立在卷组之上,卷组中的未分配空间可以用于建立新的逻辑卷,逻辑卷建立后可以动态地扩展和缩小空间。系统中的多个逻辑卷可以属于同一个卷组,也可以属于不同的多个卷组
929849-20180511172228368-364897317.png

创建LVM步骤

添加新硬盘;
给新硬盘创建分区;
创建PV;
创建VG;
创建LV;
格式化LV;
挂载LV到指定目录;

在AWS上创建LVM步骤如下:

1、先在控制台上添加存储;
2、查看添加的硬盘,

[root@hongsinvm ~]# fdisk -l

Disk /dev/nvme1n1: 483.2 GB, 483183820800 bytes, 943718400 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/nvme0n1: 53.7 GB, 53687091200 bytes, 104857600 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: 0x000c7ec9

        Device Boot      Start         End      Blocks   Id  System
/dev/nvme0n1p1   *        2048     2099199     1048576   83  Linux
/dev/nvme0n1p2         2099200    41943039    19921920   8e  Linux LVM

Disk /dev/mapper/centos-root: 18.2 GB, 18249416704 bytes, 35643392 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/mapper/centos-swap: 2147 MB, 2147483648 bytes, 4194304 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

创建lvm 8e分区:

[root@hongsinvm ~]# fdisk /dev/nvme1n1
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.

Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0x56ce9c54.

Command (m for help): o
Building a new DOS disklabel with disk identifier 0x98e04e99.

Command (m for help): p

Disk /dev/nvme1n1: 483.2 GB, 483183820800 bytes, 943718400 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: 0x98e04e99

        Device Boot      Start         End      Blocks   Id  System

Command (m for help): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-943718399, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-943718399, default 943718399):
Using default value 943718399
Partition 1 of type Linux and of size 450 GiB is set

Command (m for help): p

Disk /dev/nvme1n1: 483.2 GB, 483183820800 bytes, 943718400 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: 0x98e04e99

        Device Boot      Start         End      Blocks   Id  System
/dev/nvme1n1p1            2048   943718399   471858176   83  Linux

Command (m for help): t
Selected partition 1
Hex code (type L to list all codes): 8e
Changed type of partition 'Linux' to 'Linux LVM'

Command (m for help): p

Disk /dev/nvme1n1: 483.2 GB, 483183820800 bytes, 943718400 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: 0x98e04e99

        Device Boot      Start         End      Blocks   Id  System
/dev/nvme1n1p1            2048   943718399   471858176   8e  Linux LVM

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

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

重新读取分区

partprobe

创建PV

[root@hongsinvm ~]# pvcreate /dev/nvme1n1p1
  Physical volume "/dev/nvme1n1p1" successfully created.

创建VG

[root@hongsinvm ~]# vgcreate datavg /dev/nvme1n1p1
  Volume group "datavg" successfully created

创建LV

[root@hongsinvm ~]# lvcreate -l 100%free -n datalv datavg
  Logical volume "datalv" created.

格式化LV

[root@hongsinvm ~]# mkfs.ext4 /dev/datavg/datalv
mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
29491200 inodes, 117963776 blocks
5898188 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2267021312
3600 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, 1605632, 2654208,
        4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,
        102400000

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

创建分区并挂载

[root@hongsinvm ~]# mkdir /data
[root@hongsinvm ~]# mount /dev/datavg/datalv /data/
[root@hongsinvm ~]# df -h
Filesystem                 Size  Used Avail Use% Mounted on
devtmpfs                    16G     0   16G   0% /dev
tmpfs                       16G     0   16G   0% /dev/shm
tmpfs                       16G   17M   16G   1% /run
  pfs                       16G     0   16G   0% /sys/fs/cgroup
/dev/mapper/centos-root     17G  1.9G   16G  12% /
/dev/nvme0n1p1            1014M  265M  750M  27% /boot
tmpfs                      3.1G     0  3.1G   0% /run/user/0
/dev/mapper/datavg-datalv  443G   73M  421G   1% /data

加入开机启动

[root@hongsinvm ~]# blkid
/dev/mapper/centos-root: UUID="2489f74a-946e-452a-bf62-1a1890668844" TYPE="xfs"
/dev/nvme0n1p2: UUID="c6AGGx-gtd0-N6XE-5qP2-phqY-V4Hr-BurxpM" TYPE="LVM2_member"
/dev/nvme0n1p1: UUID="75eb43ef-927b-4b24-af8e-bfc46bd0c2c2" TYPE="xfs"
/dev/mapper/centos-swap: UUID="9424b55f-2eb2-4156-b6ea-8d4bacf27d02" TYPE="swap"
/dev/nvme1n1p1: UUID="D0fh8n-ezI3-2Ork-bdAY-d0mE-R8eC-DrtDSy" TYPE="LVM2_member"
/dev/mapper/datavg-datalv: UUID="35c5eb3d-a7a0-4365-9ab9-91e1069c1d65" TYPE="ext4"
/dev/nvme1n1: PTTYPE="dos"
/dev/nvme0n1: PTTYPE="dos"
[root@hongsinvm ~]# vim /etc/fstab

#
# /etc/fstab
# Created by anaconda on Tue Aug 13 06:35:13 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/centos-root /       xfs     defaults        0 0
UUID=75eb43ef-927b-4b24-af8e-bfc46bd0c2c2       /boot   xfs     defaults        0 0
UUID=35c5eb3d-a7a0-4365-9ab9-91e1069c1d65       /data   ext4    defaults        0 0
/dev/mapper/centos-swap swap    swap    defaults        0 0

"/etc/fstab" 12L, 458C written
[root@hongsinvm ~]# df -h
Filesystem                 Size  Used Avail Use% Mounted on
devtmpfs                    16G     0   16G   0% /dev
tmpfs                       16G     0   16G   0% /dev/shm
tmpfs                       16G   17M   16G   1% /run
tmpfs                       16G     0   16G   0% /sys/fs/cgroup
/dev/mapper/centos-root     17G  1.9G   16G  12% /
/dev/nvme0n1p1            1014M  265M  750M  27% /boot
tmpfs                      3.1G     0  3.1G   0% /run/user/0
/dev/mapper/datavg-datalv  443G   73M  421G   1% /data

Linux查看文件系统分区格式类型的几个方法

fstab 记录了计算机上硬盘分区的相关信息,启动 Linux 的时候,检查分区的 fsck 命令,和挂载分区的 mount 命令,都需要 fstab 中的信息,来正确的检查和挂载硬盘。
/etc/mtab 和 fstab 文件的结构和内容基本相同,但是不同的是,mtab 文件记录的是,当前已挂载的分区信息。
每当 mount 挂载分区、umount 卸载分区,都会动态更新 mtab,mtab 总是保持着当前系统中已挂载的分区信息,fdisk、df 这类程序,必须要读取 mtab 文件,才能获得当前系统中的分区挂载情况。
使用df -hT命令查看

[root@ops163 ~]# df -hT
Filesystem     Type      Size  Used Avail Use% Mounted on
/dev/vda2      xfs        20G  1.2G   19G   6% /
devtmpfs       devtmpfs  7.8G     0  7.8G   0% /dev
tmpfs          tmpfs     7.8G     0  7.8G   0% /dev/shm
tmpfs          tmpfs     7.8G  8.4M  7.8G   1% /run
tmpfs          tmpfs     7.8G     0  7.8G   0% /sys/fs/cgroup
/dev/vda5      xfs       172G   33M  172G   1% /data
/dev/vda1      xfs       473M  168M  305M  36% /boot
tmpfs          tmpfs     1.6G     0  1.6G   0% /run/user/0



---阅读剩余部分---

DEBUG - file: tracker_proto.c, line: 48, server: 192.168.x.x:22122, response status 28 != 0解决方法

测试fasdfs上传图片的时候报错,如下:

[fastdfs@test_dev_fastdfs_32 tmp]$ /usr/local/bin/fdfs_test /etc/fdfs/client.conf upload /tmp/11.png 
This is FastDFS client test program v4.06

Copyright (C) 2008, Happy Fish / YuQing

FastDFS may be copied only under the terms of the GNU General
Public License V3, which may be found in the FastDFS source kit.
Please visit the FastDFS Home Page http://www.csource.org/ 
for more detail.

[2017-10-10 10:05:30] DEBUG - base_path=/file/fastdfs_group5, connect_timeout=30, network_timeout=60, tracker_server_count=1, anti_steal_token=0, anti_steal_secret_key length=0, use_connection_pool=0, g_connection_pool_max_idle_time=3600s, use_storage_id=0, storage server id count: 0

[2017-10-10 10:05:30] DEBUG - file: tracker_proto.c, line: 48, server: 192.168.121.32:22122, response status 28 != 0
[2017-10-10 10:05:30] DEBUG - file: tracker_proto.c, line: 48, server: 192.168.121.32:22122, response status 28 != 0
tracker_query_storage fail, error no: 28, error info: No space left on device

故障分析:
使用df查看硬盘空间


---阅读剩余部分---

CentOS6.9安装Oracle 11g Release 2、创建监听、实例全记录

系统版本:CentOS release 6.9 (Final)
Oracle版本:Oracle Database 11g Release 2 (11.2.0.1.0)
Oracle 11g Release 2下载地址:http://www.oracle.com/technetwork/database/enterprise-edition/downloads/112010-linx8664soft-100572.html

一、初始化系统

系统安装时建议采用mini版,单独分区/data用来安装oracle数据库,关闭SELinux,getsebool: SELinux is disabled

cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime    #修改时区为上海
*/30 * * * * /usr/sbin/ntpdate pool.ntp.org   #加入定时任务,30分钟更新一次时间
cat <<EOF>> /etc/security/limits.conf
* soft nofile 65535
* hard nofile 65535
* soft nproc 65535
* hard nproc 65535
EOF
sed -i "s/1024/65535/g" /etc/security/limits.d/90-nproc.conf
#修改文件句柄数


---阅读剩余部分---

This is a prerequisite condition to test whether sufficient total swap space is available on the system解决方法

安装oracle的时候swap空间设置太小,会报This is a prerequisite condition to test whether sufficient total swap space is available on the system. (more details)
Expected Value
: 15.64GB (1.6403472E7KB) 16400000
Actual Value
: 4.87GB (5111800.0KB)
类似于上面的错误,
原因是swap空间设置太小,比如内存是8G设置swap为4G就会出现这个报错,解决办法扩展swap空间即可:
方法如下:
使用dd命令创建一个4G大小的swap分区
dd if=/dev/zero of=/data/swap bs=1M count=4096

格式化刚才创建的分区
mkswap /data/swap

再使用swapon命令把这个文件分区变成swap分区
swapon /data/swap

关闭SWAP分区的命令为:swapoff /data/swap

再用free -m 查看已经扩容的了swap分区。

让swap自动挂载,需要修改etc/fstab文件, vi /etc/fstab
在文件末尾加上 /data/swap swap swap default 0 0即可。

CentOS清理/boot分区空间

  装系统的时候给/boot分区空间是200M,升级内核以后发现boot分区空间不到20M了,yum update不能安装,解决方法如下:

rpm -q kernel
查看当前安装内核版本

保留一个,一般保留较新的,然后卸载其他不要的内核即可

rpm -e kernel-3.10.0-514.10.2.el7.x86_64

会提示
warning: file /boot/symvers-3.10.0-514.10.2.el7.x86_64.gz: remove failed: No such file or directory

忽略,然后df查看空间boot分区空间已经释放出来了·

azure升级hyper-v驱动Linux Integration Services到4.1

azure上普通磁盘,大于1T的时候分区很慢,升级LIS到4.1以后速度会提升,参加微软说明文档页面https://www.microsoft.com/en-us/download/details.aspx?id=51612

1.下载最新的驱动:https://www.microsoft.com/en-us/search/result.aspx?q=Linux+Integration+Services+Version&form=dlc
下载回来的文件是lis-rpms-4.1.3-2.tar.gz
20170412132902.png

2.查看当前的版本:

modinfo hv_vmbus
tar xvf lis-rpms-4.1.3-2.tar.gz
cd LISISO
./install.sh


---阅读剩余部分---

Linux手动创建Swap交换分区及Swap说明

Swap分区在系统的物理内存不够用的时候,把硬盘空间中的一部分空间释放出来,以供当前运行的程序使用。那些被释放的空间可能来自一些很长时间没有什么操作的程序,这些被释放的空间被临时保存到 Swap 分区中,等到那些程序要运行时,再从 Swap 分区中恢复保存的数据到内存中;一种是将文件作为 Swap 分区,一种是将分区作为 Swap 分区,将分区作为 Swap 分区相比于文件更优。

RHEL 6.8 的建议如下,当然还是需要根据实际情况进行适当调整:

---阅读剩余部分---

最新

分类

归档

评论

其它