In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Remote execution of SaltStack practice-Returners
Learning SaltStack
Remote execution of SaltStack practice-Returners
1. Returners list
two。 Introduce the usage of mysql returner
2.1 install pip and MySQLdb
2.2 configure the mysql database
2.2 configure salt-master
2.3 Test
1. Returners list
Https://docs.saltstack.com/en/latest/ref/returners/all/index.html
Returnersdescriptioncarbon_returnTake data from salt and "return" it into a carbon receivercassandra_cql_returnReturn data to a cassandra servercassandra_returnReturn data to a Cassandra ColumnFamilycouchbase_returnSimple returner for Couchbase.couchdb_returnS imple returner for CouchDB.django_returnA returner that will infor a Django system that returns are available using Django's signal system.elasticsearch_returnReturn data to an elasticsearch server for indexing.etcd_returnReturn data to an etcd server or clusterhipchat_returnReturn salt data via hipchat.influxdb_returnReturn data to an influxdb server.kafka_returnReturn data to a Kafka topiclocalThe local returner is used to test the returner interface It just prints thelocal_cacheReturn data to local job cachememcache_returnReturn data to a memcache servermongo_future_returnReturn data to a mongodb servermongo_returnReturn data to a mongodb servermulti_returnerRead/Write multiple returnersmysqlReturn data to a mysql servernagios_returnReturn salt data to NagiosodbcReturn data to an ODBC compliant server.pgjsonbReturn data to a PostgreSQL server with json data stored in Pg's jsonb data typepostgresReturn data to a postgresql serverpostgres_local_cacheUse a postgresql server for the master job cache.pushover_returnerReturn salt data via pushover (http://www.pushover.net)rawfile_jsonTake data from salt and "return" it into a raw file containing the json With one line per event.redis_returnReturn data to a redis serversentry_returnSalt returner that reports execution results back to sentry.slack_returnerReturn salt data via slacksms_returnReturn data by SMS.smtp_returnReturn salt data via emailsplunkSend json response data to Splunk via the HTTP Event Collectorsqlite3_returnInsert minion return data into a sqlite3 databasesyslog_returnReturn data to the host operating system's syslog facilityxmpp_returnReturn salt data via xmppzabbix_returnReturn salt data to Zabbix2. Introduce the usage of mysql returner
Because the python MySQLdb module is required for mysql returner use, the MySQLdb module needs to be installed first.
2.1 install pip and MySQLdb
Download the installation package at the following address.
Https://pypi.python.org/pypi/setuptools
Https://pypi.python.org/pypi/pip/
[root@salt-master111 tmp] # yum-y install python-devel mysql-devel
[root@salt-master111 tmp] # unzip setuptools-36.0.1.zip
[root@salt-master111 tmp] # cd setuptools-36.0.1
[root@salt-master111 tmp] # python setup.py install
[root@salt-master111 tmp] # cd.. /
[root@salt-master111 tmp] # tar-zxvf pip-9.0.1.tar.gz
[root@salt-master111 tmp] # cd pip-9.0.1
[root@salt-master111 tmp] # python setup.py install
[root@salt-master111 tmp] # pip install mysql
[root@salt-master111 tmp] # python
Python 2.7.5 (default, Nov 6 2016, 00:28:07)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-11)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
> import MySQLdb
> > >
2.2 configure the mysql database
Use the official datasheet structure and give the minion server relevant permissions.
CREATE DATABASE `salt`
DEFAULT CHARACTER SET utf8
DEFAULT COLLATE utf8_general_ci
USE `salt`
--
-- Table structure for table `jids`
--
DROP TABLE IF EXISTS `jids`
CREATE TABLE `jids` (
`jid` varchar (255) NOT NULL
`load` mediumtext NOT NULL
UNIQUE KEY `jid` (`jid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8
CREATE INDEX jid ON jids (jid) USING BTREE
--
-- Table structure for table `salt_ roomns`
--
DROP TABLE IF EXISTS `salt_ roomns`
CREATE TABLE `salt_ roomns` (
`Fun` varchar (50) NOT NULL
`jid` varchar (255) NOT NULL
`roomn` mediumtext NOT NULL
`id` varchar (255) NOT NULL
`room`varchar (10) NOT NULL
`full_ ret` mediumtext NOT NULL
`alter_ time`TIMESTAMP DEFAULT CURRENT_TIMESTAMP
KEY `id` (`id`)
KEY `jid` (`jid`)
KEY `fun` (`fun`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8
--
-- Table structure for table `salt_ events`
--
DROP TABLE IF EXISTS `salt_ events`
CREATE TABLE `salt_ events` (
`id` BIGINT NOT NULL AUTO_INCREMENT
`tag` varchar (255) NOT NULL
`data`mediumtext NOT NULL
`alter_ time`TIMESTAMP DEFAULT CURRENT_TIMESTAMP
`master_ id` varchar (255) NOT NULL
PRIMARY KEY (`id`)
KEY `tag` (`tag`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8
Grant all on salt.* to salt@ "10.1.0.%" identified by "saltpass"
2.2 configure salt-master
/ etc/salt/master
Return: mysql
Mysql.host: 'salt-host'
Mysql.user: 'salt'
Mysql.pass: 'saltpass'
Mysql.db: 'salt'
Restart master and minion services
Systemctl restart salt-master
Systemctl restart salt-minion
2.3 Test
The master side executes commands.
[root@salt-master111] # salt 'salt-master111' test.ping-- return mysql
Salt-master111:
True
[root@salt-master111 ~] #
Check in the database to see if salt_returns has any data coming in.
Mysql > select * from salt_returns
+- -+
| | fun | jid | return | id | success | full_ret | alter_time | |
+- -+
| | test.ping | 2017060917283535506510 | true | salt-master111 | 1 | {"fun_args": [], "jid": "20170609172835506510", "return": true, "retcode": 0, "success": true, "fun": "test.ping", "id": "salt-master111"} | 2017-06-0917: 28:35 |
| | test.ping | 20170609172841714924 | true | salt-master111 | 1 | {"fun_args": [], "jid": "20170609172841714924", "return": true, "retcode": 0, "success": true, "fun": "test.ping", "id": "salt-master111"} | 2017-06-0917: 28:41 |
| | test.ping | 20170609173636297217 | true | salt-master111 | 1 | {"fun_args": [], "jid": "20170609173636297217", "return": true, "retcode": 0, "success": true, "fun": "test.ping", "id": "salt-master111"} | 2017-06-0917: 36:36 |
| | test.ping | 20170609173653113715 | true | salt-master111 | 1 | {"fun_args": [], "jid": "20170609173653113715", "return": true, "retcode": 0, "success": true, "fun": "test.ping", "id": "salt-master111"} | 2017-06-0917: 36:53 |
+- -+
4 rows in se
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.