Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/junneyang/xxproject

SpringCloud 微服务综合实例。分布式配置中心,服务发现&负载均衡,链路断路器,API网关,OAuth2认证授权,分布式追踪,ELK日志中心,Ansible/Docker持续交付等最佳实践。
https://github.com/junneyang/xxproject

ansible config docker docker-compose elk eureka hystrix oauth2 springcloud turbine zipkin zuul

Last synced: 3 months ago
JSON representation

SpringCloud 微服务综合实例。分布式配置中心,服务发现&负载均衡,链路断路器,API网关,OAuth2认证授权,分布式追踪,ELK日志中心,Ansible/Docker持续交付等最佳实践。

Awesome Lists containing this project

README

        

#################### Delpoy as Host App

cd /opt/java/workspace/xproject
mvn clean
mvn package
ps -ef | grep java | grep 1.0.0-RELEASE.jar | awk -F' ' '{ print $2 }' | xargs kill -9

# support-service: config-server
source bootstrap.rc && java -jar support/config-server/target/config-server-1.0.0-RELEASE.jar
# http://localhost:7001/service-test01/default/1.0.0
# support-service: auth-server
source bootstrap.rc && java -jar support/auth-server/target/auth-server-1.0.0-RELEASE.jar
http://localhost:9999/uaa/oauth/authorize?response_type=code&client_id=acme&redirect_uri=http://example.com&scope=webshop&state=97536
https://www.xproject.com:9999/uaa/oauth/authorize?response_type=code&client_id=acme&redirect_uri=http://example.com&scope=webshop&state=97536

curl acme:acmesecret@localhost:9999/uaa/oauth/token \
-d grant_type=authorization_code \
-d client_id=acme \
-d redirect_uri=http://example.com \
-d code=$CODE -s | jq .
curl https://acme:[email protected]:9999/uaa/oauth/token \
-d grant_type=authorization_code \
-d client_id=acme \
-d redirect_uri=http://example.com \
-d code=$CODE -ks | jq .

curl "http://localhost:9999/uaa/user" -H "Authorization: Bearer $TOKEN" -s | jq .
curl "https://www.xproject.com:9999/uaa/user" -H "Authorization: Bearer $TOKEN" -ks | jq .

# support-service: eureka01
source bootstrap.rc && SPRING_CLOUD_CONFIG_PROFILE=${EUREKA_SERVER01} java -jar support/eureka-server/target/eureka-server-1.0.0-RELEASE.jar
# support-service: eureka02
source bootstrap.rc && SPRING_CLOUD_CONFIG_PROFILE=${EUREKA_SERVER02} java -jar support/eureka-server/target/eureka-server-1.0.0-RELEASE.jar
# support-service: zuul
source bootstrap.rc && java -jar support/zuul-server/target/zuul-server-1.0.0-RELEASE.jar

# support-service: turbine-server(optional, need to delete composite-service spring-cloud-netflix-hystrix-amqp && amqp config)
source bootstrap.rc && java -jar support/turbine-server/target/turbine-server-1.0.0-RELEASE.jar
# support-service: hystrix-dashboard(optional)
source bootstrap.rc && java -jar support/hystrix-dashboard/target/hystrix-dashboard-1.0.0-RELEASE.jar
# http://localhost:8088/hystrix
# http://turbine-server:8989/turbine.stream

# core-service: product-service
source bootstrap.rc && java -jar core/product-service/target/product-service-1.0.0-RELEASE.jar
# core-service: review-service
source bootstrap.rc && java -jar core/review-service/target/review-service-1.0.0-RELEASE.jar

# composite-service: product-composite-service
source bootstrap.rc && java -jar composite/product-composite-service/target/product-composite-service-1.0.0-RELEASE.jar
# http://localhost:5555/api/product-composite-service/product-test
# http://localhost:5555/api/product-composite-service/product-composite

# api-service: product-api-service
source bootstrap.rc && java -jar api/product-api-service/target/product-api-service-1.0.0-RELEASE.jar
# http://localhost:5555/api/product-api-service/product-api-test
# http://localhost:5555/api/product-api-service/product-api-composite

# test-api
# curl "http://localhost:5555/api/product-api-service/product-api-composite" -H "Authorization: Bearer $TOKEN" -s | jq .
curl "https://www.xproject.com:5555/api/product-api-service/product-api-composite" -H "Authorization: Bearer $TOKEN" -ks | jq .
# curl "http://localhost:5555/api/product-api-service/product-api-test" -H "Authorization: Bearer $TOKEN" -s | jq .
curl "https://www.xproject.com:5555/api/product-api-service/product-api-test" -H "Authorization: Bearer $TOKEN" -ks | jq .

#################### Delpoy as Docker App
docker images | grep xproject | awk -F' ' '{ print $3 }' | xargs docker rmi -f
docker rmi $(docker images -qa --filter=reference='xproject/*/*:*1.0.0-RELEASE')
unset JAVA_TOOL_OPTIONS
mvn clean
mvn package docker:build
docker rmi $(docker images -qa -f dangling=true)
docker volume rm $(docker volume ls -qf dangling=true)
rm -rf /var/lib/docker/aufs/diff/*-removing
source bootstrap.rc
docker-compose rm -sf
docker-compose up -d
docker-compose ps
docker-compose up --scale product-service=2

# http://www.blogjava.net/icewee/archive/2012/06/04/379947.html
keytool -validity 365 -genkey -v -alias server -keyalg RSA -keystore server.keystore -dname "CN=www.xproject.com, OU=XPROJECT, O=XPROJECT, L=WuHan, ST=HuBei, C=CN" -storepass passw0rd -keypass passw0rd
#keytool -validity 365 -genkey -v -alias server -keyalg RSA -keystore server.keystore \
# -dname "CN=localhost, OU=XPROJECT, O=XPROJECT, L=WuHan, ST=HuBei, C=CN" -storepass passw0rd -keypass passw0rd
keytool -export -v -alias server -keystore server.keystore -storepass passw0rd -rfc -file server.cer

keytool -validity 365 -genkeypair -v -alias client -keyalg RSA -storetype PKCS12 -keystore client.p12 -dname "CN=www.xproject.com, OU=XPROJECT, O=XPROJECT, L=WuHan, ST=HuBei, C=CN" -storepass passw0rd -keypass passw0rd
keytool -export -v -alias client -keystore client.p12 -storetype PKCS12 -storepass passw0rd -rfc -file client.cer

keytool -import -v -alias server -file server.cer -keystore client.truststore -storepass passw0rd -noprompt
keytool -import -v -alias client -file client.cer -keystore server.keystore -storepass passw0rd -noprompt

keytool -list -keystore server.keystore -storepass passw0rd

# JWT
# http://blog.csdn.net/zhao1949/article/details/68064984
# http://www.jianshu.com/p/6307c89fe3fa
# https://github.com/Baeldung/spring-security-oauth/
# https://github.com/junneyang/spring-cloud-security-oauth2-jwt
keytool -genkeypair -alias jwtstote -keyalg RSA -keypass passw0rd -keystore jwtkeystore.jks -dname "CN=www.xproject.com, OU=XPROJECT, O=XPROJECT, L=WuHan, ST=HuBei, C=CN" -storepass passw0rd
keytool -list -rfc --keystore jwtkeystore.jks | openssl x509 -inform pem -pubkey

-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAg8Duclg0/nXNSGWLi6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uJVmGNTnBBn7bokFPPg
q3mvefM0aVJIVFMEPgzz+BJTWrbv24KLX+ZHrUiAXF3xgCCdMhuNBc3165YpAuYG
nyGrAgMBAAGjITAfMB0GA1UdDgQWBBSqgHn0egrll8owOJG9UWONjI2kmDANBgkq
hkiG9w0BAQsFAAOCAQEADeM4X3EMxvlMKLe9geyLbLHjnGil6jV1GJA0ea/MvkVt
dJ0K6jHYkS7NsjP/vguforg+3pGi734Gj2107DvB/revKeqkUl0TV3g22toTY3gX
jG0FX4QBzQfKMUuzBlkJs5QavoeI91zKibL1/GKhZ6UPs927PYvrPT4xfo+ov7Qw
CZt2NBiO/Ga1WvXE6bQVlxKqUlEe8/wMWnJ3KXocBLEYUI7UqFLJlprmW+jRV8MN
mch1pnEOixSCx7waem7MV7Ws7IA4PCxih0L5vx10IemAgEnsbGZhh7O+1+IEFVwC
/fuGwdfJHPXrLG0lWmThdHGFqHYbYjheZTLo2u6gcA==
-----END CERTIFICATE-----

# Ref: MicroService Framework
# http://blog.csdn.net/showgood119/article/details/55510685
# https://www.zhihu.com/question/50806354
# http://blog.csdn.net/qq_32971807/article/details/54693254
# https://segmentfault.com/p/1210000008728111
# https://github.com/yidongnan/grpc-spring-boot-starter/tree/master/examples
# https://fuxiaopang.gitbooks.io/learnelasticsearch/getting_started/tutorial_conclusion.html