centos8安装ElasticSearch8并配置

1.下载

ElasticSearch

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

mv elasticsearch-8.1.2 /usr/local/

2.配置

cd /usr/local/elasticsearch-8.1.2/

mkdir data

vim ./config/elasticsearch.yml

内容如下

cluster.name: wzz-es

node.name: es-node1

path.data: /usr/local/elasticsearch-8.1.2/data

path.logs: /usr/local/elasticsearch-8.1.2/logs

network.host: 0.0.0.0

cluster.initial_master_nodes: ["es-node1"]

xpack.security.enabled: false
#装es-header需添加以下内容
http.cors.enabled: true
http.cors.allow-origin: "*"

centos8安装ElasticSearch8并配置_第1张图片

vim /usr/local/elasticsearch-8.1.2/config/jvm.options

修改这两个,如果内存不足的话改小点 (中间不能有空格)

-Xms256m
-Xmx256m

3.创建用户

elasticsearch不允许使用root用户启动,所以要创建一个新用户
创建一个用户名为: es

useradd es

-R递归修改es文件夹的拥有者和属组

chown -R es:es /usr/local/elasticsearch-8.1.2/

切换到es用户

su es
cd /usr/local/elasticsearch-8.1.2/bin
#启动es 加 -d为后台运行
./elasticsearch

4.解决报错

centos8安装ElasticSearch8并配置_第2张图片

报错1:

[1]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
elasticsearch用户拥有的内存权限太小,至少需要262144;

切回root修改配置su root

vim /etc/sysctl.conf

在末尾追加一下内容:

vm.max_map_count=655350

在这里插入图片描述
使配置生效

sysctl -p
报错2:

Transport SSL must be enabled if security is enabled. Please set [xpack.security.transport.ssl.enabled] to [true] or disable security by setting [xpack.security.enabled] to [false]

如果启用了安全性,则必须启用传输SSL。请将[xpack.security.transport.ssl.enabled]设置为[true],或通过将[xpack.security.enabled]设置为[false]来禁用安全性

修改elasticsearch.yml文件,关闭安全设置(前面添加过就不用改了)

vim ../config/elasticsearch.yml

在末尾追加以下内容:

xpack.security.enabled: false

centos8安装ElasticSearch8并配置_第3张图片

可能出现报错3:

[1]: max number of threads [2048] for user [es] is too low, increase to at least [4096]
需要修改用户线程数
永久生效:

vim /etc/security/limits.conf

在末尾添加以下内容:

* soft nofile 65535
* hard nofile 131072
* soft nproc 4096
* hard nproc 4096

临时生效:ulimit -u 4096

再启动./elasticsearch -d,成功
centos8安装ElasticSearch8并配置_第4张图片如果不能访问,可能需要防火墙开放端口:

firewall-cmd --permanent --zone=public --add-port=9200/tcp
firewall-cmd --reload

5.安装head插件(可选)

没有装git请移步
或者yum install git -y

git clone https://github.com/mobz/elasticsearch-head.git

mv elasticsearch-head/ /usr/local/es-head

cd /usr/local/es-head

或者

wget https://github.com/mobz/elasticsearch-head/archive/refs/tags/v5.0.0.tar.gz

tar -zxvf v5.0.0.tar.gz

mv elasticsearch-head-5.0.0/ /usr/local/es-head

cd /usr/local/es-head

然后启动

没有装node请移步

npm install
npm run start

修改elasticsearch.yml文件

vim /usr/local/elasticsearch-8.1.2/config/elasticsearch.yml 

允许同源访问,在末尾添加:

http.cors.enabled: true
http.cors.allow-origin: "*"

centos8安装ElasticSearch8并配置_第5张图片

6.安装ik分词器(可选)

下载ik,(版本号要一一对应)
插件安装:

./bin/elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v8.1.2/elasticsearch-analysis-ik-8.1.2.zip

或者

wget https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v8.1.2/elasticsearch-analysis-ik-8.1.2.zip

unzip elasticsearch-analysis-ik-8.1.2.zip -d /usr/local/elasticsearch-8.1.2/plugins/ik

完!

你可能感兴趣的:(linux安装软件,linux,centos,elasticsearch)