热爱技术,追求卓越
不断求索,精益求精

ubuntu部署Elasticsearch 8 和中文分词ik

部署Elasticsearch 8

打开如下网址:

https://www.elastic.co/cn/downloads/elasticsearch

登录到服务器上,使用如下命令查看操作系统cpu型号及详细信息。

cat /proc/cpuinfo

在输出结果中会显示CPU的型号,例如Intel Xeon或AMD EPYC等属于x86架构,而ARM Cortex-A系列则属于ARM架构。

我的服务器属于x86结构64位,在打开的网页“Choose platform” 处下拉选择“Linux x86_64”。下载压缩包为:elasticsearch-8.12.2-linux-x86_64.tar.gz

可以看出当前的elasticsearch版本为8.12.2。

把包上传到服务器后解压(目录根据自己喜好)

wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-8.12.2-linux-x86_64.tar.gz
tar -zxvf elasticsearch-8.12.2-linux-x86_64.tar.gz

配置es,进入elasticsearch-8.12.2/config目录,修改elasticsearch.yml

cluster.name: es-cluster
node.name: es-node-1
path.data: /var/www/data/elasticsearch-8.12.2/data
path.logs: /var/www/data/elasticsearch-8.12.2/logs
network.host: 0.0.0.0

确保服务器已经配置了java运行环境并设置了环境变量后,启动es

cd elasticsearch-8.12.2/bin/
./elasticsearch -d

启动若报错如下:

[1] bootstrap checks failed. You must address the points described in the following [1] lines before starting Elasticsearch. For more information see [https://www.elastic.co/guide/en/elasticsearch/reference/8.14/bootstrap-checks.html]
bootstrap check failure [1] of [1]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]; for more information see [https://www.elastic.co/guide/en/elasticsearch/reference/8.14/_maximum_map_count_check.html]
ERROR: Elasticsearch did not exit normally - check the logs at /var/www/data/elasticsearch-8.12.2/logs/es-cluster.log

则修改/etc/sysctl.conf文件,增加配置vm.max_map_count=262144

vi /etc/sysctl.conf
执行如下命令使配置生效
sysctl -p 

调整jvm配置,进入elasticsearch-8.12.2/config目录,修改jvm.options,设置Xms和Xmx

-Xms1g
-Xmx1g

重启后,查看进程

 ps -ef | grep elasticsearch

进程在,但访问如下地址:

curl http://127.0.0.1:9200/
curl: (52) Empty reply from server

查看es-cluster.log日志,如下:

received plaintext http traffic on an https channel, closing connection Netty4HttpChannel

原因是ES8默认开启了 ssl 认证。解决方案:elasticsearch.yml配置文件
将xpack.security.enabled设置为false

重新启动后访问如下:

$ curl http://127.0.0.1:9200/
{
  "name" : "es-node-1",
  "cluster_name" : "es-cluster",
  "cluster_uuid" : "r28Gh6fbQR-k-AanTWD5Gw",
  "version" : {
    "number" : "8.12.2",
    "build_flavor" : "default",
    "build_type" : "tar",
    "build_hash" : "93a57a1a76f556d8aee6a90d1a95b06187501310",
    "build_date" : "2024-06-10T23:35:17.114581191Z",
    "build_snapshot" : false,
    "lucene_version" : "9.10.0",
    "minimum_wire_compatibility_version" : "7.17.0",
    "minimum_index_compatibility_version" : "7.0.0"
  },
  "tagline" : "You Know, for Search"
}

则部署成功。

es8增加中文分词ik

下载地址:

https://github.com/medcl/elasticsearch-analysis-ik/releases

我们这里是elasticsearch-8.12.2,下载elasticsearch-analysis-ik-8.12.2.zip并上传到elasticsearch部署目录的plugins下,解压:

mkdir ik
unzip elasticsearch-analysis-ik-8.12.2.zip -d ik

删除压缩包

rm elasticsearch-analysis-ik-8.12.2.zip

重启后,出现 loaded plugin [analysis-ik] 这成功

赞(0)
未经允许不得转载:LoveCTO » ubuntu部署Elasticsearch 8 和中文分词ik

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

热爱技术 追求卓越 精益求精