ElasticSearch官网
国内镜像下载
环境
- IP: 192.168.1.46
- 系统: CentOS 7.6
HostName | IP | DES |
---|---|---|
test1 | 192.168.1.46 | 主控机 |
test2 | 192.168.1.47 | node-1 |
test3 | 192.168.1.48 | node-2 |
test4 | 192.168.1.18 | node-3 |
修改hosts
[root@test1 ~]# cat >> /etc/hosts << eric
192.168.180.47 node-1
eric
[root@test1 ~]#
1. 创建用户
[root@test1 ~]# useradd -m -d /home/elasticsearch elasticsearch
[root@test1 ~]# passwd elasticsearch
输入密码
passwd:所有的身份验证令牌已经成功更新。
[root@test1 ~]#
[root@test1 ~]# visudo
elasticsearch ALL=(ALL) NOPASSWD: ALL
[root@test1 ~]#
[root@test1 ~]# su - elasticsearch
[elasticsearch@test1 ~]$
2. 下载/解压
[elasticsearch@test1 deploy]$ pwd
/home/elasticsearch/deploy
[elasticsearch@test1 deploy]$
[elasticsearch@test1 ~]$ curl -L -O https://elasticsearch.thans.cn/downloads/elasticsearch/elasticsearch-7.3.2-linux-x86_64.tar.gz
[elasticsearch@test1 deploy]$
[elasticsearch@test1 deploy]$ tar -zxvf elasticsearch-7.3.2-linux-x86_64.tar.gz
tar zxvf test.tgz -C 指定目录
3. [安装JDK]
4. 替换配置文件中如下部分属性
注意: 不修改配置,是不可以外网访问的,如下属性都是必须要配置的
[elasticsearch@test1 deploy]$ vim elasticsearch-7.3.2/config/elasticsearch.yml
#node.name: node-1
node.name: node-1
#network.host: 192.168.0.1
network.host: node-1
#http.port: 9200
http.port: 9200
# 允许跨域访问
http.cors.enabled: true
http.cors.allow-origin: "*"
path.data: /home/elasticsearch/deploy/elasticsearch-7.3.2/data
path.logs: /home/elasticsearch/deploy/elasticsearch-7.3.2/logs
# 快照路径
path.repo: /home/elasticsearch/deploy/elasticsearch-7.3.2/snapshots
cluster.initial_master_nodes: ['node-1']
##优化参数
indices.memory.index_buffer_size: 20%
indices.query.bool.max_clause_count: 100000000
5. 后台 启动 ElasticSearch
[elasticsearch@test1 ~]$ ./deploy/elasticsearch-7.3.2/bin/elasticsearch -d
Java HotSpot(TM) 64-Bit Server VM warning: Option UseConcMarkSweepGC was deprecated in version 9.0 and will likely be removed in a future release.
[elasticsearch@test1 ~]$
6. 查看启动是否成功
[elasticsearch@test1 ~]$ curl localhost:9200
{
"name" : "node-1",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "GwWYck6bRTyyMgXFxZW9Ew",
"version" : {
"number" : "7.3.2",
"build_flavor" : "default",
"build_type" : "tar",
"build_hash" : "22e1767283e61a198cb4db791ea66e3f11ab9910",
"build_date" : "2019-09-27T08:36:48.569419Z",
"build_snapshot" : false,
"lucene_version" : "8.2.0",
"minimum_wire_compatibility_version" : "6.8.0",
"minimum_index_compatibility_version" : "6.0.0-beta1"
},
"tagline" : "You Know, for Search"
}
[elasticsearch@test1 ~]$
7、杀死es进程
ps -ef | grep elastic
kill -9 进程id
常见问题
1 bootstrap checks failed
ERROR: [3] bootstrap checks failed
[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65535]
[2]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
[3]: 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
原因:虚拟机限制用户的执行内存
解决问题[1][3]:在文件末尾追加配置
[elasticsearch@test1 deploy]$ sudo vim /etc/security/limits.conf
# BEGIN ES
* soft nofile 65536
* hard nofile 65536
* soft nproc 2048
* hard nproc 4096
# END ES
[elasticsearch@test1 deploy]$
# 需要重新连接用户
解决问题[2]:在文件末尾追加配置
[elasticsearch@test1 deploy]$ sudo vim /etc/sysctl.conf
......
vm.max_map_count = 262144
[elasticsearch@test1 deploy]$ sysctl -p
# 需要重新连接用户