在本节中,我们讨论 NDB 集群提供的事件日志类型,以及记录的事件类型。In this section, we discuss the types of event logs provided by NDB Cluster, and the types of events that are logged.
NDB 集群提供两种类型的事件日志:NDB Cluster provides two types of event log:
集群日志,包括所有集群节点生成的事件。集群日志是大多数用途推荐的日志,因为它提供了整个集群在单一位置的日志信息。The cluster log, which includes events generated by all cluster nodes. The cluster log is the log recommended for most uses because it provides logging information for an entire cluster in a single location.
默认情况下,集群日志会保存到名为
ndb_的文件中,(其中node_id_cluster.lognode_id是管理服务器的节点 ID)位于管理服务器的DataDir中。By default, the cluster log is saved to a file namedndb_, (wherenode_id_cluster.lognode_idis the node ID of the management server) in the management server'sDataDir.集群日志信息也可以发送到
stdout或syslog设施,除了保存到文件之外,或者替代保存到文件,这取决于DataDir和LogDestination配置参数的设置值。有关这些参数的更多信息,请参见 第 25.4.3.5 节,“定义 NDB 集群管理服务器”。Cluster logging information can also be sent tostdoutor asyslogfacility in addition to or instead of being saved to a file, as determined by the values set for theDataDirandLogDestinationconfiguration parameters. See Section 25.4.3.5, “Defining an NDB Cluster Management Server”, for more information about these parameters.节点日志 是每个节点本地的。Node logs are local to each node.
节点事件日志生成的输出写入文件
ndb_(其中node_id_out.lognode_id是节点的节点 ID),文件位于该节点的DataDir中。节点事件日志会为管理节点和数据节点生成。Output generated by node event logging is written to the filendb_(wherenode_id_out.lognode_idis the node's node ID) in the node'sDataDir. Node event logs are generated for both management nodes and data nodes.节点日志仅用于应用开发期间,或用于调试应用代码。Node logs are intended to be used only during application development, or for debugging application code.
每个可报告事件可以根据三种不同的标准进行区分:Each reportable event can be distinguished according to three different criteria:
类别:可以是以下任意一个值:
STARTUP、SHUTDOWN、STATISTICS、CHECKPOINT、NODERESTART、CONNECTION、ERROR或INFO。Category: This can be any one of the following values:STARTUP,SHUTDOWN,STATISTICS,CHECKPOINT,NODERESTART,CONNECTION,ERROR, orINFO.Priority: This is represented by one of the numbers from 0 to 15 inclusive, where 0 indicates “most important” and 15 “least important.”
严重性级别:这可以是以下任意一个值:
ON、DEBUG、INFO、WARNING、ERROR、CRITICAL、ALERT或ALL。(这有时也被称为日志级别。)Severity Level: This can be any one of the following values:ON,DEBUG,INFO,WARNING,ERROR,CRITICAL,ALERT, orALL. (This is also sometimes referred to as the log level.)
可以使用 NDB 管理客户端的 CLUSTERLOG 命令根据这些属性过滤集群日志。此命令仅影响集群日志,对节点日志没有影响;可以使用 ndb_mgm NODELOG DEBUG 命令在一个或多个节点日志中开启或关闭调试日志。The cluster log can be filtered on these properties using the NDB
management client CLUSTERLOG
command. This command affects the cluster log only, and has no
effect on the node logs; debug logging in one or more node logs
can be turned on and off using the ndb_mgm
NODELOG DEBUG command.
NDB Cluster 生成的日志消息使用的格式如下:The format used in a log message generated by NDB Cluster is as shown here:
timestamp[node_type]level-- Nodenode_id:message
日志或日志消息中的每一行包含以下信息:Each line in the log, or log message, contains the following information:
timestamp的格式为YYYY-MM-DD HH:MM:SS。时间戳值当前仅精确到整数秒;不支持分秒。Atimestampinformat. The timestamp value currently resolves to whole seconds only; fractional seconds are not supported.YYYY-MM-DDHH:MM:SSnode_type,即执行日志记录的节点或应用类型。在集群日志中,这始终是[MgmSrvr];在数据节点日志中,这始终是[ndbd]。在由 NDB API 应用程序和工具生成的日志中,可能出现[NdbApi]以及其他值。Thenode_type, or type of node or application which is performing the logging. In the cluster log, this is always[MgmSrvr]; in the data node log, it is always[ndbd].[NdbApi]and other values are possible in logs generated by NDB API applications and tools.事件的
level,有时也称为其严重性级别或日志级别。有关严重性级别的更多信息,请参见本节前面的内容,以及第 25.6.3.1 节,“NDB 集群日志管理命令”。Thelevelof the event, sometimes also referred to as its severity level or log level. See earlier in this section, as well as Section 25.6.3.1, “NDB Cluster Logging Management Commands”, for more information about severity levels.报告该事件的节点 ID(
node_id)。The ID of the node reporting the event (node_id).包含事件描述的
message。日志中最常出现的事件类型是集群中不同节点之间的连接和断开连接,以及发生检查点时的事件。在某些情况下,描述可能包含状态或其他信息。Amessagecontaining a description of the event. The most common types of events to appear in the log are connections and disconnections between different nodes in the cluster, and when checkpoints occur. In some cases, the description may contain status or other information.
下面显示了一个来自实际集群日志的示例:A sample from an actual cluster log is shown here:
2021-06-10 10:01:07 [MgmtSrvr] INFO -- Node 5: Start phase 5 completed (system restart) 2021-06-10 10:01:07 [MgmtSrvr] INFO -- Node 6: Start phase 5 completed (system restart) 2021-06-10 10:01:07 [MgmtSrvr] INFO -- Node 5: Start phase 6 completed (system restart) 2021-06-10 10:01:07 [MgmtSrvr] INFO -- Node 6: Start phase 6 completed (system restart) 2021-06-10 10:01:07 [MgmtSrvr] INFO -- Node 5: President restarts arbitration thread [state=1] 2021-06-10 10:01:07 [MgmtSrvr] INFO -- Node 5: Start phase 7 completed (system restart) 2021-06-10 10:01:07 [MgmtSrvr] INFO -- Node 6: Start phase 7 completed (system restart) 2021-06-10 10:01:07 [MgmtSrvr] INFO -- Node 5: Start phase 8 completed (system restart) 2021-06-10 10:01:07 [MgmtSrvr] INFO -- Node 6: Start phase 8 completed (system restart) 2021-06-10 10:01:07 [MgmtSrvr] INFO -- Node 5: Start phase 9 completed (system restart) 2021-06-10 10:01:07 [MgmtSrvr] INFO -- Node 6: Start phase 9 completed (system restart) 2021-06-10 10:01:07 [MgmtSrvr] INFO -- Node 5: Start phase 50 completed (system restart) 2021-06-10 10:01:07 [MgmtSrvr] INFO -- Node 6: Start phase 50 completed (system restart) 2021-06-10 10:01:07 [MgmtSrvr] INFO -- Node 5: Start phase 101 completed (system restart) 2021-06-10 10:01:07 [MgmtSrvr] INFO -- Node 6: Start phase 101 completed (system restart) 2021-06-10 10:01:07 [MgmtSrvr] INFO -- Node 5: Started (mysql-8.4.7 ndb-8.4.7) 2021-06-10 10:01:07 [MgmtSrvr] INFO -- Node 6: Started (mysql-8.4.7 ndb-8.4.7) 2021-06-10 10:01:07 [MgmtSrvr] INFO -- Node 5: Node 50: API mysql-8.4.7 ndb-8.4.7 2021-06-10 10:01:07 [MgmtSrvr] INFO -- Node 6: Node 50: API mysql-8.4.7 ndb-8.4.7 2021-06-10 10:01:08 [MgmtSrvr] INFO -- Node 6: Prepare arbitrator node 50 [ticket=75fd00010fa8b608] 2021-06-10 10:01:08 [MgmtSrvr] INFO -- Node 5: Started arbitrator node 50 [ticket=75fd00010fa8b608] 2021-06-10 10:01:08 [MgmtSrvr] INFO -- Node 6: Communication to Node 100 opened 2021-06-10 10:01:08 [MgmtSrvr] INFO -- Node 6: Communication to Node 101 opened 2021-06-10 10:01:08 [MgmtSrvr] INFO -- Node 5: Communication to Node 100 opened 2021-06-10 10:01:08 [MgmtSrvr] INFO -- Node 5: Communication to Node 101 opened 2021-06-10 10:01:36 [MgmtSrvr] INFO -- Alloc node id 100 succeeded 2021-06-10 10:01:36 [MgmtSrvr] INFO -- Nodeid 100 allocated for API at 127.0.0.1 2021-06-10 10:01:36 [MgmtSrvr] INFO -- Node 100: mysqld --server-id=1 2021-06-10 10:01:36 [MgmtSrvr] INFO -- Node 5: Node 100 Connected 2021-06-10 10:01:36 [MgmtSrvr] INFO -- Node 6: Node 100 Connected 2021-06-10 10:01:36 [MgmtSrvr] INFO -- Node 5: Node 100: API mysql-8.4.7 ndb-8.4.7 2021-06-10 10:01:36 [MgmtSrvr] INFO -- Node 6: Node 100: API mysql-8.4.7 ndb-8.4.7
有关更多信息,请参见 第 25.6.3.2 节,“NDB 集群日志事件”。For additional information, see Section 25.6.3.2, “NDB Cluster Log Events”.