真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

consul知識點(diǎn)歸納

consul_template:?https://www.hi-linux.com/posts/36431.html

創(chuàng)新互聯(lián)建站成立與2013年,是專業(yè)互聯(lián)網(wǎng)技術(shù)服務(wù)公司,擁有項目做網(wǎng)站、網(wǎng)站制作網(wǎng)站策劃,項目實施與項目整合能力。我們以讓每一個夢想脫穎而出為使命,1280元德城做網(wǎng)站,已為上家服務(wù),為德城各地企業(yè)和個人服務(wù),聯(lián)系電話:13518219792

1、下載安裝包 并解壓consul 得到consul二進(jìn)制文件

https://releases.hashicorp.com/consul/1.3.1/consul_1.3.1_linux_amd64.zip?

mkdir /application &&? mv consul /application

2、啟動腳本啟動consul_server?

#!/bin/bash
bin_path=/application/
data_path="$bin_path"/data
nodename=`hostname`
idc=dc1
bindip=`/sbin/ifconfig?eth0?|grep?'\binet?\b'?|sed?-nr?'s#[^0-9]*([0-9.]*).*#\1#gp'`
bootstrap_expect=1
$bin_path/consul?agent??-server?\
????????????????????????-bind=$bindip?\
????????????????????????-ui?\
???-client=0.0.0.0?\
????????????????????????-bootstrap-expect=$bootstrap_expect?\
????????????????????????-data-dir?$data_path?\
????????????????????????-node?$nodename?\
????????????????????????-datacenter=$idc?\
????????????????????????-log-level=warn?\
????????????????????????-pid-file=$bin_path/consul.pid

3、consul配合consul_template自動修改prometheus配置

參考博客:https://www.hi-linux.com/posts/36431.html

1、consul指定添加單個key

./consul?kv?put?prometheus/kubernetes-apiserver/address?10.0.0.31

2、consul指定獲取單個key

./consul?kv?get?prometheus/kubernetes-apiserver/address

3、consul指定刪除單個key

./consul?kv?delete?prometheus/kubernetes-apiserver/address

4、consul_template安裝

$?wget?https://releases.hashicorp.com/consul-template/0.18.3/consul-template_0.18.3_linux_amd64.zip
$?unzip?consul-template_0.18.3_linux_amd64.zip
$?mv?consul-template?/usr/local/bin/

5、prometheus配置文件來設(shè)置tcp端口檢測機(jī)制:

-?job_name:?"tcp_port_discorvery"
??scrape_interval:?5s
??metrics_path:?/probe
??params:
????module:?[tcp_connect]
??file_sd_configs:
????-?files:
??-?/home/work/software/prometheus/tcp_port.json
??relabel_configs:
????-?source_labels:?[__address__]
??target_label:?__param_target
-?source_labels:?[__param_target]
??target_label:?instance
-?target_label:?__address__
??replacement:?xxx.xx.xx.xx:31659

配置consul_template模板來進(jìn)行配置渲染

vim?/prometheus/template.json
[{{?range?tree?"prometheus/linux"?}}
{
"targets":?["{{?.Value?}}"],
"labels":?{
"process_name":?"{{?.Key?}}"
}
},
{{?end?}}
{
"targets":?["xxx.xx.xx.xx:80"],
"labels":?{
"process_name":?"tengine"
}
}
]

vim?/application/prometheus.ops
consul?{
address?=?"xxx.xx.xx.xx:8500"
}
template?{
source?=?"/prometheus/template.json"
destination?=?"/home/work/software/prometheus/tcp_port.json"
command?=?"curl?-X?POST?http://127.0.0.1:9090/-/reload"
}

測試模板生成文件 看到文件內(nèi)容為空

consul-template??-consul-addr?xxx.xxx.xx.xx:8500?-template="complate.json:result"?-once?-dry

將要獲取的key推到consul中注冊

./consul?kv?put?prometheus/tcp_port/k8smaster-apiserver?1xx.xx.xx.xx:6443

測試無誤后啟動consul-template

consul-template?-config?"/application/prometheus.ops"?&

也可以添加到systemctl服務(wù)管理程序設(shè)置開機(jī)自啟動


網(wǎng)站名稱:consul知識點(diǎn)歸納
標(biāo)題網(wǎng)址:http://weahome.cn/article/iipssh.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部