Skip to content

Commit

Permalink
🍀 补充Nacos访问不了的问题.
Browse files Browse the repository at this point in the history
  • Loading branch information
Zealon159 committed Aug 26, 2020
1 parent b3e3da8 commit 8e797a3
Show file tree
Hide file tree
Showing 6 changed files with 276 additions and 1 deletion.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ light reading cloud(轻松阅读)是一款图书阅读类APP,基于 Spring

数据库账户:`hello_developer` ,密码:`Bestyou2020.com`

Nacos地址:`http://reading-cloud.zealon.cn:8848/nacos/`,账户密码同上,配置文件不要删改哈,感谢支持!
Nacos地址:`http://reading-cloud.zealon.cn:8848/nacos/`,账户密码同上

由于云服务器单机部署,可能内存不足导致Nacos宕机而看不见配置文件,这里专门把配置文件放置在 `bootstrap-config` 目录下,使用静态配置文件方式启动项目(手动更换各个项目对应的配置文件)。

或者切换到 `reading-1.0` 分支,该分支使用了eureka 实现的注册中心。

部分截图:

Expand Down
58 changes: 58 additions & 0 deletions bootstrap-config/reading-cloud-account.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
server:
port: 8003
compression:
enabled: true
mime-types: application/json,application/xml,text/html,text/xml,text/plain

spring:
application:
name: light-reading-cloud-account
# 数据源配置
datasource:
account-center:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/reading_cloud_account?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT%2B8
username: root
password: 'pass123'
initial-size: 5
min-idle: 5
max-active: 30
max-wait: 6000
test-while-idle: true
validation-query: 'select 1 from dual'
connect-timeout: 1500

# 线程池配置
thread-pool:
# 公用线程池
common:
corePoolSize: 1
maximumPoolSize: 5
keepAliveTime: 0
queueCapacity: 20480
# 书架线程池
bookshelf:
corePoolSize: 1
maximumPoolSize: 3
keepAliveTime: 0
queueCapacity: 10240

eureka:
client:
service-url:
defaultZone: http://localhost:1001/eureka/

feign:
okhttp:
enabled: true
hystrix:
enabled: true
compression:
request:
enabled: true
mime-type: text/html,application/xml,application/json
min-request-size: 1024
response:
enabled: true

from: dev-environment-1.0...
62 changes: 62 additions & 0 deletions bootstrap-config/reading-cloud-book.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
server:
port: 8001

spring:
application:
# 服务逻辑名称
name: light-reading-cloud-book
datasource:
book-center:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://rm-m5e52b35wx8shto17125010.mysql.rds.aliyuncs.com:3306/reading_cloud_resource?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT%2B8
username: reading_cloud
password: 'withyou2020'
initial-size: 5
min-idle: 5
max-active: 30
max-wait: 6000
test-while-idle: true
validation-query: 'select 1 from dual'
connect-timeout: 1500

#---- redis配置 ----#
redis:
database: 0
host: localhost
port: 6379
password:
jedis:
pool:
#最大连接数据库连接数,设 0 为没有限制
max-active: 30
#最大等待连接中的数量,设 0 为没有限制
max-idle: 10
#最大建立连接等待时间。如果超过此时间将接到异常。设为-1表示无限制。
max-wait: -1ms
#最小等待连接中的数量,设 0 为没有限制
min-idle: 0
lettuce:
pool:
max-active: 10
max-idle: 5
max-wait: -1ms
min-idle: 0
shutdown-timeout: 100ms
eureka:
instance:
# 注册服务的IP,而不是逻辑名称
prefer-ip-address: true
client:
service-url:
defaultZone: http://localhost:1001/eureka/
register-with-eureka: true
fetch-registry: true

hystrix:
threadpool:
default:
coreSize: 20 #并发执行的最大线程数,默认10
maxQueueSize: 1000 #BlockingQueue的最大队列数,默认值-1
queueSizeRejectionThreshold: 400

from: dev-environment-1.0...
83 changes: 83 additions & 0 deletions bootstrap-config/reading-cloud-gateway.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
server:
port: 8010

spring:
application:
# 服务逻辑名称
name: light-reading-cloud-gateway
cloud:
gateway:
discovery:
locator:
enabled: true
lowerCaseServiceId: true
routes:
- id: book-center-rpc
uri: lb://light-reading-cloud-book
predicates:
- Path=/book/**
- Method=GET
filters:
# 降级配置
- name: Hystrix
args:
name: fallbackcmd
fallbackUri: forward:/fallback
# 限流配置
- name: RequestRateLimiter
args:
redis-rate-limiter.replenishRate: 3 # 每秒允许处理的请求数量
redis-rate-limiter.burstCapacity: 5 # 每秒最大处理的请求数量
key-resolver: "#{@ipKeyResolver}" # 限流策略,对应策略的Bean


- id: homepage-rpc
uri: lb://light-reading-cloud-homepage
predicates:
- Path=/index/**
filters:
# 降级配置
- name: Hystrix
args:
name: fallbackcmd
fallbackUri: forward:/fallback
# 限流配置
- name: RequestRateLimiter
args:
redis-rate-limiter.replenishRate: 3
redis-rate-limiter.burstCapacity: 5
key-resolver: "#{@ipKeyResolver}"

- id: account-center-rpc
uri: lb://light-reading-cloud-account
predicates:
- Path=/account/**
filters:
# 降级配置
- name: Hystrix
args:
name: fallbackcmd
fallbackUri: forward:/fallback
# 限流配置
- name: RequestRateLimiter
args:
redis-rate-limiter.replenishRate: 3
redis-rate-limiter.burstCapacity: 5
key-resolver: "#{@ipKeyResolver}"

eureka:
instance:
# 注册服务的IP,而不是逻辑名称
prefer-ip-address: true
client:
service-url:
defaultZone: http://localhost:1001/eureka/
register-with-eureka: true
fetch-registry: true

hystrix:
threadpool:
default:
coreSize: 20 #并发执行的最大线程数,默认10
maxQueueSize: 1000 #BlockingQueue的最大队列数,默认值-1
queueSizeRejectionThreshold: 400
55 changes: 55 additions & 0 deletions bootstrap-config/reading-cloud-homepage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
server:
port: 8002
compression:
enabled: true
mime-types: application/json,application/xml,text/html,text/xml,text/plain

spring:
application:
name: light-reading-cloud-homepage
datasource:
book-center:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/reading_cloud_resource?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT%2B8
username: root
password: 'pass123'
initial-size: 5
min-idle: 5
max-active: 30
max-wait: 6000
test-while-idle: true
validation-query: 'select 1 from dual'
connect-timeout: 1500

#---- ElasticSearch 配置 ----#
es:
indexType: book
aliasName: books
servers: http://47.104.241.41:9200

eureka:
client:
service-url:
defaultZone: http://localhost:1001/eureka/

feign:
okhttp:
enabled: true
hystrix:
enabled: true
compression:
request:
enabled: true
mime-type: text/html,application/xml,application/json
min-request-size: 1024
response:
enabled: true

logging:
level:
cn:
zealon:
cn.zealon.readingcloud.book.feign.client: debug

from: dev-environment-1.0...
debug: false
13 changes: 13 additions & 0 deletions bootstrap-config/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# 项目配置说明

由于系统内容不足,经常导致Nacos宕机,所以这里存放每个项目的配置文件 bootstrap.yml

调试时可以不使用Nacos注册发现,用静态配置文件和Eureka进行服务发现哈

| 项目 | 配置文件 |
| ---------------------- | -------------------------- |
| reading-cloud-account | reading-cloud-account.yml |
| reading-cloud-book | reading-cloud-book.yml |
| reading-cloud-gateway | reading-cloud-gateway.yml |
| reading-cloud-homepage | reading-cloud-homepage.yml |

0 comments on commit 8e797a3

Please sign in to comment.