In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/03 Report--
Salt provides a wealth of functional modules, involving the basic functions of the operating system, common tool support, and so on. You can list the modules supported by the current version through the sys module.
Salt'* 'sys.list_modules781915e2:-acl-aliases-alternatives-apache-archive-artifactory-at-blockdev-btrfs-buildout-cloud-cmd.
The principle of API is realized by calling the master client module, instantiating a LocalClient object, and then calling the cmd () method.
API implementation test.ping example:
> import salt.client > client = salt.client.LocalClient () > ret = client.cmd ('*', 'test.ping') > print ret {' 781915e2dictionary: True} # result is returned as a string in the form of a standard Python dictionary, which can be converted to the dictionary type of Python through the eval () function, which is convenient for subsequent business logic processing.
(1) Archive module
Function: realize the system-level call of compressed package, supporting gunzip, gzip, rar, tar, unrar, unzip and so on.
Example:
Salt '781915e2' cmd.run' mkdir / opt/test' # create / opt/test directory for the controlled side 781915e2: scp test.txt.gz root@kurol:/opt/test # copy the tested gzip file to the controlled side minionsalt '781915e2' archive.gunzip / opt/test/test.txt.gz # decompress the controlled side / opt/test/test.txt.gz file 781915e2: salt' 781915e2' archive.gzip / opt/test/test.txt # compress 781915e2:
API call:
> import salt.client > client = salt.client.LocalClient () > client.cmd ('*', 'archive.gunzip', [' / opt/test/test.txt.gz']) {'781915e2regions: []}
(2) cmd module
Function: remote command line call execution (root operation permission is available by default, and risk assessment is required when using it)
Example:
[root@server] # salt'* 'cmd.run "free-m" 781915e2: total used free shared buffers cached Mem: 996 834 162 0 121 252-/ + buffers/cache: 460 536 Swap: 0 000
API call:
Client.cmd ('*', 'cmd.run', [' free-m])
(3) cp module
Function: to copy remote files and directories, as well as download URL files.
Example:
Salt'* 'cp.cache_local_file / etc/hosts # copy the / etc/hosts file of the designated host to the local salt cache directory of the host (/ var/cache/salt/minion/localfiles) 781915e2: / var/cache/salt/minion/localfiles/etc/hosts salt' * 'cp.get_dir salt://path/to/dir/ / minion/dest # copy the directory under the location specified by the master server file_roots to the controlled host The first'/'of salt:// is the root specified by the configuration file base The second is the path separator 781915e2: salt'* 'cp.get_file salt://path/to/file / minion/dest # to copy the files under the location specified by the master server file_roots to the controlled host 781915e2: salt' * 'cp.get_url http://www.baidu.com / tmp/index.html # to download the URL content to the specified location 781915e2: / tmp/index.html
API call:
Client.cmd ('*', 'cp.get_file', [' salt://path/to/file','/ minion/dest'])
(4) cron module
Function: realize the crontab operation of the controlled host
Example:
Salt'* 'cron.raw_cron root # View the crontab list of the specified controlled host and root user 781915e2: # secu-tcs-agent monitor Install at Sat Mar 18 15:55:40 CST 2017 * / usr/local/sa/agent/secu-tcs-agent-mon-safe.sh / usr/local/sa/agent > / dev/null 2 > & 1 * / 1 * / usr/local/qcloud/stargate/admin/start.sh > / dev/null 2 > & 1 & * / 20 * / usr/sbin/ntpdate ntpupdate.tencentyun.com > / dev/null & 302 * / www/server/panel/certbot-auto renew > > / www/server/panel/logs/certbot.log salt'* 'cron.set_job root' *'1 / usr/local/weekly # is the designated controlled host, Root user add / usr/local/weekly task job 781915e2: newsalt '789880e2' cron.rm_job root / usr/local/weekly # Delete the specified controlled host, root user crontab / usr/local/weekly task job 781915e2: removed
API call:
Client.cmd ('*', 'cron.set_job, [' root','*','/usr/echo'])
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.