|
|
# 执行环境交付
|
|
|
|
|
|
## 系统
|
|
|
执行环境系统一般为centos
|
|
|
|
|
|
## 硬盘
|
|
|
数据硬盘一般要求为SSD
|
|
|
|
|
|
## mysql数据
|
|
|
版本为8.0版本
|
|
|
|
|
|
## Python环境
|
|
|
python3.7
|
|
|
miniconda(conda)
|
|
|
|
|
|
## collie基础包
|
|
|
安装完成后需要替换其中的logging.conf, 参考
|
|
|
```html
|
|
|
/home/fanzx/work_space/pycharm/project-collie/deploy/deploy_baiduyun.sh
|
|
|
```
|
|
|
|
|
|
## FTP/SFTP
|
|
|
```html
|
|
|
lftp user@ip
|
|
|
ftp user@ip
|
|
|
```
|
|
|
|
|
|
用户在交付ftp服务(被动模式)后,通过NAT方式给机器加了外网的IP,造成FTP数据传输时,返回的建立数据传输的IP是内网的IP,无法传输数据,解决方案
|
|
|
1.修改FTP的配置,增加一条配置,让建立输出传输通道的时候从外网IP(139.198.31.38)走
|
|
|
```html
|
|
|
pasv_address=139.198.31.38
|
|
|
```
|
|
|
2.修改我们的writer--FTP
|
|
|
```
|
|
|
import socket
|
|
|
from ftplib import FTP, FTP_TLS, FTP_PORT, error_perm, parse150, error_reply
|
|
|
import os
|
|
|
import socket
|
|
|
import traceback
|
|
|
|
|
|
class FtpClient(FTP):
|
|
|
def ntransfercmd(self, cmd, rest=None):
|
|
|
size = None
|
|
|
if self.passiveserver:
|
|
|
host, port = self.makepasv()
|
|
|
conn = socket.create_connection((self.host, port), self.timeout,
|
|
|
source_address=self.source_address)
|
|
|
try:
|
|
|
if rest is not None:
|
|
|
self.sendcmd("REST %s" % rest)
|
|
|
resp = self.sendcmd(cmd)
|
|
|
# Some servers apparently send a 200 reply to
|
|
|
# a LIST or STOR command, before the 150 reply
|
|
|
# (and way before the 226 reply). This seems to
|
|
|
# be in violation of the protocol (which only allows
|
|
|
# 1xx or error messages for LIST), so we just discard
|
|
|
# this response.
|
|
|
if resp[0] == '2':
|
|
|
resp = self.getresp()
|
|
|
if resp[0] != '1':
|
|
|
raise error_reply(resp)
|
|
|
except:
|
|
|
conn.close()
|
|
|
raise
|
|
|
else:
|
|
|
with self.makeport() as sock:
|
|
|
if rest is not None:
|
|
|
self.sendcmd("REST %s" % rest)
|
|
|
resp = self.sendcmd(cmd)
|
|
|
# See above.
|
|
|
if resp[0] == '2':
|
|
|
resp = self.getresp()
|
|
|
if resp[0] != '1':
|
|
|
raise error_reply(resp)
|
|
|
conn, sockaddr = sock.accept()
|
|
|
if self.timeout is not socket._GLOBAL_DEFAULT_TIMEOUT:
|
|
|
conn.settimeout(self.timeout)
|
|
|
if resp[:3] == '150':
|
|
|
# this is conditional in case we received a 125
|
|
|
size = parse150(resp)
|
|
|
return conn, size
|
|
|
|
|
|
class FtpFileHelper(object):
|
|
|
def __init__(self, host, user, password, port=FTP_PORT, ssl=False):
|
|
|
self._host = host
|
|
|
self._user = user
|
|
|
self._password = password
|
|
|
self._port = port
|
|
|
if ssl:
|
|
|
self._ftp = FTP_TLS()
|
|
|
else:
|
|
|
self._ftp = FtpClient()
|
|
|
self._ftp.set_debuglevel(1)
|
|
|
self._connect()
|
|
|
``` |