# consul.php
微服务的配置文件
* leader_service_name
用于同种类型的服务进行leader选举,系统启动后会告诉你是leader还是不是leader。
* watches
监听服务
* services
发布服务
这里监听和发布的都是Controller名。
```php
//是否启用consul
$config['consul_enable'] = false;
//数据中心配置
$config['consul']['datacenter'] = 'dc1';
//服务器名称,同种服务应该设置同样的名称,用于leader选举
$config['consul']['leader_service_name'] = 'Test';
//node的名字,每一个都必须不一样
$config['consul']['node_name'] = 'SD-1';
//consul的data_dir默认放在临时文件下
$config['consul']['data_dir'] = "/tmp/consul";
//consul join地址,可以是集群的任何一个,或者多个
$config['consul']['start_join'] = ["192.168.8.85"];
//本地网卡地址
$config['consul']['bind_addr'] = "192.168.8.57";
//监控服务
$config['consul']['watches'] = ['MathService'];
//发布服务
//$config['consul']['services']=['MathService:8081'];
//是否开启TCP集群,启动consul才有用
$config['cluster']['enable'] = true;
//TCP集群端口
$config['cluster']['port'] = 9999;
//***断路器设置****
//阀值
$config['fuse']['threshold'] = 0.01;
//检查时间
$config['fuse']['checktime'] = 2000;
//尝试打开的间隔
$config['fuse']['trytime'] = 1000;
//尝试多少个
$config['fuse']['trymax'] = 3;
return $config;
```
# 集群配置
集群基于Consul,所以必须启动Consul服务,然后打开['cluster']['enable']配置好集群端口即可。