书接上回,已经安装启动了mariadb,接下来看看mariadb是如何启动的,最便捷的方式就是直接分析一下mariadb的启动日志。
截取启动日志,并展示如下,
$ cat alert_err.log
2023-06-07 14:51:17 0 [Note] Starting MariaDB 10.11.3-MariaDB source revision 0bb31039f54bd6a0dc8f0fc7d40e6b58a51998b0 as process 1388462
2023-06-07 14:51:17 0 [Warning] Plugin 'OQGRAPH' is of maturity level gamma while the server is stable
2023-06-07 14:51:17 0 [Note] RocksDB: 2 column families found
2023-06-07 14:51:17 0 [Note] RocksDB: Column Families at start:
2023-06-07 14:51:17 0 [Note] cf=default
2023-06-07 14:51:17 0 [Note] write_buffer_size=67108864
2023-06-07 14:51:17 0 [Note] target_file_size_base=67108864
2023-06-07 14:51:17 0 [Note] cf=__system__
2023-06-07 14:51:17 0 [Note] write_buffer_size=67108864
2023-06-07 14:51:17 0 [Note] target_file_size_base=67108864
2023-06-07 14:51:18 0 [Note] RocksDB: Table_store: loaded DDL data for 0 tables
2023-06-07 14:51:18 0 [Note] RocksDB: global statistics using get_sched_indexer_t indexer
2023-06-07 14:51:18 0 [Note] MyRocks storage engine plugin has been successfully initialized.
2023-06-07 14:51:18 0 [Note] InnoDB: Compressed tables use zlib 1.2.7
2023-06-07 14:51:18 0 [Note] InnoDB: Number of transaction pools: 1
2023-06-07 14:51:18 0 [Note] InnoDB: Using crc32 + pclmulqdq instructions
2023-06-07 14:51:18 0 [Note] InnoDB: Using Linux native AIO
2023-06-07 14:51:18 0 [Note] InnoDB: Initializing buffer pool, total size = 128.000MiB, chunk size = 2.000MiB
2023-06-07 14:51:18 0 [Note] InnoDB: Completed initialization of buffer pool
2023-06-07 14:51:18 0 [Note] InnoDB: File system buffers for log disabled (block size=512 bytes)
2023-06-07 14:51:18 0 [Note] InnoDB: 128 rollback segments are active.
2023-06-07 14:51:18 0 [Note] InnoDB: Setting file './ibtmp1' size to 12.000MiB. Physically writing the file full; Please wait ...
2023-06-07 14:51:18 0 [Note] InnoDB: File './ibtmp1' size is now 12.000MiB.
2023-06-07 14:51:18 0 [Note] InnoDB: log sequence number 45500; transaction id 15
2023-06-07 14:51:18 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
230607 14:51:18 Columnstore: Started; Version: 6.4.7-1
2023-06-07 14:51:18 0 [Note] CONNECT: Version 1.07.0002 March 22, 2021
2023-06-07 14:51:18 0 [Note] Plugin 'FEEDBACK' is disabled.
2023-06-07 14:51:18 0 [Warning] mariadbd: GSSAPI plugin : default principal 'mariadb/centos@' not found in keytab
2023-06-07 14:51:18 0 [Note] InnoDB: Buffer pool(s) load completed at 230607 14:51:18
2023-06-07 14:51:18 0 [ERROR] mariadbd: Server GSSAPI error (major 851968, minor 2529639093) : gss_acquire_cred failed -Unspecified GSS failure. Minor code may provide more information. Keytab FILE:/etc/krb5.keytab is nonexistent or empty.
2023-06-07 14:51:18 0 [ERROR] Plugin 'gssapi' init function returned error.
2023-06-07 14:51:18 0 [Note] Server socket created on IP: '0.0.0.0'.
2023-06-07 14:51:18 0 [Note] Server socket created on IP: '::'.
2023-06-07 14:51:18 0 [Note] /usr/sbin/mariadbd: ready for connections.
Version: '10.11.3-MariaDB' socket: '/var/lib/mysql/mysql.sock' port: 3306 MariaDB Server
下面逐一分析:
启动时间及版本
2023-06-07 14:51:17 0 [Note] Starting MariaDB 10.11.3-MariaDB source revision 0bb31039f54bd6a0dc8f0fc7d40e6b58a51998b0 as process 1388462
启动时间为 2023-06-07 14:51:17
启动的数据库版本为 MariaDB 10.11.3,对应的代码版本为0bb31039f54bd6a0dc8f0fc7d40e6b58a51998b0
https://github.com/MariaDB/server/commit/0bb31039f54bd6a0dc8f0fc7d40e6b58a51998b0
OQGRAPH
2023-06-07 14:51:17 0 [Warning] Plugin 'OQGRAPH' is of maturity level gamma while the server is stable
OQGRAPH 是 Open Query GRAPH 的缩写,是mariadb上的一个图查询引擎,可以处理树状结构和复杂的图,可以使用sql对图、树状关系来进行查询。
cpu 指令
mariadb 使用了 crc32 加密算法,
CRC(Cyclic Redundancy Check)校验实用程序库在数据存储和数据通讯领域,为了保证数据的正确,就不得不采用检错的手段。在诸多检错手段中,CRC是最著名的一种。CRC的全称是循环冗余校验。
2023-06-07 14:51:18 0 [Note] InnoDB: Using crc32 + pclmulqdq instructions
以及 pclmulqdq 指令集,当前机器使用的指令集可通过lscpu 进行查看,如:
$ lscpu | grep pclmulqdq
Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss syscall nx pdpe1gb rdtscp lm constant_tsc rep_good nopl xtopology eagerfpu pni pclmulqdq vmx ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch invpcid_single ssbd ibrs ibpb tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm mpx avx512f avx512dq rdseed adx smap clflushopt clwb avx512cd avx512bw avx512vl xsaveopt xsavec xgetbv1 arat pku ospke md_clear spec_ctrl
buffer_pool
buffer pool 的初始化日志,初始化默认占用128M空间,生成了128个回滚段,缓存池对应文件位置在 /var/lib/mysql/ib_buffer_pool, 可通过参数 datadir 进行位置调整。
2023-06-07 14:51:18 0 [Note] InnoDB: Initializing buffer pool, total size = 128.000MiB, chunk size = 2.000MiB
2023-06-07 14:51:18 0 [Note] InnoDB: Completed initialization of buffer pool
2023-06-07 14:51:18 0 [Note] InnoDB: File system buffers for log disabled (block size=512 bytes)
2023-06-07 14:51:18 0 [Note] InnoDB: 128 rollback segments are active.
2023-06-07 14:51:18 0 [Note] InnoDB: Setting file './ibtmp1' size to 12.000MiB. Physically writing the file full; Please wait ...
2023-06-07 14:51:18 0 [Note] InnoDB: File './ibtmp1' size is now 12.000MiB.
2023-06-07 14:51:18 0 [Note] InnoDB: log sequence number 45500; transaction id 15
2023-06-07 14:51:18 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
2023-06-07 14:51:18 0 [Note] InnoDB: Buffer pool(s) load completed at 230607 14:51:18
Columnstore
MariaDB ColumnStore是一个利用大规模并行分布式数据架构的列式存储引擎。 它是一个通过将InfiniDB 4.6.7移植到MariaDB而构建的列式存储系统,并在GPL许可下发布。
230607 14:51:18 Columnstore: Started; Version: 6.4.7-1
在mairadb中,columnstore引擎是以插件形式加载的,引用到类包 ha_columnstore.so, 通过 show plugin 可以查看到相关插件名。
| Columnstore | ACTIVE | STORAGE ENGINE | ha_columnstore.so | GPL |
| COLUMNSTORE_COLUMNS | ACTIVE | INFORMATION SCHEMA | ha_columnstore.so | GPL |
| COLUMNSTORE_TABLES | ACTIVE | INFORMATION SCHEMA | ha_columnstore.so | GPL |
| COLUMNSTORE_FILES | ACTIVE | INFORMATION SCHEMA | ha_columnstore.so | GPL |
| COLUMNSTORE_EXTENTS | ACTIVE | INFORMATION SCHEMA | ha_columnstore.so | GPL |
CONNECT
类似的,db启动时初始化了CONNECT引擎,
CONNECT存储引擎使MariaDB能够访问外部本地或远程数据(MED)。 这是通过基于不同数据类型定义表来实现的,特别是各种格式的文件,通过ODBC或JDBC从其他DBMS或产品(如Excel或MongoDB)提取的数据,或从环境(例如DIR、WMI和MAC表)检索的数据。
2023-06-07 14:51:18 0 [Note] CONNECT: Version 1.07.0002 March 22, 2021
GSSAPI
GSSAPI是一种身份验证协议,通常由Unix上的Kerberos或Windows上的Active Directory实现。MaxScale中的认证模块名称为GSSAPIAuth。
2023-06-07 14:51:18 0 [Warning] mariadbd: GSSAPI plugin : default principal 'mariadb/centos@' not found in keytab
2023-06-07 14:51:18 0 [ERROR] mariadbd: Server GSSAPI error (major 851968, minor 2529639093) : gss_acquire_cred failed -Unspecified GSS failure. Minor code may provide more information. Keytab FILE:/etc/krb5.keytab is nonexistent or empty.
2023-06-07 14:51:18 0 [ERROR] Plugin 'gssapi' init function returned error.
gssapi身份验证插件的共享库作为auth_gssapi包含在MariaDB包中。 因此,在可以构建auth_gssapi.dll的系统上,也可以使用该共享库。 该插件首先包含在MariaDB 10.1.11中。
在RHEL、CentOS、Fedora和其他类似的Linux发行版上,强烈建议使用yum或dnf从MariaDB的存储库安装相关的RPM包。 从RHEL 8和Fedora 22开始,yum已经被dnf取代,这是yum的下一个主要版本。 但是,yum命令仍然可以在许多使用dnf的系统上工作。 例如:
sudo yum install MariaDB-gssapi-server
如果MariaDB服务器在Unix上运行,那么可以通过配置gssapi_keytab_path系统变量来设置前面创建的keytab文件的路径。 这可以作为mysqld的命令行参数指定,也可以在选项文件中的相关服务器选项组中指定。 例如:
[mariadb]
...
gssapi_keytab_path=/path/to/mariadb.keytab
如果无需使用该插件,则配置文件中就不需要添加这些内容,以防止报错。
[mariadb]
plugin-load-add=auth_gssapi.so
启动成功
最后,当mariadb启动成功后,会报出如下日志,提示可以接受连接,并监听3306端口。
2023-06-07 14:51:18 0 [Note] /usr/sbin/mariadbd: ready for connections.
Version: '10.11.3-MariaDB' socket: '/var/lib/mysql/mysql.sock' port: 3306 MariaDB Server
总结
以上内容大致盘点了mairadb的启动信息,以及启动过程中都调用了哪些插件。




