CentOS 7 安装 elasticsearch 7.5.1
1.创建elsearch用户, 因为Elasticsearch不支持root用户运行
useradd elsearch
2.在根目录创建文件夹itcast,进入该目录,创建es目录
mkdir itcast
cd itcast
mkdir es
3.更改itcast目录所属的用户
chown elsearch:elsearch itcast/ -R
4.切换用户
su - elsearch
5.进入itcast目录
cd /itcast/
6.将下载的elsearch压缩包放到这里
7.解压安装包
tar -xvf elasticsearch-6.5.4.tar.gz -C /itcast/es/
8.进入config
cd /itcast/es/elasticsearch-7.5.1/config
9.修改配置文件
vim elasticsearch.yml
network.host: 0.0.0.0 #设置ip地址 ,任意网络均可访问
10.修改jvm启动参数
vim jvm.options
-Xms128m
-Xmx128m
11.切换到root用户:su root,设置一个进程在VMAS(虚拟内存区域)创建内存映射最大数量
vim /etc/sysctl.conf
vm.max_map_count=655360
sysctl -p #使配置生效
12.切换回elsearch用户:su - elsearch,启动es
cd bin
./elasticsearch 或 ./elasticsearch -d #后台系统
使用虚拟机IP:9200访问,若出现以下信息表示成功
{
"name" : "node-1",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "H2ye1sRGQK-vl1bcU3H7JQ",
"version" : {
"number" : "7.5.1",
"build_flavor" : "default",
"build_type" : "tar",
"build_hash" : "3ae9ac9a93c95bd0cdc054951cf95d88e1e18d96",
"build_date" : "2019-12-16T22:57:37.835892Z",
"build_snapshot" : false,
"lucene_version" : "8.3.0",
"minimum_wire_compatibility_version" : "6.8.0",
"minimum_index_compatibility_version" : "6.0.0-beta1"
},
"tagline" : "You Know, for Search"
}
报错解决
1: max file descriptors [4096] for elasticsearch process is too 1ow, increase to at least [65536]
#解决:切换到root用户。编辑limits.conf添加类似如下内容
vi /etc/security/limits.conf
添加如下内容:
* soft nofile 65536
* hard nofile 131072
* soft nproc 2048
* hard nproc 4096
CentOS 6 下处理2、3错误
2: max number of threads [1024] for user [elsearch] is too 1ow,increase to at least [4096]
#解决:切换到root用户,进入limits.d目录下修改配置文件。
vi /etc/security/limits.d/90-nproc.conf
#修改如下内容:
*soft nproc 1024
#修改为
soft nproc 4096
3: system call filters failed to install; check the logs and fix your configuration
or disable system cal1 filters at your own risk
#解决: Centos6不支持SecComp,而ES5.2。0默认bootstrap.system ca11. .filter为true
vim config/elasticsearch. yml
添加:
bootstrap.system_call_filter:false
4:the default discovery settings are unsuitable for production use; at least one of [discovery.seed_hosts, discovery.seed_providers, cluster.initial_master_nodes] must be configured
按照下文修改elasticsearch.yml文件配置
cluster.name: elasticsearch-cluster
node.name: es-node1
network.bind_host: 0.0.0.0
network.publish_host: 192.168.209.129
http.port: 9200
transport.tcp.port: 9300
http.cors.enabled: true
http.cors.allow-origin: "*"
http.cors.allow-headers: Authorization,X-Requested-With,Content-Type,Content-Length
node.master: true
node.data: true
discovery.zen.ping.unicast.hosts: ["192.168.209.129:9200"]
discovery.zen.minimum_master_nodes: 1
xpack.security.enabled: true
xpack.license.self_generated.type: basic
xpack.security.transport.ssl.enabled: true
[5]:启动后内部命令访问测试成功:
curl -get localhost:9200
但是外部访问不到,是防火墙的原因,可以关闭防火墙:
systemctl stop firewalld.service
成功访问返回JSON格式数据:
{
"name" : "node-1",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "H2ye1sRGQK-vl1bcU3H7JQ",
"version" : {
"number" : "7.5.1",
"build_flavor" : "default",
"build_type" : "tar",
"build_hash" : "3ae9ac9a93c95bd0cdc054951cf95d88e1e18d96",
"build_date" : "2019-12-16T22:57:37.835892Z",
"build_snapshot" : false,
"lucene_version" : "8.3.0",
"minimum_wire_compatibility_version" : "6.8.0",
"minimum_index_compatibility_version" : "6.0.0-beta1"
},
"tagline" : "You Know, for Search"
}
注意:本文归作者所有,未经作者允许,不得转载