In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
Consul_template: https://www.hi-linux.com/posts/36431.html
1. Download the installation package and extract the consul to get the consul binary file
Https://releases.hashicorp.com/consul/1.3.1/consul_1.3.1_linux_amd64.zip
Mkdir / application & & mv consul / application
2. Start consul_server with startup script
#! / bin/bashbin_path=/application/data_path= "$bin_path" / datanodename= `hostname`idc = dc1bindip= `/ sbin/ifconfig eth0 | grep'\ binet\ b' | sed-nr's # [^ 0-9] * ([0-9.] *). * #\ 1roomgp`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 cooperates with consul_template to automatically modify prometheus configuration
Reference blog: https://www.hi-linux.com/posts/36431.html
1. Consul specifies to add a single key
. / consul kv put prometheus/kubernetes-apiserver/address 10.0.0.31
2. Consul specifies to get a single key
. / consul kv get prometheus/kubernetes-apiserver/address
3. Consul specifies to delete a single key
. / consul kv delete prometheus/kubernetes-apiserver/address
4. Consul_template installation
$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 configuration file to set the tcp port detection mechanism:
-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
Configure the consul_template template for configuration rendering
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.opsconsul {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"}
The test template generation file saw that the content of the file was empty
Consul-template-consul-addr xxx.xxx.xx.xx:8500-template= "complate.json:result"-once-dry
Push the key to be obtained to register in consul
. / consul kv put prometheus/tcp_port/k8smaster-apiserver 1xx.xx.xx.xx:6443
Start consul-template after the test is correct
Consul-template-config "/ application/prometheus.ops" &
It can also be added to the systemctl service manager to set boot self-startup
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.