Linux入门(六)

1、自建yum仓库,分别为网络源和本地源
本地源:
1). 挂载iso文件
]# mkdir /mnt/cd
]# mount -o loop /dev/cdrom /mnt/cd/
2). 编辑repo文件
[local]
name=Local Cd
baseurl=file:///mnt/cd
enabled=1
gpgcheck=0

3). 测试

]# yum clean all
yum Loaded plugins: fastestmirror
Cleaning repos: local
Cleaning up list of fastest mirrors
Other repos take up 172 M of disk space (use --verbose for details)
]# yum repolist
Loaded plugins: fastestmirror
Determining fastest mirrors
local                                                                                   | 3.6 kB  00:00:00     
(1/2): local/group_gz                                                                   | 153 kB  00:00:00     
(2/2): local/primary_db                                                                 | 3.3 MB  00:00:00     
repo id                                             repo name                                            status
local                                               Local Cd                                             4,071
repolist: 4,071

 

网络源(一):
1). 安装http服务
yum -y install httpd
2). 挂载iso文件
]# mkdir /var/www/html/centos7/
]# mv /root/CentOS-7-x86_64-DVD-2003.iso /var/www/html/
]# mount -o loop /var/www/html/CentOS-7-x86_64-DVD-2003.iso /var/www/html/centos7/

3). 编辑repo文件

[centos7]
name=Centos7
baseurl=http://192.168.74.103/centos7/
enable=1
gpgcheck=0

4). 测试

]# yum repolist
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
centos7                                                                                 | 3.6 kB  00:00:00     
(1/2): centos7/group_gz                                                                 | 153 kB  00:00:00     
(2/2): centos7/primary_db                                                               | 3.3 MB  00:00:00     
repo id                                             repo name                                            status
centos7                                             Centos7                                              4,071
local                                               Local Cd                                             4,071
repolist: 8,142

 

网络源(二):
可以搭建Nexus服务器,通过代理的方式获取最新的rpm包,可以配置yum源、apt源、pipy源等。


 
2、编译安装http2.4,实现可以正常访问,并将编译步骤和结果提交。
1). 下载编译包
]# curl -o httpd-2.4.43.tar.gz https://mirrors.tuna.tsinghua.edu.cn/apache//httpd/httpd-2.4.43.tar.gz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 9129k  100 9129k    0     0  7758k      0  0:00:01  0:00:01 --:--:-- 7762k
2). 解压
]# tar zxf httpd-2.4.43.tar.gz
3). 环境准备
]# yum -y install apr-devel apr-util-devel gcc pcre-devel openssl-devel

4). configure脚本

]# ./configure --prefix=/usr/local/httpd-2.4.43 --enable-ssl --enable-mpms-shared
5). make && make install
 
6). 安装后配置
]# cd /usr/local
]# ln -s httpd-2.4.43/ httpd
]# cat /etc/profile.d/httpd.sh
export PATH=/usr/local/httpd/bin:$PATH
7). 测试
]# curl http://192.168.74.103
<html><body><h1>It works!</h1></body></html>

 


 

3、创建一个2G的文件系统,块大小为2048byte,预留1%可用空间,文件系统 ext4,卷标为TEST,要求此分区开机后自动挂载至/test目录,且默认有acl挂载选项
1). 创建块设备
]# fdisk /dev/sdb
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 0xe29fb483.
 
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-10485759, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-10485759, default 10485759): +2G
Partition 1 of type Linux and of size 2 GiB is set
 
Command (m for help): p
 
Disk /dev/sdb: 5368 MB, 5368709120 bytes, 10485760 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: 0xe29fb483
 
   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048     4196351     2097152   83  Linux
 
Command (m for help): w
The partition table has been altered!
 
Calling ioctl() to re-read partition table.
Syncing disks.

2). 格式化:预留1%可用空间,文件系统 ext4,卷标为TEST

]# mkfs.ext4 -L TEST -m 1 /dev/sdb1
]# blkid /dev/sdb1
/dev/sdb1: LABEL="TEST" UUID="64a9946c-3c44-445a-9993-9edc57d61ba4" TYPE="ext4"
3). 挂载:开机后自动挂载至/test目录,且默认有acl挂载选项
]# mkdir /test
编辑
/etc/fstab,添加: /dev/sdb1 /test ext4 defaults,acl 0 0 ]# mount -a
4). 验证:
]# mount| grep test
/dev/sdb1 on /test type ext4 (rw,relatime,data=ordered)

 


 

4、创建一个至少有两个PV组成的大小为20G的名为testvg的VG;要求PE大小 为16MB, 而后在卷组中创建大小为5G的逻辑卷testlv;挂载至/users目录
1). 创建pv
]# pvcreate /dev/sdc1
  Physical volume "/dev/sdc1" successfully created.
]# pvcreate /dev/sdd1
  Physical volume "/dev/sdd1" successfully created.

2). 创建VG

]# vgcreate -s 16M testvg /dev/sdc1 /dev/sdd1
  Volume group "testvg" successfully created
3). 创建LV
]# lvcreate -L 5G -n testlv testvg
  Logical volume "testlv" created.
4). 格式化
]# mkfs.ext4 /dev/testvg/testlv
5). 挂载
]# mkdir /users
]# mount /dev/testvg/testlv /users
]# mount | grep /users
/dev/mapper/testvg-testlv on /users type ext4 (rw,relatime,data=ordered)

Linux入门(六)

上一篇:Eclipse的基本设置与使用


下一篇:C#NLog帮助类同时输出内容到文件和文本框