1、安装JDK
Elasticsearch官方文档中所说,不需要在运行Elasticsearch的机器上安装 JVM,因为它已经在Elasticsearch的jdk目录中放入了JAVA,只需要做相应软连接即可。
参考:https://www.elastic.co/guide/en/elasticsearch/reference/current/setup.html
因为7.10.2版本自带的JDK是15版本,因此,这里选择安装长期支持版:
yum install java-11-openjdk-devel -y
2、配置系统相关参数
vim /etc/security/limits.conf* soft nproc 65535* hard nproc 65535* soft nofile 65535* hard nofile 65535* soft stack 65535* hard stack 65535vim /etc/sysctl.confvm.max_map_count=2655350vm.swappiness=1
3、解压到安装目录
tar xf elasticsearch-7.10.2-linux-x86_64.tar.gz -C /data/
4、创建用户
groupadd elasticsearchuseradd elasticsearch -g elasticsearchchown -R elasticsearch:elasticsearch /data/elasticsearch-7.10.2
5、创建配置文件
vim /data/elasticsearch-7.10.2/config/elasticsearch.yml
cluster.name: test-es-clusternode.name: es-node01node.roles:- master- datanetwork.host: 0.0.0.0network.publish_host: 192.168.0.71http.port: 9200transport.port: 9300path.data:- /data/elasticsearch-7.10.2/datadiscovery.seed_hosts:- 192.168.0.72:9300- 192.168.0.73:9300cluster.initial_master_nodes:- es-node01- es-node02- es-node03http.cors.enabled: truehttp.cors.allow-origin: "*"
6、测试启动
su -l elasticsearch -c "/data/elasticsearch-7.10.2/bin/elasticsearch"
7、配置密码
各实例的elasticserarch.yml文件中增加:
xpack.security.enabled: truexpack.license.self_generated.type: basicxpack.security.transport.ssl.enabled: truexpack.security.transport.ssl.verification_mode: certificatexpack.security.transport.ssl.keystore.path: elastic-certificates.p12xpack.security.transport.ssl.truststore.path: elastic-certificates.p12
生成证书:
bin/elasticsearch-certutil cert -out config/elastic-certificates.p12 -pass ""#生成的证书需要改文件属主属组chown -R elasticsearch:elasticsearch /data/elasticsearch-7.10.2
随后将证书拷贝到其他节点的config目录下
重启集群
设置密码:
# bin/elasticsearch-setup-passwords interactiveInitiating the setup of passwords for reserved users elastic,apm_system,kibana,kibana_system,logstash_system,beats_system,remote_monitoring_user.You will be prompted to enter passwords as the process progresses.Please confirm that you would like to continue [y/N]yEnter password for [elastic]:Reenter password for [elastic]:Enter password for [apm_system]:Reenter password for [apm_system]:Enter password for [kibana_system]:Reenter password for [kibana_system]:Enter password for [logstash_system]:Reenter password for [logstash_system]:Enter password for [beats_system]:Reenter password for [beats_system]:Enter password for [remote_monitoring_user]:Reenter password for [remote_monitoring_user]:Changed password for user [apm_system]Changed password for user [kibana_system]Changed password for user [kibana]Changed password for user [logstash_system]Changed password for user [beats_system]Changed password for user [remote_monitoring_user]Changed password for user [elastic]
8、配置systemd管理
vim /usr/lib/systemd/system/elasticsearch.service
[Unit]Description=ElasticsearchDocumentation=https://www.elastic.coWants=network-online.targetAfter=network-online.target[Service]ExecStart=/data/elasticsearch-7.10.2/bin/elasticsearchUser=elasticsearchGroup=elasticsearchStandardOutput=journalStandardError=inheritLimitNOFILE=65535LimitNPROC=65535LimitAS=infinityLimitFSIZE=infinityLimitMEMLOCK=infinityTimeoutStopSec=0KillSignal=SIGTERMKillMode=processSendSIGKILL=noSuccessExitStatus=143timeoutTimeoutStartSec=75[Install]WantedBy=multi-user.target
