安装ElasticSearch
安装包可直接在官网下载,我这边也提供了官网下载的linux的安装包,安装包下载地址:
https://download.csdn.net/download/weixin_59230567/21355078
1、把安装包拷贝到 /opt/es文件夹下
2、解压
tar -zxvf elasticsearch-7.14.0-linux-x86_64.tar.gz
1、文件目录在config包下,进入配置文件的命令:
vim /opt/es/elasticsearch-7.14.0/config/elasticsearch.yml
2、在文件的结尾添加
cluster.name: my-application
node.name : node-1
network.host: 0.0.0.0
http: 9200
cluster.initial_master_nodes: ["node-1"]
注意:由于是yml文件,所以分号后面要右一个空格
cluster.name:配置elasticsearch的集群名称,默认是elasticsearch。建议改成一个有意义的名称
node.name:节点名,elasticsearch会默认随机指定一个名字,建议指定一个有意义的名称,方便管理
network.hos:设置为0.0.0.0允许外网访问
http.port:ElasticSearch的http访问端口
cluster.initial_master_nodes:初始化配置新的集群时需要此配置来选举master
- 运行时报错如下?can not run elasticsearch as root, 因为安全问题es不允许oot用户直接运行下运行,所以需要创建其他用户
[2021-08-19T03:08:25,036][ERROR][o.e.b.ElasticsearchUncaughtExceptionHandler] [node-1] uncaught exception in thread [main]
org.elasticsearch.bootstrap.StartupException: java.lang.RuntimeException: can not run elasticsearch as root
at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:163) ~[elasticsearch-7.14.0.jar:7.14.0]
at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:150) ~[elasticsearch-7.14.0.jar:7.14.0]
at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:75) ~[elasticsearch-7.14.0.jar:7.14.0]
at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:116) ~[elasticsearch-cli-7.14.0.jar:7.14.0]
at org.elasticsearch.cli.Command.main(Command.java:79) ~[elasticsearch-cli-7.14.0.jar:7.14.0]
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:115) ~[elasticsearch-7.14.0.jar:7.14.0]
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:81) ~[elasticsearch-7.14.0.jar:7.14.0]
Caused by: java.lang.RuntimeException: can not run elasticsearch as root
at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:103) ~[elasticsearch-7.14.0.jar:7.14.0]
at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:170) ~[elasticsearch-7.14.0.jar:7.14.0]
at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:399) ~[elasticsearch-7.14.0.jar:7.14.0]
at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:159) ~[elasticsearch-7.14.0.jar:7.14.0]
... 6 more
uncaught exception in thread [main]
java.lang.RuntimeException: can not run elasticsearch as root
at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:103)
at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:170)
at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:399)
at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:159)
at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:150)
at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:75)
at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:116)
at org.elasticsearch.cli.Command.main(Command.java:79)
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:115)
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:81)
For complete error details, refer to the log at /opt/es/elasticsearch-7.14.0/logs/my-application.log
[root@localhost bin]# 2021-08-19 10:08:25,392424 UTC [2382] INFO Main.cc@106 Parent process died - ML controller exiting
useradd itck -- 新增itck用户
passwd itck -- 为itck用户设置密码
chown -R itck:itck /opt/es/elasticsearch-7.14.0
su itck
- 新创建的itck用户最大可创建文件数太小,最大虚拟机内存太小,切换root用户,编辑下列配置文件,添加类似如下内容
#切换root用户
su root
#1、最大可创建文件数太小
vim /etc/security/limits.conf
#在文件末尾中增加下面内容
itck soft nofile 65536
itck hard nofile 65536
#=======
vim /etc/security/limits.d/20-nproc.conf
#在文件末尾中增加下面内容
itck soft nofile 65536
itck hard nofile 65536
* hard nproc 4096
#注:*代表Linux所有用户名称
#2.===最大虚拟内存太小======
vim /etc/sysctl.conf
#在文件中增加下面内容
vm.max_map_count=655360
#重新加载,输入下面命令:
sysctl -p
# 切换到itck用户
su itck
cd /opt/es/elasticsearch-7.14.0/bin
./elasticsearch #启动es
#暂时关闭防火墙
systemctl stop firewalld
#永久设置防火墙状态
systemctl enable firewalld.service #打开防火墙永久性生效,启动不会复原
systemctl disable firewalld.service #关闭防火墙,永久性生效,重启后不会复原
{
"name" : "node-1",
"cluster_name" : "my-application",
"cluster_uuid" : "rAFf95XmQ86szrfpGyUppg",
"version" : {
"number" : "7.14.0",
"build_flavor" : "default",
"build_type" : "tar",
"build_hash" : "dd5a0a2acaa2045ff9624f3729fc8a6f40835aa1",
"build_date" : "2021-07-29T20:49:32.864135063Z",
"build_snapshot" : false,
"lucene_version" : "8.9.0",
"minimum_wire_compatibility_version" : "6.8.0",
"minimum_index_compatibility_version" : "6.0.0-beta1"
},
"tagline" : "You Know, for Search"
}
安装Kibana
1、把安装包拷贝到 /opt/es文件夹下
2、解压
tar -zxvf kibana-7.14.0-linux-x86_64.tar.gz
vim /opt/es/kibana-7.14.0-linux-x86_64/config/kibana.yml
server.port: 5601
server.host: "0.0.0.0"
server.name: "kibana-itck"
elasticsearch.hosts: ["http://127.0.0.1:9200"]
elasticsearch.requestTimeout: 60000
#注意:yml文件需要在:右边加空格
#server.port:http访问端口
#server.host :IP地址,0.0.0.0表示可远程访问
#server.name : kibana 服务名
#elasticsearch.hosts:elasticsearch地址
#elasticsearch.requestTimeout:请求elasticsearch超时时间,默认为30000,此处可根据查询情况设置
cd /opt/es/kibana-7.14.0-linux-x86_64/bin
./kibana
#提示Kibana should not be run as root. Use --allow-root to continue.
#不建议使用root用户启动,如果非要启动,请在后面加上 --allow-root
./kibana --allow-root
|