暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

elasticsearch搭建

臭虫说 2021-04-27
255

es安装

#下载指定版本
cd opt
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.6.1-linux-x86_64.tar.gz
#解压到指定的位置
tar -zxvf elasticsearch-7.6.1-linux-x86_64.tar.gz -C usr/local/
cd usr/local/elasticsearch-7.6.1

准备

#创建用户组es
groupadd es
#添加用户 es 到 es组 设置密码 123456
useradd es -g es -p 123456

修改配置文件 或者直接替换 elasticsearch.yml 文件

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

#找到配置文件中的cluster.name,打开该配置并设置集群名称
cluster.name: es-demo
#找到配置文件中的node.name,打开该配置并设置节点名称
node.name: node-elk-1
#修改data存放的路径
path.data: /usr/local/elasticsearch-7.6.1/data/es-data
#修改logs日志的路径
path.logs: /usr/local/elasticsearch-7.6.1/logs/es-log/
#配置内存使用用交换分区
bootstrap.memory_lock: true
#监听的网络地址
network.host: 0.0.0.0
#开启监听的端口
http.port: 9200
#ip替换host1等,多节点请添加多个ip地址
cluster.initial_master_nodes: ["node-elk-1"]
#增加新的参数,这样head插件可以访问es (5.x版本,如果没有可以自己手动加)
http.cors.enabled: true
http.cors.allow-origin: "*"

修改系统文件

vim /etc/security/limits.conf 追加以下内容 后保存

* soft nofile 65536
* hard nofile 65536
* soft nproc 32000
* hard nproc 32000
* hard memlock unlimited
* soft memlock unlimited

vim /etc/sysctl.conf 追加以下内容
vm.max_map_count=655360
保存后,执行:
sysctl -p

修改启动占用的jvm

vim /etc/elasticsearch-7-6.1/jvm.options

-Xms128m
-Xmx128m

启动服务

#切换目录
cd /usr/local
chown -R es:es elasticsearch-7.6.1

#切换到elsearch用户再启动
su es #切换用户
cd elasticsearch-7.6.1/bin
sh elasticsearch #前台启动
sh elasticsearch -d #后台启动

访问测试

[root@bogon logs]# curl localhost:9200
{
"name" : "node-elk-1",
"cluster_name" : "my-demo",
"cluster_uuid" : "xs_RnSjJTGSGjOOIwI25aw",
"version" : {
"number" : "6.4.3",
"build_flavor" : "default",
"build_type" : "tar",
"build_hash" : "fe40335",
"build_date" : "2018-10-30T23:17:19.084789Z",
"build_snapshot" : false,
"lucene_version" : "7.4.0",
"minimum_wire_compatibility_version" : "5.6.0",
"minimum_index_compatibility_version" : "5.0.0"
},
"tagline" : "You Know, for Search"
}

关闭防火墙
systemctl status firewalld.service
systemctl stop firewalld.service
systemctl start firewalld.service
可以使用浏览器进行访问http://ip:9200 出现同样的内容

es安装完成


文章转载自臭虫说,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论