我们有将配置文件上传到 HDFS 的代码:
from hdfs import InsecureClient
def upload_file_to_hdfs(local_path, remote_path):
client = InsecureClient(url='http://hdfs_server:50070', user='dr.who')
try:
ret = client.upload(remote_path, local_path)
except Exception as e:
logging.info(f'Error: {e}')
print(f'File is uploaded: {local_path} -> {remote_path}')
return ret
现在域名和端口都固定了。如果我们有一个节点被切换怎么办?