为方便测试,防火墙和selinux全关闭。
安装jdik
yum install java-1.8.0-openjdk -y
下载rpm包
https://www.elastic.co/cn/downloads/elasticsearch
安装,初始化,启动
[root@localhost ~]# rpm -ivh elasticsearch-7.7.0-x86_64.rpm
警告:elasticsearch-7.7.0-x86_64.rpm: 头V4 RSA/SHA512 Signature, 密钥 ID d88e42b4: NOKEY
准备中... ################################# [100%]
Creating elasticsearch group... OK
Creating elasticsearch user... OK
正在升级/安装...
1:elasticsearch-0:7.7.0-1 ################################# [100%]
### NOT starting on installation, please execute the following statements to configure elasticsearch service to start automatically using systemd
sudo systemctl daemon-reload
sudo systemctl enable elasticsearch.service
### You can start elasticsearch service by executing
sudo systemctl start elasticsearch.service
Created elasticsearch keystore in /etc/elasticsearch/elasticsearch.keystore
[root@localhost ~]# systemctl daemon-reload
[root@localhost ~]# systemctl enable elasticsearch.service
Created symlink from /etc/systemd/system/multi-user.target.wants/elasticsearch.service to /usr/lib/systemd/system/elasticsearch.service.
[root@localhost ~]# systemctl start elasticsearch.service
配置文件修改
[root@localhost bin]# grep -v ^# /etc/elasticsearch/elasticsearch.yml
cluster.name: jiqunming
node.name: node-249
path.data: /data/es
path.logs: /var/log/elasticsearch
bootstrap.memory_lock: true
network.host: 10.0.2.249
http.port: 9200
discovery.seed_hosts: ["10.0.2.249", "10.0.2.205"]
cluster.initial_master_nodes: ["10.0.2.249", "10.0.2.205"]
discovery.zen.minimum_master_nodes: 2
加目录权限
chown -R elasticsearch:elasticsearch /data/es
bootstrap.memory_lock: true 开了这个后,要编辑下面文件否则会报错 systemctl edit elasticsearch。
# systemctl edit elasticsearch
[Service]
LimitMEMLOCK=infinity
所有节点都要按照以上步骤操作,注意配置文件修改ip,节点名称等。
systemctl daemon-reload
systemctl start elasticsearch
其他配置文件
su – root
vi /etc/security/limits.conf
添加如下内容:
- soft nofile 65536
- hard nofile 131072
- soft nproc 2048
- hard nproc 4096
vi /etc/security/limits.d/90-nproc.conf 注:(有些主机为20-nproc.conf)
找到如下内容:
- soft nproc 1024
修改为
- soft nproc 2048
vi /etc/sysctl.conf
添加下面配置:
vm.max_map_count=655360
并执行命令:
sysctl -p