meilisearch는 elasticsearch 같은 검색엔진
elk의 카프카 cdc 같은 툴 사용해서 동기화 가능한데
meilisync다.
기존 mysql 5에서 했을 때 에러가 발생 했는데
8버전에서는 잘된다.
https://github.com/long2ice/meilisync/issues/18
postgres 14에서 동기화 성공해서 기록 남긴다.
PostgreSQL: wal_level = logical and install wal2json extension, use logical replication.
FROM postgres:14.1
RUN apt-get update
RUN apt-get install -y postgresql-14-wal2json
wal_level
은 아래 도커 컴포즈 postgres에서 설정
command: ['postgres', '-c', 'wal_level=logical']
meilisearch:
container_name: meilisearch
image: getmeili/meilisearch:v1.3.1
env_file:
- .env
environment:
- http_proxy
- https_proxy
- MEILI_MASTER_KEY=${MEILI_MASTER_KEY:-masterKey}
- MEILI_NO_ANALYTICS=${MEILI_NO_ANALYTICS:-true}
- MEILI_ENV=${MEILI_ENV:-development}
- MEILI_LOG_LEVEL
- MEILI_DB_PATH=${MEILI_DB_PATH:-/data.ms}
ports:
- 8080:7700
# volumes:
# - ./data.ms:/data.ms
restart: unless-stopped
depends_on:
postgres:
condition: service_healthy
meilisync:
image: long2ice/meilisync
volumes:
- ./meilisync-config.yml:/meilisync/config.yml
restart: always
depends_on:
postgres:
condition: service_healthy
debug: true
plugins:
- meilisync.plugin.Plugin
progress:
type: file
source:
type: postgres
host: postgres // 도커 컨테이너 이름
port: 5432
user: postgres
password: 'password'
database: testdb
meilisearch:
api_url: http://meilisearch:7700 // 도커 컨테이너 이름
api_key: ef3d098b4ddd4e41....284a8a2a39 // 밀리서치 api key
insert_size: 1000
insert_interval: 3
sync:
- table: posts
index: post
plugins:
- meilisync.plugin.Plugin
full: true
fields:
id:
title:
content:
writer:
created_at:
updated_at:
deleted_at:
기본적으로 특정 테이블의 생성, 수정, 삭제에 대해 동기화 해준다.
insert_interval
설정으로 polling 설정.
확인해 보니
insert_interval
와insert_size
가 모두 설정이 안되어 있어야 바로바로 동기화 한다.
둘 중 하나만 적용하는 경우 이벤트는 확인이 되는데 (debug 모드엣서) 동기화는 안된다.
https://github.com/long2ice/meilisync/blob/dev/meilisync/main.py#L110...L112
글 재미있게 봤습니다.