0%

Linux 下,不要使用 root用户管理 Docker

迁移镜像

保存镜像到本地

保存镜像命令

1
docker save -o 本地文件名  要保存的镜像

查看镜像

1
docker images

保存一个镜像

1
docker save -o redis.tar redis

导入镜像

1
2
3
docker load --input 文件
#或者
docker load < 文件名

附录

daemon.json

  • windows 下的地址 C:\Users\${USER}\.docker\daemon.json
  • linux 下的地址 /etc/docker/daemon.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
{
"registry-mirrors": [
"https://kfwkfulq.mirror.aliyuncs.com",
"https://2lqq34jg.mirror.aliyuncs.com",
"https://pee6w651.mirror.aliyuncs.com",
"https://docker.mirrors.ustc.edu.cn",
"https://registry.docker-cn.com",
"http://hub-mirror.c.163.com"
],
"dns": ["8.8.8.8", "8.8.4.4"],
"insecure-registries": [],
"debug": false,
"experimental": false,
"features": {
"buildkit": true
},
"builder": {
"gc": {
"enabled": true,
"defaultKeepStorage": "20GB"
}
}
}

本文地址: https://github.com/maxzhao-it/blog/post/34094/

一、前言

Pivotal Greenplum Database是一个建立在开源PostgreSQL上的MPP(大规模并行处理)数据库。系统由主节点、备节点和段节点组成。

所有数据驻留在段节点上,目录信息存储在主节点中。段节点运行一个或多个段,这些段是修改后的PostgreSQL数据库实例,并被分配一个内容标识符。

对于每个表,根据用户在DDL语句中指定的分布列键,将数据划分到段节点中。

对于每个段内容标识符,都有一个不在同一物理主机上运行的主段和镜像段。

当一个SQL查询进入主节点时,它将被解析、优化并分发到所有段以执行查询计划,并返回请求的数据或将查询结果插入数据库表。

官方最佳实践

二、准备

概述

Master节点存储全局系统元数据信息,不存储真实数据。数据通过hash分布到不同的segment中,master作为sql的全局入口,负责在segment中分配工作负载,整合处理结果,返回客户端。

Greenplum架构特点如下:

  • master节点可以做主备,segment节点也有镜像保证高可用,segment主备尽量混布到不同服务器上。
  • 支持行列混合存储引擎,同时支持外部表。
  • join时也涉及到数据跨节点重分布的问题,这也是share nothing数据库不可避免的问题。
  • 高速内部interconnect网络,实现数据join时的高速移动和汇总。
  • 高效的数据并行加载。

greenplum架构图

部署方案

  • gp-master:192.168.2.21 master 节点
  • gp-master2:192.168.2.22
  • gp-master3:192.168.2.23
  • gp-master4:192.168.2.24

具体部署请参考附录中的虚拟机安装Centos系统配置

三、安装 Greenplum

配置 Centos

  • host
1
2
3
4
ssh root@192.168.2.21 "hostnamectl set-hostname host21;echo -e \"192.168.2.21  host21 dw1\\n192.168.2.22  host22 dw2\\n192.168.2.23  host23 dw3\\n192.168.2.24  host24 dw4\" >> /etc/hosts;"
ssh root@192.168.2.22 "hostnamectl set-hostname host22;echo -e \"192.168.2.21 host21 dw1\\n192.168.2.22 host22 dw2\\n192.168.2.23 host23 dw3\\n192.168.2.24 host24 dw4\" >> /etc/hosts;"
ssh root@192.168.2.23 "hostnamectl set-hostname host23;echo -e \"192.168.2.21 host21 dw1\\n192.168.2.22 host22 dw2\\n192.168.2.23 host23 dw3\\n192.168.2.24 host24 dw4\" >> /etc/hosts;"
ssh root@192.168.2.24 "hostnamectl set-hostname host24;echo -e \"192.168.2.21 host21 dw1\\n192.168.2.22 host22 dw2\\n192.168.2.23 host23 dw3\\n192.168.2.24 host24 dw4\" >> /etc/hosts;"
  • 安装相关的依赖包
1
yum install -y net-tools which openssh-clients openssh-server less zip unzip iproute
  • 启动 ssh

Centos 中默认已经启动 ssh,为了方便各节点之间的互连,创建相关的认证key。

1
2
3
4
5
# 所有节点都要执行
ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key
ssh-keygen -t ecdsa -f /etc/ssh/ssh_host_ecdsa_key
ssh-keygen -t ed25519 -f /etc/ssh/ssh_host_ed25519_key
/usr/sbin/sshd

同时修改所有节点里面的/etc/sysconfig/network文件,保持与主机名一致

1
2
3
4
5
6
7
8
9
# 查看
cat /etc/sysconfig/network
# 不存在,则写入
echo "NETWORKING=yes" >> /etc/sysconfig/network
echo "HOSTNAME=mdw" >> /etc/sysconfig/network
# 存在,则修改
vi /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=mdw
  • 创建Greenplum的用户和用户组

为了方便安装Greenplum集群,且使Greenplum自带的python不与系统的python版本相冲突,在每个节点中创建Greenplum的用户和用户组

1
2
3
4
5
6
7
# 所有部署服务器节点都做这个操作
groupadd -g 530 gpadmin
useradd -g 530 -u 530 -m -d /home/gpadmin -s /bin/bash gpadmin
chown -R gpadmin:gpadmin /home/gpadmin
# 这里可能会提示 bash: passwd: command not found
passwd gpadmin
echo "gpadmin ALL=(ALL) ALL" >> /etc/sudoers
  • 修改每个节点上的文件打开数量限制
1
2
3
4
5
6
cat /etc/security/limits.conf
# 不存在,则写入, 存在,则用 vi 修改
echo "soft nofile 65536" >> /etc/security/limits.conf
echo "hard nofile 65536" >> /etc/security/limits.conf
echo "soft nproc 131072" >> /etc/security/limits.conf
echo "hard nproc 131072" >> /etc/security/limits.conf

下载Greenplum安装包

greenplum的官网上,下载Greenplum安装包
GitHub下载,点开Greenplum Database Server,根据自己的操作系统下载安装包,我下载当前最新的open-source-greenplum-db-6.17.2-rhel7-x86_64.rpm,将其拷到master节点的/home/gpadmin目录中

版本快速链接: open-source-greenplum-db-6.17.2-rhel7-x86_64.rpm

安装Greenplum

切换到gpadmin用户

1
2
su gpadmin
cd ~/

Rpm 安装

  • 传递文件到Centos
1
2
3
scp D:\tools\linux\open-source-greenplum-db-6.17.2-rhel7-x86_64.rpm root@192.168.2.21:/home/gpadmin/
# 直接在 Centos中下载
wget https://github.com/greenplum-db/gpdb/releases/download/6.17.2/open-source-greenplum-db-6.17.2-rhel7-x86_64.rpm
  • 安装
1
sudo yum localinstall /home/gpadmin/open-source-greenplum-db-6.17.2-rhel7-x86_64.rpm -y
1
2
3
4
5
6
7
# 查看安装地址
whereis greenplum-db
# greenplum-db: /usr/local/greenplum-db
ls -l /usr/local/greenplum-db
# lrwxrwxrwx. 1 root root 30 8月 17 23:43 /usr/local/greenplum-db -> /usr/local/greenplum-db-6.17.2
# 安装目录权限
chown -R gpadmin:gpadmin /usr/local/greenplum-db*

gpssh-exkeys 报错问题:

1
2
cd /usr/bin
mv python python.bak

解压安装(ZIP)

解压下载后的zip文件

1
unzip greenplum-db-6.17.2-rhel7-x86_64.zip

执行安装文件

1
./greenplum-db-6.17.2-rhel7-x86_64.bin

安装期间需要配置安装目录,输入/home/gpadmin/greenplum-db-6.17.2

批量操作节点

配置

为了方便安装集群,Greenplum提供了批量操作节点的命令,通过指定配置文件使用批处理命令

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# 在主节点 host21 配置
cd ~/ ;mkdir conf
echo dw1 > ./conf/hostlist
echo dw2 >> ./conf/hostlist
echo dw3 >> ./conf/hostlist
echo dw4 >> ./conf/hostlist
# 批量处理服务器列表
cat ./conf/hostlist
ssh dw2 # 连接后 exit
ssh dw3 # 连接后 exit
ssh dw4 # 连接后 exit

echo dw2 > ./conf/seg_hosts
echo dw3 >> ./conf/seg_hosts
echo dw4 >> ./conf/seg_hosts
# 批量处理服务器列表
cat ./conf/seg_hosts

/usr/local/greenplum-db/greenplum_path.sh中保存了运行greenplum的一些环境变量,包括GPHOMEPYTHONHOME等。

免密登录

  1. 客户端生成公私钥
  2. 上传公钥到服务器
    1. id_rsa (私钥)
    2. id_rsa.pub (公钥)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# host21 执行,一直回车 
ssh-keygen -t ecdsa
# ssh-keygen -t rsa -C "email@domain.com" -f filename
# 分发到服务器
ssh-copy-id -i ~/.ssh/id_ecdsa.pub gpadmin@192.168.2.21
ssh-copy-id -i ~/.ssh/id_ecdsa.pub gpadmin@192.168.2.22
ssh-copy-id -i ~/.ssh/id_ecdsa.pub gpadmin@192.168.2.23
ssh-copy-id -i ~/.ssh/id_ecdsa.pub gpadmin@192.168.2.24
# 或者拷贝到服务器
scp ~/.ssh/id_ecdsa.pub gpadmin@192.168.2.22:/home/gpadmin/.ssh/id_ecdsa_21.pub
scp ~/.ssh/id_ecdsa.pub gpadmin@192.168.2.23:/home/gpadmin/.ssh/id_ecdsa_21.pub
scp ~/.ssh/id_ecdsa.pub gpadmin@192.168.2.24:/home/gpadmin/.ssh/id_ecdsa_21.pub
# 添加到免密登录:host22 执行
cat ~/.ssh/id_ecdsa_21.pub >> ~/.ssh/authorized_keys
# 添加到免密登录:host23 执行
cat ~/.ssh/id_ecdsa_21.pub >> ~/.ssh/authorized_keys
# 添加到免密登录:host24 执行
cat ~/.ssh/id_ecdsa_21.pub >> ~/.ssh/authorized_keys
  • 权限

    1
    2
    3
    4
    5
    su gpadmin
    sudo chmod 600 ~/.ssh/*
    sudo chmod 700 ~/.ssh
    sudo chmod 775 ~/
    sudo cp ~/.ssh/authorized_keys /root/.ssh/authorized_keys
  • 配置服务器的秘钥验证

1
sudo vim /etc/ssh/sshd_config
  • 修改
1
2
3
4
# 设置ssh在接收登录请求之前是否检查用户家目录和rhosts文件的权限和所有权。这通常是必要的,因为新手经常会把自己的目录和文件设成任何人都有写权限。)
StrictModes no
PermitRootLogin yes
PubkeyAuthentication yes
  • 重启

    1
    sudo systemctl restart sshd.service
  • 测试

    1
    ssh root@dw2

分发 masterrsa key

gpadmin账号下设置环境变量,并将master节点的key 交换到各个segment节点

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# 解压安装 source /home/gpadmin/greenplum-db/greenplum_path.sh 
# 或者
source /usr/local/greenplum-db/greenplum_path.sh
gpssh-exkeys -f /home/gpadmin/conf/hostlist
[STEP 1 of 5] create local ID and authorize on local host
[STEP 2 of 5] keyscan all hosts and update known_hosts file
[STEP 3 of 5] authorize current user on remote hosts
... send to mdw
... send to sdw1
***
*** Enter password for sdw1:
... send to sdw2
... send to sdw3

[STEP 4 of 5] determine common authentication file content

[STEP 5 of 5] copy authentication files to all remote hosts
... finished key exchange with mdw
... finished key exchange with sdw1
... finished key exchange with sdw2
... finished key exchange with sdw3

[INFO** completed successfully

批量处理

后续就可以使用一些命令执行批量操作

注意:使用gpssh-exkeys命令时一定要使用gpadmin用户,因为会在/home/gpadmin/.ssh中生成ssh的免密码登录秘钥,如果使用其它账号登录,则会在其它账号下生成密钥,在gpadmin
账号下就无法使用gpssh的批处理命令

1
2
3
4
5
6
7
8
9
10
11
12
gpssh -f /home/gpadmin/conf/hostlist
=> pwd
[dw1] /home/gpadmin
[dw2] /home/gpadmin
[dw3] /home/gpadmin
[dw4] /home/gpadmin
=> ls
[dw1] /home/gpadmin/conf/
[dw2]
[dw3]
[dw4]
=> exit

分发安装包到每个子节点

打包master节点上的安装包

1
tar -czf gp.tar.gz greenplum-db-6.17.2

使用gpscp命令将这个文件复制到每个子节点

1
gpscp -f /home/gpadmin/conf/seg_hosts gp.tar.gz =:/home/gpadmin

批量解压,并创建软链接

1
2
3
4
5
6
7
8
9
gpssh -f /home/gpadmin/conf/seg_hosts
=> tar -zxf gp.tar.gz
[dw2]
[dw3]
[dw4]
=> ln -s greenplum-db-6.17.2 greenplum-db
[dw2]
[dw3]
[dw4]

这样就完成了所有子节点数据库的安装

初始化安装数据库

  • 批量创建数据目录
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
gpssh -f /home/gpadmin/conf/hostlist
=> mkdir gpdata
[dw1]
[dw2]
[dw3]
[dw4]
=> cd gpdata
[dw1]
[dw2]
[dw3]
[dw4]
=> mkdir gpmaster gpdatap1 gpdatap2 gpdatam1 gpdatam2
[dw1]
[dw2]
[dw3]
[dw4]
=> exit
  • 在master节点上修改.bash_profile配置环境变量,并发送给其他子节点,确保这些环境变量生效
1
2
3
4
5
6
7
8
9
#.bash_profile 
echo "source /user/local/greenplum-db/greenplum_path.sh" >> ~/.bash_profile
echo "export MASTER_DATA_DIRECTORY=/home/gpadmin/gpdata/gpmaster/gpseg-1" >> ~/.bash_profile
echo "export PGPORT=2345" >> ~/.bash_profile
echo "export PGDATABASE=testDB" >> ~/.bash_profile
source .bash_profile
gpscp -f /home/gpadmin/conf/seg_hosts /home/gpadmin/.bash_profile =:/home/gpadmin/
# dw2、dw3、dw4 执行
source .bash_profile
  • 初始化配置文件
1
vim /home/gpadmin/conf/gpinitsystem_config

填写配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
ARRAY_NAME=\"Greenplum\"
MACHINE_LIST_FILE=/home/gpadmin/conf/seg_hosts
# Segment 的名称前缀
SEG_PREFIX=gpseg
# Primary Segment 起始的端口号
PORT_BASE=33000
# 指定 Primary Segment 的数据目录
declare -a DATA_DIRECTORY=(/home/gpadmin/gpdata/gpdatap1 /home/gpadmin/gpdata/gpdatap2)
# Master 所在机器的 Hostname
MASTER_HOSTNAME=dw1
# 指定 Master 的数据目录
MASTER_DIRECTORY=/home/gpadmin/gpdata/gpmaster
# Master 的端口
MASTER_PORT=5432
# 指定Bash的版本
TRUSTED_SHELL=/usr/bin/ssh
# Mirror Segment起始的端口号
MIRROR_PORT_BASE=43000
# Primary Segment 主备同步的起始端口号
REPLICATION_PORT_BASE=34000
# Mirror Segment 主备同步的起始端口号
MIRROR_REPLICATION_PORT_BASE=44000
# Mirror Segment 的数据目录
declare -a MIRROR_DATA_DIRECTORY=(/home/gpadmin/gpdata/gpdatam1 /home/gpadmin/gpdata/gpdatam2)
  • 初始化数据库
1
gpinitsystem -c /home/gpadmin/conf/gpinitsystem_config -s host24 -e 1

其中,-s dw4是指配置masterstandby节点,然后按照提示步骤就能完成安装了

如果gpinitsystem不成功,在master节点的/home/gpadmin/gpAdminLogs目录下gpinitsystem_*.log文件中查看日志信息,找出原因进行修改,然后再重新执行gpinitsystem进行初始化安装。

清空重来

所有的服务器执行

1
2
3
4
5
6
7
8
9
10
# 关闭查询到的进程
ps ax |grep greenplum |grep -v grep |awk '{print $1}'
# 删除锁定文件
sudo rm -f /tmp/.s.PGSQL*
rm -rf /home/gpadmin/gpdata/gpdatam1/*
rm -rf /home/gpadmin/gpdata/gpdatam2/*
rm -rf /home/gpadmin/gpdata/gpdatap1/*
rm -rf /home/gpadmin/gpdata/gpdatap2/*
rm -rf /home/gpadmin/gpdata/gpmaster/*
rm -rf /home/gpadmin/gpdata/gpAdminLogs/*

四、配置

鬼鬼,有点复杂,待续

附:

1、虚拟机安装

虚拟机网络配置

虚拟机系统网络

虚拟机CD设置

2、Centos系统配置

1
2
sudo cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
vim /etc/yum.repos.d/CentOS-Base.repo

详情请看附

1
2
3
4
5
6
7
8
9
10
11
12
13
14
# 清空缓存
yum clean all
# 更新源
yum repolist
# 安装基础依赖
yum -y install epel-release

sed -e 's!^metalink=!#metalink=!g' \
-e 's!^#baseurl=!baseurl=!g' \
-e 's!//download\.fedoraproject\.org/pub!//mirrors.tuna.tsinghua.edu.cn!g' \
-e 's!http://mirrors\.tuna!https://mirrors.tuna!g' \
-i /etc/yum.repos.d/epel.repo /etc/yum.repos.d/epel-testing.repo

rpm -ivh https://mirrors.tuna.tsinghua.edu.cn/epel/6/x86_64/epel-release-6-8.noarch.rpm

报错 RPM-GPG-KEY-EPEL-7

先设置 CentOS-Base.repo 中的 gpgcheck=0

1
2
cd /etc/pki/rpm-gpg
wget https://archive.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-7

国内

1
2
3
4
5
6
7
8
sudo sed -e 's|^mirrorlist=|#mirrorlist=|g' \
-e 's|^#baseurl=http://mirror.centos.org|baseurl=https://mirrors.tuna.tsinghua.edu.cn|g' \
-i.bak \
/etc/yum.repos.d/CentOS-*.repo

sudo yum clean all
sudo yum makecache
sudo yum -y update

关闭防火墙

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
systemctl status firewalld
# 关闭服务
systemctl stop firewalld
# 关闭自启服务
systemctl disable firewalld
# 开放端口
firewall-cmd --zone=public --add-port=80/tcp --add-port=3306/tcp --permanent
# 重新载入
firewall-cmd --reload
# 查看
firewall-cmd --zone=public --query-port=80/tcp
# 查看全部
firewall-cmd --zone=public --list-all
# 删除
firewall-cmd --zone=public --remove-port=80/tcp --permanent

max file

修改

1
sudo vim /etc/security/limits.conf

添加

1
2
3
4
* soft nofile 65536
* hard nofile 65536
* soft nproc 65536
* hard nproc 65536

或者直接执行添加

1
echo -e "* soft nofile 65536\\n* hard nofile 65536\\n* soft nproc 65536\\n* hard nproc 65536" >>/etc/security/limits.conf

执行

1
sudo source /etc/security/limits.conf

中文字体

方式1

1
2
3
4
yum -y install fonts-chinese
yum -y install fonts-ISO8859
fc-cache -fv
reboot

方式2

1
2
3
4
yum -y install fontconfig
mkdir chinses
chmod -R 755 /usr/share/fonts/chinses/
vim /etc/fonts/fonts.conf

<dir prefix="xdg">fonts</dir> 这一行下面插入:

1
<dir>/usr/share/fonts/chinses</dir> 
1
2
# 拷贝本地字体
fc-cache

网络

需要安装 net-tools

1
yum -y install net-tools

查看网络

1
ifconfig

我这里的网络魏 ens33

编辑网络

1
vim /etc/sysconfig/network-scripts/ifcfg-ens33

1
2
3
4
5
6
7

BOOTPROTO=static #开机协议,有dhcp及static;
ONBOOT=yes #设置为开机启动;
DNS1=114.114.114.114 #这个是国内的DNS地址,是固定的;
IPADDR=192.168.2.2 #你想要设置的固定IP,理论上192.168.2.2-255之间都可以,请自行验证;
NETMASK=255.255.255.0 #子网掩码,不需要修改;
GATEWAY=192.168.2.254 #网关,这里应该和你“2.配置虚拟机的NAT模式具体地址参数”中的(2)选择VMnet8--取消勾选使用本地DHCP--设置子网IP--网关IP设置 一样才行。

重启网略

1
service network restart

测试网络

1
ping www.baidu.com

设置hostname

默认hostnamelocalhost,所以这里做区分

1
ssh root@192.168.2.3 "hostnamectl set-hostname host3;echo -e \"192.168.2.3  host3\\n192.168.2.4  host4\\n192.168.2.5  host5\\n192.168.2.6  host6\\n192.168.2.7  host7\" >> /etc/hosts;"

3、关闭脚本

1
greenplum

4、gpinitsystem命令

-a 不提示用户确认
- b < parallel_processes > 要并行创建的段的数量。如果不指定,

该实用程序一次将启动4个并行进程。
- c < gpinitsystem_config > 必需的。配置文件的完整路径和文件名,其中

包含要配置和初始化的所有已定义参数

新的Greenplum系统。请参阅下面的初始化配置文件格式。
- d 设置日志输出级别为调试。
- h < hostfile_gpinitsystem > 可选的。包含主机的文件的完整路径和文件名

段主机的地址。如果没有在命令行中指定,

您可以使用MACHINE_LIST_FILE参数指定主机文件

在gpinitsystem_config文件中。
Sets the default locale used by Greenplum Database. 可选的。输入配置文件的完整路径和文件名,

定义Greenplum数据库成员和段使用

QD_PRIMARY_ARRAY和PRIMARY_ARRAY参数。输入配置

文件通常是通过使用gpinitsystem和-O

output_configuration_file选项。您必须提供-c

或-I input_configuration_file . cluster_configuration_file选项

gpinitsystem选项。
-l 要写入日志文件的目录。默认为~ / gpAdminLogs。
–max_connections= |-m 设置主服务器允许的最大客户端连接数。

默认为25。
- s 可选的。如果您希望配置备份主主机,请指定

使用此选项的主机名。必须使用Greenplum Database软件

已在此主机上安装和配置。
-e <password> password to set for Greenplum superuser in database [default su_password]
  -a, don't ask to confirm instance creation [default:- ask]
  -D, set log output to debug level, shows all function calls
  -l, logfile_directory [optional]
      Alternative logfile directory
  -q, quiet mode, do not log progress to screen [default:- verbose output to screen]

  Configuration options:
  -b, shared_buffers per instance [default 128000kB]
      Specify either the number of database I/O buffers (without suffix) or the
      amount of memory to use for buffers (with suffix 'kB', 'MB' or 'GB').
      Applies to master and all segments.
  -B, <number> run this batch of create segment processes in parallel [default 60]
  -c, gp_config_file [mandatory]
      Supplies all Greenplum configuration information required by this utility.
      Full description of all parameters contained within the example file
      supplied with this distribution.
      Also see gpinitsystem_INSTRUCTIONS file for greater detail on
      the operation and configuration of this script
  -e, , 
  -S, standby_datadir [optional]
  -h, gp_hostlist_file [optional]
      Contains a list of all segment instance hostnames required to participate in
      the new Greenplum instance. Normally set in gp_config_file.
  -I, <input_configuration_file>
      The full path and filename of an input configuration file, which defines the
      Greenplum Database members and segments using the QD_PRIMARY_ARRAY and
      PRIMARY_ARRAY parameters. The input configuration file is typically created by
      using gpinitsystem with the -O <output_configuration_file> option. You must
      provide either the -c <cluster_configuration_file> option or the -I
      <input_configuration_file> option to gpinitsystem.
  -m, maximum number of connections for master instance [default 250]
  -n, <locale>, setting for locale to be set when database initialized [default en_US.utf8]
  -O, <output_configuration_file>
      When used with the -O option, gpinitsystem does not create a new Greenplum
      Database cluster but instead writes the supplied cluster configuration
      information to the specified output_configuration_file. This file defines
      Greenplum Database members and segments using the QD_PRIMARY_ARRAY and
      PRIMARY_ARRAY parameters, and can be later used with -I
      <input_configuration_file> to initialize a new cluster.
  -p, postgresql_conf_gp_additions [optional]
      List of additional PostgreSQL parameters to be applied to each Master/Segment
      postgresql.conf file during Greenplum database initialization.
  -P, standby_port [optional]
  -s, standby_hostname [optional]

  Return codes:

本文地址: https://github.com/maxzhao-it/blog/post/58641/

前言

随着微服务的流行,服务和服务之间的稳定性变得越来越重要。Sentinel 是面向分布式服务架构的流量控制组件,主要以流量为切入点,从流量控制、熔断降级、系统自适应保护等多个维度来帮助您保障微服务的稳定性。

来自官网

下载 DashboardGitHub releases

安装

下载镜像

1
docker pull bladex/sentinel-dashboard

运行

1
docker run --name sentinel  -d -p 8858:8858 -d  bladex/sentinel-dashboard:latest

查看

githubhttps://github.com/chillzhuang/SpringBlade

websitehttps://bladex.vip

https://blog.csdn.net/Andy_Health/article/details/123790979

本文地址: https://github.com/maxzhao-it/blog/post/729b6d7f/

查看 docker 网络模式

1
docker network ls

创建新的 bridge 网络

1
docker network create --driver bridge --subnet=172.2.2.0/16 --gateway=172.2.1.1 mynet

查看网络信息

1
docker network inspect mynet

创建容器并指定IP

1
docker run -e TZ="Asia/Shanghai" --privileged -itd  --name redis-demo --network=mynet --ip 172.2.12.1 redis /usr/sbin/init

docker-compose指定IP

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
version: '2'
services:
nginx:
image: nginx:1.13.12
container_name: nginx
restart: always
tty: true
networks:
extnetwork:
ipv4_address: 172.2.12.3
networks:
# 自定义的网络名称
extnetwork:
ipam:
config:
- subnet: 172.2.12.0/16
gateway: 172.2.1.1

删除网路模式

1
docker network rm mynet

本文地址: https://github.com/maxzhao-it/blog/post/11485/

一、前言

Nacos 使用MySql8存储数据。

这里会描述 Docker 中的 Nacos 服务配置,服务器直接部署配置比较简单。

版本

  • Nacos2.0.3
  • MySql8

二、配置

指定当前服务器 Docker ip

查看 docker 网络模式

1
docker network ls

创建新的 bridge 网络

1
docker network create --driver bridge --subnet=172.2.2.0/16 --gateway=172.2.1.1 mynet

查看网络信息

1
docker network inspect mynet

创建容器并指定IP

1
docker run -e TZ="Asia/Shanghai" --privileged -itd  --name redis-demo --network=mynet --ip 172.2.12.1 redis /usr/sbin/init

docker-compose指定IP

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
version: '2'
services:
nginx:
image: nginx:1.13.12
container_name: nginx
restart: always
tty: true
networks:
extnetwork:
ipv4_address: 172.2.12.3
networks:
# 自定义的网络名称
extnetwork:
ipam:
config:
- subnet: 172.2.12.0/16
gateway: 172.2.1.1

删除网路模式

1
docker network rm mynet

docker-compose.yml方式配置

/plugins/mysql/目录下放的是 /plugins/mysql/mysql-connector-java-8.0.21.jar

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
version: '3.9'
services:
nacos:
image: nacos/nacos-server:2.0.3
container_name: nacos-standalone-mysql
env_file:
- ./env/nacos-standlone-mysql.env
volumes:
- ./standalone-logs/:/home/nacos/logs
- ./init.d/custom.properties:/home/nacos/init.d/custom.properties
- ./plugins/mysql/:/home/nacos/plugins/mysql/
ports:
- "8848:8848"
- "9848:9848"
- "9555:9555"
restart: always
networks:
mynet:
ipv4_address: 172.2.2.2

networks:
mynet:
external: true

NacosMySql数据库脚本

nacos-standlone-mysql.env

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
PREFER_HOST_MODE=hostname
MODE=standalone
# 项目地址
SERVER_SERVLET_CONTEXTPATH=/nacos
# 端口
NACOS_APPLICATION_PORT=8848
MYSQL_DATABASE_NUM=1
SPRING_DATASOURCE_PLATFORM=mysql
# 本机的IP 地址
MYSQL_SERVICE_HOST=192.168.2.1
MYSQL_SERVICE_DB_NAME=nacos_db
MYSQL_SERVICE_PORT=3306
MYSQL_SERVICE_USER=nacos
MYSQL_SERVICE_PASSWORD=nacos
#MYSQL_SERVICE_DB_PARAM=characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useSSL=false
MYSQL_SERVICE_DB_PARAM=charset=utf8mb4&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&serverTimezone=GMT%2B8&useUnicode=true&useSSL=false

custom.properties

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#spring.security.enabled=false
#management.security=false
#security.basic.enabled=false
#nacos.security.ignore.urls=/**
#management.metrics.export.elastic.host=http://localhost:9200
# metrics for prometheus
management.endpoints.web.exposure.include=*

# metrics for elastic search
#management.metrics.export.elastic.enabled=false
#management.metrics.export.elastic.host=http://localhost:9200

# metrics for influx
#management.metrics.export.influx.enabled=false
#management.metrics.export.influx.db=springboot
#management.metrics.export.influx.uri=http://localhost:8086
#management.metrics.export.influx.auto-create-db=true
#management.metrics.export.influx.consistency=one
#management.metrics.export.influx.compressed=true

附:

docker下的 nacos 属性配置列表

属性名称 描述 选项
MODE 系统启动方式: 集群/单机 cluster/standalone默认 cluster
NACOS_SERVERS 集群地址 p1:port1空格ip2:port2 空格ip3:port3
PREFER_HOST_MODE 支持IP还是域名模式 hostname/ip 默认 ip
NACOS_SERVER_PORT Nacos 运行端口 默认 8848
NACOS_SERVER_IP 多网卡模式下可以指定IP
SPRING_DATASOURCE_PLATFORM 单机模式下支持MYSQL数据库 mysql / 空 默认:空
MYSQL_SERVICE_HOST 数据库 连接地址
MYSQL_SERVICE_PORT 数据库端口 默认 : 3306
MYSQL_SERVICE_DB_NAME 数据库库名
MYSQL_SERVICE_USER 数据库用户名
MYSQL_SERVICE_PASSWORD 数据库用户密码
MYSQL_SERVICE_DB_PARAM 数据库连接参数 default : characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useSSL=false
MYSQL_DATABASE_NUM It indicates the number of database 默认 :1
JVM_XMS -Xms 默认 :1g
JVM_XMX -Xmx 默认 :1g
JVM_XMN -Xmn 默认 :512m
JVM_MS -XX:MetaspaceSize 默认 :128m
JVM_MMS -XX:MaxMetaspaceSize 默认 :320m
NACOS_DEBUG 是否开启远程DEBUG y/n 默认 :n
TOMCAT_ACCESSLOG_ENABLED server.tomcat.accesslog.enabled 默认 :false
NACOS_AUTH_SYSTEM_TYPE 权限系统类型选择,目前只支持nacos类型 默认 :nacos
NACOS_AUTH_ENABLE 是否开启权限系统 默认 :false
NACOS_AUTH_TOKEN_EXPIRE_SECONDS token 失效时间 默认 :18000
NACOS_AUTH_TOKEN token 默认 :SecretKey012345678901234567890123456789012345678901234567890123456789
NACOS_AUTH_CACHE_ENABLE 权限缓存开关 ,开启后权限缓存的更新默认有15秒的延迟 默认 : false
MEMBER_LIST 通过环境变量的方式设置集群地址 例子:192.168.16.101:8847?raft_port=8807,192.168.16.101?raft_port=8808,192.168.16.101:8849?raft_port=8809
EMBEDDED_STORAGE 是否开启集群嵌入式存储模式 embedded 默认 : none
NACOS_AUTH_CACHE_ENABLE nacos.core.auth.caching.enabled default : false
NACOS_AUTH_USER_AGENT_AUTH_WHITE_ENABLE nacos.core.auth.enable.userAgentAuthWhite default : false
NACOS_AUTH_IDENTITY_KEY nacos.core.auth.server.identity.key default : serverIdentity
NACOS_AUTH_IDENTITY_VALUE nacos.core.auth.server.identity.value default : security
NACOS_SECURITY_IGNORE_URLS nacos.security.ignore.urls default : /,/error,/**/*.css,/**/*.js,/**/*.html,/**/*.map,/**/*.svg,/**/*.png,/**/*.ico,/console-fe/public/**,/v1/auth/**,/v1/console/health/**,/actuator/**,/v1/console/server/**

本文地址: https://github.com/maxzhao-it/blog/post/56649/

前言

Elasticsearch 是使用比较广泛的分布式搜索引擎,es 提供了一个的单字分词工具,还有一个分词插件 ik 使用比较广泛,HanLP是一个自然语言处理包,能更好的根据上下文的语义,人名,地名,组织机构名等来切分词。

分词

elasticsearch-analysis-hanlp插件地址:github

默认分词器

1
2
3
4
GET /_analyze?pretty=true
{
"text":"赵联胜添加了一个使用默认分词器的语句"
}

1.HanLP分词器

安装(安装步骤一个不能少)

注意:只能使用修改过的 elasticsearch-analysis-hanlp-7.10.2-to-7.13.2.zip 文件安装

1
2
3
bin\elasticsearch-plugin install file:///D:\tools\window\elasticsearch\elasticsearch-analysis-hanlp-7.10.2-to-7.13.2.zip
# 这个在 win10 下不行,权限过不了。
bin\elasticsearch-plugin install https://github.com/KennFalcon/elasticsearch-analysis-hanlp/releases/download/v6.5.4/elasticsearch-analysis-hanlp-7.10.2.zip

安装步骤:

1、下载插件并解压到 esplugins目录下

1
2
3
修改analysis-hanlp目录下的hanlp.properties文件,修改root的属性,值为analysis-hanlp下的data 目录的地址
修改analysis-hanlp目录下的plugin-descriptor.properties文件,
修改elasticsearch的版本为你当前的版本elasticsearch.version=你的es版本号(like:5.5.1)

2、修改es config目录下的 jvm.options 文件,最后一行添加

1
-Djava.security.policy=/home/es/elasticsearch-7.0.1/plugins/analysis-hanlp/plugin-security.policy(地址换成你自己的地址)

当前方式不行请看 ES安装HanLP分词插件 文件

重启 es

特别注意

注意,在win10下配置 policy:这里会报错非法许可

permission ("java.io.FilePermission" "plugins/analysis-hanlp/data/-" "read,write,delete") in global grant

1
2
3
4
C:\Program Files\Java\jdk1.8.0_291\jre\lib\security\java.policy

[JDK]\jre\lib\security中的 java.policy 文件添加上面的权限控制后,win
10下可以用hanlp分词了

第一次启动比较慢

测试是否安装成功

1
2
3
4
5
POST http://localhost:9200/twitter2/_analyze
{
"text": "美国阿拉斯加州发生8.0级地震",
"tokenizer": "hanlp"
}

索引模式

analyzerhanlp_max_word(索引模式)和 hanlp_smart(智能模式)

  • hanlp_max_word:尽可能的切分多的结果
  • hanlp_smart:切分少的词

自定义词典:

1
2
3
4
5
修改plugins/analysis-hanlp/data/dictionary/custom下的 CustomDictionary.txt文件

格式遵从[单词] [词性A] [A的频次]

修改完后删除同目录下的CustomDictionary.txt.bin文件

重启 es 服务

2. HanLP 数据包

release包中存放的为HanLP源码中默认的分词数据,若要下载完整版数据包,请查看HanLP Release

数据包目录:*ES_HOME*/plugins/analysis-hanlp

注:因原版数据包自定义词典部分文件名为中文,这里的hanlp.properties中已修改为英文,请对应修改文件名

3. 重启Elasticsearch(最新:Github

注:上述说明中的ES_HOME为自己的ES安装路径,需要绝对路径

4. 热更新(最新:Github

在本版本中,增加了词典热更新,修改步骤如下:

a. 在*ES_HOME*/plugins/analysis-hanlp/data/dictionary/custom目录中新增自定义词典

b. 修改hanlp.properties,修改CustomDictionaryPath,增加自定义词典配置

c. 等待1分钟后,词典自动加载

注:每个节点都需要做上述更改

提供的分词方式说明

  • hanlp: hanlp默认分词
  • hanlp_standard: 标准分词
  • hanlp_index: 索引分词
  • hanlp_nlp: NLP分词
  • hanlp_crf: CRF分词
  • hanlp_n_short: N-最短路分词
  • hanlp_dijkstra: 最短路分词
  • hanlp_speed: 极速词典分词

样例

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
POST http://localhost:9200/twitter2/_analyze
{
"text": "美国阿拉斯加州发生8.0级地震",
"tokenizer": "hanlp"
}
{
"tokens" : [
{
"token" : "美国",
"start_offset" : 0,
"end_offset" : 2,
"type" : "nsf",
"position" : 0
},
{
"token" : "阿拉斯加州",
"start_offset" : 0,
"end_offset" : 5,
"type" : "nsf",
"position" : 1
},
{
"token" : "发生",
"start_offset" : 0,
"end_offset" : 2,
"type" : "v",
"position" : 2
},
{
"token" : "8.0",
"start_offset" : 0,
"end_offset" : 3,
"type" : "m",
"position" : 3
},
{
"token" : "级",
"start_offset" : 0,
"end_offset" : 1,
"type" : "q",
"position" : 4
},
{
"token" : "地震",
"start_offset" : 0,
"end_offset" : 2,
"type" : "n",
"position" : 5
}
]
}

远程词典配置

配置文件为ES_HOME/config/analysis-hanlp/hanlp-remote.xml

1
2
3
4
5
6
7
8
9
<properties>
<comment>HanLP Analyzer 扩展配置</comment>

<!--用户可以在这里配置远程扩展字典 -->
<entry key="remote_ext_dict">words_location</entry>

<!--用户可以在这里配置远程扩展停止词字典-->
<entry key="remote_ext_stopwords">stop_words_location</entry>
</properties>
1. 远程扩展字典

其中words_location为URL或者URL+” “+词性,如:

1
2
3
1. http://localhost:8080/mydic

2. http://localhost:8080/mydic nt

第一个样例,是直接配置URL,词典内部每一行代表一个单词,格式遵从[单词] [词性A] [A的频次] [词性B] [B的频次] … 如果不填词性则表示采用词典的默认词性n。

第二个样例,配置词典URL,同时配置该词典的默认词性nt,当然词典内部同样遵循[单词] [词性A] [A的频次] [词性B] [B的频次] … 如果不配置词性,则采用默认词性nt。

2. 远程扩展停止词字典

其中stop_words_location为URL,如:

1
1. http://localhost:8080/mystopdic

样例直接配置URL,词典内部每一行代表一个单词,不需要配置词性和频次,换行符用 \n 即可。

注意,所有的词典URL是需要满足条件即可完成分词热更新:

  • 该 http 请求需要返回两个头部(header),一个是 Last-Modified,一个是 ETag,这两者都是字符串类型,只要有一个发生变化,该插件就会去抓取新的分词进而更新词库。
  • 可以配置多个字典路径,中间用英文分号;间隔
  • URL每隔1分钟访问一次
  • 保证词典编码UTF-8

自定义分词配置

HanLP在提供了各类分词方式的基础上,也提供了一系列的分词配置,分词插件也提供了相关的分词配置,我们可以在通过如下配置来自定义自己的分词器:

Config Elastic version
enable_custom_config 是否开启自定义配置
enable_index_mode 是否是索引分词
enable_number_quantifier_recognize 是否识别数字和量词
enable_custom_dictionary 是否加载用户词典
enable_translated_name_recognize 是否识别音译人名
enable_japanese_name_recognize 是否识别日本人名
enable_organization_recognize 是否识别机构
enable_place_recognize 是否识别地名
enable_name_recognize 是否识别中国人名
enable_traditional_chinese_mode 是否开启繁体中文
enable_stop_dictionary 是否启用停用词
enable_part_of_speech_tagging 是否开启词性标注
enable_remote_dict 是否开启远程词典
enable_normalization 是否执行字符正规化
enable_offset 是否计算偏移量

注意: 如果要采用如上配置配置自定义分词,需要设置enable_custom_config为true

例如:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
PUT test
{
"settings": {
"analysis": {
"analyzer": {
"my_hanlp_analyzer": {
"tokenizer": "my_hanlp"
}
},
"tokenizer": {
"my_hanlp": {
"type": "hanlp",
"enable_stop_dictionary": true,
"enable_custom_config": true
}
}
}
}
}
POST test/_analyze
{
"text": "美国,|=阿拉斯加州发生8.0级地震",
"analyzer": "my_hanlp_analyzer"
}

结果:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
{
"tokens" : [
{
"token" : "美国",
"start_offset" : 0,
"end_offset" : 2,
"type" : "nsf",
"position" : 0
},
{
"token" : ",|=",
"start_offset" : 0,
"end_offset" : 3,
"type" : "w",
"position" : 1
},
{
"token" : "阿拉斯加州",
"start_offset" : 0,
"end_offset" : 5,
"type" : "nsf",
"position" : 2
},
{
"token" : "发生",
"start_offset" : 0,
"end_offset" : 2,
"type" : "v",
"position" : 3
},
{
"token" : "8.0",
"start_offset" : 0,
"end_offset" : 3,
"type" : "m",
"position" : 4
},
{
"token" : "级",
"start_offset" : 0,
"end_offset" : 1,
"type" : "q",
"position" : 5
},
{
"token" : "地震",
"start_offset" : 0,
"end_offset" : 2,
"type" : "n",
"position" : 6
}
]
}

本文地址: https://github.com/maxzhao-it/blog/post/1864/

安装步骤:

1、下载插件并解压到es的plugins目录下

1
2
3
4
5
修改analysis-hanlp目录下的hanlp.properties文件,修改root的属性,值为analysis-hanlp下的data 目录的地址
root=plugins/analysis-hanlp/

修改analysis-hanlp目录下的plugin-descriptor.properties文件,
修改elasticsearch的版本为你当前的版本elasticsearch.version=你的es版本号(like:5.5.1)

2、修改es config目录下的jvm.options文件,最后一行添加

1
-Djava.security.policy=/home/es/elasticsearch-7.0.1/plugins/analysis-hanlp/plugin-security.policy(地址换成你自己的地址)
1
2
3
mkdir config/analysis-hanlp
cp plugins/analysis-hanlp/config/hanlp.properties config/analysis-hanlp/
cp plugins/analysis-hanlp/config/hanlp-remote.xml config/analysis-hanlp/

重启es

1
2
3
4
5
6
7
GET /_analyze?analyzer=hanlp-index&pretty=true 

{

"text":"张柏芝士蛋糕店"

}

测试是否安装成功

analyzer有hanlp_max_word(索引模式)和hanlp_smart(智能模式)

hanlp_max_word:尽可能的切分多的结果

hanlp_smart:切分少的词

自定义词典:

1
2
3
4
5
修改plugins/analysis-hanlp/data/dictionary/custom下的 我的词典.txt文件

格式遵从[单词] [词性A] [A的频次]

修改完后删除同目录下的CustomDictionary.txt.bin文件

重启es服务

首次启动hanlp会生成相应的文件,首次启动可能会慢一点

注意,在win10下配置 policy

1
2
[JDK]\jre\lib\security中的 java.policy 文件添加上面的权限控制后,win
10下可以用hanlp分词了

本文地址: https://github.com/maxzhao-it/blog/post/41645/

前言

索引中的分词过滤器的配置

这里以 lowercase 举例:分词全部变为小写

更多查看

近义词配置

创建索引时

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
{
"settings": {
"number_of_shards": 1,
"number_of_replicas": 1,
"analysis": {
"analyzer": {
"my_hanlp_analyzer": {
"type": "custom",
"tokenizer": "hanlp",
"char_filter": [
"html_strip"
],
"filter": [
"my_lowercase"
]
},
"default": {
"type": "hanlp"
}
},
"filter": {
"my_lowercase": {
"type": "lowercase",
"language": "greek"
}
}
}
}
}

附录

创建索引配置

当前配置包含近义词配置、HanLP 自定义分词并忽略大小写

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
{
"settings": {
"number_of_shards": 1,
"number_of_replicas": 1,
"analysis": {
"analyzer": {
"my_hanlp_analyzer": {
"type": "custom",
"tokenizer": "my_hanlp",
"char_filter": [
"html_strip"
],
"filter": [
"my_lowercase",
"my_synonym"
]
},
"default": {
"type": "hanlp"
}
},
"tokenizer": {
"my_hanlp": {
"type": "hanlp",
"enable_stop_dictionary": false,
"enable_custom_config": false
}
},
"filter": {
"my_lowercase": {
"type": "lowercase",
"language": "greek"
},
"my_synonym": {
"type": "synonym_graph",
"synonyms_path": "analysis/synonym/synonym.txt"
}
}
}
},
"mappings": {
"properties": {
"title": {
"type": "text",
"analyzer": "my_hanlp_analyzer",
"search_analyzer": "my_hanlp_analyzer"
},
"content": {
"type": "text",
"analyzer": "my_hanlp_analyzer",
"search_analyzer": "my_hanlp_analyzer"
}
}
}
}

ElasticSearch API

Java Rest Client 7.13.2

本文地址: https://github.com/maxzhao-it/blog/post/14230/

前言

索引近义词的配置,需要在创建索引时就配置好

近义词配置

创建索引时

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
{
"settings": {
"analysis": {
"analyzer": {
"my_hanlp_analyzer": {
"type": "custom",
"char_filter": [
"html_strip"
],
"filter": [
"my_synonym"
]
}
},
"filter": {
"my_synonym": {
"type": "synonym_graph",
"synonyms_path": "analysis/synonym/synonym.txt",
"updateable": true
}
}
}
}
}

ElasticSearch 配置文件

路径

${ES_HOME}/analysis/synonym/synonym.txt

近义词配置方式

  • 中文,汉语,汉字
    • 这种写法在分词的时候,有中文的地方,都会解析成中文,汉语,汉字,把中文,汉语,汉字存入索引中
  • 毛衣,毛裤 => 线服
    • 这种写法在分词的时候,毛衣,毛裤都会解析成为线服,然后把线服存入索引中

附录

创建索引配置

当前配置包含近义词配置、HanLP 自定义分词并忽略大小写

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
{
"settings": {
"number_of_shards": 1,
"number_of_replicas": 1,
"analysis": {
"analyzer": {
"my_hanlp_analyzer": {
"type": "custom",
"tokenizer": "my_hanlp",
"char_filter": [
"html_strip"
],
"filter": [
"my_lowercase",
"my_synonym"
]
},
"default": {
"type": "hanlp"
}
},
"tokenizer": {
"my_hanlp": {
"type": "hanlp",
"enable_stop_dictionary": false,
"enable_custom_config": false
}
},
"filter": {
"my_lowercase": {
"type": "lowercase",
"language": "greek"
},
"my_synonym": {
"type": "synonym_graph",
"synonyms_path": "analysis/synonym/synonym.txt"
}
}
}
},
"mappings": {
"properties": {
"title": {
"type": "text",
"analyzer": "my_hanlp_analyzer",
"search_analyzer": "my_hanlp_analyzer"
},
"content": {
"type": "text",
"analyzer": "my_hanlp_analyzer",
"search_analyzer": "my_hanlp_analyzer"
}
}
}
}

ElasticSearch API

Java Rest Client 7.13.2

本文地址: https://github.com/maxzhao-it/blog/post/28907/