监控系统
Prometheus
安装prometheus
CPU报警规则
磁盘报警规则
内存报警规则
实例存活告警规则
node_exporter
安装node_exporter
consul服务发现
安装consul
ansible注册服务器到consul
curl注册、注销服务到consul
AlertManger
安装AlertManger
BlackBox_exporter
安装blackbox_exporter
本文档使用 MrDoc 发布
-
+
首页
安装consul
# 安装consul - 版本:1.10.1 - 下载:[【附件】consul_1.10.1_linux_amd64.zip](/media/attachment/2021/08/consul_1.10.1_linux_amd64.zip) ## 配置 下载后将压缩包上传至consul服务器。 ```shell unzip consul_1.10.1_linux_amd64.zip cp consul /usr/bin/ ``` ``` consul --help Usage: consul [--version] [--help] <command> [<args>] Available commands are: acl Interact with Consul's ACLs agent Runs a Consul agent catalog Interact with the catalog config Interact with Consul's Centralized Configurations connect Interact with Consul Connect debug Records a debugging archive for operators event Fire a new event exec Executes a command on Consul nodes force-leave Forces a member of the cluster to enter the "left" state info Provides debugging information for operators. intention Interact with Connect service intentions join Tell Consul agent to join cluster keygen Generates a new encryption key keyring Manages gossip layer encryption keys kv Interact with the key-value store leave Gracefully leaves the Consul cluster and shuts down lock Execute a command holding a lock login Login to Consul using an auth method logout Destroy a Consul token created with login maint Controls node or service maintenance mode members Lists the members of a Consul cluster monitor Stream logs from a Consul agent operator Provides cluster-level tools for Consul operators reload Triggers the agent to reload configuration files rtt Estimates network round trip time between nodes services Interact with services snapshot Saves, restores and inspects snapshots of Consul server state tls Builtin helpers for creating CAs and certificates validate Validate config files/directories version Prints the Consul version watch Watch for changes in Consul # 参数 Usage: -advertise value Sets the advertise address to use. -advertise-wan value Sets address to advertise on WAN instead of -advertise address. -allow-write-http-from value Only allow write endpoint calls from given network. CIDR format, can be specified multiple times. -alt-domain value Alternate domain to use for DNS interface. -bind value Sets the bind address for cluster communication. -bootstrap Sets server to bootstrap mode. -bootstrap-expect value Sets server to expect bootstrap mode. -check_output_max_size value Sets the maximum output size for checks on this agent -client value Sets the address to bind for client access. This includes RPC, DNS, HTTP, HTTPS and gRPC (if configured). -config-dir value Path to a directory to read configuration files from. This will read every file ending in '.json' as configuration in this directory in alphabetical order. Can be specified multiple times. -config-file value Path to a file in JSON or HCL format with a matching file extension. Can be specified multiple times. -config-format string Config files are in this format irrespective of their extension. Must be 'hcl' or 'json' -data-dir value Path to a data directory to store agent state. -datacenter value Datacenter of the agent. -default-query-time value the amount of time a blocking query will wait before Consul will force a response. This value can be overridden by the 'wait' query parameter. -dev Starts the agent in development mode. -disable-host-node-id Setting this to true will prevent Consul from using information from the host to generate a node ID, and will cause Consul to generate a random node ID instead. -disable-keyring-file Disables the backing up of the keyring to a file. -dns-port value DNS port to use. -domain value Domain to use for DNS interface. -enable-local-script-checks Enables health check scripts from configuration file. -enable-script-checks Enables health check scripts. -encrypt value Provides the gossip encryption key. -grpc-port value Sets the gRPC API port to listen on (currently needed for Envoy xDS only). -hcl value hcl config fragment. Can be specified multiple times. -http-port value Sets the HTTP API port to listen on. -https-port value Sets the HTTPS API port to listen on. -join value Address of an agent to join at start time. Can be specified multiple times. -join-wan value Address of an agent to join -wan at start time. Can be specified multiple times. -log-file value Path to the file the logs get written to -log-json Output logs in JSON format. -log-level value Log level of the agent. -log-rotate-bytes value Maximum number of bytes that should be written to a log file -log-rotate-duration value Time after which log rotation needs to be performed -log-rotate-max-files value Maximum number of log file archives to keep -max-query-time value the maximum amount of time a blocking query can wait before Consul will force a response. Consul applies jitter to the wait time. The jittered time will be capped to MaxQueryTime. -node value Name of this node. Must be unique in the cluster. -node-id value A unique ID for this node across space and time. Defaults to a randomly-generated ID that persists in the data-dir. -node-meta key:value An arbitrary metadata key/value pair for this node, of the format key:value. Can be specified multiple times. -non-voting-server (Enterprise-only) DEPRECATED: -read-replica should be used instead -pid-file value Path to file to store agent PID. -primary-gateway value Address of a mesh gateway in the primary datacenter to use to bootstrap WAN federation at start time with retries enabled. Can be specified multiple times. -protocol value Sets the protocol version. Defaults to latest. -raft-protocol value Sets the Raft protocol version. Defaults to latest. -read-replica (Enterprise-only) This flag is used to make the server not participate in the Raft quorum, and have it only receive the data replication stream. This can be used to add read scalability to a cluster in cases where a high volume of reads to servers are needed. -recursor value Address of an upstream DNS server. Can be specified multiple times. -rejoin Ignores a previous leave and attempts to rejoin the cluster. -retry-interval value Time to wait between join attempts. -retry-interval-wan value Time to wait between join -wan attempts. -retry-join value Address of an agent to join at start time with retries enabled. Can be specified multiple times. -retry-join-wan value Address of an agent to join -wan at start time with retries enabled. Can be specified multiple times. -retry-max value Maximum number of join attempts. Defaults to 0, which will retry indefinitely. -retry-max-wan value Maximum number of join -wan attempts. Defaults to 0, which will retry indefinitely. -segment value (Enterprise-only) Sets the network segment to join. -serf-lan-allowed-cidrs value Networks (eg: 192.168.1.0/24) allowed for Serf LAN. Can be specified multiple times. -serf-lan-bind value Address to bind Serf LAN listeners to. -serf-lan-port value Sets the Serf LAN port to listen on. -serf-wan-allowed-cidrs value Networks (eg: 192.168.1.0/24) allowed for Serf WAN (other datacenters). Can be specified multiple times. -serf-wan-bind value Address to bind Serf WAN listeners to. -serf-wan-port value Sets the Serf WAN port to listen on. -server Switches agent to server mode. -server-port value Sets the server port to listen on. -syslog Enables logging to syslog. -ui Enables the built-in static web UI server. -ui-content-path value Sets the external UI path to a string. Defaults to: /ui/ -ui-dir value Path to directory containing the web UI resources. ``` ## 启动脚本 ``` cat /usr/lib/systemd/system/consul.service [Unit] Description=consul After=syslog.target network.target ConditionFileIsExecutable=/usr/bin/consul [Service] StartLimitInterval=5 StartLimitBurst=10 PIDFile=/var/run/consul.pid ExecStart=/usr/bin/consul agent -bind=0.0.0.0 -client=0.0.0.0 -config-dir=/usr/local/consul/consul.d ExecReload=/bin/kill -HUP $MAINPID KillMode=process Restart=always RestartSec=120 [Install] WantedBy=multi-user.target cat /usr/local/consul/consul.d/consul.json { "bootstrap": false, "bootstrap_expect": 3, "server": true, "ui": true, "data_dir": "/usr/local/consul/data", "pid_file": "/var/run/consul.pid", "retry_join": ["${consul01ip}", "${consul02ip}", "${consul03ip}"] } ```
zhangky
2021年8月9日 16:27
分享文档
收藏文档
上一篇
下一篇
微信扫一扫
复制链接
手机扫一扫进行分享
复制链接
关于 MrDoc
觅思文档MrDoc
是
州的先生
开发并开源的在线文档系统,其适合作为个人和小型团队的云笔记、文档和知识库管理工具。
如果觅思文档给你或你的团队带来了帮助,欢迎对作者进行一些打赏捐助,这将有力支持作者持续投入精力更新和维护觅思文档,感谢你的捐助!
>>>捐助鸣谢列表
微信
支付宝
QQ
PayPal
Markdown文件
分享
链接
类型
密码
更新密码