操作环境为CentOs 9
Meilisearch 官方文档
- Git源码安装
## git https://git-scm.com/book/zh/v2/%E8%B5%B7%E6%AD%A5-%E5%AE%89%E8%A3%85-Git
# 安装必要的依赖
$ yum -y install curl-devel wget gcc-c++ expat-devel gettext-devel
openssl-devel zlib-devel gcc perl-ExtUtils-MakeMaker make autoconf automake libtool
$ wget https://github.com/git/git/archive/refs/tags/v2.40.0.tar.gz
$ tar -zxf v2.40.0.tar.gz
$ cd git-2.40.0
$ make configure
$ ./configure --prefix=/usr
$ make prefix=/usr/git all
$ make prefix=/usr/git install
# 环境变量更新 /etc/profile 中
$ PATH=/root/.local/bin:/root/bin:/usr/share/Modules/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/usr/git/bin
$ source /etc/profile
-
rust 安装
https://www.rust-lang.org/tools/install
$ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
$ source "$HOME/.cargo/env"
$ rustc --version
rustc 1.68.2 (9eb3afe9e 2023-03-27)
- Meilisearch源码编译安装
$ git clone https://github.com/meilisearch/meilisearch
$ cd meilisearch
$ git checkout latest
# Finally, update the rust toolchain, compile the project, and execute the binary.
# Update the rust toolchain to the latest version
rustup update
# Compile the project
cargo build --release
# Execute the server binary
./target/release/meilisearch
# 正常启动后如下:
$ 888b d888 d8b 888 d8b 888
$ 8888b d8888 Y8P 888 Y8P 888
$ 88888b.d88888 888 888
$ 888Y88888P888 .d88b. 888 888 888 .d8888b .d88b. 8888b. 888d888 .d8888b 88888b.
$ 888 Y888P 888 d8P Y8b 888 888 888 88K d8P Y8b "88b 888P" d88P" 888 "88b
$ 888 Y8P 888 88888888 888 888 888 "Y8888b. 88888888 .d888888 888 888 888 888
$ 888 " 888 Y8b. 888 888 888 X88 Y8b. 888 888 888 Y88b. 888 888
$ 888 888 "Y8888 888 888 888 88888P' "Y8888 "Y888888 888 "Y8888P 888 888
$
$ Config file path: "./config.toml"
$ Database path: "./data.ms"
$ Server listening on: "http://0.0.0.0:7700"
$ Environment: "development"
$ Commit SHA: "572608c121d960cdf48c2c289a6dfd3dc834873a"
$ Commit date: "2023-02-23T13:52:56Z"
$ Package version: "1.0.2"
$
$ Thank you for using Meilisearch!
$
$
$ We collect anonymized analytics to improve our product and your experience. To learn more, including how to turn off analytics, visit our dedicated documentation page: https://docs.meilisearch.com/learn/what_is_meilisearch/telemetry.html
$
$ Anonymous telemetry: "Enabled"
$ Instance UID: "bc346a80-b426-4320-bbc3-f7cc3ad9e0f8"
$
$ A master key has been set. Requests to Meilisearch won't be authorized unless you provide an authentication key.
$
$ Documentation: https://docs.meilisearch.com
$ Source code: https://github.com/meilisearch/meilisearch
$ Contact: https://docs.meilisearch.com/resources/contact.html
$
$ [2023-04-06T01:29:32Z INFO actix_server::builder] Starting 1 workers
$ [2023-04-06T01:29:32Z INFO actix_server::server] Actix runtime found; starting in Actix runtime
# 初次启动时会生成 master-key
$ We generated a new secure master key for you (you can safely use this token):
$ >> --master-key kqdzcisF0wF8_RK#%lRXBYILYPBwI!EOZyJmIwqT6g84E@ <<
$ Restart Meilisearch with the argument above to use this new and secure master key.
# 后续启动时需要进行鉴权
$ ./target/release/meilisearch --master-key kqdzcisF0wF8_RK#%lRXBYILYPBwI!EOZyJmIwqT6g84E@
# 常用参数 说明 默认值
# –db-path 数据存储的位置
# –master-key 访问Meilisearch的master key 无
# –http-addr 监听的地址和端口 “0.0.0.0:7700”
# –env 运行环境(development/production) 为production时,必须要设置master-key development
# –dumps-dir dumps运行后,创建.dump文件的目录 dumps/
# –import-dump 运行时导入.dump文件中的数据
-
测试数据
movies.json 作为测试数据
# 添加数据
curl \
-X POST 'http://localhost:7700/indexes/movies/documents?primaryKey=id' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer $your_masterkey' \
--data-binary @movies.json
-- 响应结果
{
"taskUid": 0,
"indexUid": "movies",
"status": "enqueued",
"type": "documentAdditionOrUpdate",
"enqueuedAt": "2023-03-31T06:05:04.69303478Z"
}
-- 查询数据
curl \
-X GET 'http://localhost:7700/indexes/movies/documents/2' \
-H 'Authorization: Bearer $your_masterkey'