目录
一、YUM仓库
1、yum介绍
2、yum源的提供方式
配置本地源仓库
配置ftp源
centOS7 清华源
163 yum 源
阿里云
其他网络源
3、yum命令
二、FTP文件传输
1、ftp基本信息
2、ftp配置文件
匿名用户设置
设置本地用户
三、NFS服务
1、介绍
2、配置
学习YUM 软件仓库,可以完成安装、卸载、自动升级 rpm 软件包等任务,能够自动 查找并解决 rpm 包之间的依赖关系,而无须管理员逐个、手工地去安装每个 rpm 包,使管 理员在维护大量 Linux 服务器时更加轻松自如。特别是在拥有大量 Linux 主机的本地网络中, 构建一台“源”服务器可以大大缓解软件安装、升级等对 Internet 的依赖。
YUM 的前身是 YUP(Yellow dog Updater,Yellow dog Linux 的软件更新器),最初由 TSS 公司(Terra Soft Solutions,INC.)使用 Python 语言开发而成,后来由杜克大学(Duck University)的 Linux 开发队伍进行改进,命名为 YUM(Yellow dog Updater,Modified)。 要成功使用 YUM 机制来更新系统和软件,需要有一个包含各种 rpm 安装包文件及其依 赖软件的软件仓库(repository),提供软件仓库的服务器也称为“源”服务器。在客户机中只 要正确指定软件仓库的地址等信息,就可以通过对应的“源”服务器来安装或更新软件
[root@localhost ~]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# ls
CentOS-Base.repo CentOS-fasttrack.repo CentOS-Vault.repo
CentOS-CR.repo CentOS-Media.repo
CentOS-Debuginfo.repo CentOS-Sources.repo
[root@localhost yum.repos.d]# mkdir repos.bak
[root@localhost yum.repos.d]# mv *.repo repos.bak/ #移除网络源
[root@localhost yum.repos.d]# ls
repos.bak
[root@localhost yum.repos.d]# vim local.repo[local] #仓库类别
name=local #仓库名称
baseur=file:///mnt #指定URL访问路径为光盘挂载目录
enabled=1 #开启yum源
gpgcheck=0 #不验证软件包[root@localhost yum.repos.d]# mount /dev/sr0 /mnt #挂载光盘[root@localhost ~]# yum clean all && yum makecache #清理和更新[root@localhost ~]# yum repolist #检查
服务器配置
1)安装vsftpd服务端软件
2)创建并制作yum远程ftp站点的源
3)启动ftp服务[root@localhost ~]# yum install vsftpd -y
[root@localhost ~]# mkdir /var/ftp/centos7 #创建挂盘挂载目录
[root@localhost ~]# mount /dev/sr0 /mnt #镜像挂载
mount: /dev/sr0 写保护,将以只读方式挂载
[root@localhost ~]# cp -rf /mnt/* /var/ftp/centos7/ &
[root@localhost ~]# mkdir /var/ftp/other # 创建目录repodata 数据文件
[root@localhost ~]# cd /var/ftp/other/
[root@localhost other]# createrepo -g /mnt/repodata/repomd.xml ./ #工具建立仓库数据文件
Saving Primary metadata
Saving file lists metadata
Saving other metadata
Generating sqlite DBs
Sqlite DBs complete
[root@localhost other]# systemctl start vsftpd
[root@localhost other]# systemctl status vsftpd
配置客户端
1)创建远程yum源的配置文件
2)yum安装软件验证结果[root@localhost ~]# yum install ftp -y #安装ftp
[root@localhost ~]# ftp 192.168.149.175 #测试ftp服务
Connected to 192.168.149.175 (192.168.149.175).
220 (vsFTPd 3.0.2)
Name (192.168.149.175:root): ftp
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> ls
227 Entering Passive Mode (192,168,149,175,113,184).
150 Here comes the directory listing.
drwxr-xr-x 8 0 0 220 Aug 31 09:54 centos7
drwxr-xr-x 3 0 0 22 Aug 31 09:55 other
drwxr-xr-x 2 0 0 6 Jun 09 16:15 pub
226 Directory send OK.
ftp> exit
221 Goodbye.[root@localhost ~]# cd /etc/yum.repos.d/ #配置源
[root@localhost yum.repos.d]# ls
CentOS-Base.repo CentOS-Debuginfo.repo CentOS-Media.repo CentOS-Vault.repo
CentOS-CR.repo CentOS-fasttrack.repo CentOS-Sources.repo
[root@localhost yum.repos.d]# mkdir repo.bak
[root@localhost yum.repos.d]# mv *.repo repo.bak/
[root@localhost yum.repos.d]# ls
repo.bak[root@localhost yum.repos.d]# vim ftp.repo
[root@localhost yum.repos.d]# cat ftp.repo
[ftp]
name=ftp
baseurl=ftp://192.168.149.175/centos7
enabled=1
gpgcheck=0[other]
name=ftp
baseurl=ftp://192.168.149.175/other
enabled=1
gpgcheck=0[root@localhost yum.repos.d]# yum clean all #更新
[root@localhost yum.repos.d]# yum makecache
[root@localhost ~]# yum install httpd -y #测试结果
vim CentOS7-Base-tsinghua.repo[base]
name=CentOS-$releasever - Base
baseurl=http://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7#released updates
[updates]
name=CentOS-$releasever - Updates
baseurl=http://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
baseurl=http://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
baseurl=http://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
下载链接:wget http://mirrors.163.com/.help/CentOS7-Base-163.repovim CentOS7-Base-163.repo #编辑163 yum 网络源
[base]
name=CentOS-$releasever - Base - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
baseurl=http://mirrors.163.com/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7#released updates
[updates]
name=CentOS-$releasever - Updates - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
baseurl=http://mirrors.163.com/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
baseurl=http://mirrors.163.com/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus - 163.com
baseurl=http://mirrors.163.com/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
下载地址:wget http://mirrors.aliyun.com/repo/Centos-7.repovim CentOS7-Base-aliyun.repo #编辑阿里云yum 网络源
[base]
name=CentOS-$releasever - Base - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/http://mirrors.aliyuncs.com/centos/$releasever/os/$basearch/http://mirrors.cloud.aliyuncs.com/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7#released updates
[updates]
name=CentOS-$releasever - Updates - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/updates/$basearch/http://mirrors.aliyuncs.com/centos/$releasever/updates/$basearch/http://mirrors.cloud.aliyuncs.com/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/extras/$basearch/http://mirrors.aliyuncs.com/centos/$releasever/extras/$basearch/http://mirrors.cloud.aliyuncs.com/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/centosplus/$basearch/http://mirrors.aliyuncs.com/centos/$releasever/centosplus/$basearch/http://mirrors.cloud.aliyuncs.com/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/contrib/$basearch/http://mirrors.aliyuncs.com/centos/$releasever/contrib/$basearch/http://mirrors.cloud.aliyuncs.com/centos/$releasever/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
1)http://ftp.sjtu.edu.cn/centos #上海交大,但服务器位于北京,中国教育网网络中心,我看像是朝阳区那边的IP,以前在那边上过 班,下载速度高达十M。 北方用户与教育网用户推荐,速度飞快。2)http://centos.ustc.edu.cn,#中国科技大学,服务器位于合肥。 南方用户推荐。3)http://mirrors.sohu.com/,sohu的开源镜像服务器,服务器位于山东省联通。 速度飞快,全国用户推荐,经常用FireFox下载CD镜像
yum常用的操作命令:
yum -y install 软件名 #安装、升级软件包,“-y”选项表示自动确认
yum -y remove 软件名 #卸载软件包,可自动解决其依赖关系
yum -y update 软件名 #升级软件包
yum list #查询软件包列表
yum list installed #查询系统中已安装的软件包
yum list available #查询仓库中尚未安装的软件包
yum list updates #查询可以升级版本的软件包
案列搜索RPM包(两种方法)
yum search vim
yum list | grep "vim"
yum info 软件名 #查询软件包的描述信息
yum info httpd
yum search [all] 关键词 #根据某个关键词来查找相关的软件包
yum search all httpd
yum whatprovides 命令 #查询命令属于哪个软件包
yum whatprovides netstat
下载RPM包而不安装
# yum install 包名 -y --downloadonly
# yum reinstall -y bash --downloadonly #下载已安装过的rpm包
# yum install 包名 -y --downloadonly --downloaddir=/tmp/ #下载RPM包到指定目录
yum history 查看历史记录来找到它所依赖的包,然后删除,
如:yum history list 列出最近的历史
yum history info id 列出某次的详细信息,
yum history undo id 撤销某次更改
yum history help 查看帮助
yum info vsftpd 查看信息
作用: Internet 上用来传送文件的协议。VSFTP全称
VSFTP模式: C/S模式
FTP服务器默认使用TCP协议的20、21端口与客户端进行通信
20瑞口用于建立数据连接,并传输文件数据
21端口用于建立控制连接,并传输FTP控制命令
FTP数据连接分为主动模式和被动模式
主动模式:服务器主动发起数据连接
被动模式:服务器被动等待数据连接
[root@localhost ~]# yum install vsftpd -y[root@localhost ~]# cd /etc/vsftpd/
[root@localhost vsftpd]# ls
ftpusers user_list vsftpd.conf vsftpd_conf_migrate.sh
[root@localhost vsftpd]# cp -r vsftpd.conf vsftpd.conf.bak
[root@localhost vsftpd]# ls
ftpusers user_list vsftpd.conf vsftpd.conf.bak vsftpd_conf_migrate.sh
[root@localhost vsftpd]# vim vsftpd.conf
listen=YES
vim /etc/vsftpd/vsftpd. conf
anonymous enable=YES #开启匿名用户访问。默认已开启
write_enable=YES #开放服务器的写权限(若要上传,必须开启)。默认已开启
anon_umask=022 #设置匿名用户所上传数据的权限掩码(反掩码)。
anon_upload_enable=YES #允许匿名用户.上传文件。默认已注释,需取消注释
anon_mkdir_write_enable=YES #允许匿名用户创建(上传)目录。默认已注释,需取消注释anon_other_write_enable =YES #允许删除、重命名、覆盖等操作。需添加
[root@localhost ~]# chmod 777 /var/ftp/pub/
[root@localhost ~]# systemctl restart vsftpd
chmod 777 /var/ftp/pub/
#为匿名访问ftp的根目录下的pub子目录设置最大权限,以便匿名用户上传数据
禁止切换到ftp以外的目录(默认登录的根目录为本地用户的家目录)#修改配置文件
vim /etc/vsftpd/vsftpd
[root@localhost ftp]# cd /etc/vsftpd/
[root@localhost vsftpd]# ls
ftpusers user_list vsftpd.conf vsftpd.conf.bak vsftpd_conf_migrate.sh
[root@localhost vsftpd]# vim vsftpd.conf
listen=YES
local_enable=Yes #启用本地用户
anonymous_enable=NO #关闭匿名用户访问
write_enable=YES #开放服务器的写权限(若要上传,必须开启)
local_umask=077 #可设置仅宿主用户拥有被上传的文件的权限(反掩码)
chroot_local_user=YES #将访问禁锢在用户的宿主目录中
allow_writeable_chroot=YES #允许被限制的用户主目录具有写权限
#anon_mkdir_write_enable=YES #注释
#anon_other_write_enable=YES # 注释
重启服务
systemctl restart vsftpd
用户只能在自己的/home/用户下
修改匿名用户、本地用户登录的默认根目录
anon_root=/var/www/html #anon _root针对匿名用户
local_root=/var/www /html #local_root针对系统用户
使用user_list用户列表文件
vim /etc/vsftpd/user_list
//末尾添加zhangsan用户
zhangsan
vim /etc/vsftpd/vsftpd.conf
userlist_enable=YES #启用user list用户列表文件
userlist_deny=NO
#设置白名单,仅允许user_list用户列表文件的用户访问。默认为YES,为黑名单,禁用
NFS是一种基于TCP/IP传输的网络文件系统协议,最初由 sun公司开发。通过使用 NPS协议,客户机可以像访问本地目录一样访问远程服务器中的共享资源
NFS 也是NAS 存储设备必然支持的一种协议
NFS服务的实现依赖于RPC (Remote Process Call,远端过程调用)机制,以完成远程到本地的映射过程。在Centos "系统中,需要安装nfs-utils、rpcbind软件包来提供NFS共享服务,前者用于NFS共享发布和访问,后者用于RPC支持。手动加载 NFS 共享服务时,应该先启动rpcbind,再启动nfs。
nfs端口号2049
RPC瑞口号111
特点
采用TCP/IP传输网络文件安全性低
简单易操作
适合局域网环境
安装nfs和rpcbind软件修改配置文件设置共享创建共享目录
开启服务
客户端验证共享目录可访问
客户端[root@localhost ~]# yum install rpcbind nfs-utils -y
[root@localhost ~]# vim /etc/exports
[root@localhost ~]# cat /etc/exports
/opt/web 192.168.149.0/24(rw,sync,no_root_squash)
[root@localhost ~]# systemctl restart rpcbind
[root@localhost ~]# systemctl restart nfs
[root@localhost ~]# exportfs -v
/opt/web 192.168.149.0/24(rw,sync,wdelay,hide,no_subtree_check,sec=sys,secure,no_
root_squash,no_all_squash)[root@localhost ~]# mkdir /opt/web
[root@localhost ~]# showmount -e localhost
Export list for localhost:
/opt/web 192.168.149.0/24
服务端[root@localhost ~]# yum install rpcbind nfs-utils -y
[root@localhost ~]# showmount -e 192.168.149.139
Export list for 192.168.149.139:
/opt/web 192.168.149.0/24mount 192.168.149.139.141:/opt/web /home/text此时服务器客户端的/opt/web 和 服务端/home/text 已经实现了文件共享功能,一般情况下服务端的这个文件位置,我们会做raid来实现文件安全备份