1、自建yum仓库,分别为网络源和本地源
网络源
配置阿里源
[root@cn02-ansible yum.repos.d]# wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
--2022-03-28 13:11:15-- https://mirrors.aliyun.com/repo/Centos-7.repo
Connecting to 10.4.0.61:3128... connected.
Proxy request sent, awaiting response... 200 OK
Length: 2523 (2.5K) [application/octet-stream]
Saving to: ‘/etc/yum.repos.d/CentOS-Base.repo’
100%[========================================================================================================================================================================>] 2,523 --.-K/s in 0s
2022-03-28 13:11:15 (373 MB/s) - ‘/etc/yum.repos.d/CentOS-Base.repo’ saved [2523/2523]
[root@cn02-ansible yum.repos.d]# [root@cn02-ansible yum.repos.d]# cat CentOS-Base.repo
# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client. You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#
[base]
name=CentOS-$releasever - Base - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/
http://mirrors.aliyuncs.com/centos/$releasever/os/$basearch/
http://mirrors.cloud.aliyuncs.com/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
#released updates
[updates]
name=CentOS-$releasever - Updates - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/updates/$basearch/
http://mirrors.aliyuncs.com/centos/$releasever/updates/$basearch/
http://mirrors.cloud.aliyuncs.com/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/extras/$basearch/
http://mirrors.aliyuncs.com/centos/$releasever/extras/$basearch/
http://mirrors.cloud.aliyuncs.com/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/centosplus/$basearch/
http://mirrors.aliyuncs.com/centos/$releasever/centosplus/$basearch/
http://mirrors.cloud.aliyuncs.com/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/contrib/$basearch/
http://mirrors.aliyuncs.com/centos/$releasever/contrib/$basearch/
http://mirrors.cloud.aliyuncs.com/centos/$releasever/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
[root@cn02-ansible yum.repos.d]#
本地源
挂在光驱 [root@cn02-ansible yum.repos.d]# mount /dev/sr0 /var/www/BaseOS mount: /dev/sr0 is write-protected, mounting read-only
[root@cn02-ansible yum.repos.d]# vim local.repo
[Base]
name=Centos 7.9 Local
baseurl=http://10.4.1.214/base
enabled=1
gpgcheck=1
gpgkey=file:///mnt/rpm-gpg/RPM-GPG-KEY-CentOS-7
本机源
[Base2]
name=Centos 7.9 Local
baseurl=file:///var/www/base
enabled=1
gpgcheck=1
gpgkey=file:///mnt/rpm-gpg/RPM-GPG-KEY-CentOS-7
2、编译安装http2.4,实现可以正常访问,并将编译步骤和结果提交。
安装依赖包
[root@cn02-ansible ~]#yum install gcc make autoconf apr-devel apr-util-devel pcredevel openssl-devel redhat-rpm-config
解压安装包
[root@cn02-ansible ~]# tar zxvf httpd-2.4.53.tar.gz
配置
[root@cn02-ansible httpd-2.4.53]# ./configure --prefix=/root/httpd --sysconfdir=/etc/httpd --enable-ssl
[root@cn02-ansible httpd-2.4.53]# make -j 8
[root@cn02-ansible httpd-2.4.53]# make install
[root@cn02-ansible httpd-2.4.53]# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
[root@cn02-ansible httpd-2.4.53]# echo 'PATH=/root/httpd/bin:$PATH' > /etc/profile.d/httpd.sh
[root@cn02-ansible httpd-2.4.53]# . /etc/profile.d/httpd.sh
[root@cn02-ansible httpd]# vim /etc/httpd/httpd.conf
[root@cn02-ansible httpd]# apachectl restart
[root@cn02-ansible ~]# sed -ri 's/^(#[[:space:]]+)(.*)/\2/g' fstab
3、利用sed 取出ifconfig命令中本机的IPv4地址
[root@cn02-ansible httpd]# ifconfig ens192| sed -rn '2s/.inet ([0-9.]+) netmask./\1/p' 10.4.1.214
4、删除/etc/fstab文件中所有以#开头,后面至少跟一个空白字符的行的行首的#和空白字符
[root@cn02-ansible ~]# cat -A fstab
[root@cn02-ansible ~]# sed -ri 's/^(#[[:space:]]+)(.*)/\2/g' fstab
5、处理/etc/fstab路径,使用sed命令取出其目录名和基名
[root@cn02-ansible httpd]# echo /etc/fstab| sed -nr 's#^(.)/([^/]+)#\1#p' /etc [root@cn02-ansible httpd]# echo /etc/fstab| sed -nr 's#^(.)/([^/]+)#\2#p' fstab
6、列出ubuntu软件管理工具apt的一些用法(自由总结)
Debian 使用apt 工具集来管理包系统
apt 常用子命令
apt install 安装软件包
apt remove 移除软件包
apt purge 移除软件包及配置文件
apt update 刷新存储库索引
apt upgrade 升级所有可升级的软件包
apt autoremove 自动删除不需要的包
apt full-upgrade 在升级软件包时自动处理依赖关系
apt search 搜索引用程序
apt show 显示安装细节
apt update 更新包的索引,相当于 yum clean all yum makecache dnf
注意: 每次执行软件的安装 卸载 之前都需要先执行 apt update 更新包的索引
使用示例
apt install tree zip -y 安装包 apt install ubuntu-desktop 安装图形桌面 apt remove tree zip -y 说明: apt remove 中添加 --purge 选项会删除软件包配置文件,谨慎使用 apt update 更新包的索引,相当于 yum clean all yum makecache dnf apt upgrade -y 升级包 要升级系统 请首先更新软件包 索引 再升级 apt list 列出仓库软件包 等于 yum list apt search nginx 搜索软件包 apt show vsftpd 查看某个软件包的详细信息 apt remove apache2 卸载软件包但是保留配置文件 apt autoremove apache2 删除安装包并解决依赖关系 apt update 更新本地软件包列表索引 修改了 apt 仓库后必须执行 apt purge apache2 -y 卸载单个软件包删除配置文件 apt upgrade 升级所有一安装且可以升级到新版本的软件包 apt full-upgrade -y 升级整个系统 必要时可以移除旧软件包 apt edit-sources 编辑 source 源文件 apt-cache madison nginx 查看仓库中软件包有哪些版本可以安装 apt install nginx=1.14.0-0ubuntu1.9 安装软件包的时候指定要安装的具体版本
#查看文件来自于哪个包,类似redhat中的yum provides <filename> apt install apt-file apt update apt-file search -F /usr/sbin/nginx nginx-core: /usr/sbin/nginx nginx-extras: /usr/sbin/nginx nginx-full: /usr/sbin/nginx nginx-light: /usr/sbin/nginx
查看包相关信息
显示系统安装包的统计信息 可以统计已经安装包的数量 大小 占用空间等 apt-cache stats
显示xxx 包的信息 可以看到某个包的源 版本等信息 apt-cache show nginx
查看仓库中的指定软件的所有版本
apt-cache madison docker-ce apt -y install docker-ce=18.06.3~ce~3-0~ubuntu 安装指定版本的 docker-ce
ubuntu 建议安装的常用的包
apt install iproute2 ntpdate tcpdump telnet traceroute nfs-kernel-server nfs-common lrzsz tree openssl libssl-dev libpcre3 libpcre3-dev zlib1g-dev gcc openssh-server iotop unzip zip