简介:
Elasticsearch是一个基于Lucene的分布式搜索引擎,可存储大量的数据。
特点:
高可用,高扩展,有众多的api接口
实践:
从官网下载最新的elasticsearch安装包,最好是全量包,带jdk的那种并解压。
[crazyliop@localhost opt]$ ll
total 311340
drwxr-xr-x 10 crazyliop crazyliop 167 Aug 24 05:57 elasticsearch-7.10.2
-rw------- 1 crazyliop crazyliop 318808405 Aug 24 05:14 elasticsearch-7.10.2-linux-x86_64.tar.gz
进入解压后的目录,并修改conf//elasticsearch.yml文件
[crazyliop@localhost opt]$ cd elasticsearch-7.10.2
[crazyliop@localhost elasticsearch-7.10.2]$ vi config/elasticsearch.yml
cluster.name: my-book
node.name: book-2
network.host: 192.168.11.131
node.master: true
node.data: true
http.port: 9200
transport.tcp.port: 9300
index.store.type: mmapfs
bootstrap.memory_lock: true
discovery.zen.minimum_master_nodes: 2
cluster.initial_master_nodes: ["book-1","book-2","book-3"]
discovery.zen.ping.unicast.hosts: ["192.168.11.130","192.168.11.131","192.168.11.132"]
其中一台的配置文件如上
修改系统配置(需用到root权限)
[crazyliop@localhost elasticsearch-7.10.2]$ sudo -i
[root@localhost ~]# vi /etc/sysctl.conf
# sysctl settings are defined through files in
# /usr/lib/sysctl.d/, /run/sysctl.d/, and /etc/sysctl.d/.
#
# Vendors settings live in /usr/lib/sysctl.d/.
# To override a whole file, create a new file with the same in
# /etc/sysctl.d/ and put new settings there. To override
# only specific settings, add a file with a lexically later
# name in /etc/sysctl.d/ and put new settings there.
#
# For more information, see sysctl.conf(5) and sysctl.d(5).
fs.file-max = 999999
vm.max_map_count=262144
修改部署用户的文件句柄数及内存锁限制(添加至文件末)
[root@localhost ~]# vi /etc/security/limits.conf
* soft nofile 65536
* hard nofile 65536
[root@localhost ~]# vi /etc/security/limits.d/20-nproc.conf
* soft nproc 65535
* hard nproc 65535
* soft memlock unlimited
* hard memlock unlimited
关闭交换分区
[root@localhost ~]# swapoff -a
生效系统配置(普通用户的句柄数生效最好退出去重进)
[root@localhost ~]# sysctl -p
[root@localhost ~]# exit
logout
[crazyliop@localhost elasticsearch-7.10.2]$ exit
logout
Connection to 192.168.11.131 closed.
[crazyliop@Host_192_168_11_129 ~]$ ssh 192.168.11.131
Last login: Tue Aug 24 06:45:29 2021 from 192.168.11.129
启动es
[crazyliop@localhost ~]$ cd /opt/elasticsearch-7.10.2
[crazyliop@localhost elasticsearch-7.10.2]$ bin/elasticsearch -d
验证:
[crazyliop@localhost elasticsearch-7.10.2]$ curl 192.168.11.130:9200/_cat/nodes
192.168.11.131 28 62 0 0.00 0.02 0.05 cdhilmrstw - book-2
192.168.11.132 18 63 0 0.01 0.03 0.07 cdhilmrstw - book-1
192.168.11.130 31 63 0 0.01 0.03 0.07 cdhilmrstw * book-3
|