Centos7 安装Elasticsearch+Kibana 7.17.7
从 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
Centos7 安装Elasticsearch+Kibana 7.17.7Centos7 安装Elasticsearch+Kibana 7.17.7Centos7 安装Elasticsearch+Kibana 7.17.7Centos7 安装Elasticsearch+Kibana 7.17.7Centos7 安装Elasticsearch+Kibana 7.17.7Centos7 安装Elasticsearch+Kibana 7.17.7Centos7 安装Elasticsearch+Kibana 7.17.7Centos7 安装Elasticsearch+Kibana 7.17.7Centos7 安装Elasticsearch+Kibana 7.17.7