天津网站优,中山市安全平台教育,廊坊免费网站建设模板,厦门网站设计公司找哪家记录#xff1a;381场景#xff1a;在CentOS 7.9操作系统上#xff0c;安装seata-1.6.0。在Windows上操作系统上#xff0c;安装seata-1.6.0。Seata#xff0c;一款开源的分布式事务解决方案#xff0c;致力于提供高性能和简单易用的分布式事务服务。版本#xff1a;JDK…记录381场景在CentOS 7.9操作系统上安装seata-1.6.0。在Windows上操作系统上安装seata-1.6.0。Seata一款开源的分布式事务解决方案致力于提供高性能和简单易用的分布式事务服务。版本JDK 1.8
seata-1.6.0
CentOS 7.9官网地址https://seata.io/源码地址https://github.com/seata/seata 官网手册https://seata.io/zh-cn/docs/ops/deploy-guide-beginner.html Seata一款开源的分布式事务解决方案致力于提供高性能和简单易用的分布式事务服务。Three roles in Seata Framework:Transaction Coordinator(TC): Maintain status of global and branch transactions, drive the global commit or rollback.Transaction Manager(TM): Define the scope of global transaction: begin a global transaction, commit or rollback a global transaction.Resource Manager(RM): Manage resources that branch transactions working on, talk to TC for registering branch transactions and reporting status of branch transactions, and drive the branch transaction commit or rollback.一、在Linux上安装seata安装Seata存储模式使用MySQL服务发现和配置使用Nacos。1.下载Seata版本v1.6.0发布日期Dec 17, 2022下载地址wget https://github.com/seata/seata/releases/download/v1.6.0/seata-server-1.6.0.tar.gz下载包seata-server-1.6.0.tar.gz2.解压Seata解压命令tar -zxvf seata-server-1.6.0.tar.gz -C /opt/seata-1.6.0解析把seata-server-1.6.0.tar.gz解压到/opt/seata-1.6.0。在seata下的目录。bin目录是启动脚本。conf目录是配置文件。ext目录下是skywalking插件相关内容。lib目录是全量jar包。logs目录是日志包。script目录是脚本目录。target目录是seata-server.jar包。3.初始化数据库脚本本例存储模式使用MySQL数据库。3.1创建数据库和用户用户名/口令hub_seata/12345678数据库名称hub_seatadb登录控制台mysql -u root -p在MySQL命令行控制台执行脚本。USE mysql;
CREATE DATABASE hub_seatadb DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
CREATE USER hub_seata% IDENTIFIED BY 12345678;
GRANT ALL ON hub_seatadb.* TO hub_seata% IDENTIFIED BY 12345678;
FLUSH PRIVILEGES;3.2初始化seata数据库脚本目录/opt/seata-1.6.0/script/server/db/mysql.sql初始化表branch_table、distributed_lock、global_table、lock_table。4.启动Nacos启动脚本目录/opt/nacos-2.1.1/bin4.1启动Nacos启动命令sh startup.sh -m standalone地址http://127.0.0.1:18848/nacos用户名/口令nacos/nacos4.2创建seata命名空间命名空间名称hub_seata命名空间ID142eba5f-a7b5-4a83-85bb-663c582c8ef15.配置seata在/opt/seata-1.6.0/conf目录下application.example.yml是配置文件的模板包含全量配置。application.yml是应用启动时加载配置根据实际情况按需从application.example.yml中拷贝添加就行5.1修改application.yml配置修改文件/opt/seata-1.6.0/conf/application.yml修改内容server:port: 7091
spring:application:name: seata-server
logging:config: classpath:logback-spring.xmlfile:path: ${user.home}/logs/seataextend:logstash-appender:destination: 127.0.0.1:4560kafka-appender:bootstrap-servers: 127.0.0.1:9092topic: logback_to_logstash
console:user:username: seatapassword: seata
seata:config:type: nacosnacos:server-addr: 192.168.19.203:18848namespace: 142eba5f-a7b5-4a83-85bb-663c582c8ef1group: SEATA_GROUPusername: nacospassword: nacoscontext-path:data-id: seataServer.propertiesregistry:type: nacosnacos:application: seata-serverserver-addr: 192.168.19.203:18848group: SEATA_GROUPnamespace: 142eba5f-a7b5-4a83-85bb-663c582c8ef1cluster: defaultusername: nacospassword: nacoscontext-path:store:mode: dbdb:datasource: druiddb-type: mysqldriver-class-name: com.mysql.jdbc.Driverurl: jdbc:mysql://192.168.19.202:3306/hub_seatadb?rewriteBatchedStatementstrueuser: hub_seatapassword: 12345678min-conn: 5max-conn: 100global-table: global_tablebranch-table: branch_tablelock-table: lock_tabledistributed-lock-table: distributed_lockquery-limit: 100max-wait: 5000 security:secretKey: SeataSecretKey0c382ef121d778043159209298fd40bf3850a017tokenValidityInMilliseconds: 1800000ignore:urls: /,/**/*.css,/**/*.js,/**/*.html,/**/*.map,/**/*.svg,/**/*.png,/**/*.ico,/console-fe/public/**,/api/v1/auth/login5.2在Nacos新建seataServer.properties5.2.1页面配置在Nacos页面中选择命名空间hub_seata。命名空间ID142eba5f-a7b5-4a83-85bb-663c582c8ef1。创建配置seataServer.properties。Data IDseataServer.properties。GroupSEATA_GROUP配置格式Properties配置内容从/opt/seata-1.6.0/script/config-center\config.txt文件中拷贝需求的配置。本例从config.txt摘取的配置修改过的配置。service.vgroupMapping.hub_tx_groupdefault
store.modedb
store.lock.modedb
store.session.modedb
store.publicKey123456
store.db.datasourcedruid
store.db.dbTypemysql
store.db.driverClassNamecom.mysql.jdbc.Driver
store.db.urljdbc:mysql://192.168.19.203:3306/hub_seatadb?useUnicodetruerewriteBatchedStatementstrue
store.db.userhub_seata
store.db.password12345678解析config.txt配置内容在源码包../seata-1.6.0/config/seata-config-core/src/main/resources/config.txt和安装包/opt/seata-1.6.0/script/config-center/config.txt两处位置都可以找到。5.2.2配置生效在Nacos中配置已经生效。6启动seata6.1启动seata操作目录/opt/seata-1.6.0/bin启动命令sh seata-server.sh6.2查看seata日志日志/opt/seata-1.6.0/logs/start.out命令tail -f -n 300 /opt/seata-1.6.0/logs/start.out6.3查看seata已注册在Nacos已经注册了seata-server服务。7基于普通用户使用seata在启动seata时不使用root用户直接启动建议使用普通用户。改变安装目录赋权给一个普通用户就可以。7.1创建普通用户操作创建用户命令useradd learn修改密码命令passwd解析在执行passwd时提示输入密码。可以查看用户信息cat /etc/passwd。7.2普通用户信息用户名称/口令learn/123456787.3把seata的安装目录赋权给普通用户命令chown -R learn:learn /opt/seata-1.6.07.4启动seata切换用户su learn操作目录/opt/seata-1.6.0/bin启动命令sh seata-server.sh8.使用nacos-config.sh脚本加载配置使用nacos-config.sh脚本加载config.txt配置到nacos。脚本目录/opt/seata-1.6.0/script/config-center/nacos命令sh nacos-config.sh -h 192.168.19.203 -p 18848 -g SEATA_GROUP -t 142eba5f-a7b5-4a83-85bb-663c582c8ef1 -u nacos -w nacos解析本例没有使用这种方式。二、在Windows上安装seata安装Seata存储模式使用MySQL服务发现和配置使用Nacos。1.下载Seata版本v1.6.0发布日期Dec 17, 2022下载地址https://github.com/seata/seata/releases/download/v1.6.0/seata-server-1.6.0.zip下载包seata-server-1.6.0.zip2.解压Seataseata-server-1.6.0.zip包解压到D:\dev\hub\ali\seata-1.6.0。在seata-1.6.0下的目录。bin目录是启动脚本。conf目录是配置文件。ext目录下是skywalking插件相关内容。lib目录是全量jar包。logs目录是日志包。script目录是脚本目录。target目录是seata-server.jar包。3.初始化数据库脚本本例存储模式使用MySQL数据库。3.1创建数据库和用户用户名/口令hub_seata/12345678数据库名称hub_seatadb登录控制台mysql -u root -p在MySQL命令行控制台执行脚本。USE mysql;
CREATE DATABASE hub_seatadb DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
CREATE USER hub_seata% IDENTIFIED BY 12345678;
GRANT ALL ON hub_seatadb.* TO hub_seata% IDENTIFIED BY 12345678;
FLUSH PRIVILEGES;3.2初始化seata数据库脚本目录seata\script\server\db\mysql.sql初始化表branch_table、distributed_lock、global_table、lock_table。4.启动Nacos启动脚本目录D:\dev\hub\ali\nacos-2.1.1\nacos\bin4.1启动Nacos启动命令sh startup.sh -m standalone地址http://192.168.19.203:18848/nacos用户名/口令nacos/nacos4.2创建seata命名空间命名空间名称hub_seata命名空间ID142eba5f-a7b5-4a83-85bb-663c582c8ef15.配置seata在..\seata\conf目录下application.example.yml是配置文件的模板包含全量配置。application.yml是应用启动时加载配置根据实际情况按需从application.example.yml中拷贝添加就行5.1修改application.yml配置修改文件application.yml修改内容server:port: 7091
spring:application:name: seata-server
logging:config: classpath:logback-spring.xmlfile:path: ${user.home}/logs/seataextend:logstash-appender:destination: 127.0.0.1:4560kafka-appender:bootstrap-servers: 127.0.0.1:9092topic: logback_to_logstash
console:user:username: seatapassword: seata
seata:config:type: nacosnacos:server-addr: 127.0.0.1:18848namespace: 142eba5f-a7b5-4a83-85bb-663c582c8ef1group: SEATA_GROUPusername: nacospassword: nacoscontext-path:data-id: seataServer.propertiesregistry:type: nacosnacos:application: seata-serverserver-addr: 127.0.0.1:18848group: SEATA_GROUPnamespace: 142eba5f-a7b5-4a83-85bb-663c582c8ef1cluster: defaultusername: nacospassword: nacoscontext-path:store:mode: dbdb:datasource: druiddb-type: mysqldriver-class-name: com.mysql.jdbc.Driverurl: jdbc:mysql://127.0.0.1:3306/hub_seatadb?rewriteBatchedStatementstrueuser: hub_seatapassword: 12345678min-conn: 5max-conn: 100global-table: global_tablebranch-table: branch_tablelock-table: lock_tabledistributed-lock-table: distributed_lockquery-limit: 100max-wait: 5000 security:secretKey: SeataSecretKey0c382ef121d778043159209298fd40bf3850a017tokenValidityInMilliseconds: 1800000ignore:urls: /,/**/*.css,/**/*.js,/**/*.html,/**/*.map,/**/*.svg,/**/*.png,/**/*.ico,/console-fe/public/**,/api/v1/auth/login5.2在Nacos新建seataServer.properties5.2.1页面配置在Nacos页面中选择命名空间hub_seata。命名空间ID142eba5f-a7b5-4a83-85bb-663c582c8ef1。创建配置seataServer.properties。Data IDseataServer.properties。GroupSEATA_GROUP配置格式Properties配置内容从seata\script\config-center\config.txt文件中拷贝需求的配置。本例从config.txt摘取的配置修改过的配置。service.vgroupMapping.hub_tx_groupdefault
store.modedb
store.lock.modedb
store.session.modedb
store.publicKey123456
store.db.datasourcedruid
store.db.dbTypemysql
store.db.driverClassNamecom.mysql.jdbc.Driver
store.db.urljdbc:mysql://127.0.0.1:3306/hub_seatadb?useUnicodetruerewriteBatchedStatementstrue
store.db.userhub_seata
store.db.password12345678解析config.txt配置内容在源码包seata-1.6.0\config\seata-config-core\src\main\resources\config.txt和编译包seata\script\config-center\config.txt两处位置都可以找到。5.2.2配置生效在Nacos中配置已经生效。6启动seata6.1启动seata操作目录..\seata\bin双击seata-server.bat启动。6.2查看seata已注册在Nacos已经注册了seata-server服务。三、官方配置和SQL脚本配置文件均是官网原件。1.mysql.sql文件目录/opt/seata-1.6.0/script/server/db文件内容CREATE TABLE IF NOT EXISTS global_table
(xid VARCHAR(128) NOT NULL,transaction_id BIGINT,status TINYINT NOT NULL,application_id VARCHAR(32),transaction_service_group VARCHAR(32),transaction_name VARCHAR(128),timeout INT,begin_time BIGINT,application_data VARCHAR(2000),gmt_create DATETIME,gmt_modified DATETIME,PRIMARY KEY (xid),KEY idx_status_gmt_modified (status , gmt_modified),KEY idx_transaction_id (transaction_id)
) ENGINE InnoDBDEFAULT CHARSET utf8mb4;-- the table to store BranchSession data
CREATE TABLE IF NOT EXISTS branch_table
(branch_id BIGINT NOT NULL,xid VARCHAR(128) NOT NULL,transaction_id BIGINT,resource_group_id VARCHAR(32),resource_id VARCHAR(256),branch_type VARCHAR(8),status TINYINT,client_id VARCHAR(64),application_data VARCHAR(2000),gmt_create DATETIME(6),gmt_modified DATETIME(6),PRIMARY KEY (branch_id),KEY idx_xid (xid)
) ENGINE InnoDBDEFAULT CHARSET utf8mb4;-- the table to store lock data
CREATE TABLE IF NOT EXISTS lock_table
(row_key VARCHAR(128) NOT NULL,xid VARCHAR(128),transaction_id BIGINT,branch_id BIGINT NOT NULL,resource_id VARCHAR(256),table_name VARCHAR(32),pk VARCHAR(36),status TINYINT NOT NULL DEFAULT 0 COMMENT 0:locked ,1:rollbacking,gmt_create DATETIME,gmt_modified DATETIME,PRIMARY KEY (row_key),KEY idx_status (status),KEY idx_branch_id (branch_id),KEY idx_xid (xid)
) ENGINE InnoDBDEFAULT CHARSET utf8mb4;CREATE TABLE IF NOT EXISTS distributed_lock
(lock_key CHAR(20) NOT NULL,lock_value VARCHAR(20) NOT NULL,expire BIGINT,primary key (lock_key)
) ENGINE InnoDBDEFAULT CHARSET utf8mb4;INSERT INTO distributed_lock (lock_key, lock_value, expire) VALUES (AsyncCommitting, , 0);
INSERT INTO distributed_lock (lock_key, lock_value, expire) VALUES (RetryCommitting, , 0);
INSERT INTO distributed_lock (lock_key, lock_value, expire) VALUES (RetryRollbacking, , 0);
INSERT INTO distributed_lock (lock_key, lock_value, expire) VALUES (TxTimeoutCheck, , 0);2.config.txt文件目录/opt/seata-1.6.0/script/config-center文件内容#For details about configuration items, see https://seata.io/zh-cn/docs/user/configurations.html
#Transport configuration, for client and server
transport.typeTCP
transport.serverNIO
transport.heartbeattrue
transport.enableTmClientBatchSendRequestfalse
transport.enableRmClientBatchSendRequesttrue
transport.enableTcServerBatchSendResponsefalse
transport.rpcRmRequestTimeout30000
transport.rpcTmRequestTimeout30000
transport.rpcTcRequestTimeout30000
transport.threadFactory.bossThreadPrefixNettyBoss
transport.threadFactory.workerThreadPrefixNettyServerNIOWorker
transport.threadFactory.serverExecutorThreadPrefixNettyServerBizHandler
transport.threadFactory.shareBossWorkerfalse
transport.threadFactory.clientSelectorThreadPrefixNettyClientSelector
transport.threadFactory.clientSelectorThreadSize1
transport.threadFactory.clientWorkerThreadPrefixNettyClientWorkerThread
transport.threadFactory.bossThreadSize1
transport.threadFactory.workerThreadSizedefault
transport.shutdown.wait3
transport.serializationseata
transport.compressornone#Transaction routing rules configuration, only for the client
service.vgroupMapping.default_tx_groupdefault
#If you use a registry, you can ignore it
service.default.grouplist127.0.0.1:8091
service.enableDegradefalse
service.disableGlobalTransactionfalse#Transaction rule configuration, only for the client
client.rm.asyncCommitBufferLimit10000
client.rm.lock.retryInterval10
client.rm.lock.retryTimes30
client.rm.lock.retryPolicyBranchRollbackOnConflicttrue
client.rm.reportRetryCount5
client.rm.tableMetaCheckEnabletrue
client.rm.tableMetaCheckerInterval60000
client.rm.sqlParserTypedruid
client.rm.reportSuccessEnablefalse
client.rm.sagaBranchRegisterEnablefalse
client.rm.sagaJsonParserfastjson
client.rm.tccActionInterceptorOrder-2147482648
client.tm.commitRetryCount5
client.tm.rollbackRetryCount5
client.tm.defaultGlobalTransactionTimeout60000
client.tm.degradeCheckfalse
client.tm.degradeCheckAllowTimes10
client.tm.degradeCheckPeriod2000
client.tm.interceptorOrder-2147482648
client.undo.dataValidationtrue
client.undo.logSerializationjackson
client.undo.onlyCareUpdateColumnstrue
server.undo.logSaveDays7
server.undo.logDeletePeriod86400000
client.undo.logTableundo_log
client.undo.compress.enabletrue
client.undo.compress.typezip
client.undo.compress.threshold64k
#For TCC transaction mode
tcc.fence.logTableNametcc_fence_log
tcc.fence.cleanPeriod1h#Log rule configuration, for client and server
log.exceptionRate100#Transaction storage configuration, only for the server. The file, db, and redis configuration values are optional.
store.modefile
store.lock.modefile
store.session.modefile
#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.dirfile_store/data
store.file.maxBranchSessionSize16384
store.file.maxGlobalSessionSize512
store.file.fileWriteBufferCacheSize16384
store.file.flushDiskModeasync
store.file.sessionReloadReadSize100#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.datasourcedruid
store.db.dbTypemysql
store.db.driverClassNamecom.mysql.jdbc.Driver
store.db.urljdbc:mysql://127.0.0.1:3306/seata?useUnicodetruerewriteBatchedStatementstrue
store.db.userusername
store.db.passwordpassword
store.db.minConn5
store.db.maxConn30
store.db.globalTableglobal_table
store.db.branchTablebranch_table
store.db.distributedLockTabledistributed_lock
store.db.queryLimit100
store.db.lockTablelock_table
store.db.maxWait5000#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.modesingle
store.redis.single.host127.0.0.1
store.redis.single.port6379
store.redis.sentinel.masterName
store.redis.sentinel.sentinelHosts
store.redis.maxConn10
store.redis.minConn1
store.redis.maxTotal100
store.redis.database0
store.redis.password
store.redis.queryLimit100#Transaction rule configuration, only for the server
server.recovery.committingRetryPeriod1000
server.recovery.asynCommittingRetryPeriod1000
server.recovery.rollbackingRetryPeriod1000
server.recovery.timeoutRetryPeriod1000
server.maxCommitRetryTimeout-1
server.maxRollbackRetryTimeout-1
server.rollbackRetryTimeoutUnlockEnablefalse
server.distributedLockExpireTime10000
server.xaerNotaRetryTimeout60000
server.session.branchAsyncQueueSize5000
server.session.enableBranchAsyncRemovefalse
server.enableParallelRequestHandlefalse#Metrics configuration, only for the server
metrics.enabledfalse
metrics.registryTypecompact
metrics.exporterListprometheus
metrics.exporterPrometheusPort9898以上感谢。2023年2月19日