docker方式启动
mkdir -p /var/es/config
mkdir -p /var/es/data
mkdir -p /var/es/plugins
chmod 777 /var/es/data
echo "http.host: 0.0.0.0" >> /var/es/config/elasticsearch.yml
docker run -d --name es --network
=host \
-e
"discovery.type=single-node" \
-e ES_JAVA_OPTS
="-Xms1g -Xmx1g" \
-v /var/es/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml \
-v /var/es/data:/usr/share/elasticsearch/data \
-v /var/es/plugins:/usr/share/elasticsearch/plugins \
elasticsearch:7.6.2
elasticsearch.yml是挂载的配置文件 data是挂载的数据 plugins是es的插件,如ik -e “discovery.type=single-node” 设置为单节点
安装ik中文分词器
网络好进入容器中,使用es命令安装
elasticsearch-plugin
install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v7.6.2/elasticsearch-analysis-ik-7.6.2.zip
网络不好,单独下载插件包
mkdir /var/es/plugins/analysis-ik
cd /var/es/plugins/analysis-ik
&& unzip elasticsearch-analysis-ik-7.6.2.zip
查看安装结果
开启x-pack验证
修改es配置文件
vim elasticsearch.yml
http.cors.enabled:
true
http.cors.allow-origin:
"*"
http.cors.allow-headers: Authorization
xpack.security.enabled:
true
xpack.security.transport.ssl.enabled:
true
重启es
执行设置用户名和密码的命令,需要为4个用户分别设置密码:elastic、kibana、logstash_system、beats_system
cd /usr/local/elasticsearch-7.6.2/bin
./elasticsearch-setup-passwords interactive