Linux command
consul 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Start agent in development mode
consul agent -dev
List datacenter members
consul members
Register service
consul services register [service.json]
Deregister service
consul services deregister -id=[service-id]
List services in catalog
consul catalog services
DNS lookup for service
dig @127.0.0.1 -p 8600 [web.service.consul]
Store key-value pair
consul kv put [key] [value]
Get key-value
consul kv get [key]
Join cluster
consul join [192.168.1.100]
Validate configuration files
consul validate [/etc/consul.d/]
Reload agent configuration
consul reload
说明
consul is HashiCorp's service discovery and configuration tool. It provides service mesh, health checking, key/value storage, multi-datacenter support, and secure service-to-service communication.
参数
- -dev
- Development mode (single node, no persistence)
- -server
- Run agent in server mode
- -bind _addr_
- Address for internal cluster communications (default: 0.0.0.0)
- -token _token_
- ACL token for authentication
- -token-file _file_
- File containing the ACL token
- -datacenter _dc_
- Target datacenter
- -http-addr _addr_
- Consul HTTP API address
- -auto-reload-config
- Automatically reload configuration when files change
FAQ
What is the consul command used for?
consul is HashiCorp's service discovery and configuration tool. It provides service mesh, health checking, key/value storage, multi-datacenter support, and secure service-to-service communication.
How do I run a basic consul example?
Run `consul agent -dev` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -dev do in consul?
Development mode (single node, no persistence)