Apollo&&Eureka安裝配置
阿新 • • 發佈:2020-12-02
# Apollo安裝 準備: 環境要求:jdk1.8 mysql5.7.27 下載:https://github.com/ctripcorp/apollo/wiki ![image-20201127141729485](Apollo安裝.assets/image-20201127141729485.png) *** 上傳壓縮包: ![image-20201127142154770](Apollo安裝.assets/image-20201127142154770.png) 在Apollo目錄下建立三個資料夾,因為在同一目錄下解壓會有名稱相同的檔案。 在三個資料夾下分別解壓,logs是記錄日誌的檔案。 下載sql檔案:生成資料庫: 地址:同上找一下。apolloconfigdb.sql和apolloportaldb.sql 匯入MySQL生成資料庫。 上傳sql檔案到/root/目錄下: ![image-20201127143125517](Apollo安裝.assets/image-20201127143125517.png) 匯入mysql: ~~~shell mysql> source /root/apolloconfigdb.sql mysql> source /root/apolloportaldb.sql mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | ApolloConfigDB | | ApolloPortalDB | | mysql | | performance_schema | | sys | +--------------------+ 6 rows in set (0.00 sec) mysql> flush privileges; ~~~ ![image-20201127143258138](Apollo安裝.assets/image-20201127143258138.png) *** ### 三個服務的配置資訊: #### 修改一: ~~~shell 每個對應檔案下有個/config/application-github.properties檔案,修改資料庫url 使用者 密碼。 [root@docker-angent_1 ~]# cd /apollo/adminservice/apollo-adminservice-1.3.0/config/ [root@docker-angent_1 config]# vim application-github.properties # DataSource spring.datasource.url = jdbc:mysql://10.160.103.100:3306/ApolloConfigDB?characterEncoding=utf8 spring.datasource.username = root spring.datasource.password = 123 別遺漏,改三個檔案!! ~~~ ![image-20201127143732841](Apollo安裝.assets/image-20201127143732841.png) *** #### 修改二: ~~~shell 修改startup.sh檔案: 同樣:每個對應檔案下有個scripts/startup.sh檔案 [root@docker-angent_1 scripts]# pwd /apollo/adminservice/apollo-adminservice-1.3.0/scripts [root@docker-angent_1 scripts]# vim startup.sh #!/bin/bash SERVICE_NAME=apollo-adminservice ## Adjust log dir if necessary LOG_DIR=/apollo/logs 修改日誌地址 ## Adjust server port if necessary SERVER_PORT=9002 是否被佔用 別遺漏,改三個檔案!! ~~~ ![image-20201127144441022](Apollo安裝.assets/image-20201127144441022.png) *** #### 修改三: ~~~shell 修改portal服務下的meta配置: [root@docker-angent_1 ~]# cd /apollo/portal/apollo-portal-1.3.0/config [root@docker-angent_1 config]# vim apollo-env.properties local.meta=http://localhost:9001 dev.meta=http://localhost:9001 fat.meta=http://fill-in-fat-meta-server:8080 uat.meta=http://fill-in-uat-meta-server:8080 lpt.meta=${lpt_meta} pro.meta=http://fill-in-pro-meta-server:8080 ~~~ *** ### 修改資料庫meta地址: ~~~shell mysql> use ApolloConfigDB; Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed mysql> show tables; +--------------------------+ | Tables_in_ApolloConfigDB | +--------------------------+ | AccessKey | | App | | AppNamespace | | Audit | | Cluster | | Commit | | GrayReleaseRule | | Instance | | InstanceConfig | | Item | | Namespace | | NamespaceLock | | Release | | ReleaseHistory | | ReleaseMessage | | ServerConfig | +--------------------------+ 16 rows in set (0.01 sec) mysql> use ServerConfig; ERROR 1049 (42000): Unknown database 'ServerConfig' mysql> select * from ServerConfig; +----+------------------------------+---------+-------------------------------+---------------------------------------------------------------------------------------------+-----------+----------------------+------------------------+---------------------------+---------------------+ | Id | Key | Cluster | Value | Comment | IsDeleted | DataChange_CreatedBy | DataChange_CreatedTime | DataChange_LastModifiedBy | DataChange_LastTime | +----+------------------------------+---------+-------------------------------+---------------------------------------------------------------------------------------------+-----------+----------------------+------------------------+---------------------------+---------------------+ | 1 | eureka.service.url | default | http://localhost:8080/eureka/ | Eureka服務Url,多個service以英文逗號分隔 | | default | 2020-11-27 14:28:57 | | 2020-11-27 14:28:57 | | 2 | namespace.lock.switch | default | false | 一次釋出只能有一個人修改開關 | | default | 2020-11-27 14:28:57 | | 2020-11-27 14:28:57 | | 3 | item.value.length.limit | default | 20000 | item value最大長度限制 | | default | 2020-11-27 14:28:57 | | 2020-11-27 14:28:57 | | 4 | config-service.cache.enabled | default | false | ConfigService是否開啟快取,開啟後能提高效能,但是會增大記憶體消耗! | | default | 2020-11-27 14:28:57 | | 2020-11-27 14:28:57 | | 5 | item.key.length.limit | default | 128 | item key 最大長度限制 | | default | 2020-11-27 14:28:57 | | 2020-11-27 14:28:57 | +----+------------------------------+---------+-------------------------------+---------------------------------------------------------------------------------------------+-----------+----------------------+------------------------+---------------------------+---------------------+ 5 rows in set (0.00 sec) mysql> exit # eureka地址修改為真實的地址: mysql> update ServerConfig set Value="http://10.162.1.76:8761/eureka/" where id = 1; ----------------------------------------------------------- 設定最大連線數為1500、預設是100太小了。 mysql> show variables like 'max_connections'; +-----------------+-------+ | Variable_name | Value | +-----------------+-------+ | max_connections | 1000 | +-----------------+-------+ 1 row in set (0.02 sec) mysql> set global max_connections = 1500; Query OK, 0 rows affected (0.00 sec) mysql> show variables like 'max_connections'; +-----------------+-------+ | Variable_name | Value | +-----------------+-------+ | max_connections | 1500 | +-----------------+-------+ 1 row in set (0.00 sec) ~~~ ![image-20201127152112832](Apollo安裝.assets/image-20201127152112832.png) *** #### 啟動三個服務 啟動三個/scripts/startup.sh 注意服務的啟動順序: configservice—adminservice—portal ### 核算微服務apollo配置與使用 1. 使用apollo新建專案新增配置檔案 1.1. 登入apollo 測試環境地址:http://10.162.1.76:9003/ 使用者名稱:apollo 密碼:admin 1.2. 新建專案 ![img](Apollo安裝.assets/wps5AB2.tmp.jpg) 輸入ID與名稱,一般與應用名保持一致,輸入完成點選提交 ![img](Apollo安裝.assets/wps5AB3.tmp.jpg) 預設application.properties,核算配置檔案為application.yml,需要新建namespace,點選新增namespace ![img](Apollo安裝.assets/wps5AB4.tmp.jpg) 點選建立namespace ![img](Apollo安裝.assets/wps5AB5.tmp.jpg) 點選private ![img](Apollo安裝.assets/wps5AB6.tmp.jpg) 選擇yml輸入application,點選提交 ![img](Apollo安裝.assets/wps5AB7.tmp.jpg) 點選返回專案首頁 ![img](Apollo安裝.assets/wps5AB8.tmp.jpg) 點選編輯 ![img](Apollo安裝.assets/wps5AB9.tmp.jpg) 貼上進去配置檔案的所有內容(注意license內容是單行的,出現以下情況需要刪除回車符),然後點選✔號 ![img](Apollo安裝.assets/wps5ABA.tmp.jpg) 點擊發布 ![img](Apollo安裝.assets/wps5ABB.tmp.jpg) ![img](Apollo安裝.assets/wps5ABC.tmp.jpg) 這樣apollo專案就建好了,如果一個應用在多個環境使用apollo配置,只需要新建叢集即可,步驟如下: 點選新增叢集 ![img](Apollo安裝.assets/wps5ABD.tmp.jpg) 輸入叢集名稱 ![img](Apollo安裝.assets/wps5ABE.tmp.jpg) 點選返回專案首頁,這樣就有一個環境單獨使用的配置 ![img](Apollo安裝.assets/wps5ABF.tmp.jpg) 按照之前步驟新增配置資訊即可 1.3. 修改專案配置使用apollo 在配置檔案bootstrap.yml中新增apollo 注意資訊如下如果多個環境新建了多個叢集,每個環境的cluster都要改為相應的叢集名稱 app: id: ycloans-file-service apollo: meta: http://10.200.9.7:9001 cluster: DEV #叢集名稱 cacheDir: ../apollo/ #apollo配置檔案存放目錄 bootstrap: enabled: ***\*true\**** namespace: application.yml 應用的main方法新增相應的註解 @EnableApolloConfig({"application.yml"}) ![img](Apollo安裝.assets/wps5AD0.tmp.jpg) 以上就完成了apollo的配置使用。 ycloans-pay-service (namespace 配置) ~~~shell EUREKA: eureka.instance.prefer-ip-address = true eureka.instance.instanceId = ${spring.cloud.client.ip-address}:${spring.application.name}:${server.port} eureka.instance.lease-renewal-interval-in-seconds = 5 eureka.instance.lease-expiration-duration-in-seconds = 10 eureka.instance.status-page-url-path = /management/info eureka.instance.health-check-url-path = /management/health eureka.instance.metadata-map.profile = ${spring.profiles.active} eureka.instance.metadata-map.version = ${info.project.version} eureka.client.service-url.defaultZone = http://10.162.1.76:8761/eureka/,http://10.162.1.100:8762/eureka/ eureka.client.enabled = true eureka.client.healthcheck.enabled = true eureka.client.fetch-registry = true eureka.client.register-with-eureka = true eureka.client.instance-info-replication-interval-seconds = 10 eureka.client.registry-fetch-interval-seconds = 10 ---------------------------------------------------------- ############################################ #### ActiveMq 訊息佇列配置 ############################################ # 採用的訊息佇列型別: # 0-default,僅記憶體模擬 # 1-redisMq # 2-activeMq spring.mq.type = 2 # 消費通知方式 0-開啟執行緒呼叫borker介面; 1-開啟執行緒放入訊息佇列 # 如果此值被設定成1,則broker啟動時需要開啟監聽通知結果的佇列,佇列命名 # 規則是: 業務對列:result reliable.message.consumer.notify.type = 1 reliable.message.consumer.notify.thread.corePerSize = 100 reliable.message.consumer.notify.thread.maxPerSize = 500 reliable.message.consumer.notify.thread.keepAliveTime = 500 reliable.message.consumer.notify.thread.blockingQueueSize = 500 test.activemq.net-address = 127.0.0.1 # spring.activemq.broker-url = tcp://10.162.1.245:61616 測試環境 spring.activemq.broker-url = tcp://10.162.1.100:61616 #spring.activemq.broker-url = tcp://activemq-net:61616 spring.activemq.user = admin spring.activemq.password = admin # 在考慮結束之前等待的時間 spring.activemq.close-timeout = 15s # 預設代理URL是否應該在記憶體中。如果指定了顯式代理,則忽略此值。 spring.activemq.in-memory = false # 是否在回滾訊息之前停止訊息傳遞。這意味著當啟用此命令時,訊息順序不會被保留。 spring.activemq.non-blocking-redelivery = false # 等待訊息傳送響應的時間。設定為0等待永遠。 spring.activemq.send-timeout = 0 spring.activemq.queue-name = aa:pay:mock spring.activemq.response-queue-name = aa:pay:mock:result # 表示使用Topic模式還是queue模式,預設使用topic模式 spring.activemq.toTopic = true spring.pool.enabled = true spring.pool.max-connections = 10 spring.pool.idle-timeout = 30000 #預設情況下activemq提供的是queue模式,若要使用topic模式需要配置下面配置 spring.jms.pub-sub-domain = true # 是否信任所有包 #spring.activemq.packages.trust-all= # 要信任的特定包的逗號分隔列表(當不信任所有包時) #spring.activemq.packages.trusted= # 當連線請求和池滿時是否阻塞。設定false會拋“JMSException異常”。 #spring.activemq.pool.block-if-full=true # 如果池仍然滿,則在丟擲異常前阻塞時間。 #spring.activemq.pool.block-if-full-timeout=-1ms # 是否在啟動時建立連線。可以在啟動時用於加熱池。 #spring.activemq.pool.create-connection-on-startup=true # 是否用Pooledconnectionfactory代替普通的ConnectionFactory。 #spring.activemq.pool.enabled=false # 連線過期超時。 #spring.activemq.pool.expiry-timeout=0ms # 連線空閒超時 #spring.activemq.pool.idle-timeout=30s # 連線池最大連線數 #spring.activemq.pool.max-connections=1 # 每個連線的有效會話的最大數目。 #spring.activemq.pool.maximum-active-session-per-connection=500 # 當有"JMSException"時嘗試重新連線 #spring.activemq.pool.reconnect-on-exception=true # 在空閒連線清除執行緒之間執行的時間。當為負數時,沒有空閒連線驅逐執行緒執行。 #spring.activemq.pool.time-between-expiration-check=-1ms # 是否只使用一個MessageProducer #spring.activemq.pool.use-anonymous-producers=true ---------------------------------- YCLOANS-PUBLIC: license.licenseContext = <?xml version="1.0" encoding="UTF-8"?><license build-time="Mon May 06 11:39:46 CST 2019" validate-code="FC6107A40B8E7CF356B4EC5CC39A9CA6"><element name="license_code">0000011874</element><element name="product_code">0000001122</element><element name="product_name_zh-cn">宇信科技基於微服務框架統一開發平臺</element><element name="product_name_en-us">YUSP</element><element name="version_major">1</element><element name="version_sub">0</element><element name="version_publish">1</element><element name="complie_date">2018-03-20</element><element name="license_type">內部試用許可證</element><element name="customer_name"/><element name="contract_code"/><element name="license_start_time">2019-05-06</element><element name="license_end_time">2119-06-01</element></license> license.licenseModel = TRIAL management.health.rabbit.enabled = false management.health.ycloansmq.enabled = true management.endpoints.web.base-path = /api/system/actuator management.endpoint.health.show-details = always management.endpoints.web.exposure.include = * management.security.enabled = false swagger.enabled = true swagger.title = YUSP APP ycloans-starter Application API swagger.description = YUSP APP ycloans-starter API documentation swagger.version = 2.1.1.RELEASE spring.liquibase.enabled = false spring.liquibase.change-log = classpath:config/liquibase/master.xml spring.cloud.inetutils.preferred-networks = 172.20.* spring.jackson.serialization.INDENT_OUTPUT = true spring.messages.cache-duration = 1 pagehelper.helperDialect = mysql pagehelper.reasonable = true mapper.mappers[0] = cn.com.yusys.yusp.commons.mapper.CommonMapper ----------------------------------------------- MYSQL: ###################################### ## MYSQL資料庫配置 ###################################### spring.datasource.url = jdbc:mysql://10.162.1.102:3306/apolloconfigdb?useUnicode=true&characterEncoding=utf8&useSSL=false spring.datasource.username = apollo spring.datasource.password = apollo spring.datasource.hikari.minimum-idle = 20 spring.datasource.hikari.maximum-pool-size = 500 spring.datasource.hikari.data-source-properties.cachePrepStmts = true spring.datasource.hikari.data-source-properties.prepStmtCacheSize = 250 spring.datasource.hikari.data-source-properties.prepStmtCacheSqlLimit = 2048 spring.datasource.hikari.data-source-properties.useServerPrepStmts = true # 特別注意此處,否則儲存mysql將無效 mybatis.mapperLocations = classpath*:mapper/**/*.xml mybatis.configuration.map-underscore-to-camel-case = true ~~~ ![image-20201201091750509](Apollo安裝.assets/image-20201201091750509.png) ![image-20201201091919475](Apollo安裝.assets/image-20201201091919475.png) ![image-20201201092011593](Apollo安裝.assets/image-20201201092011593.png) ![image-20201201092101493](Apollo安裝.assets/image-20201201092101493.png) ycloans-agent-service ~~~shell application: spring.application.name = ycloans-pay-service spring.liquibase.enabled = false spring.liquibase.change-log = classpath:config/liquibase/master.xml spring.cloud.inetutils.preferred-networks = 10 spring.cloud.inetutils.ignored-interfaces = lo,lo:0 spring.jackson.serialization.INDENT_OUTPUT = true spring.datasource.driver-class-name = oracle.jdbc.OracleDriver spring.datasource.type = com.zaxxer.hikari.HikariDataSource spring.datasource.url = jdbc:oracle:thin:@10.162.1.57:1521:orcl spring.datasource.username = ycloanspay spring.datasource.password = ycloanspay spring.datasource.hikari.minimum-idle = 2 spring.datasource.hikari.maximum-pool-size = 2 spring.datasource.hikari.data-source-properties.cachePrepStmts = true spring.datasource.hikari.data-source-properties.prepStmtCacheSize = 250 spring.datasource.hikari.data-source-properties.prepStmtCacheSqlLimit = 2048 spring.datasource.hikari.data-source-properties.useServerPrepStmts = true spring.messages.cache-duration = 1 ############################################ #### ActiveMq 訊息佇列配置 ############################################ # 採用的訊息佇列型別: # 0-default,僅記憶體模擬 # 1-redisMq # 2-activeMq spring.mq.type = 2 # 消費通知方式 0-開啟執行緒呼叫borker介面; 1-開啟執行緒放入訊息佇列 # 如果此值被設定成1,則broker啟動時需要開啟監聽通知結果的佇列,佇列命名 # 規則是: 業務對列:result reliable.message.consumer.notify.type = 1 reliable.message.consumer.notify.thread.corePerSize = 100 reliable.message.consumer.notify.thread.maxPerSize = 500 reliable.message.consumer.notify.thread.keepAliveTime = 500 reliable.message.consumer.notify.thread.blockingQueueSize = 500 test.activemq.net-address = 127.0.0.1 # spring.activemq.broker-url = tcp://10.162.1.245:61616 測試環境 spring.activemq.broker-url = tcp://10.162.1.100:61616 #spring.activemq.broker-url = tcp://activemq-net:61616 spring.activemq.user = admin spring.activemq.password = admin # 在考慮結束之前等待的時間 spring.activemq.close-timeout = 15s # 預設代理URL是否應該在記憶體中。如果指定了顯式代理,則忽略此值。 spring.activemq.in-memory = false # 是否在回滾訊息之前停止訊息傳遞。這意味著當啟用此命令時,訊息順序不會被保留。 spring.activemq.non-blocking-redelivery = false # 等待訊息傳送響應的時間。設定為0等待永遠。 spring.activemq.send-timeout = 0 spring.activemq.queue-name = CommonPaySendQueue spring.activemq.response-queue-name = CommonPayResultQueue spring.activemq.topic-name = abc spring.activemq.respone-topic-name = abc # 表示使用Topic模式還是queue模式,預設使用topic模式 spring.activemq.toTopic = true spring.pool.enabled = true spring.pool.max-connections = 10 spring.pool.idle-timeout = 30000 #預設情況下activemq提供的是queue模式,若要使用topic模式需要配置下面配置 spring.jms.pub-sub-domain = true ############################################ #### 業務引數配置 ############################################ moneyPay.pay = http://10.162.4.92:8080/paybatch/receipt/order11 moneyPay.qry = http://10.162.4.92:8080/paybatch/receipt/query11 moneyPay.notify = http://10.162.4.92:8080/paybatch/receipt/batch/state/notify11 ############################################ #### 註冊中心 配置 ############################################ eureka.instance.prefer-ip-address = true eureka.instance.instanceId = ${spring.cloud.client.ip-address}:${spring.application.name}:${server.port} eureka.instance.lease-renewal-interval-in-seconds = 5 eureka.instance.lease-expiration-duration-in-seconds = 10 eureka.instance.status-page-url-path = /management/info eureka.instance.health-check-url-path = /management/health eureka.instance.metadata-map.profile = ${spring.profiles.active} eureka.instance.metadata-map.version = ${info.project.version} eureka.client.service-url.defaultZone = http://10.162.1.76:8761/eureka/,http://10.162.1.100:8762/eureka/ eureka.client.enabled = true eureka.client.healthcheck.enabled = true eureka.client.fetch-registry = true eureka.client.register-with-eureka = true eureka.client.instance-info-replication-interval-seconds = 10 eureka.client.registry-fetch-interval-seconds = 10 ~~~ ![image-20201201092325873](Apollo安裝.assets/image-20201201092325873.png) ycloans-common-reliable-message ~~~shell EUREKA: eureka.instance.prefer-ip-address = true eureka.instance.instanceId = ${spring.cloud.client.ip-address}:${spring.application.name}:${server.port} eureka.instance.lease-renewal-interval-in-seconds = 5 eureka.instance.lease-expiration-duration-in-seconds = 10 eureka.instance.status-page-url-path = /management/info eureka.instance.health-check-url-path = /management/health eureka.instance.metadata-map.profile = ${spring.profiles.active} eureka.instance.metadata-map.version = ${info.project.version} eureka.client.service-url.defaultZone = http://10.162.1.76:8761/eureka/,http://10.162.1.100:8762/eureka/ eureka.client.enabled = true eureka.client.healthcheck.enabled = true eureka.client.fetch-registry = true eureka.client.register-with-eureka = true eureka.client.instance-info-replication-interval-seconds = 10 eureka.client.registry-fetch-interval-seconds = 10 -------------------------------- ActiveMq: ############################################ #### ActiveMq 訊息佇列配置 ############################################ # 採用的訊息佇列型別: # 0-default,僅記憶體模擬 # 1-redisMq # 2-activeMq spring.mq.type = 2 # 消費通知方式 0-開啟執行緒呼叫borker介面; 1-開啟執行緒放入訊息佇列 # 如果此值被設定成1,則broker啟動時需要開啟監聽通知結果的佇列,佇列命名 # 規則是: 業務對列:result reliable.message.consumer.notify.type = 1 reliable.message.consumer.notify.thread.corePerSize = 100 reliable.message.consumer.notify.thread.maxPerSize = 500 reliable.message.consumer.notify.thread.keepAliveTime = 500 reliable.message.consumer.notify.thread.blockingQueueSize = 500 test.activemq.net-address = 127.0.0.1 # spring.activemq.broker-url = tcp://10.162.1.245:61616 測試環境 spring.activemq.broker-url = tcp://10.162.1.100:61616 #spring.activemq.broker-url = tcp://activemq-net:61616 spring.activemq.user = admin spring.activemq.password = admin # 在考慮結束之前等待的時間 spring.activemq.close-timeout = 15s # 預設代理URL是否應該在記憶體中。如果指定了顯式代理,則忽略此值。 spring.activemq.in-memory = false # 是否在回滾訊息之前停止訊息傳遞。這意味著當啟用此命令時,訊息順序不會被保留。 spring.activemq.non-blocking-redelivery = false # 等待訊息傳送響應的時間。設定為0等待永遠。 spring.activemq.send-timeout = 0 spring.activemq.queue-name = aa:pay:mock spring.activemq.response-queue-name = aa:pay:mock:result # 表示使用Topic模式還是queue模式,預設使用topic模式 spring.activemq.toTopic = true spring.pool.enabled = true spring.pool.max-connections = 10 spring.pool.idle-timeout = 30000 #預設情況下activemq提供的是queue模式,若要使用topic模式需要配置下面配置 spring.jms.pub-sub-domain = true # 是否信任所有包 #spring.activemq.packages.trust-all= # 要信任的特定包的逗號分隔列表(當不信任所有包時) #spring.activemq.packages.trusted= # 當連線請求和池滿時是否阻塞。設定false會拋“JMSException異常”。 #spring.activemq.pool.block-if-full=true # 如果池仍然滿,則在丟擲異常前阻塞時間。 #spring.activemq.pool.block-if-full-timeout=-1ms # 是否在啟動時建立連線。可以在啟動時用於加熱池。 #spring.activemq.pool.create-connection-on-startup=true # 是否用Pooledconnectionfactory代替普通的ConnectionFactory。 #spring.activemq.pool.enabled=false # 連線過期超時。 #spring.activemq.pool.expiry-timeout=0ms # 連線空閒超時 #spring.activemq.pool.idle-timeout=30s # 連線池最大連線數 #spring.activemq.pool.max-connections=1 # 每個連線的有效會話的最大數目。 #spring.activemq.pool.maximum-active-session-per-connection=500 # 當有"JMSException"時嘗試重新連線 #spring.activemq.pool.reconnect-on-exception=true # 在空閒連線清除執行緒之間執行的時間。當為負數時,沒有空閒連線驅逐執行緒執行。 #spring.activemq.pool.time-between-expiration-check=-1ms # 是否只使用一個MessageProducer #spring.activemq.pool.use-anonymous-producers=true -------------------------------------------------------- YCLOANS-PUBLIC: license.licenseContext = <?xml version="1.0" encoding="UTF-8"?><license build-time="Mon May 06 11:39:46 CST 2019" validate-code="FC6107A40B8E7CF356B4EC5CC39A9CA6"><element name="license_code">0000011874</element><element name="product_code">0000001122</element><element name="product_name_zh-cn">宇信科技基於微服務框架統一開發平臺</element><element name="product_name_en-us">YUSP</element><element name="version_major">1</element><element name="version_sub">0</element><element name="version_publish">1</element><element name="complie_date">2018-03-20</element><element name="license_type">內部試用許可證</element><element name="customer_name"/><element name="contract_code"/><element name="license_start_time">2019-05-06</element><element name="license_end_time">2119-06-01</element></license> license.licenseModel = TRIAL management.health.rabbit.enabled = false management.health.ycloansmq.enabled = true management.endpoints.web.base-path = /api/system/actuator management.endpoint.health.show-details = always management.endpoints.web.exposure.include = * management.security.enabled = false swagger.enabled = true swagger.title = YUSP APP ycloans-starter Application API swagger.description = YUSP APP ycloans-starter API documentation swagger.version = 2.1.1.RELEASE spring.liquibase.enabled = false spring.liquibase.change-log = classpath:config/liquibase/master.xml spring.cloud.inetutils.preferred-networks = 172.20.* spring.jackson.serialization.INDENT_OUTPUT = true spring.messages.cache-duration = 1 pagehelper.helperDialect = mysql pagehelper.reasonable = true mapper.mappers[0] = cn.com.yusys.yusp.commons.mapper.CommonMapper ---------------------------------------------------------------------- MYSQL: ###################################### ## MYSQL資料庫配置 ###################################### spring.datasource.url = jdbc:mysql://10.162.1.102:3306/apolloconfigdb?useUnicode=true&characterEncoding=utf8&useSSL=false spring.datasource.username = apollo spring.datasource.password = apollo spring.datasource.hikari.minimum-idle = 20 spring.datasource.hikari.maximum-pool-size = 500 spring.datasource.hikari.data-source-properties.cachePrepStmts = true spring.datasource.hikari.data-source-properties.prepStmtCacheSize = 250 spring.datasource.hikari.data-source-properties.prepStmtCacheSqlLimit = 2048 spring.datasource.hikari.data-source-properties.useServerPrepStmts = true # 特別注意此處,否則儲存mysql將無效 mybatis.mapperLocations = classpath*:mapper/**/*.xml mybatis.configuration.map-underscore-to-camel-case = true ~~~ ![image-20201201092635441](Apollo安裝.assets/image-20201201092635441.png) #### **Eureka配置:** ![image-20201201092852867](Apollo安裝.assets/image-20201201092852867.png) Eureka註冊主要在本地(服務:pay/ agent/ nc*)進行配置,如下: ~~~shell [root@mysql01 ycloans-pay-service]# pwd /home/hxusr/ap/app/ycloans-pay-service [root@mysql01 ycloans-pay-service]# ls bootstrap.yml config-cache nohup.out out1130.log out.log robotcenter.sh ycloans_app.jar ycloans_app.jar.1 ycloans_app.jar4 [root@mysql01 ycloans-pay-service]# cat bootstrap.yml spring: application: name: ycloans-pay-service #應用名 叢集名 liquibase: enabled: false change-log: "classpath:config/liquibase/master.xml" server: port: 6002 #應用啟動埠 app: id: ycloans-pay-service # Apollo叢集名稱 apollo: meta: http://10.162.1.76:9001 #meta: http://10.162.1.102:9081/ cluster: SIT #環境 cacheDir: ../apollo/ #apollo配置檔案存放目錄 bootstrap: enabled: true namespaces: application,EUREKA,YCLOANS-PUBLIC,ACTIVE_MQ # 名稱空間注意:namespace 和 namespaces。 # 日誌相關 logging: path: ../logs #日誌檔案路徑 file: ${spring.application.name}_${server.port}.log #日誌檔名稱 level: root: INFO springfox.documentation.spring.web.readers.operation: OFF #springfox日誌關閉輸出 #actuator監控配置 management: health: rabbit: enabled: false # 停啟 指令碼: robotcenter.sh # 日誌 : out.log ------------------------------------------------------------- [root@peer1-dev ~]# cd /home/ap/app/mock/order/ [root@peer1-dev order]# ls bootstrap.yml logs out.log robotcenter.sh ycloans_app.jar [root@peer1-dev order]# cat bootstrap.yml spring: application: name: ycloans-common-reliable-message-mock-order #應用名稱 liquibase: enabled: false change-log: "classpath:config/liquibase/master.xml" server: port: 18814 #應用啟動埠 test: apollo: env: SIT log: level: INFO app: id: ycloans-common-reliable-message apollo: #meta: http://10.200.10.13:9001 # 湖北消金的配置 #meta: http://10.162.1.102:9081 # 北銀消金的配置 meta: http://10.162.1.76:9001 cluster: ${test.apollo.env} #叢集名稱 cacheDir: ../apollo/ #apollo配置檔案存放目錄 bootstrap: enabled: true namespaces: application,YCLOANS-PUBLIC,EUREKA,UNDERTOW,LOAD_BALANCE,LEVEL_CACHE,MYSQL,ACTIVE_MQ # 日誌相關 logging: path: ./logs #日誌檔案路徑 file: ${spring.application.name}_${server.port}.log #日誌檔名稱 level: root: ${test.log.level} springfox.documentation.spring.web.readers.operation: OFF #springfox日誌關閉輸出 #actuator監控配置 management: health: rabbit: enabled: false ~~~ ### 2. 避坑指南 統一開發平臺的配置會有影響,導致啟動報錯,原因未知,如果不用請刪除 ![img](Apollo安裝.assets/wps5AD1.tmp.jpg) *** # Eureka安裝 ### 安裝包位置: G:\宇信\北銀核算\專案文件\北銀核算\包 eureka.zip 兩臺伺服器互相註冊: ### 配置hosts檔案: ~~~shell ## 兩臺都要配: [root@hexin2 eureka]# cat /etc/hosts 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 10.162.1.100 peer2-dev 10.162.1.76 peer1-dev ~~~ ### 配置76: ~~~shell ## 上傳解壓: [root@peer1-dev ~]# cd eureka eureka/ eureka.zip [root@peer1-dev ~]# cd eureka [root@peer1-dev eureka]# ls application.yml ncloan-registry-server-eureka.log startup-peer4-dev.sh ncloan-registry-server-eureka.jar startup-peer1-dev.sh ~~~ ##### 配置application.yml: ~~~shell [root@peer1-dev eureka]# cat application.yml eureka: client: #是否要註冊到其他Eureka Server例項 register-with-eureka: true #是否要從其他Eureka Server例項獲取資料 fetch-registry: true service-url: defaultZone: http://peer1-dev:8761/eureka/,http://peer2-dev:8762/eureka/ instance: prefer-ip-address: true #將自己的ip地址註冊到Eureka服務中 #服務過期時間配置,預設90s lease-expiration-duration-in-seconds: 30 #租期更新時間間隔 lease-renewal-interval-in-seconds: 10 server: #啟用主動失效,並且每次主動失效檢測間隔為3s eviction-interval-timer-in-ms: 3000 # 關閉自我保護機制,保證不可用服務及時踢出 enable-self-preservation: false spring: application: name: servers-eureka logging: level: com.netflix.eureka: OFF com.netflix.discovery: OFF --- spring: #指定profile=peer1_dev profiles: peer1-dev server: port: 8761 eureka: instance: #指定當profile=peer1_dev時,主機名是peer1_dev hostname: peer1-dev --- spring: #指定profile=peer2 profiles: peer2-dev server: port: 8762 eureka: instance: #指定當profile=peer2_dev時,主機名是peer2_dev hostname: peer2-dev ~~~ ##### 啟動指令碼:startup-peer1-dev.sh ~~~shell [root@peer1-dev eureka]# vim startup-peer1-dev.sh 注意必須:jdk1.8 #!/bin/bash nohup /usr/local/java1.8/bin/java -jar -Dfile.encoding=UTF-8 -Dapollo.bootstrap.enabled=false ncloan-registry-server-eureka.jar --spring.profiles.active=peer1-dev --spring.config.location=application.yml > ncloan-registry-server-eureka.log 2>& 1 & ~~~ ### 配置100: ~~~shell 上傳解壓: [root@hexin2 ~]# cd eureka eureka/ eureka.zip [root@hexin2 ~]# cd eureka [root@hexin2 eureka]# ll application.yml ncloan-registry-server-eureka.log startup-peer4-dev.sh ncloan-registry-server-eureka.jar startup-peer2-dev.sh ~~~ ##### 配置application.yml: ~~~shell [root@hexin2 eureka]# cat application.yml eureka: client: #是否要註冊到其他Eureka Server例項 register-with-eureka: true #是否要從其他Eureka Server例項獲取資料 fetch-registry: true service-url: defaultZone: http://peer2-dev:8762/eureka/,http://peer1-dev:8761/eureka/ instance: prefer-ip-address: true #將自己的ip地址註冊到Eureka服務中 #服務過期時間配置,預設90s lease-expiration-duration-in-seconds: 30 #租期更新時間間隔 lease-renewal-interval-in-seconds: 10 server: #啟用主動失效,並且每次主動失效檢測間隔為3s eviction-interval-timer-in-ms: 3000 # 關閉自我保護機制,保證不可用服務及時踢出 enable-self-preservation: false spring: application: name: servers-eureka logging: level: com.netflix.eureka: OFF com.netflix.discovery: OFF --- spring: #指定profile=peer1_dev profiles: peer1-dev server: port: 8761 eureka: instance: #指定當profile=peer1_dev時,主機名是peer1_dev hostname: peer1-dev --- spring: #指定profile=peer2 profiles: peer2-dev server: port: 8762 eureka: instance: #指定當profile=peer2_dev時,主機名是peer2_dev hostname: peer2-dev ~~~ ##### 配置啟動指令碼:startup-peer2-dev.sh ~~~shell [root@needyou eureka]# cat startup-peer2-dev.sh 注意必須:jdk1.8 #!/bin/bash nohup java -jar -Dfile.encoding=UTF-8 -Dapollo.bootstrap.enabled=false ncloan-registry-server-eureka.jar --spring.profiles.active=peer2-dev --spring.config.location=application.yml > ncloan-registry-server-eureka.log 2>& 1 & ~~~ *** # 時間同步: ntpdate time1.aliyun.com 需要外網環境! ntpdate 10.162.2.100 搭建內網時間伺服器 10.162.2.100是唯一能連外網的伺服器。作為內網的時間伺服器。 主節點(時間伺服器)10.162.2.100 ~~~shell # 檢視是否安裝 ntp 服務 [root@waiwang ~]# rpm -qa ntp ntp-4.2.2p1-15.el5 # 如果有、檢視服務配置檔案 [root@waiwang ~]# rpm -qc ntp /etc/ntp.conf /etc/ntp/keys /etc/ntp/step-tickers /etc/rc.d/init.d/ntpd /etc/sysconfig/ntpd # 沒有則安裝: [root@waiwang ~]# yum -y install ntp # 配置 [root@waiwang ~]# more /etc/ntp.conf # Permit time synchronization with our time source, but do not # permit the source to query or modify the service on this system. restrict default kod nomodify notrap nopeer noquery restrict -6 default kod nomodify notrap nopeer noquery # Permit all access over the loopback interface. This could # be tightened as well, but to do so would effect some of # the administrative functions. restrict 127.0.0.1 restrict -6 ::1 # Hosts on local network are less restricted. restrict 10.162.2.100 mask 255.255.0.0 nomodify notrap # Use public servers from the pool.ntp.org project. # Please consider joining the pool (http://www.pool.ntp.org/join.html). server 0.rhel.pool.ntp.org server 1.rhel.pool.ntp.org server 2.rhel.pool.ntp.org #broadcast 192.168.1.255 key 42 # broadcast server #broadcastclient # broadcast client #broadcast 224.0.1.1 key 42 # multicast server #multicastclient 224.0.1.1 # multicast client #manycastserver 239.255.254.254 # manycast server #manycastclient 239.255.254.254 key 42 # manycast client # Undisciplined Local Clock. This is a fake driver intended for backup # and when no outside source of synchronized time is available. server 127.127.1.0 # local clock fudge 127.127.1.0 stratum 10 # Drift file. Put this in a directory which the daemon can write to. # No symbolic links allowed, either, since the daemon updates the file # by creating a temporary in the same directory and then rename()'ing # it to the file. driftfile /var/lib/ntp/drift # Key file containing the keys and key identifiers used when operating # with symmetric key cryptography. keys /etc/ntp/keys # Specify the key identifiers which are trusted. #trustedkey 4 8 42 # Specify the key identifier to use with the ntpdc utility. #requestkey 8 # Specify the key identifier to use with the ntpq utility. #controlkey 8 ~~~ 客戶端: ~~~shell [root@hx245 ~]# yum -y install ntpdate [root@hx245 ~]# ntpdate 10.162.2.100 2 Dec 17:52:30 ntpdate[38066]: step time server 10.162.2.100 offset -26113.326900 sec [root@hx245 ~]# date Wed Dec 2 17:52:33 CST 2020 ~~~