从 Elasticsearch 7.x 版本开始,Elasticsearch 发行版包含了本人的 JDK。因而,您不须要独自装置 Java。以下是在 CentOS 7 上装置 Elasticsearch 7.17.7 的残缺步骤:(数据默认保留在 /var/lib/elasticsearch 下,自行更改)
增加 Elasticsearch 仓库 创立一个新 repo 文件:
vim /etc/yum.repos.d/elasticsearch.repo
将以下内容粘贴到文件中:[elasticsearch-7.x]
name=Elasticsearch repository for 7.x packages
baseurl=https://artifacts.elastic.co/packages/7.x/yum
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
enabled=1
autorefresh=1
type=rpm-md
装置 Elasticsearch:yum install elasticsearch-7.17.7 -y\
配置 Elasticsearch:
vim /etc/elasticsearch/elasticsearch.yml
依据须要批改一些要害设置,例如:[root@vm11 jdk]# grep -v "#" /etc/elasticsearch/elasticsearch.yml| grep -v "^$"
cluster.name: my-cluster
node.name: node-1
path.data: /opt/elasticsearch/data
path.logs: /opt/elasticsearch/log
network.host: 0.0.0.0
http.port: 39200
discovery.type: single-node
对于单节点 Elasticsearch 集群,您能够将 discovery.type 设置为 single-node。这将跳过生产环境查看。要进行此更改,请将以下行增加到 /etc/elasticsearch/elasticsearch.yml 文件
记得 创立 批改后的目录
[root@vm11 ~]# mkdir -pv /opt/elasticsearch/log
[root@vm11 ~]# mkdir -pv /opt/elasticsearch/data
更改 Elasticsearch 数据和日志目录的所有权:
因为 es 只能应用普通用户
chown -R elasticsearch:elasticsearch /opt/elasticsearch/
启动并启用 Elasticsearch 服务:systemctl start elasticsearch
systemctl enable elasticsearch
问题解决
日志 呈现 java.security.AccessControlException: access denied (“java.lang.RuntimePermission” “modifyThread”)
就是 JDK 有一些平安限度,能够批改配置文件文件 jdk 目录 /conf/security 下 java.policy,禁用这些限度:解禁 modifyThread 即可
jdk 的装置目录在 es 中没有独自装置,找 java 的装置目录看 es 日志即可:/usr/share/elasticsearch/jdk
vim /usr/share/elasticsearch/jdk/conf/security/java.policy
permission java.lang.RuntimePermission "modifyThread";
装置 ik 分词插件
[root@vm11 ~]# /usr/share/elasticsearch/bin/elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v7.17.7/elasticsearch-analysis-ik-7.17.7.zip
-> Installing https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v7.17.7/elasticsearch-analysis-ik-7.17.7.zip
-> Downloading https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v7.17.7/elasticsearch-analysis-ik-7.17.7.zip
[=================================================] 100%
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: plugin requires additional permissions @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
* java.net.SocketPermission * connect,resolve
See https://docs.oracle.com/javase/8/docs/technotes/guides/security/permissions.html
for descriptions of what these permissions allow and the associated risks.
Continue with installation? [y/N]y
-> Installed analysis-ik
-> Please restart Elasticsearch to activate any plugins installed
[root@vm11 ~]# systemctl restart elasticsearch
[root@vm11 ~]#
配置 xpack
[root@vm11 ~]# vim /etc/elasticsearch/elasticsearch.yml
#在 Elasticsearch 配置文件 /etc/elasticsearch/elasticsearch.yml 中增加以下行:xpack.security.enabled: true
[root@vm11 ~]# systemctl restart elasticsearch
[root@vm11 ~]# /usr/share/elasticsearch/bin/elasticsearch-setup-passwords interactive
Initiating the setup of passwords for reserved users elastic,apm_system,kibana,kibana_system,logstash_system,beats_system,remote_monitoring_user.
You will be prompted to enter passwords as the process progresses.
Please confirm that you would like to continue [y/N]y
Enter password for [elastic]:
Reenter password for [elastic]:
Enter password for [apm_system]:
Reenter password for [apm_system]:
Enter password for [kibana_system]:
Reenter password for [kibana_system]:
Enter password for [logstash_system]:
Reenter password for [logstash_system]:
Enter password for [beats_system]:
Reenter password for [beats_system]:
Enter password for [remote_monitoring_user]:
Reenter password for [remote_monitoring_user]:
Changed password for user [apm_system]
Changed password for user [kibana_system]
Changed password for user [kibana]
Changed password for user [logstash_system]
Changed password for user [beats_system]
Changed password for user [remote_monitoring_user]
Changed password for user [elastic]
装置 kibana
[root@vm11 ~]# vim /etc/yum.repos.d/kibana.repo
[kibana-7.x]
name=Kibana repository for 7.x packages
baseurl=https://artifacts.elastic.co/packages/7.x/yum
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
enabled=1
autorefresh=1
type=rpm-md
[root@vm11 ~]# yum install kibana -y
[root@vm11 ~]# vim /etc/kibana/kibana.yml
[root@vm11 ~]# hostname
vm11
[root@vm11 ~]# vim /etc/kibana/kibana.yml
server.port: 35601
server.host: "0.0.0.0"
server.publicBaseUrl: "http://10.203.192.33:35601"
server.name: "vm11"
elasticsearch.hosts: ["http://vm11:39200"]
elasticsearch.username: "elastic"
elasticsearch.password: "66666666xxxxx11#"
elasticsearch.ssl.verificationMode: none
elasticsearch.requestTimeout: 90000
i18n.locale: "zh-CN"
[root@vm11 ~]# systemctl daemon-reload
[root@vm11 ~]# systemctl enable kibana.service
Created symlink from /etc/systemd/system/multi-user.target.wants/kibana.service to /etc/systemd/system/kibana.service.
[root@vm11 ~]# systemctl start kibana
[root@vm11 ~]# netstat -tnlp