1.yum 的分类
本地yum源:yum仓库在本地,系统光盘/镜像文件
网络源: aliyun 163源 sohu源 清华源 redhat源 epel源 centos源
特定软件:nginx MySQL zabbix
2.查看现有的yum仓库镜像备份并且删除
[root@a ~#ls-l /etc/yum.repos.d/
[root@a ~]# yum repolist all #查看本地源
[root@a ~]# yum makecache #创建缓存
[root@a ~]# tar -zcvf /etc/yum.repos.d/bak.tar.gz /etc/yum.repos.d/* #备份仓库
[root@a ~]# ls -l /etc/yum.repos.d/
-rw-r--r-- 1 root root 170 7月 16 09:54 bak.tar.gz
[root@a ~]#rm -rf /etc/yum.repos.d/*.repo #删除
[root@a ~]# yum repolist all
repolist:0 #所有的仓库都删除完了
3.在VMvare中下载光盘镜像
采用lsblk查看镜像存储信息
4.把光盘挂载到指定目录下面
(1)删除/mnt目录下所有的文件
(2)lsblk
(3)mount -o ro /dev/sr0 /mnt
选项 -o 表示挂载方式
ro=readonly
rw=read and write
[root@oneday ~]# mount /dev/sr0 /mnt/ -o ro
[root@oneday ~]# ls /mnt
4.将挂载添加到开机启动文件中
chmod + /etc/rc.loacl
echo 'mount -o ro /dev/sr0 /mnt' >> /etc/rc.local 向文件中添加一行
[root@oneday ~]# echo 'mount -o ro /dev/sr0 /mnt' >> /etc/rc.local
[root@oneday ~]# ls -l /etc/rc.local
4、编写本地 repo文件
[root@oneday ~]# vim /etc/yum.repos.d/local.repo #创建一个repo文件
[root@a ~]# yum clean all #清除缓存
[root@a~]# yum makecache #创建缓存
5、阿里镜像
[root@oneday ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
[root@oneday ~]# yum makecache #生成缓存
[root@oneday ~]# ls /etc/yum.repos.d/
[root@oneday ~]# mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
6、腾讯镜像
[root@oneday ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.cloud.tencent.com/repo/centos7_base.repo
[root@localhost ~]# yum clean all
[root@localhost ~]# yum makecache
7、下载epel
[root@oneday ~]# yum -y install epel-release
[root@oneday ~]# yum -y install sl
[root@oneday ~]# sl
nginx已经在epel中加装
8、nginx的安装
第一种方式:
[root@oneday ~]# yum -y install nginx.x86_64
[root@oneday ~]# nginx
[root@oneday ~]# curl http://localhost
第二种方式:
[root@oneday ~]# vim /etc/yum.repos.d/nginx.repo
[root@oneday ~]# yum clean all
[root@oneday ~]# yum makecache
[root@oneday ~]# yum -y install nginx.x86_64
9、自建缓存
[root@oneday ~]# cp /etc/yum.repos.d/CentOS-Base.repo.bak /etc/yum.repos.d/CentOS-B[root@oneday ~]# yum clean all
[root@oneday ~]# vim /etc/yum.conf
[root@oneday ~]# yum -y install tree
[root@oneday ~]# yum makecache
10、自建仓库
(1)下载samba的安装包
[root@oneday ~]# yum install --downloadonly --downloaddir=./soft/ samba #只下载不安装
(2)安装createrepo制作创库的软件
[root@oneday ~]# yum -y install createrepo
[root@oneday ~]# createrepo soft/ #使用createrepo指令
[root@oneday ~]# ls soft/ #出现repodata文件
(3)在/etc/yum.repos.d/soft.repo
[root@oneday ~]# vim /etc/yum.repos.d/soft.repo
[root@oneday ~]# yum clean all
[root@oneday ~]# yum makecache
[root@oneday ~]# yum -y install samba