1准备工作
在centos7中禁用关闭防火墙
[root@centos7 yum.repos.d]#systemctl disable firewalld.service 禁用防火墙 下次开机不启用
[root@centos7 yum.repos.d]#systemctl stop firewalld.service 关闭防火墙
Centos6与centos7 以上操作命令不同
[root@centos7 yum.repos.d]#iptables -vnL 查看防火墙定义规则的详细信息
Chain INPUT (policy ACCEPT 115K packets, 12M bytes)
pkts bytes target prot opt in out source destination
Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
Chain OUTPUT (policy ACCEPT 2030 packets, 247K bytes)
pkts bytes target prot opt in out source destination
[root@centos7 7]#vim /etc/selinux/config
[root@centos7 7]#setenforce 0 setenforce是Linux的selinux防火墙配置命令 执行setenforce 0 表示关闭selinux防火墙。
在centos6中 禁用关闭防火墙
[root@centos6 ~]#chkconfig iptables off
[root@centos6 ~]#service iptables stop
iptables: Setting chains to policy ACCEPT: filter [ OK ]
iptables: Flushing firewall rules: [ OK ]
iptables: Unloading modules: [ OK ]
2安装ftp服务包
假如没有仓库,首先看是否有vsftpd 包 ,vsftpd 是搭建ftp服务器应用,高效稳定。
[root@centos7 yum.repos.d]#rpm -q vsftpd
package vsftpd is not installed
[root@centos7 yum.repos.d]#rpm -ivh /run/media/root/CentOS\ 7\ x86_ 64/Packages/vsftpd-3.0.2-10.el7.x86_64.rpm
Preparing... ################################# [100%] yum仓库未搭建 选rpm安装
Updating / installing...
1:vsftpd-3.0.2-10.el7 ################################# [100%]
[root@centos7 yum.repos.d]#rpm -ql vsftpd
…….
…….
/usr/lib/systemd/system/vsftpd.service 启动此服务 ftp网络共享服务才能运行
/usr/lib/systemd/system/vsftpd.target
/usr/lib/systemd/system/vsftpd@.service
/usr/sbin/vsftpd
…….
/var/ftp 访问服务器路径 也即是网络共享路径
/var/ftp/pub
[root@centos7 yum.repos.d]#ss -tnl ftp网络共享服务会占用网络端口 查看当前监听的tcp端口
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 5 192.168.122.1:53 *:*
LISTEN 0 128 *:22 *:* ftp为21端口 服务未启动 没有21端口
LISTEN 0 128 127.0.0.1:631 *:*
LISTEN 0 128 :::22 :::*
LISTEN 0 128 ::1:631
[root@centos7 yum.repos.d]#systemctl start vsftpd.service 启动ftp共享服务
[root@centos7 yum.repos.d]#ss -tnl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 5 192.168.122.1:53 *:*
LISTEN 0 128 *:22 *:*
LISTEN 0 128 127.0.0.1:631 *:*
LISTEN 0 32 :::21 :::* 21端口打开
LISTEN 0 128 :::22 :::*
[root@centos7 yum.repos.d]#systemctl enable vsftpd.service 设置为开机启动
[root@centos7 ~]#cd /var/ftp
[root@centos7 ftp]#ls
pub
测试如下:
3 准备服务端yum 仓库安装包
[root@centos7 ftp]#cd pub
[root@centos7 pub]#mkdir -p centos/{6,7} 可以参考阿里云路径格式
[root@centos7 pub]#cp -r /run/media/root/CentOS 7 x86_64/* /var/ftp/pub/centos/7
[root@centos7 pub]#cp -r /media/root/CentOS 6 x86_64/* /var/ftp/pub/centos/6
[root@centos7 7]#ls 切换到pub/centos/6 同样查看
CentOS_BuildTag EULA images LiveOS repodata RPM-GPG-KEY-CentOS-Testing-7
EFI GPL isolinux Packages RPM-GPG-KEY-CentOS-7 TRANS.TBL
4客户端配置
[root@centos7 ~]#cat>/etc/yum.repos.d/pud.repo<<eof
[centos-ftp]
name=repulic
baseurl=ftp://172.18.254.154/pub/centos/$releasever 仓库路径为repodata的所在目录
gpgcheck=1
gpgkey=ftp://172.18.254.154/pub/centos/$releasever/RPM-GPG-KEY-CentOS-$releasever
$releasever: 当前OS的发行版的主版本号
[root@centos7 yum.repos.d]#yum repolist
repo id repo name status
centos-ftp/7 repulic 9,007
repolist: 9,007
转载于:https://blog.51cto.com/13157015/2044477