zombodb安装试用
pg 数据库安装
参考如下安装
yum install https://download.postgresql.org/pub/repos/yum/10/redhat/rhel-7-x86_64/pgdg-centos10-10-2.noarch.rpm
yum install postgresql10
yum install postgresql10-server
yum install -y postgresql10-contrib
安装zombodb 扩展
- 下载pg10 版本的扩展
wget https://www.zombodb.com/releases/v10-1.0.3/zombodb_centos7_pg10-10-1.0.3_1.x86_64.rpm
- 安装zombodb
rpm -Uvh zombodb_centos7_pg10-10-1.0.3_1.x86_64.rpm
- pg 数据库配置&&启动
为了简单,直接使用没有密码的模式,在pg_hba.conf 添加一下配置,注意生产环境坚决不能这么搞
- pg_hba.conf
host all all 0.0.0.0/0 trust
- postgresql.conf
listen_addresses = '0.0.0.0'
port = 5432
- 数据库启动
/usr/pgsql-10/bin/postgresql-10-setup initdb
systemctl enable postgresql-10
systemctl start postgresql-10
安装es
为了方便docker 安装
- docker 安装(可选,如果没有安装的话)
yum install -y yum-utils
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
yum install -y docker-ce
加速
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://b3uey254.mirror.aliyuncs.com"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker
- docker-compose 文件
version: '2'
services:
elasticsearch:
image: elasticsearch:6.6.0
ports:
- "9200:9200"
environment:
- http.host=0.0.0.0
- transport.host=0.0.0.0
- network.host=0.0.0.0
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
ulimits:
memlock:
soft: -1
hard: -1
mem_limit: 1g
可能需要配置系统vm 参数
echo vm.max_map_count=655360 >> /etc/sysctl.conf && \
sysctl -p
- 启动
docker-compose up -d
配置扩展
- 创建扩展
CREATE EXTENSION zombodb;
- 创建测试表
CREATE TABLE products (
id SERIAL8 NOT NULL PRIMARY KEY,
name text NOT NULL,
keywords varchar(64)[],
short_summary text,
long_description zdb.fulltext,
price bigint,
inventory_count integer,
discontinued boolean default false,
availability_date date
);
- 导入测试数据
COPY products FROM PROGRAM 'curl https://raw.githubusercontent.com/zombodb/zombodb/master/TUTORIAL-data.dmp';
- 创建索引
CREATE INDEX idxproducts
ON products
USING zombodb ((products.*))
WITH (url='http://localhost:9200/');
- 查询
SELECT * FROM products WHERE products ==> 'sports box';
- 查看查询计划
- es 索引数据
- 扩展的schema
说明
zombodb 功能很强大,使用标准扩展我们可以方便的进行全文检索系统的开发,同时集合graphql 以及timescaledb 我们可以设计强大的分析系统
参考资料
https://github.com/zombodb/zombodb/blob/master/INSTALL.md
https://hub.docker.com/_/elasticsearch?tab=tags
https://www.postgresql.org/download/linux/redhat/
https://github.com/zombodb/zombodb/blob/master/TUTORIAL.md