saltstack 从minion传送文件到master及minion文件后端minionfs系统

简介: 演示如下: vagrant@saltminion1:/tmp$ touch talen.txt vagrant@saltminion1:/tmp$ echo This is a test .
演示如下:

  1. vagrant@saltminion1:/tmp$ touch talen.txt
  2. vagrant@saltminion1:/tmp$ echo This is a test . > talen.txt


  1. vagrant@saltmaster:/var/cache/salt/master$ sudo salt '*' test.ping
  2. minion2:
  3.     True
  4. minion1:
  5.     True
  6. vagrant@saltmaster:/var/cache/salt/master$ sudo salt '*' cp.push /tmp/talen.txt
  7. minion2:
  8.     False
  9. minion1:
  10.     True
  11. vagrant@saltmaster:/var/cache/salt/master$ cd /var/cache/salt/master/minions/minion
  12. minion1/ minion2/
  13. vagrant@saltmaster:/var/cache/salt/master/minions$ tree
  14. .
  15. ├── minion1
  16. │   ├── files
  17. │   │   └── tmp
  18. │   │   └── talen.txt
  19. │   └── mine.p
  20. └── minion2
  21.     └── mine.p

  22. 4 directories, 3 files

有时,我们需要传送在minion上产生的文件.
salt已经有从minion上传送文件到master的特性.默认因为安全性问题,没有启用.
修改master启用这个特性.
file_recv: True

点击(此处)折叠或打开

  1. vagrant@saltmaster:~ $ vim /etc/salt/master

  2. # Allow minions to push files to the master. This is disabled by default, for
  3. # security purposes.
  4. #file_recv: False
  5. file_recv: True

salt-cp cp模块是minion端的,其它函数功能参考
https://docs.saltstack.com/en/latest/ref/modules/all/salt.modules.cp.html#salt.modules.cp.push


# File Server Backend
#文件服务后端
#
# Salt supports a modular fileserver backend system, this system allows
# the salt master to link directly to third party systems to gather and
# manage the files available to minions. Multiple backends can be
# configured and will be searched for the requested file in the order in which
# they are defined here. The default setting only enables the standard backend
# "roots" which uses the "file_roots" option.
#salt支持一个模块化的文件服务后端系统,这个系统允许master直接链接到第三方平台系统收集和管理minions上的文件.请求文件将按定义的多个后端的顺序查询.默认使用file_roots选项只启用了最基本的roots.
#fileserver_backend:
#  - roots
#
# To use multiple backends list them in the order they are searched:
#fileserver_backend:
#  - git
#  - roots
#按顺序列出要查询的后端列表.
#
#如果你想让file_server允许追踪软链接文件系统树,取消下面的注释.默认是开启的,当前默认只应用于默认的文件服务后端.
# Uncomment the line below if you do not want the file_server to follow
# symlinks when walking the filesystem tree. This is set to True
# by default. Currently this only applies to the default roots
# fileserver_backend.
#fileserver_followsymlinks: False
#
# Uncomment the line below if you do not want symlinks to be
# treated as the files they are pointing to. By default this is set to
# False. By uncommenting the line below, any detected symlink while listing
# files on the Master will not be returned to the Minion.
#fileserver_ignoresymlinks: True
#
# By default, the Salt fileserver recurses fully into all defined environments
# to attempt to find files. To limit this behavior so that the fileserver only
# traverses directories with SLS files and special Salt directories like _modules,
# enable the option below. This might be useful for installations where a file root
# has a very large number of files and performance is impacted. Default is False.
# fileserver_limit_traversal: False
#
# The fileserver can fire events off every time the fileserver is updated,
# these are disabled by default, but can be easily turned on by setting this
# flag to True
#fileserver_events: False




如果想使用minion上的文件系统,简单启用两个参数
fileserver_backend:
  - roots
  - minion

file_recv: True
从下面的执行可以看到,当我们从minion1服务器上传文件到master后,minion1的上传目录/tmp已经可以在其它minions上看到了.
其它minions可以从minion1上共享的目录下载文件.

点击(此处)折叠或打开

  1. vagrant@saltmaster:~$ sudo salt '*' cp.list_master_dirs
  2. minion2:
  3.     - .
  4.     - common
  5.     - minion1/tmp
  6. minion1:
  7.     - .
  8.     - common
  9.     - minion1/tmp
  10. vagrant@saltmaster:~$ sudo salt 'minion2' cp.get_file salt://minion1/tmp/talen.txt /tmp/talen.2.txt
  11. minion2:
  12.     /tmp/talen.2.txt
  13. vagrant@saltminion2:~$ ll /tmp/talen.2.txt
  14. -rw-r--r-- 1 root root 17 Apr 27 03:47 /tmp/talen.2.txt


目录
相关文章
|
28天前
|
缓存 前端开发
后端MultipartFile接收文件转Base64
后端MultipartFile接收文件转Base64
80 8
|
1月前
|
缓存 监控 安全
构建高效后端系统的最佳实践
本文将深入探讨如何构建一个高效的后端系统,从设计原则、架构选择到性能优化等方面详细阐述。我们将结合实际案例和理论分析,帮助读者了解在构建后端系统时需要注意的关键点,并提供一些实用的建议和技巧。
37 2
|
5天前
|
存储 缓存 监控
构建高效后端系统的关键要素
【10月更文挑战第12天】 本文将探讨如何通过合理的架构设计、数据库优化、缓存策略和性能调优等措施,构建一个稳定、高效的后端系统。我们将分享一些实用的技巧和最佳实践,帮助开发者提升后端系统的性能和用户体验。
19 1
|
15天前
|
存储 缓存 测试技术
构建高效后端系统的关键策略##
【10月更文挑战第2天】 在当今数字化时代,后端系统的性能和可扩展性对于任何技术驱动的企业都至关重要。本文将深入探讨如何通过优化数据库设计、实施缓存机制、采用微服务架构以及自动化测试等措施,构建一个既高效又可靠的后端系统。我们将从基础的代码优化开始,逐步讨论到架构级别的改进,最终目标是提供一个全面的指导方案,帮助开发者和企业提升其后端系统的性能和可维护性。 ##
31 2
|
16天前
|
数据可视化 测试技术 Linux
基于Python后端构建多种不同的系统终端界面研究
【10月更文挑战第10天】本研究探讨了利用 Python 后端技术构建多样化系统终端界面的方法,涵盖命令行界面(CLI)、图形用户界面(GUI)及 Web 界面。通过分析各种界面的特点、适用场景及关键技术,展示了如何使用 Python 标准库和第三方库(如 `argparse`、`click`、`Tkinter` 和 `PyQt`)实现高效、灵活的界面设计。旨在提升用户体验并满足不同应用场景的需求。
|
19天前
|
Web App开发 JavaScript API
构建高效后端系统:Node.js与Express框架的实践之路
【9月更文挑战第37天】在数字化时代的浪潮中,后端开发作为技术架构的核心,承载着数据处理和业务逻辑的重要职责。本文将深入探讨如何利用Node.js及其强大的Express框架来搭建一个高效、可扩展的后端系统。我们将从基础概念讲起,逐步引导读者理解并实践如何设计、开发和维护一个高性能的后端服务。通过实际代码示例和清晰的步骤说明,本文旨在为初学者和有经验的开发者提供一个全面的指南,帮助他们在后端开发的旅途上走得更远。
37 3
|
2月前
|
设计模式 物联网 Android开发
移动应用与系统:探索未来技术的融合之路后端开发中的设计模式探索
【8月更文挑战第21天】随着科技的飞速发展,移动应用和操作系统已经成为我们日常生活中不可或缺的一部分。本文将深入探讨移动应用开发和移动操作系统的相关话题,包括它们的历史、现状以及未来的发展趋势。我们将从移动应用的开发环境、编程语言和工具等方面进行详细的分析,同时也会讨论移动操作系统的特点、优势以及面临的挑战。最后,我们将展望移动应用与系统在未来技术融合中的可能方向和机遇。
127 58
|
18天前
|
存储 前端开发 Java
Java后端如何进行文件上传和下载 —— 本地版(文末配绝对能用的源码,超详细,超好用,一看就懂,博主在线解答) 文件如何预览和下载?(超简单教程)
本文详细介绍了在Java后端进行文件上传和下载的实现方法,包括文件上传保存到本地的完整流程、文件下载的代码实现,以及如何处理文件预览、下载大小限制和运行失败的问题,并提供了完整的代码示例。
114 1
|
1月前
|
关系型数据库 Java 数据库
探索后端技术:构建高效系统的秘诀
在当今信息技术飞速发展的时代,后端开发作为软件架构中的核心部分,其重要性不言而喻。本文将深入探讨后端技术的各个方面,从基础概念到高级应用,帮助读者全面了解后端开发的世界,揭示构建高效系统的秘诀。
|
10天前
|
前端开发 JavaScript 小程序
前端uni开发后端用PHP的圈子系统该 如何做源码?
圈子系统系统基于TP6+Uni-app框架开发;客户移动端采用uni-app开发,管理后台TH6开发。系统支持微信公众号端、微信小程序端、H5端、PC端多端账号同步,可快速打包生成APP