功能類
更新時間 2025-10-16 16:22:55
最近更新時間: 2025-10-16 16:22:55
分享文章
本章節主要介紹應用容災多活功能類問題。
如何查看探針程序日志
用戶可以選擇將日志打印到應用控制臺或者接入應用日志組件:
- 在啟動參數中加入-Damss.log.type=slf4j可以將日志接入slf4j組件。
- 在啟動參數中加入-Damss.log.type=console可以將日志打印到控制臺。
- 如果未設置amss.log.type,則優先尋找slf4j是否存在可用的日志組件,如果不存在則默認使用console。
用戶可以選擇探針程序打印的日志級別:
- 在啟動參數中加入-Damss.log.level=DEBUG可以將探針日志變更為DEBUG級別,用于路由分析。
- 探針程序的日志默認為INFO級別,不打印請求詳情等信息。
- 為免影響業務性能,請只在調試階段打印探針程序調試日志。
調試日志開啟示例(將探針日志輸出到控制臺并設置為DEBUG級別):
java \
-javaagent:./amss-agent-1.0.0.jar \
-Damss.log.type=console \
-Damss.log.level=debug \
-Damss.application.group=order \
-Damss.application.name=訂單應用 \
-Damss.commander.servers=172.*.*.10:47588 \
-Damss.commander.secret=****** \
-jar order-application.jar
設置成功后會在啟動日志中可以看到如下信息:
...
2025-01-16 09:59:18 Initialize log factory completed: type=console , level=DEBUG
...
如何查看業務路由日志
將日志級別設置為DEBUG,然后尋找以下信息:
-
HTTP服務端和RPC客戶端日志:
.... // 收到HTTP請求 2025-01-16 09:44:02 [http-nio-15210-exec-6] [ASPECT] Enter beforeAdvice: event=[org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle <- [org.apache.catalina.connector.RequestFacade@3d896257, org.apache.catalina.connector.ResponseFacade@43d550e0, com.ctg.amss.test.agent.service.ClientService#dubboUnitWrite(String, String, String)]] 2025-01-16 09:44:02 [http-nio-15210-exec-6] [ASPECT] Receive http server request: requestId=LnisjvgnTdOO8QbJ6oDa8Q , localUnitGroup=unit , request=HttpServletRequest [127.*.*.1:60071-> 127.*.*.1:15210 , method=POST, uri=/dubbo/unit/write , query=] 2025-01-16 09:44:02 [http-nio-15210-exec-6] [ASPECT] Executing http server request: requestId=LnisjvgnTdOO8QbJ6oDa8Q , localUnitGroup=unit , arch=active-passive 2025-01-16 09:44:02 [http-nio-15210-exec-6] [ASPECT] Executing http request: requestId=LnisjvgnTdOO8QbJ6oDa8Q , localUnitGroup=unit , routerSources=[RouterSource [routerType=http, routerSource=parameter, routerName=rid], RouterSource [routerType=http, routerSource=parameter, routerName=rid_unit]] , routerId=0 // HTTP請求路由計算結果,允許訪問 2025-01-16 09:44:02 [http-nio-15210-exec-6] [ASPECT] Legal http request: requestId=LnisjvgnTdOO8QbJ6oDa8Q , localUnitGroup=unit , routers=[[guangzhou_1]] , routerId=0 2025-01-16 09:44:02 [http-nio-15210-exec-6] [ASPECT] Enter beforeAdvice: event=[org.apache.dubbo.rpc.cluster.RouterChain.route <- [dubbo://172.*.*.21/com.ctg.amss.test.agent.remote.IServerDubboUnitService?application=dubbo-consumer-service.client.unit&check=false&dubbo=2.0.2&init=false&interface=com.ctg.amss.test.agent.remote.IServerDubboUnitService&metadata-type=remote&methods=read,write&pid=23148&qos.enable=false®ister.ip=172.*.*.21&release=2.7.13&side=consumer&sticky=false×tamp=1736991753341, RpcInvocation [methodName=write, parameterTypes=[class java.lang.String, class java.lang.String], arguments=[3, 04101814-9fe2-**-**-e2721c567b42], attachments={}]]] 2025-01-16 09:44:02 [http-nio-15210-exec-6] [ASPECT] Enter afterAdvice: event=[org.apache.dubbo.rpc.cluster.RouterChain.route <- [dubbo://172.*.*.21/com.ctg.amss.test.agent.remote.IServerDubboUnitService?application=dubbo-consumer-service.client.unit&check=false&dubbo=2.0.2&init=false&interface=com.ctg.amss.test.agent.remote.IServerDubboUnitService&metadata-type=remote&methods=read,write&pid=23148&qos.enable=false®ister.ip=172.*.*.21&release=2.7.13&side=consumer&sticky=false×tamp=1736991753341, RpcInvocation [methodName=write, parameterTypes=[class java.lang.String, class java.lang.String], arguments=[3, 04101814-9fe2-**-**-e2721c567b42], attachments={}]]] // 發起了RPC調用 2025-01-16 09:44:02 [http-nio-15210-exec-6] [ASPECT] Send dubbo client request: requestId=ifM03dL_TxOrK4kTR2qNBg , localUnitGroup=unit , request=Invocation [service=com.ctg.amss.test.agent.remote.IServerDubboUnitService , method=write , arguements=[3, 04101814-9fe2-**-**-e2721c567b42]] 2025-01-16 09:44:02 [http-nio-15210-exec-6] [ASPECT] Redirect dubbo client request: requestId=ifM03dL_TxOrK4kTR2qNBg , localUnitGroup=unit 2025-01-16 09:44:02 [http-nio-15210-exec-6] [ASPECT] Redirect dubbo client request: requestId=ifM03dL_TxOrK4kTR2qNBg , serviceType=dubbo , serviceName=providers:com.ctg.amss.test.agent.remote.IServerDubboUnitService:amss-version:amss-group 2025-01-16 09:44:02 [http-nio-15210-exec-6] [ASPECT] Executing dubbo client request: requestId=ifM03dL_TxOrK4kTR2qNBg , unitGroup=unit , arch=active-passive 2025-01-16 09:44:02 [http-nio-15210-exec-6] [ASPECT] Executing dubbo client request: requestId=ifM03dL_TxOrK4kTR2qNBg , unitGroup=unit , routerSources=1 2025-01-16 09:44:02 [http-nio-15210-exec-6] [ASPECT] Redirect dubbo client request: requestId=ifM03dL_TxOrK4kTR2qNBg , unitGroup=unit , arch=active-passive , routerId=3 // RPC調用的路由計算結果 2025-01-16 09:44:02 [http-nio-15210-exec-6] [ASPECT] Redirect dubbo client request: requestId=ifM03dL_TxOrK4kTR2qNBg , unitGroup=unit , arch=active-passive , routerId=3 , candidate=[[guangzhou_1]] 2025-01-16 09:44:02 [http-nio-15210-exec-6] [ASPECT] Redirect dubbo client request: requestId=ifM03dL_TxOrK4kTR2qNBg , unitGroup=unit , arch=active-passive , routerId=3 , target=[com.ctg.amss.agent.aspect.dubbo.callback.DubboControlCallback$1@571abb79] 2025-01-16 09:44:02 [http-nio-15210-exec-6] [ASPECT] Enter finalizeAdvice: event=[org.apache.dubbo.rpc.cluster.RouterChain.route <- [dubbo://172.*.*.21/com.ctg.amss.test.agent.remote.IServerDubboUnitService?application=dubbo-consumer-service.client.unit&check=false&dubbo=2.0.2&init=false&interface=com.ctg.amss.test.agent.remote.IServerDubboUnitService&metadata-type=remote&methods=read,write&pid=23148&qos.enable=false®ister.ip=172.*.*.21&release=2.7.13&side=consumer&sticky=false×tamp=1736991753341, RpcInvocation [methodName=write, parameterTypes=[class java.lang.String, class java.lang.String], arguments=[3, 04101814-9fe2-**-**-e2721c567b42], attachments={amss.trace.enable=true}]]] // 等待RPC調用響應 2025-01-16 09:44:02 [http-nio-15210-exec-6] [ASPECT] End dubbo client request: requestId=ifM03dL_TxOrK4kTR2qNBg , localUnitGroup=unit 2025-01-16 09:44:02 [http-nio-15210-exec-6] [ASPECT] Enter beforeAdvice: event=[org.springframework.web.method.support.HandlerMethodReturnValueHandlerComposite.handleReturnValue <- [ok, method 'dubboUnitWrite' parameter -1, ModelAndViewContainer: View is [null]; default model {}, ServletWebRequest: uri=/dubbo/unit/write;client=127.*.*.1]] 2025-01-16 09:44:02 [http-nio-15210-exec-6] [ASPECT] End http server request: requestId=LnisjvgnTdOO8QbJ6oDa8Q , localUnitGroup=unit 2025-01-16 09:44:02 [http-nio-15210-exec-6] [ASPECT] Enter afterAdvice: event=[org.springframework.web.method.support.HandlerMethodReturnValueHandlerComposite.handleReturnValue <- [ok, method 'dubboUnitWrite' parameter -1, ModelAndViewContainer: Request handled directly, ServletWebRequest: uri=/dubbo/unit/write;client=127.*.*.1]] 2025-01-16 09:44:02 [http-nio-15210-exec-6] [ASPECT] Enter finalizeAdvice: event=[org.springframework.web.method.support.HandlerMethodReturnValueHandlerComposite.handleReturnValue <- [ok, method 'dubboUnitWrite' parameter -1, ModelAndViewContainer: Request handled directly, ServletWebRequest: uri=/dubbo/unit/write;client=127.*.*.1]] 2025-01-16 09:44:02 [http-nio-15210-exec-6] [ASPECT] Enter afterAdvice: event=[org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle <- [org.apache.catalina.connector.RequestFacade@3d896257, org.apache.catalina.connector.ResponseFacade@43d550e0, com.ctg.amss.test.agent.service.ClientService#dubboUnitWrite(String, String, String)]] 2025-01-16 09:44:02 [http-nio-15210-exec-6] [ASPECT] Enter finalizeAdvice: event=[org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle <- [org.apache.catalina.connector.RequestFacade@3d896257, org.apache.catalina.connector.ResponseFacade@43d550e0, com.ctg.amss.test.agent.service.ClientService#dubboUnitWrite(String, String, String)]] .... -
RPC服務端日志:
... // 收到RPC請求 2025-01-16 09:44:02 [DubboServerHandler-172.*.*.1:25211-thread-10] [ASPECT] Enter beforeAdvice: event=[org.apache.dubbo.rpc.proxy.AbstractProxyInvoker.invoke <- [RpcInvocation [methodName=write, parameterTypes=[class java.lang.String, class java.lang.String], arguments=[3, 04101814-9fe2-**-**-e2721c567b42], attachments={input=389, path=com.ctg.amss.test.agent.remote.IServerDubboUnitService, remote.application=dubbo-consumer-service.client.unit, dubbo=2.0.2, interface=com.ctg.amss.test.agent.remote.IServerDubboUnitService, version=0.0.0, amss.trace.enable=true}]]] 2025-01-16 09:44:02 [DubboServerHandler-172.*.*.1:25211-thread-10] [ASPECT] Receive dubbo request: event=[org.apache.dubbo.rpc.proxy.AbstractProxyInvoker.invoke <- [RpcInvocation [methodName=write, parameterTypes=[class java.lang.String, class java.lang.String], arguments=[3, 04101814-9fe2-**-**-e2721c567b42], attachments={input=389, path=com.ctg.amss.test.agent.remote.IServerDubboUnitService, remote.application=dubbo-consumer-service.client.unit, dubbo=2.0.2, interface=com.ctg.amss.test.agent.remote.IServerDubboUnitService, version=0.0.0, amss.trace.enable=true}]]] 2025-01-16 09:44:02 [DubboServerHandler-172.*.*.1:25211-thread-10] [ASPECT] Receive dubbo server request: requestId=uKOSIjZISVucb8y4zT8I3g , localUnitGroup=unit , request=Invocation [service=null , method=write , arguements=[3, 04101814-9fe2-**-**-e2721c567b42]] 2025-01-16 09:44:02 [DubboServerHandler-172.*.*.1:25211-thread-10] [ASPECT] Executing dubbo server request: requestId=uKOSIjZISVucb8y4zT8I3g , localUnitGroup=unit , arch=active-passive 2025-01-16 09:44:02 [DubboServerHandler-172.*.*.1:25211-thread-10] [ASPECT] Executing dubbo request: requestId=uKOSIjZISVucb8y4zT8I3g , localUnitGroup=unit , routerSources=[RouterSource [routerType=dubbo, routerSource=parameter, routerName=1]] , routerId=3 // RPC調用的路由計算結果,允許訪問 2025-01-16 09:44:02 [DubboServerHandler-172.*.*.1:25211-thread-10] [ASPECT] Legal dubbo request: requestId=uKOSIjZISVucb8y4zT8I3g , localUnitGroup=unit , routers=[[guangzhou_1]] , routerId=3 // 執行SQL 2025-01-16 09:44:02 [DubboServerHandler-172.*.*.1:25211-thread-10] [ASPECT] Execute SQL: connection=jdbc:mysql://127.*.*.1:3306/amss_agent_test_region_beijing?autoReconnect=true&characterEncoding=utf8&useSSL=false&serverTimezone=UTC&amss.jdbc.rw= , sql=insert into amss_agent_write (message) values(?) 2025-01-16 09:44:02 [DubboServerHandler-172.*.*.1:25211-thread-10] [ASPECT] Enter afterAdvice: event=[org.apache.dubbo.rpc.proxy.AbstractProxyInvoker.invoke <- [RpcInvocation [methodName=write, parameterTypes=[class java.lang.String, class java.lang.String], arguments=[3, 04101814-9fe2-**-**-e2721c567b42], attachments={input=389, path=com.ctg.amss.test.agent.remote.IServerDubboUnitService, remote.application=dubbo-consumer-service.client.unit, dubbo=2.0.2, interface=com.ctg.amss.test.agent.remote.IServerDubboUnitService, version=0.0.0, amss.trace.enable=true}]]] 2025-01-16 09:44:02 [DubboServerHandler-172.*.*.1:25211-thread-10] [ASPECT] End dubbo server request: requestId=uKOSIjZISVucb8y4zT8I3g , localUnitGroup=unit 2025-01-16 09:44:02 [DubboServerHandler-172.*.*.1:25211-thread-10] [ASPECT] Enter finalizeAdvice: event=[org.apache.dubbo.rpc.proxy.AbstractProxyInvoker.invoke <- [RpcInvocation [methodName=write, parameterTypes=[class java.lang.String, class java.lang.String], arguments=[3, 04101814-9fe2-**-**-e2721c567b42], attachments={input=389, path=com.ctg.amss.test.agent.remote.IServerDubboUnitService, remote.application=dubbo-consumer-service.client.unit, dubbo=2.0.2, interface=com.ctg.amss.test.agent.remote.IServerDubboUnitService, version=0.0.0, amss.trace.enable=true}]]] ...
如何查看主備切換日志
在INFO級別的日志下出現以下信息的日志即為主備切換完成:
...
2025-01-16 09:43:56 [Amss worker-10] [ASPECT] Switch database completed: unitGroup=unit , center=435049117**-**
...