注册服务
手动向consul注册一个服务区,服务的check是tcp的
# 注册服务
curl -X PUT -H "Content-Type: application/json" -d
"ID": "example-service",
"Name": "example-service",
"Address": "localhost",
"Port": 8080,
"Check": {
"TCP": "localhost:8080",
"Interval": "10s",
"Timeout": "1s"
}
}
命令行方式
consul services register -id=example-service -name=example-service -address=localhost -port=8080 -check="tcp:localhost:8080"
手动向consul注册一个服务区,服务的check是http的
# 注册服务并定义HTTP健康检查
curl -X PUT -H "Content-Type: application/json" -d
"ID": "example-service",
"Name": "example-service",
"Address": "localhost",
"Port": 8080,
"Check": {
"HTTP": "http://localhost:8080/health",
"Interval": "10s",
"Timeout": "1s"
}
}
命令行方式
consul services register -id=example-service -name=example-service -address=localhost -port=8080 -check="http://localhost:8080/health"