> For the complete documentation index, see [llms.txt](https://cifar.gitbook.io/note/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cifar.gitbook.io/note/kai-fa/kai-fa-xiang-guan-gong-ju/shu-ju-ku-zhi-shi.md).

# 数据库 知识

## [Milvus 开源向量数据库](https://milvus.io/cn/docs/v1.1.1/home)

### 介绍

Milvus 是一款基于云原生架构开发的开源向量数据库，支持查询和管理由机器学习模型或神经网络生成的向量数据。Milvus 在一流的近似最近邻（ANN）搜索库（例如 Faiss、NMSLIB、Annoy）的功能基础上进行扩展，具有按需扩展、流批一体和高可用等特点。 Milvus 致力于简化非结构化数据管理，并在不同的部署环境中提供一致的用户体验。

## MySql

命令行连接

mysql  -h  10.50.41.56   -u  mgii\_dna\_rw   -P   7066   -p

别名

update base\_milvus\_config t set t.milvus\_write=0 where id=5;

### 常用语句

| 语法                                                                            | 功能         |
| ----------------------------------------------------------------------------- | ---------- |
| <p>"select count(1) as num <br>from db.partition<br>where group\_id='{}'"</p> | 计数         |
| <p>select count(distinct group\_id) as num <br>FROM db.partition</p>          | 根据某个键，去重计数 |
|                                                                               |            |

### limit ： [数据量大时limit分页慢的问题](https://www.jianshu.com/p/b40852891fb0)

改为按主键检索

> 芒果数据迁移记录，10个子进程
>
> SELECT \* FROM `ait_hnmg_20` where id BETWEEN 398871+0 and 398871+ 999&#x20;
>
> SELECT \* FROM `ait_hnmg_20` where id BETWEEN 398871+1000 and 398871+1000 + 999
>
> SELECT \* FROM `ait_hnmg_20` where id BETWEEN 398871+9000 and 398871+9000 + 999
>
> 查找已经迁移的起始点id
>
> select \* from `ait_hnmg_20` limit 1000,1

### 索引

[何时索引"失效"](https://mp.weixin.qq.com/s/g_G28-EeNOm7_imtIKvrXw)

## 消息中间件

### kafka

#### 以前入门

[基本b站视频入门，常见名词](https://www.bilibili.com/video/BV1vx411f7hA) [名词解释文档](https://www.cnblogs.com/tonglin0325/p/8810313.html) [Zookeeper 与 broker](https://www.jianshu.com/p/a036405f989c) [ 3分钟演示Kafka的消息发送：异步，批量，分区，主从备份](https://www.bilibili.com/video/BV1oC4y1s7Mc)&#x20;

运维 [Offset Explorer 2.0](https://www.kafkatool.com/)&#x20;

报文可视化工具 [Offset Explorer 2.0 使用](http://www.ibloger.net/article/3497.html)&#x20;

Kafka管理工具[Kafka Manager](https://github.com/yahoo/CMAK)

> topic : 主体
>
> partition：分区
>
> group:  消费者分组，为多程序，共同消费提供可能

```
group = "test_jiarui8"
auto_reset_offset = "earliest" 
# 常用 latest、earliest。根据业务，是否需要历史数据。earliest：最早的第一条开始，latest：最近的开始。
#（如果一个group刚刚建立，并且采用 latest 消费策略，从最近的开始。假设topic 第一条数据为 1月开始生产，如今五月，那这个group，拿到的是最近5月新生产的消息吗，1-4月左右的都忽略？这样理解吗？ 坚哥回复：理解正确）
#以上均针对group为存在的场景，如果group消费者已存在，均从记录offset处开始消费。

enable_auto_commit=False
#自动提交最好设为False，采用手动提交commit。所有环节可控。
#自动提交理解为：poll后提交上一次的消费offset，或者 指定时间后提交offset。
```

#### 详细使用

kafka的[可视化工具Offset Explorer](https://blog.csdn.net/AlbenXie/article/details/122088144)   <img src="/files/S94JSsBVNf5nYMpxGIrd" alt="" data-size="line">

kafka 命令行管理，查找对应工具，根据PATH 环境变量 <img src="/files/EuP8uMixGqSUCXTlwcS9" alt="" data-size="line">，然后百度所需功能具体命令

> [kafka集群操作命令](https://blog.csdn.net/welcome66/article/details/84915722)
>
> 查看kafka topic列表，使用–list参数
>
> bin/kafka-topics.sh --list --zookeeper localhost:2181&#x20;
>
> 查看kafka特定topic的详情，使用–topic与–describe参数
>
> bin/kafka-topics.sh --zookeeper 127.0.0.1:2181 --topic test --describe

chroot[是linux中的一种操作，即Change Root](https://blog.csdn.net/weixin_43990804/article/details/116104521)

Kafka [Schema Registry 原理](https://zhmin.github.io/posts/kafka-schema-registry/)
