Linux学习笔记008-创建本地源和http源

 

首先是添加网络源,以163源为例

1.百度搜索163源

2.进入官网,找到centos项,点击后面的Centos使用帮助,下载自己使用的Linux版本,这里我选择Centos7

3.这里就会下载centos163的源文件,把这个文件内容通过ssh远程登录工具,或者rz,FTP的方式上传到Linux主机

4.然后运行yum makecache更新源文件配置即可

配置本地源

1.首先挂载光盘镜像mount  /dev/cdrom  /mnt

#mount /dev/cdrom ./mnt

 

2.运行vim /etc/yum.repos.d/ios.repo

#vim /etc/yum.repos.d/ios.repo

写入如下配置:

name源名称

baseurl 源的url

gpgchek 是否检查GPG-KEY

enabled 是否启用源

gpgkey 指定挂载目录下的gpgkey文件验证

3.运行yum clean all,yum makecache,即可启动本地源,安装screen软件测试。

#yum clean all 

#yum makecache

#yum install sreecn

 

创建http源(及局域网源)

1.挂载好光盘后,使用本地源,安装httpd服务

#yum install httpd -y

2.在http的发布目录/var/www/html/下创建Centos7

#mkdir /var/www/html/Centos7

3.将/mnt/Pakeages/内的rpm包移动到到/var/www/html/Centos7中

#cp  /mnt/Pakeages /var/www/html/Centos7

4.安装软件createrepo,yum install createrepo* -y,安装完成后切换至目录/var/www/html运行命令createrepo Centos7

#yum install createrepo* -y

#cd /var/www/html/

#createrepo Centos7

5.编辑httpd.repo并保存

具体配置如下

#vim /etc/yum.repos.d/httpd.repo

[lan]

name=lan

baseurl=http://192.168.1.4/Centos7

gpgcheck=0

enable=1

6.运行yum clean all和yum makecache

#yum clean all

#yum makecache

可以看出lan名的源已经生效。

7.默认使用ISO镜像文件中的软件包构建的HTTP YUM源,会发现缺少很多软件包,如果服务器需要挂载移动硬盘,Mount挂载移动硬盘需要ntfs-3g软件包支持,因此需要手动配置

下载ntfs-sg包

#cd /var/www/html/Centos7

#wget http://dl.fedoraproject.org/pub/epel/7/x86_64/n/ntfs-3g-2016.2.22-3.el7.x86_64.rpm

#wget http://dl.fedoraproject.org/pub/epel/7Server/x86_64/Packages/n/ntfs-3g-devel-2017.3.23-6.el7.x86_64.rpm

#cd ..

#createrepo --update Centos7

#yum makecache

#yum install ntfs-3g -y

 

当然所有的IOS文件里面没有的软件包都可以通过以上方式进行添加

8.需要同步外网源的做法

 首先下载一个外网源(例如163源)

#cd /etc.yum.repos.d/

#wget http://mirrors.163.com/.help/CentOS7-Base-163.repo

#mv CentOS7-Base-163.repo /etc.yum.repo.d/Centos.repo

#yum clean all

#yum repolist

安装reposync软件

#yum install yum-utils createrepo -y

同步外网源

#reposync -r base -p /var/www/html/Centos7

通过createrope 命令使源生效

#createrope /var/www/html/Centos7

ok完成

rpm 安装软件是依赖关系会非常繁琐,所以在没有网络的环境下或者不能访问Internet的情况下尽量的使用http源或者本地源。

posted @ 2018-07-14 23:38  曲散  阅读(322)  评论(0编辑  收藏  举报