node_exporter
下载
wget [https://github.com/prometheus/node_exporter/releases/download/v1.0.0-rc.0/node_exporter-1.0.0-rc.0.linux-amd64.tar.gz](https://github.com/prometheus/node_exporter/releases/download/v1.0.0-rc.0/node_exporter-1.0.0-rc.0.linux-amd64.tar.gz)
启动
nohup /opt/node_exporter/node_exporter --no-collector.softnet > /opt/node_exporter/node_exporter.log 2>&1 &
mysql_exporter
下载
wget [https://github.com/prometheus/mysqld_exporter/releases/download/v0.12.1/mysqld_exporter-0.12.1.linux-amd64.tar.gz](https://github.com/prometheus/mysqld_exporter/releases/download/v0.12.1/mysqld_exporter-0.12.1.linux-amd64.tar.gz)
创建mysqld_exporter账号
grant replication client,process on *.* to mysqld_exporter@'%' identified by 'mysqld_exporter';
grant select on performance_schma.* to mysqld_exporter@'%';
flush PRIVILEGES;
增加配置文件
vi /opt/mysqld_exporter/my.cnf
[client]
user=mysqld_exporter
password=mysqld_exporter
port=3306
host=127.0.0.1
启动
nohup /opt/mysqld_exporter/mysqld_exporter --config.my-cnf="/opt/mysqld_exporter/my.cnf" --web.listen-address=":9104” /opt/mysqld_exporter/mysqld_exporter.log 2>&1 &
redis_exporter
直接去github上搜索redis_exporter下载star最多的即可
tar -zxvf redis_exporter-v1.5.2.linux-amd64.tar.gz
mv redis_exporter-v1.5.2.linux-amd64/ /opt/redis_exporter
cd /opt/redis_exporter
启动
nohup /opt/redis_exporter/redis_exporter -redis.addr 172.20.7.131:6379 -redis.password bL8sviHixu &
proxysql_exporter
下载
wget https://github.com/percona/proxysql_exporter/releases/download/v1.1.0/proxysql_exporter-1.1.0.linux-amd64.tar.gz
tar -zxvf proxysql_exporter-1.1.0.linux-amd64.tar.gz
mv proxysql_exporter-1.1.0.linux-amd64 /opt/proxysql_exporter
cd /opt/proxysql_exporter/
启动
nohup /opt/proxysql_exporter/proxysql_exporter collect.mysql_connection_pool collect.mysql_status > /opt/proxysql_exporter/proxysql_exporter.log 2>&1 &
在grafana上导入dashboard json
https://github.com/percona/grafana-dashboards/blob/master/dashboards/ProxySQL_Overview.json
postgres_exporter
下载
tar -zxvf postgres_exporter_v0.8.0_linux-amd64.tar.gz
mv postgres_exporter_v0.8.0_linux-amd64/ /opt/postgres_exporter
cd /opt/postgres_exporter/
数据库编辑
CREATE USER postgres_exporter login WITH PASSWORD 'password';
ALTER USER postgres_exporter SET SEARCH_PATH TO postgres_exporter,pg_catalog;
-- If deploying as non-superuser (for example in AWS RDS), uncomment the GRANT
-- line below and replace <MASTER_USER> with your root user.
-- GRANT postgres_exporter TO <MASTER_USER>;
CREATE SCHEMA IF NOT EXISTS postgres_exporter;
GRANT USAGE ON SCHEMA postgres_exporter TO postgres_exporter;
GRANT CONNECT ON DATABASE postgres TO postgres_exporter;
CREATE OR REPLACE FUNCTION get_pg_stat_activity() RETURNS SETOF pg_stat_activity AS
$$ SELECT * FROM pg_catalog.pg_stat_activity; $$
LANGUAGE sql
VOLATILE
SECURITY DEFINER;
CREATE OR REPLACE VIEW postgres_exporter.pg_stat_activity
AS
SELECT * from get_pg_stat_activity();
GRANT SELECT ON postgres_exporter.pg_stat_activity TO postgres_exporter;
CREATE OR REPLACE FUNCTION get_pg_stat_replication() RETURNS SETOF pg_stat_replication AS
$$ SELECT * FROM pg_catalog.pg_stat_replication; $$
LANGUAGE sql
VOLATILE
SECURITY DEFINER;
CREATE OR REPLACE VIEW postgres_exporter.pg_stat_replication
AS
SELECT * FROM get_pg_stat_replication();
GRANT SELECT ON postgres_exporter.pg_stat_replication TO postgres_exporter;
启动
DATA_SOURCE_NAME="host=172.20.7.131 user=postgres_exporter password=postgres_exporter port=5432 dbname=postgres sslmode=disable" nohup /opt/postgres_exporter/postgres_exporter --extend.query-path="/opt/postgres_exporter/queries.yaml" > postgres_exporter.log 2>&1 &