yum 源的概述和安装(seven day)

一、yum源概述

1、yum仓库

2、yum的优点

rpm安装(下载软件 单独安装 需要解决依赖关系)
源码安装(configure make make install)
yum基于rpm,相当于rpm升级版,自动解决依赖关系

3、分类

本地yum源:yum仓库在本地,系统光盘/镜像文件
网络源: aliyun 163源 sohu源 清华源 redhat源 epel源 centos源
特定软件:nginx MySQL zabbix

4、查看现有的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 #所有的仓库都删除完了

二、镜像配置及下载

1、在VMware中装载光盘镜像

2、把光盘挂载到指定目录下

(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

3、 将挂载添加到开机启动文件中

          chmod +x /etc/rc.local    #添加权限

          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

  • 20
    点赞
  • 20
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值