2.0版本seata、nacos+ruoyi(微服務)配置

一、下載:

seata下載:點擊這里

nacos下載:點擊這里

ruoyi(微服務)下載:點擊這里

Git bash下載:點擊這里

本文所用的版本:

seata-2.2.0(下圖紅色框框):

nacos-2.3.2(下圖紅色框框):

二、解壓:

分別解壓nacos、seata、ruoyi的壓縮包,并放在你的目錄下:

進入RuoYi-Cloud-Master目錄下的sql文件夾里,使用mysql工具(這里使用navicat)導入數據,先創建一個數據庫ry-cloud,并在ry-cloud數據庫里導入該文件夾下的quartz.sqlry_20250523.sql文件

之后就在根(root)右擊運行該目錄下的ry_config_20250224.sqlry_seata_20210128.sql文件即可。

進入nacos目錄下的conf文件夾下,打開application.properties文件,并根據自己需要參考同目錄下的application.properties.example修改,這里只進行了基礎配置:

#
# Copyright 1999-2021 Alibaba Group Holding Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
##*************** Spring Boot Related Configurations ***************#
### Default web context path:
server.servlet.contextPath=/nacos
### Include message field
server.error.include-message=ALWAYS
### Default web server port:
server.port=8848
#*************** Network Related Configurations ***************#
### If prefer hostname over ip for Nacos server addresses in cluster.conf:
# nacos.inetutils.prefer-hostname-over-ip=false### Specify local server's IP:
# nacos.inetutils.ip-address=#*************** Config Module Related Configurations ***************#
### If use MySQL as datasource:
### Deprecated configuration property, it is recommended to use `spring.sql.init.platform` replaced.
# spring.datasource.platform=mysql
# spring.sql.init.platform=mysql### Count of DB:
# db.num=1### Connect URL of DB:
# db.url.0=jdbc:mysql://127.0.0.1:3306/ry-config?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useUnicode=true&useSSL=false&serverTimezone=UTC
# db.user.0=nacos
# db.password.0=nacos### Connection pool configuration: hikariCP
db.pool.config.connectionTimeout=30000
db.pool.config.validationTimeout=10000
db.pool.config.maximumPoolSize=20
db.pool.config.minimumIdle=2### the maximum retry times for push
nacos.config.push.maxRetryTime=50#*************** Naming Module Related Configurations ***************#### If enable data warmup. If set to false, the server would accept request without local data preparation:
# nacos.naming.data.warmup=true### If enable the instance auto expiration, kind like of health check of instance:
# nacos.naming.expireInstance=true### Add in 2.0.0
### The interval to clean empty service, unit: milliseconds.
# nacos.naming.clean.empty-service.interval=60000### The expired time to clean empty service, unit: milliseconds.
# nacos.naming.clean.empty-service.expired-time=60000### The interval to clean expired metadata, unit: milliseconds.
# nacos.naming.clean.expired-metadata.interval=5000### The expired time to clean metadata, unit: milliseconds.
# nacos.naming.clean.expired-metadata.expired-time=60000### The delay time before push task to execute from service changed, unit: milliseconds.
# nacos.naming.push.pushTaskDelay=500### The timeout for push task execute, unit: milliseconds.
# nacos.naming.push.pushTaskTimeout=5000### The delay time for retrying failed push task, unit: milliseconds.
# nacos.naming.push.pushTaskRetryDelay=1000### Since 2.0.3
### The expired time for inactive client, unit: milliseconds.
# nacos.naming.client.expired.time=180000#*************** CMDB Module Related Configurations ***************#
### The interval to dump external CMDB in seconds:
# nacos.cmdb.dumpTaskInterval=3600### The interval of polling data change event in seconds:
# nacos.cmdb.eventTaskInterval=10### The interval of loading labels in seconds:
# nacos.cmdb.labelTaskInterval=300### If turn on data loading task:
# nacos.cmdb.loadDataAtStart=false#***********Metrics for tomcat **************************#
server.tomcat.mbeanregistry.enabled=true#***********Expose prometheus and health **************************#
#management.endpoints.web.exposure.include=prometheus,health### Metrics for elastic search
management.metrics.export.elastic.enabled=false
#management.metrics.export.elastic.host=http://localhost:9200### Metrics for influx
management.metrics.export.influx.enabled=false
#management.metrics.export.influx.db=springboot
#management.metrics.export.influx.uri=http://localhost:8086
#management.metrics.export.influx.auto-create-db=true
#management.metrics.export.influx.consistency=one
#management.metrics.export.influx.compressed=true#*************** Access Log Related Configurations ***************#
### If turn on the access log:
server.tomcat.accesslog.enabled=true### file name pattern, one file per hour
server.tomcat.accesslog.rotate=true
server.tomcat.accesslog.file-date-format=.yyyy-MM-dd-HH
### The access log pattern:
server.tomcat.accesslog.pattern=%h %l %u %t "%r" %s %b %D %{User-Agent}i %{Request-Source}i### The directory of access log:
server.tomcat.basedir=file:.#*************** Access Control Related Configurations ***************#
### If enable spring security, this option is deprecated in 1.2.0:
#spring.security.enabled=false### The ignore urls of auth
nacos.security.ignore.urls=/,/error,/**/*.css,/**/*.js,/**/*.html,/**/*.map,/**/*.svg,/**/*.png,/**/*.ico,/console-ui/public/**,/v1/auth/**,/v1/console/health/**,/actuator/**,/v1/console/server/**### The auth system to use, currently only 'nacos' and 'ldap' is supported:
nacos.core.auth.system.type=nacos### If turn on auth system:
nacos.core.auth.enabled=true### Turn on/off caching of auth information. By turning on this switch, the update of auth information would have a 15 seconds delay.
nacos.core.auth.caching.enabled=true### Since 1.4.1, Turn on/off white auth for user-agent: nacos-server, only for upgrade from old version.
nacos.core.auth.enable.userAgentAuthWhite=false### Since 1.4.1, worked when nacos.core.auth.enabled=true and nacos.core.auth.enable.userAgentAuthWhite=false.
### The two properties is the white list for auth and used by identity the request from other server.
nacos.core.auth.server.identity.key=nacos-admin
nacos.core.auth.server.identity.value=nacos### worked when nacos.core.auth.system.type=nacos
### The token expiration in seconds:
nacos.core.auth.plugin.nacos.token.cache.enable=false
nacos.core.auth.plugin.nacos.token.expire.seconds=18000
### The default token (Base64 String):
nacos.core.auth.plugin.nacos.token.secret.key=bmFjb3NjdGgxMjM0NTY3ODkxMDM1NDIxMTc3ODNjdGhjdGg=### worked when nacos.core.auth.system.type=ldap,{0} is Placeholder,replace login username
#nacos.core.auth.ldap.url=ldap://localhost:389
#nacos.core.auth.ldap.basedc=dc=example,dc=org
#nacos.core.auth.ldap.userDn=cn=admin,${nacos.core.auth.ldap.basedc}
#nacos.core.auth.ldap.password=admin
#nacos.core.auth.ldap.userdn=cn={0},dc=example,dc=org
#nacos.core.auth.ldap.filter.prefix=uid
#nacos.core.auth.ldap.case.sensitive=true
#nacos.core.auth.ldap.ignore.partial.result.exception=false#*************** Control Plugin Related Configurations ***************#
# plugin type
#nacos.plugin.control.manager.type=nacos# local control rule storage dir, default ${nacos.home}/data/connection and ${nacos.home}/data/tps
#nacos.plugin.control.rule.local.basedir=${nacos.home}# external control rule storage type, if exist
#nacos.plugin.control.rule.external.storage=#*************** Config Change Plugin Related Configurations ***************#
# webhook
#nacos.core.config.plugin.webhook.enabled=false
# It is recommended to use EB https://help.aliyun.com/document_detail/413974.html
#nacos.core.config.plugin.webhook.url=http://localhost:8080/webhook/send?token=***
# The content push max capacity ,byte
#nacos.core.config.plugin.webhook.contentMaxCapacity=102400# whitelist
#nacos.core.config.plugin.whitelist.enabled=false
# The import file suffixs
#nacos.core.config.plugin.whitelist.suffixs=xml,text,properties,yaml,html
# fileformatcheck,which validate the import file of type and content
#nacos.core.config.plugin.fileformatcheck.enabled=false#*************** Istio Related Configurations ***************#
### If turn on the MCP server:
nacos.istio.mcp.server.enabled=false#*************** Core Related Configurations ***************#### set the WorkerID manually
# nacos.core.snowflake.worker-id=### Member-MetaData
# nacos.core.member.meta.site=
# nacos.core.member.meta.adweight=
# nacos.core.member.meta.weight=### MemberLookup
### Addressing pattern category, If set, the priority is highest
# nacos.core.member.lookup.type=[file,address-server]
## Set the cluster list with a configuration file or command-line argument
# nacos.member.list=192.168.16.101:8847?raft_port=8807,192.168.16.101?raft_port=8808,192.168.16.101:8849?raft_port=8809
## for AddressServerMemberLookup
# Maximum number of retries to query the address server upon initialization
# nacos.core.address-server.retry=5
## Server domain name address of [address-server] mode
# address.server.domain=jmenv.tbsite.net
## Server port of [address-server] mode
# address.server.port=8080
## Request address of [address-server] mode
# address.server.url=/nacos/serverlist#*************** JRaft Related Configurations ***************#### Sets the Raft cluster election timeout, default value is 5 second
# nacos.core.protocol.raft.data.election_timeout_ms=5000
### Sets the amount of time the Raft snapshot will execute periodically, default is 30 minute
# nacos.core.protocol.raft.data.snapshot_interval_secs=30
### raft internal worker threads
# nacos.core.protocol.raft.data.core_thread_num=8
### Number of threads required for raft business request processing
# nacos.core.protocol.raft.data.cli_service_thread_num=4
### raft linear read strategy. Safe linear reads are used by default, that is, the Leader tenure is confirmed by heartbeat
# nacos.core.protocol.raft.data.read_index_type=ReadOnlySafe
### rpc request timeout, default 5 seconds
# nacos.core.protocol.raft.data.rpc_request_timeout_ms=5000#*************** Distro Related Configurations ***************#### Distro data sync delay time, when sync task delayed, task will be merged for same data key. Default 1 second.
# nacos.core.protocol.distro.data.sync.delayMs=1000### Distro data sync timeout for one sync data, default 3 seconds.
# nacos.core.protocol.distro.data.sync.timeoutMs=3000### Distro data sync retry delay time when sync data failed or timeout, same behavior with delayMs, default 3 seconds.
# nacos.core.protocol.distro.data.sync.retryDelayMs=3000### Distro data verify interval time, verify synced data whether expired for a interval. Default 5 seconds.
# nacos.core.protocol.distro.data.verify.intervalMs=5000### Distro data verify timeout for one verify, default 3 seconds.
# nacos.core.protocol.distro.data.verify.timeoutMs=3000### Distro data load retry delay when load snapshot data failed, default 30 seconds.
# nacos.core.protocol.distro.data.load.retryDelayMs=30000### enable to support prometheus service discovery
#nacos.prometheus.metrics.enabled=true### Since 2.3
#*************** Grpc Configurations ***************### sdk grpc(between nacos server and client) configuration
## Sets the maximum message size allowed to be received on the server.
#nacos.remote.server.grpc.sdk.max-inbound-message-size=10485760## Sets the time(milliseconds) without read activity before sending a keepalive ping. The typical default is two hours.
#nacos.remote.server.grpc.sdk.keep-alive-time=7200000## Sets a time(milliseconds) waiting for read activity after sending a keepalive ping. Defaults to 20 seconds.
#nacos.remote.server.grpc.sdk.keep-alive-timeout=20000## Sets a time(milliseconds) that specify the most aggressive keep-alive time clients are permitted to configure. The typical default is 5 minutes
#nacos.remote.server.grpc.sdk.permit-keep-alive-time=300000## cluster grpc(inside the nacos server) configuration
#nacos.remote.server.grpc.cluster.max-inbound-message-size=10485760## Sets the time(milliseconds) without read activity before sending a keepalive ping. The typical default is two hours.
#nacos.remote.server.grpc.cluster.keep-alive-time=7200000## Sets a time(milliseconds) waiting for read activity after sending a keepalive ping. Defaults to 20 seconds.
#nacos.remote.server.grpc.cluster.keep-alive-timeout=20000## Sets a time(milliseconds) that specify the most aggressive keep-alive time clients are permitted to configure. The typical default is 5 minutes
#nacos.remote.server.grpc.cluster.permit-keep-alive-time=300000## open nacos default console ui
#nacos.console.ui.enabled=true
spring.datasource.platform=mysql
db.num=1
db.url.0=jdbc:mysql://localhost:3306/ry-config?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true
db.user=root
db.password=123456

其中的數據庫mysql的user、password以及數據庫名(這里使用ruoyi的ry-config)需要根據自己的實際修改。

然后進入seata目錄下的seata-server的conf文件夾下,打開application.yml,并根據自己需要參考同目錄下的application.yml.example修改,這里只進行了基礎配置:

#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License.  You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#server:port: 7091spring:application:name: seata-serverlogging:config: classpath:logback-spring.xmlfile:path: ${log.home:${user.home}/logs/seata}extend:logstash-appender:destination: 127.0.0.1:4560kafka-appender:bootstrap-servers: 127.0.0.1:9092topic: logback_to_logstashconsole:user:username: seatapassword: seata
seata:tx-service-group: default_tx_group  # 事務分組名service:vgroup-mapping:default_tx_group: default      # 映射到 Seata Server 集群名grouplist:seata-server:  127.0.0.1:8091config:# support: nacos 、 consul 、 apollo 、 zk  、 etcd3type: nacosnacos:server-addr: 127.0.0.1:8848namespace: 7df423e8-f56c-49d5-85a0-ad035f8b947agroup: SEATA_GROUPusername: nacospassword: nacosdata-id: seataServer.propertiesregistry:# support: nacos, eureka, redis, zk, consul, etcd3, sofapreferred-networks: 30.240.*metadata:weight: 100type: nacosnacos:application: seata-serverserver-addr: 127.0.0.1:8848group: SEATA_GROUP cluster: default   namespace: 7df423e8-f56c-49d5-85a0-ad035f8b947ausername: nacospassword: nacostransport:type: TCPserver: 127.0.0.1:8091store:# support: file 、 db 、 redis 、 raftmode: dbsession:mode: dblock:mode: dbdb:datasource: druiddb-type: mysqldriver-class-name: com.mysql.cj.jdbc.Driverurl: jdbc:mysql://127.0.0.1:3306/ry-seata?rewriteBatchedStatements=true&useSSL=falseuser: rootpassword: 123456min-conn: 10max-conn: 100global-table: global_tablebranch-table: branch_tablelock-table: lock_tabledistributed-lock-table: distributed_lockvgroup-table: vgroup_tablequery-limit: 1000max-wait: 5000#  server:#    service-port: 8091 #If not configured, the default is '${server.port} + 1000'security:secretKey: SeataSecretKey0c382ef121d778043159209298fd40bf3850a017tokenValidityInMilliseconds: 1800000csrf-ignore-urls: /metadata/v1/**ignore:urls: /,/**/*.css,/**/*.js,/**/*.html,/**/*.map,/**/*.svg,/**/*.png,/**/*.jpeg,/**/*.ico,/api/v1/auth/login,/version.json,/health,/error,/vgroup/v1/**

?其中的數據庫mysql的user、password以及數據庫名(這里使用ruoyi的ry-seata)需要根據自己的實際修改。

三、seata注冊到nacos配置:

進入seata目錄下的seata-server\script\config-centerd文件夾,可以看到里面有一個config.txt文件(如果沒有,可以自己創建)

在config.txt文件里輸入以下內容(注意自己的mysql的密碼和用戶名、數據庫名ry-seata):

#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License.  You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
##For details about configuration items, see https://seata.apache.org/zh-cn/docs/user/configurations
#Transport configuration, for client and server
transport.type=TCP
transport.server=NIO
transport.heartbeat=true
transport.enableTmClientBatchSendRequest=false
transport.enableRmClientBatchSendRequest=true
transport.enableTcServerBatchSendResponse=false
transport.rpcRmRequestTimeout=30000
transport.rpcTmRequestTimeout=30000
transport.rpcTcRequestTimeout=30000
transport.threadFactory.bossThreadPrefix=NettyBoss
transport.threadFactory.workerThreadPrefix=NettyServerNIOWorker
transport.threadFactory.serverExecutorThreadPrefix=NettyServerBizHandler
transport.threadFactory.shareBossWorker=false
transport.threadFactory.clientSelectorThreadPrefix=NettyClientSelector
transport.threadFactory.clientSelectorThreadSize=1
transport.threadFactory.clientWorkerThreadPrefix=NettyClientWorkerThread
transport.threadFactory.bossThreadSize=1
transport.threadFactory.workerThreadSize=default
transport.shutdown.wait=3
transport.serialization=seata
transport.compressor=none#Transaction routing rules configuration, only for the client
service.vgroupMapping.default_tx_group=default
#If you use a registry, you can ignore it
service.default.grouplist=127.0.0.1:8091
service.disableGlobalTransaction=falseclient.metadataMaxAgeMs=30000
#Transaction rule configuration, only for the client
client.rm.asyncCommitBufferLimit=10000
client.rm.lock.retryInterval=10
client.rm.lock.retryTimes=30
client.rm.lock.retryPolicyBranchRollbackOnConflict=true
client.rm.reportRetryCount=5
client.rm.tableMetaCheckEnable=true
client.rm.tableMetaCheckerInterval=60000
client.rm.sqlParserType=druid
client.rm.reportSuccessEnable=false
client.rm.sagaBranchRegisterEnable=false
client.rm.sagaJsonParser=fastjson
client.rm.tccActionInterceptorOrder=-2147482648
client.rm.sqlParserType=druid
client.tm.commitRetryCount=5
client.tm.rollbackRetryCount=5
client.tm.defaultGlobalTransactionTimeout=60000
client.tm.degradeCheck=false
client.tm.degradeCheckAllowTimes=10
client.tm.degradeCheckPeriod=2000
client.tm.interceptorOrder=-2147482648
client.undo.dataValidation=true
client.undo.logSerialization=jackson
client.undo.onlyCareUpdateColumns=true
server.undo.logSaveDays=7
server.undo.logDeletePeriod=86400000
client.undo.logTable=undo_log
client.undo.compress.enable=true
client.undo.compress.type=zip
client.undo.compress.threshold=64k
#For TCC transaction mode
tcc.fence.logTableName=tcc_fence_log
tcc.fence.cleanPeriod=1h
# You can choose from the following options: fastjson, jackson, gson
tcc.contextJsonParserType=fastjson#Log rule configuration, for client and server
log.exceptionRate=100#Transaction storage configuration, only for the server. The file, db, and redis configuration values are optional.
store.mode=db
store.lock.mode=db
store.session.mode=db
#Used for password encryption
store.publicKey=#If `store.mode,store.lock.mode,store.session.mode` are not equal to `file`, you can remove the configuration block.
store.file.dir=file_store/data
store.file.maxBranchSessionSize=16384
store.file.maxGlobalSessionSize=512
store.file.fileWriteBufferCacheSize=16384
store.file.flushDiskMode=async
store.file.sessionReloadReadSize=100#These configurations are required if the `store mode` is `db`. If `store.mode,store.lock.mode,store.session.mode` are not equal to `db`, you can remove the configuration block.
store.db.datasource=druid
store.db.dbType=mysql
store.db.driverClassName=com.mysql.cj.jdbc.Driver
store.db.url=jdbc:mysql://127.0.0.1:3306/ry-seata?useUnicode=true&rewriteBatchedStatements=true&useSSL=false
store.db.user=root
store.db.password=123456
store.db.minConn=5
store.db.maxConn=30
store.db.globalTable=global_table
store.db.branchTable=branch_table
store.db.distributedLockTable=distributed_lock
store.db.vgroupTable=vgroup-table
store.db.queryLimit=100
store.db.lockTable=lock_table
store.db.maxWait=5000#These configurations are required if the `store mode` is `redis`. If `store.mode,store.lock.mode,store.session.mode` are not equal to `redis`, you can remove the configuration block.
store.redis.mode=single
store.redis.type=pipeline
store.redis.single.host=127.0.0.1
store.redis.single.port=6379
store.redis.sentinel.masterName=
store.redis.sentinel.sentinelHosts=
store.redis.sentinel.sentinelPassword=
store.redis.maxConn=10
store.redis.minConn=1
store.redis.maxTotal=100
store.redis.database=0
store.redis.password=
store.redis.queryLimit=100#Transaction rule configuration, only for the server
server.recovery.committingRetryPeriod=1000
server.recovery.asynCommittingRetryPeriod=1000
server.recovery.rollbackingRetryPeriod=1000
server.recovery.timeoutRetryPeriod=1000
server.maxCommitRetryTimeout=-1
server.maxRollbackRetryTimeout=-1
server.rollbackRetryTimeoutUnlockEnable=false
server.distributedLockExpireTime=10000
server.session.branchAsyncQueueSize=5000
server.session.enableBranchAsyncRemove=false
server.enableParallelRequestHandle=true
server.enableParallelHandleBranch=false
server.applicationDataLimit=64000
server.applicationDataLimitCheck=falseserver.raft.server-addr=127.0.0.1:7091,127.0.0.1:7092,127.0.0.1:7093
server.raft.snapshotInterval=600
server.raft.applyBatch=32
server.raft.maxAppendBufferSize=262144
server.raft.maxReplicatorInflightMsgs=256
server.raft.disruptorBufferSize=16384
server.raft.electionTimeoutMs=2000
server.raft.reporterEnabled=false
server.raft.reporterInitialDelay=60
server.raft.serialization=jackson
server.raft.compressor=none
server.raft.sync=true#Metrics configuration, only for the server
metrics.enabled=true
metrics.registryType=compact
metrics.exporterList=prometheus
metrics.exporterPrometheusPort=9898

修改完config.txt文件后,進入seata目錄下的seata-server\script\config-centerd\nacos文件夾,可以看到nacos-config.sh文件(如果沒有,可以自己創建):

如果自己創建后,要在nacos-config.sh里輸入以下內容:

#!/bin/sh
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License.  You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#while getopts ":h:p:g:t:u:w:" opt
docase $opt inh)host=$OPTARG;;p)port=$OPTARG;;g)group=$OPTARG;;t)tenant=$OPTARG;;u)username=$OPTARG;;w)password=$OPTARG;;?)echo " USAGE OPTION: $0 [-h host] [-p port] [-g group] [-t tenant] [-u username] [-w password] "exit 1;;esac
doneif [ -z ${host} ]; thenhost=localhost
fi
if [ -z ${port} ]; thenport=8848
fi
if [ -z ${group} ]; thengroup="SEATA_GROUP"
fi
if [ -z ${tenant} ]; thentenant=""
fi
if [ -z ${username} ]; thenusername=""
fi
if [ -z ${password} ]; thenpassword=""
finacosAddr=$host:$port
contentType="content-type:application/json;charset=UTF-8"echo "set nacosAddr=$nacosAddr"
echo "set group=$group"urlencode() {length="${#1}"i=0while [ $length -gt $i ]; dochar="${1:$i:1}"case $char in[a-zA-Z0-9.~_-]) printf $char ;;*) printf '%%%02X' "'$char" ;;esaci=`expr $i + 1`done
}failCount=0
tempLog=$(mktemp -u)
function addConfig() {dataId=`urlencode $1`content=`urlencode $2`curl -X POST -H "${contentType}" "http://$nacosAddr/nacos/v1/cs/configs?dataId=$dataId&group=$group&content=$content&tenant=$tenant&username=$username&password=$password" >"${tempLog}" 2>/dev/nullif [ -z $(cat "${tempLog}") ]; thenecho " Please check the cluster status. "exit 1fiif [ "$(cat "${tempLog}")" == "true" ]; thenecho "Set $1=$2 successfully "elseecho "Set $1=$2 failure "failCount=`expr $failCount + 1`fi
}count=0
COMMENT_START="#"
for line in $(cat $(dirname "$PWD")/config.txt | sed s/[[:space:]]//g); doif [[ "$line" =~ ^"${COMMENT_START}".*  ]]; thencontinueficount=`expr $count + 1`key=${line%%=*}value=${line#*=}addConfig "${key}" "${value}"
doneecho "========================================================================="
echo " Complete initialization parameters,  total-count:$count ,  failure-count:$failCount "
echo "========================================================================="if [ ${failCount} -eq 0 ]; thenecho " Init nacos config finished, please start seata-server. "
elseecho " init nacos config fail. "
fi

其中$(cat $(dirname "$PWD")/config.txt??這個代碼是為了找到config.txt文件的路徑,如果和本文章的config.txt位置一樣,可以不用改。

四、啟動nacos、seata:
啟動nacos:

進入nacos的bin文件夾下,按住shift鍵同時右擊鼠標,選擇在終端打開,輸入命令:?

startup.cmd -m standalone 以單機模式啟動nacos:

啟動seata:

進入seata\seata-server的bin目錄下,雙擊seata-server.bat文件啟動seata:

五、將seata注冊到nacos:

完成上面的步驟后,分別輸入http://192.168.5.1:8848/nacos/index.html和http://127.0.0.1:7091/#/transaction/list訪問nacos和seata:

在nacos的命名空間里創建空間,建議命名空間名與seata文件目錄下的config.txt以及其配置文件application.yml里面的group一樣,同時namespace也要與命名空間的ID一樣:

完成上面的配置,安裝git bash后,進入\seata\seata-server\script\config-center\nacos目錄下按住shift鍵同時右擊鼠標選擇Git Bash Here輸入命令,將seata配置注冊到nacos:

sh nacos-config.sh -h localhost -p 8848 -g SEATA_GROUP -t 命名空間 -u nacos -w nacos

參數說明:

-h:host,默認值localhost

-p:port,默認值8848

-g:配置分組,默認為SEATA_GROUP

-t:租戶信息,對應Nacos的命名空間ID,默認為空

有配置數據,說明成功了!

六、配置ruoyi:

使用idea打開ruoyi項目,在每個模塊的resources目錄下找到bootstrap.yml文件,并作出修改:

    nacos:discovery:# 服務注冊地址server-addr: 127.0.0.1:8848username: nacos  #添加用戶名password: nacos  #添加密碼config:# 配置中心地址server-addr: 127.0.0.1:8848username: nacos  #添加用戶名password: nacos  #添加密碼

打開nacos網頁,進入到配置管理的public配置:

?

修改下面的每一個配置中需要修改的mysql密碼(示例如圖):

修改之后,啟動redis,啟動ruoyi項目:

文章到此結束!

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/web/89997.shtml
繁體地址,請注明出處:http://hk.pswp.cn/web/89997.shtml
英文地址,請注明出處:http://en.pswp.cn/web/89997.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

面試高頻題 力扣 LCR 130.衣柜整理 洪水灌溉(FloodFill) 深度優先遍歷(dfs) 暴力搜索 C++解題思路 每日一題

目錄零、題目描述一、為什么這道題值得一看?二、題目拆解:核心要素與約束三、算法實現:基于 DFS 的解決方案代碼邏輯拆解五、時間復雜度與空間復雜度時間復雜度空間復雜度六、坑點總結七、舉一反三八、洪水灌溉(Flood Fill&#x…

Ext4文件系統全景解析

目錄Ext4文件系統全景解析:從inode到數據恢復實戰1. Ext文件系統的"小區規劃":塊組結構詳解 🏘?1.1 塊組:文件系統的基本管理單元1.2 超級塊的"多重備份"機制 🛡?2. inode:文件的&qu…

貪心算法Day4學習心得

先來看第一道:860. 檸檬水找零 - 力扣(LeetCode) 有如下三種情況: 情況一:賬單是5,直接收下。情況二:賬單是10,消耗一個5,增加一個10情況三:賬單是20&#…

接口自動化測試種涉及到接口依賴怎么辦?

《接口自動化測試中接口依賴的處理方式及選擇原則》在接口自動化測試中,接口依賴是指某個接口的請求參數、執行條件或測試結果依賴于其他接口的輸出(如返回數據、狀態等)。處理接口依賴是確保測試用例準確性和穩定性的關鍵,常見的…

hive分區表臨時加載日批數據文件

源系統每日上傳一個csv數據文件到數據中臺指定目錄,數據中臺用hive表進行ETL工作。 先建一個外部分區表: create external table tmp_lease_contract ( contract_id string, vin string, amount float ) partitioned by (dt string) row format delim…

Python關于pandas的基礎知識

一.掃盲(一)、pandas 是什么pandas 是 Python 的一個第三方數據處理庫,它提供了高效、靈活的數據結構(如 Series 和 DataFrame),能方便地對結構化數據進行清洗、轉換、分析和處理。(二&#xff…

React 英語單詞補全游戲——一個寓教于樂的英語單詞記憶游戲

預覽:英語單詞補全 📖 產品概述 英語單詞大冒險是一款專為 7-12 歲兒童設計的互動式英語學習游戲。通過聽音頻、補全單詞的游戲方式,讓孩子在輕松愉快的環境中提升英語詞匯能力和聽力水平。 🎯 核心價值主張 寓教于樂: 將枯燥…

我的第一個開源項目 -- 實時語音識別工具

這是我的第一個開源項目,是我一直想做的一個小工具: 端到端實時語音轉文字系統。 通過小程序和H5頁面,用戶可以實時采錄音頻,通過ws上傳到java的netty server。 Java在經過權限驗證、流量控制等操作之后,通過gRPC流…

AG32 mcu+cpld 聯合編程(概念及流程)

在使用mcucpld聯合編程之前,請確認已經熟練掌握mcu的使用方法,并且對cpld編程(verilog語言)有一定的基礎。 另外,對AHB總線也需要有一定的了解。 這個章節分為兩部分: 第一部分,展示聯合編程…

Hadoop調度器深度解析:FairScheduler與CapacityScheduler的優化策略

Hadoop調度器概述在大數據處理的生態系統中,Hadoop作為分布式計算框架的核心,其資源調度機制直接決定了集群的吞吐效率和作業執行公平性。調度器作為Hadoop資源管理的中樞神經,通過協調計算資源與任務需求之間的動態平衡,成為支撐…

怎么自己搭建云手機

用閑置電腦搭建云手機 確保電腦安裝 Ubuntu 20.04(或其他支持Docker的Linux系統)。 安裝 Docker(運行云手機的核心工具)安裝Redroid(安卓容器)運行安卓容器就歐克啦。 用云服務器搭建(適合長…

網關:數據翻譯、中轉、協議轉換與邊緣計算

網關(Gateway)詳解:翻譯與中轉站的核心作用 在計算機網絡中,網關(Gateway)是一個非常重要的概念。它本質上是一個“翻譯中轉站”,其主要作用是將不同網絡之間的數據進行“翻譯”,并確…

UE5多人MOBA+GAS 番外篇:使用ECC(UGameplayEffectExecutionCalculation)制作傷害計算的流程

文章目錄定義一些屬性用于作為傷害基礎還有獲取要打出去的傷害創建一個ECC(里面執行傷害的計算)在執行ECC的GE之前需要修改ECC需要調用的值,也可以不改直接計算在屬性中監聽ECC輸出的那個值然后處理扣血定義一些屬性用于作為傷害基礎還有獲取…

SpringBoot實戰0-5

接口文檔:通俗的講,接口文檔能告訴開發者接口能返回的數據,以及為了獲取這些數據,開發者需要輸入什么樣的數據,請求哪個接口(即規范)為什么使用接口文檔:1、項目開發過程中前后端工程…

二、SpringBoot-REST開發

rest開發(表現形式轉換): 1、優點:隱藏訪問資源的行為,無法通過地址得知對資源是何種操作,書寫簡化 2、GET查詢 POST 新增/保存 PUT(修改/更新) DELETE(刪除)…

大數據之路:阿里巴巴大數據實踐——離線數據開發

數據開發平臺 統一計算平臺MaxCompute:主要服務于海量數據的存儲和計算 ,提供完善的數據導入方案, 以及多種經典的分布式計算模型,提供海量數據倉庫的解決方案,能夠更快速地解決用戶的海量數據計算問題,有效…

我的網頁聊天室設計

一、需求分析1.用戶管理模塊注冊功能實現一個注冊頁面。注冊頁面上包含了一個輸入框,輸入用戶名和密碼. 注冊成功后可以跳轉到登錄頁面.登錄功能實現一個登錄頁面。登錄頁面上包含一個輸入框。輸入用戶名和密碼. 登錄成功后可以跳轉到主頁面.2.主界面用戶信息左上角…

數據結構自學Days10 -- 二叉樹的常用實現

? 一、為什么要學習二叉樹? 1. 📦 組織數據的高效方式 二叉樹可以快速插入、刪除、查找數據,尤其在平衡時,時間復雜度為 $O(\log n)$。 適合表示分層結構(如組織結構、文件系統、語法樹)。 2. &#x…

Java注解家族--`@ResponseBody`

ResponseBody ResponseBody是 Spring 框架中的一個注解,在基于 Spring 的 Web 開發中扮演著重要角色,以下是對它的詳細總結: 1.定義與基本功能 定義:ResponseBody注解用于將 Controller 方法的返回值,通過適當的 HttpM…

react-window 大數據列表和表格數據渲染組件之虛擬滾動

簡介 React Window 是一個高效的 React 組件庫,專為渲染大數據列表和表格數據而設計。它通過”虛擬化”技術(也稱為”窗口化”或”列表虛擬化”)解決了在 React 應用中渲染大量數據時的性能問題。與傳統方法不同,React Window 只…