(第七天)

上午
本机 cmd 中执行
C:\Users\lenovo>e: // 切换到 e 盘下
E:\>dir // 查看 e 盘下所有的目录和文件
驱动器 E 中的卷是 新加卷
卷的序列号是 BE8A-9808
E:\ 的目录
1970/01/01 08:00 64,311,808
0338db614b95b200426c357864b53a7386a4e5cc9c71d9162176de706741cd34.tar
2022/11/10 14:28 <DIR>
0f04ae71e99f5ef9021b92f76bac3979e25c98d73a51d33ce76a78da6afa9f27
2023/03/28 18:30 <DIR> 2019
E:\>scp // 默认可以使用 scp 进行传输文件
usage: scp [-346BCpqrTv] [-c cipher] [-F ssh_config] [-i identity_file]
[-J destination] [-l limit] [-o ssh_option] [-P port]
[-S program] source ... target
1 、任务要求
1 )配置本地 yum
2 )网络 yum
3 )安装 mysql
2 、任务拆解
1 yum 源配置
2 mysql 数据库软件
1 、配置 yum
介绍:
1 、了解 yum 源安装软件包
Yum 源安装软件包是在 Linux 系统中一种非常便捷和常用的软件安装方式
Yum Yellowdog Updater, Modified )是一个在众多 Linux 发行版中广泛使用的软件包管理器。它
通过预先配置好的软件源( Yum 源)来获取软件包的信息和进行安装。
Yum 源的作用
Yum 源就像是一个软件仓库,包含了各种各样的软件包及其相关的依赖信息。常见的 Yum 源有系
统默认提供的官方源,也有第三方维护的源。
Yum 安装软件包的优点
1. 自动处理依赖关系:当您安装一个软件包时,如果它依赖于其他的软件包, Yum 会自动安装这
些依赖,无需您手动逐个查找和安装。
例如,安装一个图形化界面软件时,它可能依赖于特定的库文件和其他支持组件,
Yum 会一并处理。
2. 方便的软件搜索和浏览:您可以通过简单的命令搜索和查看可用的软件包。
3. 软件包的更新管理:可以轻松更新已安装的软件包到最新版本,保持系统的安全性和稳定性。
安装过程中的关键步骤
1. 配置 Yum 源:有些系统默认已经配置好常用的源,您也可以根据需要添加或修改源的配置。
2. 执行安装命令:如前面提到的 yum install < 软件包名称 >
一些常见的 Yum 相关命令
1. yum list :列出所有可用的软件包。
2. yum info < 软件包名称 > :查看指定软件包的详细信息。
总之, Yum 源安装软件包极大地简化了在 Linux 系统中安装和管理软件的过程,提高了效率和便利 性。
2 、了解常见的网络 yum
1. 华为云 yum :例如对于 centos7 系统,其 .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 fallback you can try the
# remarked out baseurl= line instead.
#
#
(base)
name=centos7
baseurl=https://repo.huaweicloud.com/centos/$releasever/os/$basearch/
gpgcheck=0
# released updates
(updates)
name=centos-$releasever-updates-repo.huaweicloud.com
baseurl=https://repo.huaweicloud.com/centos/$releasever/updates/$basearch/
# mirrorlist=https://mirrorlist.centos.org/?
release=$releasever&arch=$basearch&repo=updates
gpgcheck=1
gpgkey=https://repo.huaweicloud.com/centos/rpm-gpg-key-centos-7
# additional packages that may be useful
(extras)
name=centos-$releasever-extras-repo.huaweicloud.com
baseurl=https://repo.huaweicloud.com/centos/$releasever/extras/$basearch/
# mirrorlist=https://mirrorlist.centos.org/?
release=$releasever&arch=$basearch&repo=extras
gpgcheck=1
gpgkey=https://repo.huaweicloud.com/centos/rpm-gpg-key-centos-7
# additional packages that extend functionality of existing packages
(centosplus)
name=centos-$releasever-plus-repo.huaweicloud.com
baseurl=https://repo.huaweicloud.com/centos/$releasever/centosplus/$basearch/
# mirrorlist=https://mirrorlist.centos.org/?
release=$releasever&arch=$basearch&repo=centosplus
其中, $releasever 表示系统版本, $basearch 表示系统架构(如 x86_64 )。
2. 中国科技大学源 :如 http://centos.ustc.edu.cn/centos/ 。使用中科大源的方法之一是,
先进入 /etc/yum.repos.d/ 目录,重命名 centos 自带的 yum 源文件(如 mv centos
base.repo centos-base.repo.save ),然后执行 wget
http://mirrors.ustc.edu.cn/centos/centos-base.5.mirrors.repo -o
/etc/yum.repos.d/centos-base.repo ,最后运行 yum makecache
3. 网易开源镜像 :例如 http://mirrors.163.com/centos/ 。使用网易源可参考如下步骤:进
/etc/yum.repos.d/ 目录,重命名 centos 自带的 yum 源文件(如 mv centos-base.repo
centos-base.repo.save ),执行 wget http://mirrors.sohu.com/help/centos-base
sohu.repo ,再运行 yum makecache
4. 阿里云镜像 http://mirrors.aliyun.com/repo/centos-7.repo (适用于 centos7
统)。
配置网络 yum 源的具体步骤可能因 Linux 发行版和版本而有所不同。一般来说,需要将相应
.repo 文件下载或创建到 /etc/yum.repos.d/ 目录下,然后运行相关命令更新 yum 缓存。
在实际使用中,你可以根据网络连接情况、 yum 源的稳定性和速度等因素选择合适的网络 yum 源。
同时,注意 .repo 文件中的版本信息要与你的系统版本相匹配。另外,还有一些其他的 yum 源可供选
择,例如一些特定软件或项目的官方 yum 源等,可以根据具体需求进行查找和配置。
3 、掌握本地和网络 yum 源的配置
Yum (全称为 Yellowdog Updater, Modified )是一个在 Fedora CentOS BCLinux RedHat
Linux 发行版中的软件包管理器。它基于 RPM 包管理,能够自动处理依赖性关系,一次安装所有依赖的
软件包。配置 Yum 源可以让系统通过指定的服务器或本地镜像来获取软件包。以下是本地和网络 Yum
源的常见配置方法:
配置网络 Yum 源(以 CentOS 7 系统,使用华为云 yum 源为例)
1. 查看本地操作系统版本,执行指令: cat /etc/redhat-release
2. 打开华为云开源镜像站( https://mirrors.huaweicloud.com/home ),找到对应的操作系统版
本的 .repo 文件链接(如: https://repo.huaweicloud.com/repository/conf/centos7.repo
)。
3. 进入服务器的 /etc/yum.repos.d/ 目录,可以执行以下命令下载并编辑 .repo 文件:
cd /etc/yum.repos.d/
vi local.repo
i 键进入编辑模式,输入以下内容(注意将 $releasever 替换成实际的操作系统版本号):
#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 fallback you can try the
# remarked out baseurl= line instead.
#
#
(base)
name=centos7
baseurl=https://repo.huaweicloud.com/centos/$releasever/os/$basearch/
gpgcheck=0
# released updates
(updates)
name=centos-$releasever-updates-repo.huaweicloud.com
baseurl=https://repo.huaweicloud.com/centos/$releasever/updates/$basearch/
# mirrorlist=https://mirrorlist.centos.org/?
release=$releasever&arch=$basearch&repo=updates
gpgcheck=1
gpgkey=https://repo.huaweicloud.com/centos/rpm-gpg-key-centos-7
# additional packages that may be useful
(extras)
name=centos-$releasever-extras-repo.huaweicloud.com
baseurl=https://repo.huaweicloud.com/centos/$releasever/extras/$basearch/
# mirrorlist=https://mirrorlist.centos.org/?
release=$releasever&arch=$basearch&repo=extras
gpgcheck=1
gpgkey=https://repo.huaweicloud.com/centos/rpm-gpg-key-centos-7
# additional packages that extend functionality of existing packages
(centosplus)
name=centos-$releasever-plus-repo.huaweicloud.com
baseurl=https://repo.huaweicloud.com/centos/$releasever/centosplus/$basearch/
# mirrorlist=https://mirrorlist.centos.org/?
release=$releasever&arch=$basearch&repo=centosplus
编辑完成后,按 Esc 键,输入 :wq 保存并退出。
1. 执行以下命令更新 Yum 源:
yum clean all :清除原有缓存。
yum makecache :构建新的缓存。
配置本地 Yum 源(以 CentOS 7 系统为例)
1. 挂载 ISO 镜像文件(假设镜像文件已上传至服务器):
创建挂载点: mkdir /opt/centos
挂载镜像: mount /your_iso_file_path /opt/centos (将
/your_iso_file_path 替换为实际的镜像文件路径)。
2. 进入 /etc/yum.repos.d/ 目录,备份原有的 .repo 文件(以防需要恢复): mv
/etc/yum.repos.d/*.repo /etc/yum.repos.d/old/
3. 创建并编辑本地 Yum 源配置文件:
vi /etc/yum.repos.d/local.repo
输入以下内容:
(centos)
name=centos # Yum 源的名称,可自定义
baseurl=file:///opt/centos # 本地 Yum 源的位置,指向挂载点目录
gpgcheck=0 # 不进行 GPG 签名检查
enabled=1 # 启用该 Yum
编辑完成后保存并退出。
1. 执行 yum clean all 命令清空缓存。
2. 执行 yum makecache 命令重建缓存。
配置完成后,就可以使用 Yum 命令来安装、更新软件包了。
另外,如果想要配置局域网 Yum 源,可以参考以下步骤(需要至少两台服务器,一台作为源服务
器,其他机器作为客户端):
配置局域网 Yum 源(服务器端)
1. 按照上述本地 Yum 源的配置方法,在源服务器上完成本地 Yum 源的配置。
2. 安装并启动 HTTP 服务(如 Apache HTTP Server Nginx 等),将挂载的 ISO 镜像目录通过
HTTP 服务共享出去。
3. 配置客户端机器的 Yum 源:
编辑 /etc/yum.repos.d/ 目录下的 .repo 文件,添加类似以下内容:
(centos)
name=centos
baseurl=http:// 源服务器 IP/ 共享目录 # 替换为实际的源服务器 IP 和共享目录
gpgcheck=0
enabled=1
然后在客户端机器上执行 yum clean all yum makecache 命令更新缓存。
这样,局域网内的客户端机器就可以通过源服务器提供的 Yum 源来安装软件包了。需注意,客户端
机器要能访问源服务器的共享目录。在实际配置过程中,可能需要根据具体的网络环境和服务器设置进
行适当调整。同时,确保拥有足够的权限来执行相关操作。
常见的一些网络 Yum 源有阿里云、华为云、网易等提供的开源镜像站点。例如,阿里云的 CentOS
7 yum 源地址为: http://mirrors.aliyun.com/repo/centos-7.repo
操作:
1 、配置本地 yum
rpm -ivh xxx //rpm 需要手动添加依赖
能够使用 yum 工具安装软件包
yum 不止执行安装,还可以自动处理依赖关系
ls -l /etc/yum.repos.d/ // 查看现有的 yum 仓库镜像
1 )打包,做成一个 tar 压缩包
yum repolist all
tar -czvf /etc/yum.repos.d/bak.tar.gz /etc/yum.repos.d/*
rm -rf /etc/yum.repos.d/*.repo
ls -l /etc/yum.repos.d/
yum repolist all
yum clean all // 清空缓存
yum makecache // 生成缓存
(2 )删除 mnt 目录下的所有文件
rm -rf /mnt/*
ls /mnt/
3 )将光盘数据挂载到 /mnt 目录中,就可以在该目录中读取光盘内容
lsblk // 找到 sr0
mount -o ro /dev/sr0 /mnt // 以只读方式挂载光盘
4 )设置开机自挂载
echo "mount -o ro /dev/sr0 /mnt" >> /etc/rc.local // 开机自动挂载
5 )规定软件包查找位置
[root@1 ~]# vim /etc/yum.repos.d/hh.repo
[a]
name=a
baseurl=file:///mnt
gpgcheck=0
[root@1 ~]# yum clean all
已加载插件: fastestmirror
正在清理软件源: a
Cleaning up everything
Maybe you want: rm -rf /var/cache/yum, to also free up space taken by
orphaned data from disabled or removed repos
Cleaning up list of fastest mirrors
[root@1 ~]# yum makecache
已加载插件: fastestmirror
Determining fastest mirrors
a |
3.6 kB 00:00:00
(1/4): a/group_gz |
166 kB 00:00:00
(2/4): a/primary_db |
5.9 MB 00:00:00
(3/4): a/filelists_db |
6.9 MB 00:00:00
(4/4): a/other_db |
2.5 MB 00:00:00
2 、配置网络 yum
1 )阿里云
https://developer.aliyun.com/mirror/
wget -O /etc/yum.repos.d/CentOS-Base.repo
https://mirrors.aliyun.com/repo/Centos-7.repo
yum clean all
yum makecache
2) 腾讯云
https://mirrors.cloud.tencent.com/
根据帮助文档一步一步做即可
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
// 备份系统旧配置文件
wget -O /etc/yum.repos.d/CentOS-Base.repo
http://mirrors.cloud.tencent.com/repo/centos7_base.repo
yum clean all
yum makecache // 更新缓存
显示下图即为成功
[root@1 ~]# yum repolist
已加载插件: fastestmirror
Loading mirror speeds from cached hostfile
源标识 源名称
状态
extras/7/x86_64 Qcloud centos extras - x86_64
526
os/7/x86_64 Qcloud centos os - x86_64
10,072
updates/7/x86_64 Qcloud centos updates - x86_64
6,173
repolist: 16,771
[root@1 ~]# yum list | grep python3
libselinux-python3.x86_64 2.5-15.el7 os
python3.i686 3.6.8-21.el7_9
updates
python3.x86_64 3.6.8-21.el7_9
updates
python3-debug.i686 3.6.8-21.el7_9
updates
python3-debug.x86_64 3.6.8-21.el7_9
updates
python3-devel.i686 3.6.8-21.el7_9
updates
python3-devel.x86_64 3.6.8-21.el7_9
updates
python3-idle.i686 3.6.8-21.el7_9
updates
python3-idle.x86_64 3.6.8-21.el7_9
updates
python3-libcomps.x86_64 0.1.8-14.el7 extras
python3-libs.i686 3.6.8-21.el7_9
updates
python3-libs.x86_64 3.6.8-21.el7_9
updates
python3-pip.noarch 9.0.3-8.el7 os
python3-rpm-generators.noarch 6-2.el7 os
python3-rpm-macros.noarch 3-34.el7 os
python3-setuptools.noarch 39.2.0-10.el7 os
python3-test.i686 3.6.8-21.el7_9
updates
python3-test.x86_64 3.6.8-21.el7_9
updates
python3-tkinter.i686 3.6.8-21.el7_9
updates
python3-tkinter.x86_64 3.6.8-21.el7_9
updates
python3-wheel.noarch 0.31.1-5.el7_7 os
下午
3 epel 源配置
对官⽅和官⽹源的扩展,有些软件找不到
[root@1 ~]# yum -y install epel-release.noarch
[root@1 ~]# ls /etc/yum.repos.d/
CentOS-Base.repo epel.repo hh.repo.b
CentOS-Base.repo.backup epel-testing.repo
[root@1 ~]# yum -y install sl // 安装小火车
[root@1 ~]# sl
4 nginx 源配置
1 )移除 epel
[root@1 ~]# rm -rf /etc/yum.repos.d/epel*
[root@1 ~]# ls /etc/yum.repos.d/
CentOS-Base.repo CentOS-Base.repo.backup hh.repo.b
[root@1 ~]# yum clean all
[root@1 ~]# yum makecache
2 )百度搜索 nginx 镜像
https://nginx.org/
找到 repo 文件内容
[root@1 ~]# vim /etc/yum.repos.d/nginx.repo
[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true // 启用模块热修复功能
[root@1 ~]# yum clean all
[root@1 ~]# yum makecache
[root@1 ~]# yum list | grep nginx
nginx.x86_64 1:1.26.1-2.el7.ngx nginx
stable
nginx-debug.x86_64 1:1.8.0-1.el7.ngx nginx
stable
nginx-debuginfo.x86_64 1:1.26.1-2.el7.ngx nginx
stable
nginx-module-geoip.x86_64 1:1.26.1-2.el7.ngx nginx
stable
nginx-module-geoip-debuginfo.x86_64 1:1.26.1-2.el7.ngx nginx
stable
nginx-module-image-filter.x86_64 1:1.26.1-2.el7.ngx nginx
stable
nginx-module-image-filter-debuginfo.x86_64 1:1.26.1-2.el7.ngx nginx
stable
nginx-module-njs.x86_64 1:1.26.1+0.8.5-2.el7.ngx nginx
stable
nginx-module-njs-debuginfo.x86_64 1:1.26.1+0.8.5-2.el7.ngx nginx
stable
nginx-module-perl.x86_64 1:1.26.1-2.el7.ngx nginx
stable
nginx-module-perl-debuginfo.x86_64 1:1.26.1-2.el7.ngx nginx
stable
nginx-module-xslt.x86_64 1:1.26.1-2.el7.ngx nginx
stable
nginx-module-xslt-debuginfo.x86_64 1:1.26.1-2.el7.ngx nginx
stable
nginx-nr-agent.noarch 2.0.0-12.el7.ngx nginx
stable
pcp-pmda-nginx.x86_64
[root@1 ~]# yum -y install nginx
[root@1 ~]# nginx // 启动服务
[root@1 ~]# whereis nginx // 查看指令
nginx: /usr/sbin/nginx /usr/lib64/nginx /etc/nginx /usr/share/nginx
/usr/share/man/man8/nginx.8.gz
[root@1 ~]# curl http://localhost // 访问服务器
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
html { color-scheme: light dark; }
body { width: 35em; margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif; }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>
<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>
<p><em>Thank you for using nginx.</em></p>
</body>
</html>
[root@1 ~]# nginx -s stop // nginx
[root@1 ~]# curl http://localhost
curl: (7) Failed connect to localhost:80; 拒绝连接
3 、自建 yum 源仓库
[root@1 ~]# vim /etc/yum.conf
keepcache=1 // 0 改为 1 YUM 在下载软件包后保留其缓存
[root@1 ~]# yum remove -y nginx // 卸载 nginx
[root@1 ~]# yum -y install nginx // 安装 nginx
[root@1 ~]# find /var/cache/ -name "*nginx*" -type f // 查看缓存文件
/var/cache/yum/x86_64/7/nginx-stable/packages/nginx-1.26.1-
2.el7.ngx.x86_64.rpm
[root@1 ~]# yum install --downloadonly --downloaddir=./soft samba // 只下载
不安装
--downloadonly 选项表示只进行下载操作,不进行安装。
--downloaddir=./soft 则指定了下载的软件包保存的目录为当前目录下的 soft 文件夹。
......
总计 1.2 MB/s |
9.0 MB 00:00:07
exiting because "Download Only" specified
[root@1 ~]# ls soft/
avahi-libs-0.6.31-20.el7.x86_64.rpm pytalloc-2.1.16-1.el7.x86_64.rpm
cups-libs-1.6.3-52.el7_9.x86_64.rpm python-tdb-1.3.18-1.el7.x86_64.rpm
gnutls-3.3.29-9.el7_6.x86_64.rpm samba-4.10.16-25.el7_9.x86_64.rpm
libldb-1.5.4-2.el7.x86_64.rpm samba-client-libs-4.10.16-
25.el7_9.x86_64.rpm
libtalloc-2.1.16-1.el7.x86_64.rpm samba-common-4.10.16-
25.el7_9.noarch.rpm
libtdb-1.3.18-1.el7.x86_64.rpm samba-common-libs-4.10.16-
25.el7_9.x86_64.rpm
libtevent-0.9.39-1.el7.x86_64.rpm samba-common-tools-4.10.16-
25.el7_9.x86_64.rpm
libwbclient-4.10.16-25.el7_9.x86_64.rpm samba-libs-4.10.16-
25.el7_9.x86_64.rpm
nettle-2.7.1-9.el7_9.x86_64.rpm trousers-0.3.14-2.el7.x86_64.rpm
pyldb-1.5.4-2.el7.x86_64.rpm
安装 createrepo 制作仓库的软件
createrepo 是一个用于创建 YUM 软件仓库的命令行工具。
它的主要作用是根据指定目录中的 RPM 软件包生成元数据,包括软件包的依赖关系、版本信息等,以便
YUM 客户端能够正确地解析和安装所需的软件。
以下是一个使用 createrepo 的示例:
假设您有一个目录 /opt/packages ,其中包含了一些 RPM 软件包。您可以在该目录下运行以下命令
来创建软件仓库:
createrepo /opt/packages
执行完该命令后, createrepo 会在 /opt/packages 目录下生成一些元数据文件,如 repodata
目录,其中包含了 repomd.xml 等重要的配置和描述文件。
这样,您就可以将这个目录配置为 YUM 源,让客户端能够从这里获取和安装软件包。
[root@1 ~]# yum -y install createrepo
[root@1 ~]# createrepo soft/ // soft 件夹做成 个本地的 建仓库
Spawning worker 0 with 19 pkgs
Workers Finished
Saving Primary metadata
Saving file lists metadata
Saving other metadata
Generating sqlite DBs
Sqlite DBs complete
[root@1 ~]# ls
soft
[root@1 ~]# cd soft/
[root@1 soft]# ls
avahi-libs-0.6.31-20.el7.x86_64.rpm pytalloc-2.1.16-1.el7.x86_64.rpm
cups-libs-1.6.3-52.el7_9.x86_64.rpm python-tdb-1.3.18-1.el7.x86_64.rpm
gnutls-3.3.29-9.el7_6.x86_64.rpm repodata
libldb-1.5.4-2.el7.x86_64.rpm samba-4.10.16-25.el7_9.x86_64.rpm
libtalloc-2.1.16-1.el7.x86_64.rpm samba-client-libs-4.10.16-
25.el7_9.x86_64.rpm
libtdb-1.3.18-1.el7.x86_64.rpm samba-common-4.10.16-
25.el7_9.noarch.rpm
libtevent-0.9.39-1.el7.x86_64.rpm samba-common-libs-4.10.16-
25.el7_9.x86_64.rpm
libwbclient-4.10.16-25.el7_9.x86_64.rpm samba-common-tools-4.10.16-
25.el7_9.x86_64.rpm
nettle-2.7.1-9.el7_9.x86_64.rpm samba-libs-4.10.16-
25.el7_9.x86_64.rpm
pyldb-1.5.4-2.el7.x86_64.rpm trousers-0.3.14-2.el7.x86_64.rpm
[root@1 soft]# vim /etc/yum.repos.d/soft.repo
[soft]
name=soft
baseurl=file:///root/soft
gpgcheck=0
enable=1
[root@1 soft]# yum clean all
已加载插件: fastestmirror
正在清理软件源: extras nginx-stable os soft updates
Cleaning up everything
Maybe you want: rm -rf /var/cache/yum, to also free up space taken by
orphaned data from disabled or removed repos
Cleaning up list of fastest mirrors
[root@1 soft]# yum makecache
[root@1 soft]# yum -y install samba // 全程直接下载,使用我们自己创建的 yum 仓库
2 、任务
任务 1 、插⼊优盘,读取优盘数据
任务 2 、在 vmware 配置光盘 iso ⽂件,在 linux 系统中读取光盘⽂件
[root@2 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 20G 0 disk
├─sda1 8:1 0 1G 0 part
└─sda2 8:2 0 19G 0 part
├─centos-root 253:0 0 18G 0 lvm /
└─centos-swap 253:1 0 1G 0 lvm [SWAP]
sr0 11:0 1 8.8G 0 rom
[root@2 ~]# ls /mnt
[root@2 ~]# mount /dev/cdrom /mnt
mount: /dev/sr0 写保护,将以只读方式挂载
[root@2 ~]# ls /mnt
CentOS_BuildTag EFI EULA GPL images isolinux LiveOS Packages repodata
RPM-GPG-KEY-CentOS-7 RPM-GPG-KEY-CentOS-Testing-7 TRANS.TBL
[root@2 ~]# vim /etc/yum.repos.d/hh.repo
[a]
name=a
baseurl=file:///mnt
gpgcheck=0
[root@2 ~]# yum repolist
任务 3 、配置阿⾥云 yum 仓库
https://developer.aliyun.com/mirror/centos // 查找帮助文档
[root@2 ~]# ls /etc/yum.repos.d
hh.repo
[root@2 ~]# mv /etc/yum.repos.d/hh.repo /etc/yum.repos.d/hh.repo.backup
[root@2 ~]# ls /etc/yum.repos.d/
hh.repo.backup
[root@2 ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo
https://mirrors.aliyun.com/repo/Centos-7.repo
[root@2 ~]# ls /etc/yum.repos.d/
CentOS-Base.repo hh.repo.backup
[root@2 ~]# yum clean all
[root@2 ~]# yum makecache
[root@2 ~]# yum repolist
任务 4 、配置清华镜像仓库
https://mirrors.tuna.tsinghua.edu.cn/help/pypi/ // 查找帮助文档
[root@2 ~]# mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS
Base.repo.backup
[root@2 ~]# ls /etc/yum.repos.d/
CentOS-Base.repo.backup hh.repo.backup
任务 5 、配置腾讯镜像仓库
https://mirrors.tencent.com/
[root@2 ~]# mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS
Base.repo.backup
[root@2 ~]# ls /etc/yum.repos.d/
CentOS-Base.repo.backup hh.repo.backup
[root@2 ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo
http://mirrors.cloud.tencent.com/repo/centos7_base.repo
[root@2 ~]# yum clean all
[root@2 ~]# yum makecache
[root@2 ~]# yum repolist
任务 6 、⾃建仓库 包含 tree net-tools bash-completion nginx 等包
vim /etc/yum.conf // keepcache 后改为 1
1029 yum install --downloadonly --downloaddir=./soft net-tools
1030 yum install --downloadonly --downloaddir=./soft bash-completion
1031 yum install --downloadonly --downloaddir=./soft nginx
1032 yum install --downloadonly --downloaddir=./soft tree
[root@2 ~]# ls soft/
bash-completion-2.1-8.el7.noarch.rpm net-tools-2.0-
0.25.20131004git.el7.x86_64.rpm
[root@2 ~]# yum -y install createrepo
[root@2 ~]# createrepo ./soft/
[root@2 ~]# ls soft/
bash-completion-2.1-8.el7.noarch.rpm net-tools-2.0-
0.25.20131004git.el7.x86_64.rpm repodata nginx-1.26.1-2.el7.ngx.x86_64.rpm
tree-1.6.0-10.el7.x86_64.rpm
[root@2 ~]# mv /etc/yum.repos.d/CentOS-Base.repo.repo
/etc/yum.repos.d/CentOS-Base.repo.txt
[root@2 ~]# mv /etc/yum.repos.d/nginx.repo /etc/yum.repos.d/nginx.repo.txt
[root@2 ~]# mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS
Base.repo.txt
[root@2 ~]# yum clean all
[root@2 ~]# yum makecache
[root@2 ~]# yum -y install bash-completion.noarch
[root@2 ~]# yum -y install net-tools.x86_64
[root@2 ~]# yum -y install nginx
[root@2 ~]# yum -y install tree
  • 12
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值