1.任务要求
配置本地yum源
网络yum源
安装MySQL
2.任务拆解
Yum源配置
MySQL数据库软件
Yum优点
分类
特定软件
Nginx mysql zabbiz
查看现有的yum仓库镜像
[root@localhost ~]# ls -l /etc/yum.repos.d/
总用量 4
-rw-r--r--. 1 root root 67 7月 12 15:23 dvd.repo
您在 /var/spool/mail/root 中有新邮件
[root@localhost ~]# yum list|grep python2
[root@localhost ~]# ls -l /etc/yum.repos.d/
总用量 4
-rw-r--r--. 1 root root 67 7月 12 15:23 dvd.repo
您在 /var/spool/mail/root 中有新邮件
[root@localhost ~]# tar -zcvf /etc/yum.repos.d/bak.tar.gz etc/yum.repos.d/*
[root@localhost ~]# rm -rf /etc/yum.repos.d/*.repo
您在 /var/spool/mail/root 中有新邮件
[root@localhost ~]# ls /-l /etc/yum.repos.d/
/etc/yum.repos.d/:
bak.tar.gz
[root@localhost ~]# yum repolist //列出系统中已配置的YUM软件仓库及其相关信息
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
repolist: 0
[root@localhost ~]# ls /etc/yum.repos.d/
bak.tar.gz
您在 /var/spool/mail/root 中有新邮件
[root@localhost ~]# yum clear //清空yum
[root@localhost ~]# yum makecache //下载并缓存所有启用的YUM仓库的元数据
[root@localhost ~]# yum repolist all
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
repolist: 0
删除mnt目录下所有文件
[root@localhost ~]# rm -rf /mnt/
[root@localhost ~]# ls /dvd/
[root@localhost ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 20G 0 disk
├─sda1 8:1 0 1G 0 part /boot
└─sda2 8:2 0 19G 0 part
├─centos-root 253:0 0 17G 0 lvm /
└─centos-swap 253:1 0 2G 0 lvm [SWAP]
sr0 11:0 1 8.8G 0 rom /dvd 挂载到dvd
[root@localhost ~]# ls /dvd/
将光盘数据挂载到/dvd目录中 就可以在该目录中读取光盘的数据
[root@localhost ~]# vi /etc/rc.local
mount -o ro /dev/sr0 /dvd直接在rc.local或者直接追加下一行 都会在配置文件中显示
[root@localhost ~]# echo "mount -o ro /dev/sr0 /dvd" >> /etc/rc.local
[root@localhost ~]# cat /etc/rc.local
本地yum源
[root@localhost ~]# vi /etc/yum.repos.d/local.repo
[root@localhost ~]# cat /etc/yum.repos.d/local.repo
[local]
name=local
baseurl=file:///dvd
gpgcheck=0
enable=1
[root@localhost ~]# yum cleanall
[root@localhost ~]# yum makecache
已加载插件:fastestmirror
Determining fastest mirrors
local | 3.6 kB 00:00
(1/4): local/group_gz | 166 kB 00:00
(2/4): local/primary_db | 5.9 MB 00:02
(3/4): local/filelists_db | 6.9 MB 00:02
(4/4): local/other_db | 2.5 MB 00:00
元数据缓存已建立
[root@localhost ~]# yum -y remove httpd
[root@localhost ~]# cat /etc/yum.repos.d/local.repo
[local]
name=local
baseurl=file:///dvd
gpgcheck=0
enable=1
[root@localhost ~]# ls /etc/yum.repos.d/
bak.tar.gz local.repo
[root@localhost ~]# rm -rf /etc/yum.repos.d/local.repo
您在 /var/spool/mail/root 中有新邮件
[root@localhost ~]# ls /etc/yum.repos.d/
bak.tar.gz
[root@localhost ~]# yum list|grep python3
[root@localhost ~]# vi /etc/resolv.conf
# Generated by NetworkManager
search localdomain
nameserver 192.168.226.22
nameserver 8.8.8.8
nameserver 8.8.4.4
[root@localhost ~]# systemctl restart NetworkManager
[root@localhost ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
--2024-07-16 11:48:50-- https://mirrors.aliyun.com/repo/Centos-7.repo
正在解析主机 mirrors.aliyun.com (mirrors.aliyun.com)... 61.162.12.191, 61.162.12.186, 61.162.12.188, ...
正在连接 mirrors.aliyun.com (mirrors.aliyun.com)|61.162.12.191|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:2523 (2.5K) [application/octet-stream]
正在保存至: “/etc/yum.repos.d/CentOS-Base.repo”
100%[=========================>] 2,523 --.-K/s 用时 0.01s
2024-07-16 11:48:54 (174 KB/s) - 已保存 “/etc/yum.repos.d/CentOS-Base.repo” [2523/2523])
您在 /var/spool/mail/root 中有邮件
[root@localhost ~]# mv /etc/yum.repos.d/CentOS-Base.repo
[root@localhost ~]# ls /etc/yum.repos.d/
bak.tar.gz CentOS-Base.repo.bak
[root@localhost ~]# cp /etc/yum.repos.d/CentOS-Base.repo.bak /etc/yum.repos.d/CentOS-Base.repo
[root@localhost ~]# ls /etc/yum.repos.d/
bak.tar.gz CentOS-Base.repo CentOS-Base.repo.bak
[root@localhost ~]# yum clean all
[root@localhost ~]# yum makecache
[root@localhost ~]# yum -y install epel-release.noarch
[root@localhost ~]# yum -y install sl
[root@localhost ~]# sl
[root@localhost ~]# yum list|grep python3.12
[root@localhost ~]# yum -y install nginx.x86_64
现在/etc/yum.repos.d/除开有阿里云镜像之外,还有epe1仓库
[root@localhost ~]# ls /etc/yum.repos.d/
bak.tar.gz CentOS-Base.repo.bak epel-testing.repo
CentOS-Base.repo epel.repo
[root@localhost ~]# rm -rrf /etc/yum.repos.d/epel*
您在 /var/spool/mail/root 中有邮件
[root@localhost ~]# ls /etc/yum.repos.d/
bak.tar.gz CentOS-Base.repo CentOS-Base.repo.bak
[root@localhost ~]# yum -y install nginx.x86_64
[root@localhost ~]# nginx
[root@localhost ~]# ls /etc/yum.repos.d/
bak.tar.gz CentOS-Base.repo.bak epel-testing.repo
CentOS-Base.repo epel.repo
[root@localhost ~]# rm -rf /etc/yum.repos.d/epel*
您在 /var/spool/mail/root 中有邮件
[root@localhost ~]# ls /etc/yum.repos.d/
bak.tar.gz CentOS-Base.repo CentOS-Base.repo.bak
[root@localhost ~]# yum clean all
[root@localhost ~]# yum makecache
已加载插件:fastestmirror
Determining fastest mirrors
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
base | 3.6 kB 00:00
extras | 2.9 kB 00:00
updates | 2.9 kB 00:00
(1/10): base/7/x86_64/group_gz | 153 kB 00:00
(2/10): base/7/x86_64/primary_db | 6.1 MB 00:24
(3/10): extras/7/x86_64/primary_db | 253 kB 00:02
(4/10): extras/7/x86_64/other_db | 154 kB 00:00
(5/10): extras/7/x86_64/filelists_db | 305 kB 00:04
(6/10): base/7/x86_64/filelists_db | 7.2 MB 00:31
(7/10): base/7/x86_64/other_db | 2.6 MB 00:10
(8/10): updates/7/x86_64/filelists_db | 15 MB 01:02
(9/10): updates/7/x86_64/other_db | 1.6 MB 00:06
(10/10): updates/7/x86_64/primary_db | 27 MB 01:48
元数据缓存已建立
[root@localhost ~]# rm -rf /etc/yum.repos.d/CentOS-Base.repo
[root@localhost ~]# ls /etc/yum.repos.d/
bak.tar.gz CentOS-Base.repo.bak
[root@localhost ~]# vi /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.keymodule hotfixes=true
[root@localhost ~]# yum clean all
[root@localhost ~]# yum makecache
[root@localhost ~]# vi /etc/yum.repos.d/nginx.repo
[root@localhost ~]# yum list|grep nginx
[root@localhost ~]# yum install --downloadonly --downloaddir=./soft/ samba
[root@localhost ~]# ls soft/