GBase 8a MPP Cluster 自V9.5.2.X版本加载功能开始支持从通用数据服务器拉取数据,支持ftp/http/hdfs/sftp等多种协议,支持kafka集群作为数据源加载数据。
今天的内容以Red Hat Enterprise Linux 6.2平台为例,先介绍下 FTP文件服务器的配置方法。

1 FTP服务器配置

使用vsftp搭建FTP服务器。

1)查看是否已安装vsftpd

# rpm -qa vsftpd
vsftpd-2.2.2-6.el6_0.1.x86_64

2)安装vsftpd

# rpm -ivh vsftpd-2.2.2-6.el6_0.1.x86_64.rpm

3)修改FTP服务器默认配置

# vim /etc/vsftpd/vsftpd.conf

# 表示允许匿名用户登录(默认为YES).
anonymous_enable=YES

# 表示允许本地用户登录(默认为YES).
local_enable=YES

# 表示开放对本地用户的写权限(默认YES,如仅用作加载文件服务器,可改为NO).
write_enable=NO

# 设置本地用户的文件生成掩码(默认对本地用户的文件生成掩码是077,可改为022)
local_umask=022

# 允许匿名FTP用户上载文件(默认为NO).
#anon_upload_enable=YES

# 允许匿名FTP用户创建目录(默认为NO).
#anon_mkdir_write_enable=YES

# 启用FTP数据端口的连接请求(默认为YES).
connect_from_port_20=YES

# 使用PAM认证的配置文件名,文件位于/etc/pam.d目录下
pam_service_name=vsftpd

# 是否使用userlist文件控制访问FTP服务器
userlist_enable=YES

# 设置禁止访问的文件或目录
#deny_file={*.mp3,*.mov,.private}

# 设置隐藏的文件或目录
#hide_file={*.mp3,.hidden,hide*,h?}

# 设置FTP被动模式开放端口范围(默认为0,表示任意可用端口)
pasv_min_port=20001
pasv_max_port=21000

# 设置允许的最大客户连接数(默认为2000)
max_clients=2000

# 设置每个IP上允许的最大客户连接数(默认为50)
max_per_ip=50

# 用于被动传输方式的连接超时(默认为60)
accept_timeout=60    

# 用于主动传输方式的连接超时(默认为60)
connect_timeout=60    

# 无进度状态下的数据传输超时(默认为300)
data_connection_timeout=300    

# 空闲连接超时(默认为300)
idle_session_timeout=300    

# 是否使用系统调用sendfile优化传输(默认为YES,使用nfs等网络盘时应设置为NO)
use_sendfile=YES

# 设置非匿名登录用户的主目录
#local_root=/var/ftp/pub

更多的配置可查看vsftpd.conf文档
# man vsftpd.conf

在集群最大并发加载任务数为N,单加载任务最大加载机数(max_data_processors)为M时,部分参数最小值和推荐值如下:

参数名称

默认值

最小值

推荐值

max_clients

2000

M*N

M*N*2

max_per_ip

50

N

N*2

pasv_min_port

0

max-min : M*N

max-min : M*N*2

4)配置允许或禁止访问FTP服务器的用户列表(可跳过)

# vim /etc/vsftpd/user_list
  • 当/etc/vsftpd/vsftpd.conf中配置如下时,禁止/etc/vsftpd/user_list中的所有用户访问FTP服务器。

    userlist_enable=YES
    userlist_deny=YES(缺省为YES)

  • 当/etc/vsftpd/vsftpd.conf中配置如下时,允许/etc/vsftpd/user_list中的所有用户访问FTP服务器。

    userlist_enable=YES
    userlist_deny=NO

5)配置禁止访问FTP服务器的用户列表(可跳过)

# vim /etc/vsftpd/ftpusers

6)关闭SELINUX功能或更改其配置(两种方式二选一即可)

  • 关闭SELINUX功能
# vim /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=disable
# SELINUXTYPE= can take one of these two values:
#     targeted - Targeted processes are protected,
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted

重启或者执行

# setenforce 0
  • 更改SELINUX配置
# setsebool ftp_home_dir 1

注意:当用浏览器访问FTP服务器遇到“500 OOPS: cannot change directory:/home/...”时,可能为此问题。

7)关闭或配置防火墙

  • 关闭防火墙

停止防火墙服务

# service iptables stop
iptables:清除防火墙规则:                                 [确定]
iptables:将链设置为政策 ACCEPT:filter                    [确定]
iptables:正在卸载模块:                                   [确定]

查看防火墙是否在开机时自动启动

# chkconfig --list iptables
iptables    0:关闭  1:关闭  2:启用  3:启用  4:启用  5:启用  6:关闭

禁止防火墙在开机时自动启动

# chkconfig iptables off

或   

# chkconfig iptables off --level 2345

设置后防火墙在开机时自动启动状态

# chkconfig --list iptables
iptables    0:关闭  1:关闭  2:关闭  3:关闭  4:关闭  5:关闭  6:关闭
  • 配置防火墙

设置默认规则

# iptables -A INPUT -j DROP

注:添加上条规则会阻止未处理的传入数据包,如在此规则之前未添加允许规则将会阻止远程连接

# iptables -A FORWARD -j ACCEPT

开放FTP端口

# iptables -I INPUT -p tcp --dport 21 -j ACCEPT
# iptables -I OUTPUT -p tcp --sport 21 -j ACCEPT
# iptables -I INPUT -p tcp --dport 20 -j ACCEPT
# iptables -I OUTPUT -p tcp --sport 20 -j ACCEPT
# iptables -I INPUT -p tcp --dport 20001:21000 -j ACCEPT
# iptables -I OUTPUT -p tcp --sport 20001:21000 -j ACCEPT

保存防火墙设置

# iptables-save > /etc/sysconfig/iptables

8)启动vsftpd服务并设置为开机启动项

# service vsftpd start
为 vsftpd 启动 vsftpd:                                    [确定]
# chkconfig vsftpd on

9)复制文件到FTP目录

  • 如未设置local_root=/var/ftp/pub时,复制文件到/home/xxxx(用户的home目录)
  • 如已设置local_root=/var/ftp/pub时,复制文件到/var/ftp/pub
  • 如已设置anonymous_enable=YES时,复制文件到/var/ftp或/var/ftp/pub(匿名登录的主目录)

以上就是今天的内容,感谢大家阅读!