lamp-cloud-项目熟悉
一、项目地址
本项目统一使用master分支,lamp-cloud mater分支版本是3.10.0
项目地址:https://gitee.com/dromara/lamp-cloud
项目依赖工具:https://gitee.com/zuihou111/lamp-util
代码生成器:https://gitee.com/zuihou111/lamp-generator
lamp-job(任务调度):https://gitee.com/zuihou111/lamp-job
前台:https://gitee.com/zuihou111/lamp-web
注意:想启动 lamp-cloud 项目,需要先将 lamp-util 和 lamp-job编译打包
项目的编译顺序是:lamp-util -> lamp-cloud -> lamp-job
二、环境安装及配置启动
2.1 准备工作
idea2022.3.3、VSCode 1.90.2
maven3.9.1、Jdk1.8
mysql-8.0.22-winx64、Redis-x64-5.0.14.1
nacos-server-2.3.2、seata-server-2.0.0
Node版本管理工具:nvm 1.1.12
Node v20.15.0
lamp-web项目支持Node 16版本以上
2.2 环境安装
详细安装见:0-环境安装-整体.md 、1-Mysql8安装及配置.md、2-Redis安装及配置.md、3-nacos-server-2.3.2-安装及配置.md、4-Sentinel-2.0.0-安装及配置.md、5-Node安装及配置.md
lamp-web master分支,node版本21,实际上是低于这版本,又高于16版本
2.3 数据库导入
前提:本地安装好mysql
mysql脚本位置:D:\workspace\code\gitee\lamp-cloud\01-docs\sql\mysql
1、创建表:lamp_defaults
CREATE DATABASE IF NOT EXISTS `lamp_defaults` CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
2、导入数据
然后将lamp_defaults、lamp_base_0000、lamp_extend_0000、lamp_column脚本数据到导入到lamp_defaults库
执行顺序:lamp_defaults、lamp_base_0000、lamp_extend_0000、lamp_column
注意:master分支项目没有进行跨库操作,即都放在lamp_defaults表中了。
2.4 服务启动
服务启动顺序:Mysql、Redis、Nacos、Seata
1、启动Redis:
.\redis-server.exe redis.windows.conf
注意:不能启动的使用,点加斜杠运行需要运行的命令, .\命令
注意启动顺序:先启动nacos、再启动seata
2、nacos启动:
D:\software\nacos\nacos-server-2.3.2\bin目录下执行
.\startup.cmd -m standalone
3、Seata启动:
D:\software\seata\seata-server-2.0.0\bin目录下执行
.\seata-server.bat -p 8091 -h 192.168.1.79 -m db -n 1
注意事项:
如不能正常启动请检查相应的配置
Redis配置在nacos中需要修改,原因:本地redis没有设置密码,需要在nacos配置中去掉密码
本地Nacos配置、Seata配置需要注意修改,具体的
三、项目运行
启动项目前:
在nacos中导入相关配置
其中:D:\workspace\code\gitee\lamp-cloud\01-third-party对应的nacos压缩包配置和seata配置都需要导入
3.0 nacos创建seata配置
参考:https://tangyh.top/doc/start/%E5%8D%95%E6%9C%BA%E7%89%88Seata%E5%90%AF%E5%8A%A8.html
在新建的命名空间中新增配置: seataServer.properties
, 将修改后的 config.txt 文件中的内容复制进来。
命名空间id: 5b51e46a-4aeb-4d40-8398-8a9d33e2f0ad
seataServer.properties配置:
#For details about configuration items, see https://seata.io/zh-cn/docs/user/configurations.html
#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
# 待修改 start
service.vgroupMapping.lamp_cloud_seata_tx_group=default
#If you use a registry, you can ignore it
service.default.grouplist=192.168.1.190:8091
# 待修改 end
service.enableDegrade=false
service.disableGlobalTransaction=false
#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.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
# 待修改 start
client.undo.logSerialization=protostuff
# 待修改 end
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
#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=file
store.session.mode=file
#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
# 待修改 start
store.db.driverClassName=com.mysql.jdbc.Driver
store.db.url=jdbc:mysql://127.0.0.1:3306/lamp_seata?useUnicode=true&rewriteBatchedStatements=true
store.db.user=root
store.db.password=root
# 待修改 end
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.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.single.host=127.0.0.1
store.redis.single.port=6379
store.redis.sentinel.masterName=
store.redis.sentinel.sentinelHosts=
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.xaerNotaRetryTimeout=60000
server.session.branchAsyncQueueSize=5000
server.session.enableBranchAsyncRemove=false
server.enableParallelRequestHandle=false
#Metrics configuration, only for the server
metrics.enabled=false
metrics.registryType=compact
metrics.exporterList=prometheus
metrics.exporterPrometheusPort=9898
3.1 后端项目启动
1、先确保
nacos
、MySQL
、Redis
、Seata
、RabbitMQ
(可选)、等基础服务是否启动成功2、执行顺序,逐一启动:OauthServerApplication、AuthorityServerApplication、FileServerApplication、MsgServerApplication、TenantServerApplication、GatewayServerApplication、MonitorApplication
参考:https://tangyh.top/doc/start/cloud/%E5%90%8E%E7%AB%AF%E5%90%AF%E5%8A%A8.html
3.2 前台项目启动
1、拉取依赖:
npm i
2、运行命令:
npm run dev
lamp-web项目目录下运行
3.3 服务访问
nacos服务
http://localhost:8848/nacos/index.html
用户名:nacos
密码:nacos
seata服务
用户名:seata
密码:seata
Swagger文档: http://192.168.1.79:8778/doc.html 数据库监控: http://127.0.0.1:8778/druid
用户名:lamp
密码:lamp
lamp-web访问地址:
附件
参考
lamp-cloud官方文档:https://tangyh.top/opendoc/%E7%AE%80%E4%BB%8B.html (开源版)
启动后的效果图:
链接:https://lcnutsmhwcrk.feishu.cn/docx/O12Qd6NsDovF0Kx5uDBcpEivnce
密码:X4#33414
介绍
微服务:
lamp-cloud每个服务都有一个server模块,存放各个服务自己的配置文件和启动类。
服务访问扩展
应用 'lamp-authority-server' 运行成功! 访问连接: Swagger文档: http://192.168.1.79:8764/doc.html 数据库监控: http://127.0.0.1:8764/druid
应用 'lamp-gateway-server' 运行成功! 访问连接: Swagger文档: http://192.168.1.79:8760/api/doc.html
应用 'lamp-file-server' 运行成功! 访问连接: Swagger文档: http://192.168.1.79:8765/doc.html 数据库监控: http://127.0.0.1:8765/druid
应用 'lamp-msg-server' 运行成功! 访问连接: Swagger文档: http://192.168.1.79:8768/doc.html 数据库监控: http://192.168.1.79:8768/druid
应用 'lamp-oauth-server' 运行成功! 访问连接: Swagger文档: http://192.168.1.79:8773/doc.html 数据库监控: http://127.0.0.1:8773/druid