用户工具

站点工具


light4j:registry

差别

这里会显示出您选择的修订版和当前版本之间的差别。

到此差别页面的链接

两侧同时换到之前的修订记录 前一修订版
后一修订版
前一修订版
light4j:registry [2020/07/09 17:35]
admin
light4j:registry [2020/07/09 18:16] (当前版本)
admin
行 14: 行 14:
     - api_c:c => d,Http2Client.connect(https://​localhost:​7444),ClientRequest(/​v1/​data@get)     - api_c:c => d,Http2Client.connect(https://​localhost:​7444),ClientRequest(/​v1/​data@get)
     - Cluster:SingletonServiceFactory.getBean(Cluster.class).serviceToUrl("​https",​ serviceId, tag, null)     - Cluster:SingletonServiceFactory.getBean(Cluster.class).serviceToUrl("​https",​ serviceId, tag, null)
-    - parameters:配置服务映射地址,tag=ServerConfig.environment(仅用于注册中心+测试环境通常null即可)+    - parameters:serviceId ​=> host+portmultiple时使用RoundRobin轮询调用
 <​code>​ <​code>​
 singletons: singletons:
行 31: 行 31:
 </​code>​ </​code>​
  
-  * 注册中心:''​consul''​,ServerConfig.enableRegistry=true+  * 注册中心:''​consul''​、''​token''​,ServerConfig.enableRegistry=true
 <​code>​ <​code>​
 - com.networknt.registry.URL:​ - com.networknt.registry.URL:​
行 46: 行 46:
   - com.networknt.consul.ConsulRegistry   - com.networknt.consul.ConsulRegistry
 #docker run -d -p 8400:8400 -p 8500:​8500/​tcp -p 8600:53/udp -e '​CONSUL_LOCAL_CONFIG={"​acl_datacenter":"​dc1","​acl_default_policy":"​allow","​acl_down_policy":"​extend-cache","​acl_master_token":"​the_one_ring","​bootstrap_expect":​1,"​datacenter":"​dc1","​data_dir":"/​usr/​local/​bin/​consul.d/​data","​server":​true}'​ consul agent -server -ui -bind=127.0.0.1 -client=0.0.0.0 #docker run -d -p 8400:8400 -p 8500:​8500/​tcp -p 8600:53/udp -e '​CONSUL_LOCAL_CONFIG={"​acl_datacenter":"​dc1","​acl_default_policy":"​allow","​acl_down_policy":"​extend-cache","​acl_master_token":"​the_one_ring","​bootstrap_expect":​1,"​datacenter":"​dc1","​data_dir":"/​usr/​local/​bin/​consul.d/​data","​server":​true}'​ consul agent -server -ui -bind=127.0.0.1 -client=0.0.0.0
-#​http://​localhost:​8500/​ui #​查看已注册服务+#​http://​localhost:​8500/​ui #​查看已注册服务,acl_default_policy=allow仅用于测试环境 
 + 
 +docker run -d -p 8400:8400 -p 8500:​8500/​tcp -p 8600:53/udp -e '​CONSUL_LOCAL_CONFIG={"​acl_datacenter":"​dc1","​acl_default_policy":"​deny","​acl_down_policy":"​extend-cache","​acl_master_token":"​the_one_ring","​bootstrap_expect":​1,"​datacenter":"​dc1","​data_dir":"/​usr/​local/​bin/​consul.d/​data","​server":​true}'​ consul agent -server -ui -bind=127.0.0.1 -client=0.0.0.0 
 + 
 +#create agent token,acl_default_policy=deny生产需要密钥,响应{"​ID":"​67ccac85-36a3-e912-d0b3-bce1194119a0"​} 
 +curl --request PUT --header "​X-Consul-Token:​ the_one_ring"​ --data \ 
 +'{ 
 +  "​Name":​ "Agent Token",​ 
 +  "​Type":​ "​client",​ 
 +  "​Rules":​ "node \"​\"​ { policy = \"​write\"​ } service \"​\"​ { policy = \"​read\"​ }" 
 +}' http://​127.0.0.1:​8500/​v1/​acl/​create 
 + 
 +#introduce token,有读写权限 
 +curl --request PUT --header "​X-Consul-Token:​ the_one_ring"​ --data \ 
 +'{ 
 +  "​Token":​ "​67ccac85-36a3-e912-d0b3-bce1194119a0"​ 
 +}' http://​127.0.0.1:​8500/​v1/​agent/​token/​acl_agent_token 
 + 
 +#​anonymous,只读权限,响应{"​ID":"​anonymous"​} 
 +curl --request PUT --header "​X-Consul-Token:​ the_one_ring"​ --data \ 
 +'{ 
 +  "​ID":​ "​anonymous",​ 
 +  "​Type":​ "​client",​ 
 +  "​Rules":​ "node \"​\"​ { policy = \"​read\"​ } service \"​\"​ { policy = \"​read\"​ }" 
 +}' http://​127.0.0.1:​8500/​v1/​acl/​update 
 + 
 +#​密钥配置 consulToken:​ the_one_ring,consul.yml优先于server.yml
 </​code>​ </​code>​
  
 +  * 容器部署:''​consuldocker''​,''​consul''​.consulUrl,修改localhost为本机ip
 +<​code>​
 +#​修改consul.yml
 +consulUrl: http://​192.168.1.144:​8500
 +#​docker/​Dockerfile
 +FROM openjdk:​11.0.3-slim
 +ADD /​target/​aa-1.0.0.jar server.jar
 +CMD ["/​bin/​sh","​-c","​java -Dlight-4j-config-dir=/​config -Dlogback.configurationFile=/​config/​logback.xml -jar /​server.jar"​]
 +#​构建build
 +cd ~/​networknt/​light-example-4j/​discovery/​api_a/​consuldocker
 +mvn clean install -Prelease
 +docker build -t networknt/​com.networknt.aa-1.0.0 -f docker/​Dockerfile ​
 +#git clone https://​github.com/​networknt/​light-docker.git
 +cd light-docker
 +docker-compose -f docker-compose-consul.yml up -d
 +docker-compose -f docker-compose-discovery.yml up -d
 +#curl -k https://​localhost:​7441/​v1/​data
 +</​code>​
  
  
  
light4j/registry.1594287355.txt.gz · 最后更改: 2020/07/09 17:35 由 admin