In the Saltstack default mode of operation, the Minion will return data directly to the MySQL database, which does not require master involvement. By providing more flexible management, you can also save the execution result (job cache) on the master side, the default save address on the master side is:/var/cache/salt/master/jobs. Minion.
The job cache has the corresponding configuration parameters in the configuration file on the master side:
#cachedir:/var/cache/salt/master Saved Path
#keep_jobs: 24 Saved time 24 hours
Configure the job cache to write directly to the database
The cache on the master side can be written directly to the database via configuration.
The default table structure of the job cache is the same as the table structure of the salt database, but if you want to interact with the database, you need to install Mysql-python on the master side:
Yum Install Mysql-python-y
Modify the master configuration file, and at the end, add the MySQL configuration directly:
# Vim/etc/salt/master
Master_job_cache:mysqlmysql.host: ' 172.16.10.60 ' mysql.user: ' Salt ' mysql.pass: ' SALTPW ' mysql.db: ' Salt ' mysql.port: 3306
Restart Salt-master:
# systemctl Restart Salt-master
Execute on the master side:
# salt ' * ' test.ping
If there are no errors, the execution succeeds and you can see whether the data is written in MySQL:
MariaDB [salt]> Use Salt;select * from Salt_returns\g
Each time it is executed, two records (two minion) are generated.
This allows the job cache to be returned to the database each time it executes.
Salt Common management commands:
# Salt-run Jobs.list_jobs View the history of the Salt Job-cache task, from the directory to query, not from the database.
# Salt-run Jobs.lookup_jid 20161124144637116519 Viewing the execution results of a task
To view the status of the current minion:
# Salt-run Manage.status
To view the Minion in the down state:
# Salt-run Manage-down
To view the Minion in the UP state:
# Salt-run Manage-up
To view version information:
# Salt-run Manage.versions
This article is from the "Trying" blog, make sure to keep this source http://tryingstuff.blog.51cto.com/4603492/1876210
SALTSTCK Building Web cluster-job management