风信建站新开发项目应用于Linux服务器,操作系统为CentOS Linux 8.2,下面我们将新购服务器进行的一些初始化操作及配置相关运行环境,便于新项目的运行。
[root@iZbp1emne76ykf63euczfpZ ~]# cat /etc/redhat-release
CentOS Linux release 8.2.2004 (Core)
1、查看磁盘目前的初始情况
[root@iZbp1emne76ykf63euczfpZ ~]# fdisk -l
Disk /dev/vda: 20 GiB, 21474836480 bytes, 41943040 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
Disklabel type: dos
Disk identifier: 0x4500abcf
Device Boot Start End Sectors Size Id Type
/dev/vda1 * 2048 41943039 41940992 20G 83 Linux
Disk /dev/vdb: 40 GiB, 42949672960 bytes, 83886080 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
2、对/dev/vdb磁盘进行初始化
[root@iZbp1emne76ykf63euczfpZ ~]# fdisk /dev/vdb
Welcome to fdisk (util-linux 2.32.1).
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.
Created a new DOS disklabel with disk identifier 0x8333cdc4.
输入命令(输入“n”,按“Enter”,开始新建分区)
Command (m for help): n
Partition type
p primary (0 primary, 0 extended, 4 free)
e extended (container for logical partitions)
输入命令(输入“p”,按“Enter”,开始新建主分区)
Select (default p): p
输入命令(输入主分区编号“1”,按“Enter”)
Partition number (1-4, default 1): 1
First sector (2048-83886079, default 2048):
Last sector, +sectors or +size{K,M,G,T,P} (2048-83886079, default 83886079):
Created a new partition 1 of type 'Linux' and of size 40 GiB.
输入命令(输入“p”,按“Enter”),查看新建分区的详细信息
Command (m for help): p
Disk /dev/vdb: 40 GiB, 42949672960 bytes, 83886080 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
Disklabel type: dos
Disk identifier: 0x8333cdc4
Device Boot Start End Sectors Size Id Type
/dev/vdb1 2048 83886079 83884032 40G 83 Linux
输入命令(输入“w”,按“Enter”),保存分区表信息。
Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
3、设置/dev/vdb1数据盘文件系统的格式
[root@iZbp1emne76ykf63euczfpZ ~]# mkfs -t ext4 /dev/vdb1
mke2fs 1.45.4 (23-Sep-2019)
Creating filesystem with 10485504 4k blocks and 2621440 inodes
Filesystem UUID: c2f07f3a-a93d-4e29-8d2b-7326f66fbf39
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624
Allocating group tables: done
Writing inode tables: done
Creating journal (65536 blocks): done
Writing superblocks and filesystem accounting information: done
4、设置挂载的目录
[root@iZbp1emne76ykf63euczfpZ /]# mkdir www
5、将/dev/vdb1数据盘挂载到www目录
[root@iZbp1emne76ykf63euczfpZ /]# mount /dev/vdb1 /www
6、挂载成功之后,查看挂载结果
[root@iZbp1emne76ykf63euczfpZ /]# df -TH
Filesystem Type Size Used Avail Use% Mounted on
devtmpfs devtmpfs 888M 0 888M 0% /dev
tmpfs tmpfs 904M 0 904M 0% /dev/shm
tmpfs tmpfs 904M 484k 904M 1% /run
tmpfs tmpfs 904M 0 904M 0% /sys/fs/cgroup
/dev/vda1 xfs 22G 2.8G 19G 13% /
tmpfs tmpfs 181M 0 181M 0% /run/user/0
/dev/vdb1 ext4 43G 51M 40G 1% /www
7、设置开机自动挂载/dev/vdb1数据盘
查询/dev/vdb1数据盘的UUID
[root@iZbp1emne76ykf63euczfpZ /]# blkid /dev/vdb1
/dev/vdb1: UUID="c2f07f3a-a93d-4e29-8d2b-7326f66fbf39" TYPE="ext4" PARTUUID="8333cdc4-01"
使用vi命令编辑fstab文件,将数据盘的UUID信息保存至fstab文件中。
[root@iZbp1emne76ykf63euczfpZ /]#vi /etc/fstab
#
# /etc/fstab
# Created by anaconda on Mon Aug 24 06:23:59 2020
#
# 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.
#
# After editing this file, run 'systemctl daemon-reload' to update systemd
# units generated from this file.
#
UUID=32f2af94-a1cd-4880-bb61-9ede22264d88 / xfs defaults 0 0
UUID=c2f07f3a-a93d-4e29-8d2b-7326f66fbf39 /www ext4 defaults 0 2
按“i”,进入编辑模式。
将光标移至文件末尾,按“Enter”,添加如下内容。UUID=UUID=c2f07f3a-a93d-4e29-8d2b-7326f66fbf39 /mnt/sdc ext4 defaults 0 2
按“ESC”后,输入“:wq”,按“Enter”,保存设置并退出编辑器,至此,数据盘的操作已经完成,我们可以开始布署运行环境。
风信建站网站定制功能开发、微信公众号开发、小程序开发、企业官网重构,企业官网安全漏洞修复,请致电:189-8648-0214