N63050 第四周运维作业

第七天(学习线路图对应的第九天)

文本处理sed&软件管理
1、文本处理三剑客之sed的高级用法
2、软件运行和编译过程及库调用机制
3、rpm包管理器常用用法
4、yum实现和配置文件
5、yum的私有仓库和内核升级
6、源码编译安装软件
7、源码编译安装软件实战

第八天(学习线路图对应的第十天)
软件管理2
1、ubunut软件管理
2、磁盘类型和结构
3、MBR和GPT分区类型
4、文件系统管理
5、挂载管理和swap空间管理
6、移动设备和raid初步
7、raid工作原理和特性

全程班及就业班小伙伴本周作业:

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

本地源搭设

#centos8 加载光盘步骤
[root@centos8 ~]#rpm -q autofs || yum -y install autofs
[root@centos8 ~]#systemctl enable --now autofs
Created symlink /etc/systemd/system/multi-user.target.wants/autofs.service → /usr/lib/systemd/system/autofs.service.
[root@centos8 ~]#yum -y install httpd
[root@centos8 ~]#systemctl enable --now httpd
Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service → /usr/lib/systemd/system/httpd.service.
[root@centos8 ~]#lsblk
NAME        MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sr0          11:0    1  8.6G  0 rom  
sr1          11:1    1  9.5G  0 rom  
nvme0n1     259:0    0  200G  0 disk 
[root@centos8 ~]#cd /var/www/html
[root@centos8 html]#ls
[root@centos8 html]#mkdir centos/{7,8} -pv
mkdir: created directory 'centos'
mkdir: created directory 'centos/7'
mkdir: created directory 'centos/8'
[root@centos8 html]#tree centos/
centos/
├── 7
└── 8
[root@centos8 html]#mount /dev/sr1 /var/www/html/centos/7
mount: /var/www/html/centos/7: WARNING: device write-protected, mounted read-only.

#切换centos7 
vim /etc/yum.repos.d/base.repo
cat /etc/yum.repos.d/base.repo
[baseOS]
name=CentOS
baseurl=http://10.0.0.155/centos/7/
#baseurl=file:///misc/cd/BaseOS
#        https://mirrors.cloud.tencent.com/centos/8/BaseOS/x86_64/os/
#        https://mirrors.163.com/centos/8-stream/BaseOS/x86_64/os/
#gpgcheck=0

[extras]
name=extras
baseurl=https://mirrors.cloud.tencent.com/centos/8/extras/x86_64/os/
        https://mirrors.163.com/centos/8-stream/extras/x86_64/os/
gpgcheck=0
enabled=1

[epel]
name=EPEL
baseurl=https://mirrors.aliyun.com/epel/8/Everything/x86_64
        https://mirrors.cloud.tencent.com/epel/8/Everything/x86_64/
        https://mirrors.tuna.tsinghua.edu.cn/epel/8/Everything/x86_64/
gpgcheck=0
enabled=1

[root@centos7 yum.repos.d]#yum repolist -v
Loading "fastestmirror" plugin
Config time: 0.009
Yum version: 3.4.3
Loading mirror speeds from cached hostfile
 * epel: mirrors.cloud.tencent.com
 * extras: mirrors.cloud.tencent.com
Setting up Package Sacks
pkgsack time: 0.018
Repo-id      : baseOS
Repo-name    : CentOS
Repo-revision: 1604001756
Repo-updated : Fri Oct 30 04:03:00 2020
Repo-pkgs    : 10,072
Repo-size    : 8.9 G
Repo-baseurl : http://10.0.0.155/centos/7/
Repo-expire  : 21,600 second(s) (last: Wed Feb 16 23:37:51 2022)
  Filter     : read-only:present
Repo-filename: /etc/yum.repos.d/base.repo

网络源搭设

#centos8 配置base.repo文件
[root@centos8 ~]#cat /etc/yum.repos.d/base.repo
[baseOS]
name=BaseOS
baseurl=https://mirrors.cloud.tencent.com/centos/8/BaseOS/x86_64/os/
        https://mirrors.163.com/centos/8-stream/BaseOS/x86_64/os/
gpgcheck=0

[AppStream]
name=AppStream
baseurl=https://mirrors.cloud.tencent.com/centos/8/AppStream/x86_64/os/
        https://mirrors.163.com/centos/8-stream/AppStream/x86_64/os/
gpgcheck=0

[extras]
name=extras
baseurl=https://mirrors.cloud.tencent.com/centos/8/extras/x86_64/os/
        https://mirrors.163.com/centos/8-stream/extras/x86_64/os/
gpgcheck=0
enabled=1

[epel]
name=EPEL
baseurl=https://mirrors.aliyun.com/epel/8/Everything/x86_64
        https://mirrors.cloud.tencent.com/epel/8/Everything/x86_64/
        https://mirrors.tuna.tsinghua.edu.cn/epel/8/Everything/x86_64/
gpgcheck=0
enabled=1

#epel源
[root@centos8 ~]#cat /etc/yum.repos.d/base.repo
[epel]
name=EPEL
baseurl=https://mirrors.aliyun.com/epel/8/Everything/x86_64/
gpgcheck=0
[root@centos8 ~]#dnf repolist
Last metadata expiration check: 0:07:40 ago on Sun 22 Dec 2019 03:14:16 PM CST.
repo id repo name status
AppStream AppStream 4,681
BaseOS BaseOS 1,655
epel EPEL 3,707
#下载相关仓库包和元数据
[root@centos8 ~]#dnf reposync --repoid=epel --download-metadata -p
/var/www/html
#--download-metadata 加此选项可以下载元数据
#下载相关的key文件
[root@repo-server ~]#wget -P /var/www/html/epel/
https://mirrors.aliyun.com/epel/RPM-GPG-KEY-EPEL-8
#下面两个步骤只有没meta数据才需要执行
#[root@centos8 ~]#dnf -y install createrepo httpd
#[root@centos8 ~]#createrepo /var/www/html/epel/
[root@centos8 ~]#ls /var/www/html/epel/
Packages repodata
[root@centos8 ~]#systemctl start httpd
[root@repo-client ~]#cat /etc/yum.repos.d/test.repo
[BaseOS]
name=BaseOS
baseurl=http://10.0.0.8/centos/8/BaseOS
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
[AppStream]
name=Appstream
baseurl=http://10.0.0.8/centos/8/AppStream/
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
[extras]
name=extras
baseurl=http://10.0.0.8/centos/extras/
[epel]
name=epel
baseurl=http://10.0.0.8/epel/
gpgkey=http://10.0.0.8/epel/RPM-GPG-KEY-EPEL-8
[root@repo-client ~]#yum repolist
extras 1.6 MB/s | 4.9 kB 00:00
epel 88 MB/s | 6.2 MB 00:00
repo id repo name status
AppStream Appstream 4,755
BaseOS BaseOS 1,659
epel epel 5,206
extras extras 12
[root@repo-client ~]#dnf install openvpn

2、编译安装http2.4,实现可以正常访问,并将编译步骤和结果提交。

yum info httpd
wget https://mirrors.tuna.tsinghua.edu.cn/apache/httpd/httpd-2.4.51.tar.gz
mv httpd-2.4.51.tar.gz /usr/local/src
cd /usr/local/src
tar xvf httpd-2.4.51.tar.gz
./configure --prefix=/apps/httpd --sysconfdir=/etc/httpd --enable-ssl
yum install apr-devel
./configure --prefix=/apps/httpd --sysconfdir=/etc/httpd --enable-ssl
yum install apr-util-devel
./configure --prefix=/apps/httpd --sysconfdir=/etc/httpd --enable-ssl
yum install gcc -y
./configure --prefix=/apps/httpd --sysconfdir=/etc/httpd --enable-ssl
yum install pcre-devel
./configure --prefix=/apps/httpd --sysconfdir=/etc/httpd --enable-ssl
yum list openssl*
yum install openssl-devel.x86_64 
cd httpd-2.4.51/
./configure --prefix=/apps/httpd --sysconfdir=/etc/httpd --enable-ssl
make -j 2
 yum provides /usr/lib/rpm/redhat/redhat-hardened-ld
yum -y install redhat-rpm-config-125-1.el8.noarch
make -j 2
make install
echo 'PATH=/apps/httpd/bin/:$PATH' > /etc/profile.d/httpd.sh
. /etc/profile.d/httpd.sh
apachectl start

Snipaste_2022-02-18_01-00-45

3、利用sed 取出ifconfig命令中本机的IPv4地址

[root@centos8 ~]#ifconfig ens160
ens160: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 10.0.0.155  netmask 255.255.255.0  broadcast 10.0.0.255
        inet6 fe80::b802:8dd5:213f:d3f1  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:16:38:b1  txqueuelen 1000  (Ethernet)
        RX packets 3087  bytes 829332 (809.8 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 617  bytes 269773 (263.4 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
[root@centos8 ~]#ifconfig ens160 |sed -rn 2p
        inet 10.0.0.155  netmask 255.255.255.0  broadcast 10.0.0.255
[root@centos8 ~]#ifconfig ens160 |sed -rn '2s/.*inet ([0-9.]+)  netmask.*/\1/p'
10.0.0.155

4、删除/etc/fstab文件中所有以#开头,后面至少跟一个空白字符的行的行首的#和空白字符

[root@centos8 ~]#cat /etc/fstab

#
# /etc/fstab
# Created by anaconda on Wed Feb 16 21:23:24 2022
#
# 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=40fce1d8-972d-415e-aea0-60ceca94a4bd /                       xfs     defaults        0 0
UUID=38351429-177a-4e6f-a970-c31d0c0adc4d /boot                   ext4    defaults        1 2
UUID=f27b1b1b-bc71-48ae-be64-7ff64aa41337 /data                   xfs     defaults        0 0
UUID=e4531e32-53de-46b7-8e30-b2ed652dec55 none                    swap    defaults        0 0
[root@centos8 ~]#cat /etc/fstab | sed '/^#/d'

UUID=40fce1d8-972d-415e-aea0-60ceca94a4bd /                       xfs     defaults        0 0
UUID=38351429-177a-4e6f-a970-c31d0c0adc4d /boot                   ext4    defaults        1 2
UUID=f27b1b1b-bc71-48ae-be64-7ff64aa41337 /data                   xfs     defaults        0 0
UUID=e4531e32-53de-46b7-8e30-b2ed652dec55 none                    swap    defaults        0 0

5、处理/etc/fstab路径,使用sed命令取出其目录名和基名

[root@centos8 ~]#echo /etc/fstab | sed -rn 's@^(.*)/([^/]+)@\1@p'
/etc
[root@centos8 ~]#echo /etc/fstab | sed -rn 's@^(.*)/([^/]+)@\2@p'
fstab

6、列出ubuntu软件管理工具apt的一些用法(自由总结)

apt install 安装软件包

apt remove 移除软件包

apt purge 移除软件包及配置文件

apt update 刷新存储库索引

apt search 搜索应用程序

apt show 显示安装细节

apt list 列出包含条件的包(已安装,可升级等)

apt edit-sources 编辑source源⽂件

apt-cache madison nginx 查看仓库中软件包有哪些版本可以安装

apt install nginx=1.14.0-0ubuntu1.6 安装软件包的时候指定安装具体的版本

查看文件来自于哪个包,类似redhat中的yum provides
apt-file search 'string' 默认是包含此字符串的文件
apt-file search -x '正则表达式'

显示系统安装包的统计信息,可以统计已经安装包的数量,大小,占用空间等
apt-cache stats

显示xxx包的信息,可以看到某个包的源、版本等信息
apt-cache show xxx 更详细
apt show xxx

查询软件xxx依赖哪些包
apt depends xxx
apt-cache depends xxx

posted @   BruceLebron  阅读(43)  评论(1编辑  收藏  举报
相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
点击右上角即可分享
微信分享提示