参考:https://www.elastic.co/guide/en/elasticsearch/reference/7.9/rpm.html#rpm-repo
[root@es01 ~]# rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch
[root@es01 ~]# cat << EOF > /etc/yum.repos.d/elasticsearch.repo
> [elasticsearch]
> name=Elasticsearch repository for 7.x packages
> baseurl=https://artifacts.elastic.co/packages/7.x/yum
> gpgcheck=1
> gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
> enabled=0
> autorefresh=1
> type=rpm-md
> EOF
[root@es01 ~]# dnf install --enablerepo=elasticsearch elasticsearch
[root@es01 ~]# ll el*
-rw-r--r--. 1 root root 317277408 Oct 13 09:34 elasticsearch-7.9.2-x86_64.rpm
-rw-r--r--. 1 root root 160 Oct 13 09:34 elasticsearch-7.9.2-x86_64.rpm.sha512
[root@es01 ~]# shasum -a 512 -c elasticsearch-7.9.2-x86_64.rpm.sha512
elasticsearch-7.9.2-x86_64.rpm: OK
[root@es01 ~]# rpm --install elasticsearch-7.9.2-x86_64.rpm
Creating elasticsearch group... OK
Creating elasticsearch user... OK
### 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
[/usr/lib/tmpfiles.d/elasticsearch.conf:1] Line references path below legacy directory /var/run/, updating /var/run/elasticsearch → /run/elasticsearch; please update the tmpfiles.d/ drop-in file accordingly.
[root@es01 ~]# systemctl daemon-reload
[root@es01 ~]#
文件 | 说明 |
---|---|
/etc/elasticsearch/elasticsearch.yml | 主配置文件 |
/etc/elasticsearch/jvm.options | JVM虚拟机配置 |
/etc/sysconfig/elasticsearch | 环境变量相关参数 |
/usr/lib/sysctl.d/elasticsearch.conf | JVM相关配置 |
[root@es01 ~]# cp /etc/elasticsearch/elasticsearch.yml{,.bak}
[root@es01 ~]# sed '/^#/d' /etc/elasticsearch/elasticsearch.yml
path.data: /var/lib/elasticsearch
path.logs: /var/log/elasticsearch
[root@es01 ~]# sed -i '/^#/d' /etc/elasticsearch/elasticsearch.yml
[root@es01 ~]# vi /etc/elasticsearch/elasticsearch.yml
[root@es01 ~]# cat /etc/elasticsearch/elasticsearch.yml
# Use a descriptive name for the node:
node.name: es01
# Path to directory where to store the data (separate multiple locations by comma):
path.data: /var/lib/elasticsearch
# Path to log files:
path.logs: /var/log/elasticsearch
# Lock the memory on startup:
bootstrap.memory_lock: true
# Set the bind address to a specific IP (IPv4 or IPv6):
network.host: 13.13.13.5
[root@es01 ~]#
[root@es01 ~]# systemctl restart elasticsearch.service
Job for elasticsearch.service failed because the control process exited with error code.
See "systemctl status elasticsearch.service" and "journalctl -xe" for details.
[root@es01 ~]# tail /var/log/elasticsearch/elasticsearch.log
[2020-10-13T10:10:32,962][INFO ][o.e.t.TransportService ] [es01] publish_address {13.13.13.5:9300}, bound_addresses {13.13.13.5:9300}
[2020-10-13T10:10:33,211][INFO ][o.e.b.BootstrapChecks ] [es01] bound or publishing to a non-loopback address, enforcing bootstrap checks
[2020-10-13T10:10:33,226][ERROR][o.e.b.Bootstrap ] [es01] node validation exception
[2] bootstrap checks failed
[1]: memory locking requested for elasticsearch process but memory is not locked
[2]: 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
[2020-10-13T10:10:33,233][INFO ][o.e.n.Node ] [es01] stopping ...
[2020-10-13T10:10:33,242][INFO ][o.e.n.Node ] [es01] stopped
[2020-10-13T10:10:33,242][INFO ][o.e.n.Node ] [es01] closing ...
[2020-10-13T10:10:33,259][INFO ][o.e.n.Node ] [es01] closed
[root@es01 ~]#
参考:https://www.elastic.co/guide/en/elasticsearch/reference/7.9/setup-configuration-memory.html
[root@es01 ~]# systemctl edit elasticsearch
[root@es01 ~]# cat /etc/systemd/system/elasticsearch.service.d/override.conf
[Service]
LimitMEMLOCK=infinity
[root@es01 ~]# systemctl daemon-reload
[root@es01 ~]# systemctl restart elasticsearch.service
Job for elasticsearch.service failed because the control process exited with error code.
See "systemctl status elasticsearch.service" and "journalctl -xe" for details.
[root@es01 ~]#
[root@es01 ~]# tail /var/log/elasticsearch/elasticsearch.log
[2020-10-13T10:17:59,804][INFO ][o.e.n.Node ] [es01] starting ...
[2020-10-13T10:17:59,964][INFO ][o.e.t.TransportService ] [es01] publish_address {13.13.13.5:9300}, bound_addresses {13.13.13.5:9300}
[2020-10-13T10:18:00,272][INFO ][o.e.b.BootstrapChecks ] [es01] bound or publishing to a non-loopback address, enforcing bootstrap checks
[2020-10-13T10:18:00,288][ERROR][o.e.b.Bootstrap ] [es01] node validation exception
[1] bootstrap checks failed
[1]: 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
[2020-10-13T10:18:00,290][INFO ][o.e.n.Node ] [es01] stopping ...
[2020-10-13T10:18:00,301][INFO ][o.e.n.Node ] [es01] stopped
[2020-10-13T10:18:00,301][INFO ][o.e.n.Node ] [es01] closing ...
[2020-10-13T10:18:00,322][INFO ][o.e.n.Node ] [es01] closed
[root@es01 ~]#
参考:https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-discovery-settings.html
[root@es01 ~]# tail -5 /etc/elasticsearch/elasticsearch.yml
# Specifies whether Elasticsearch should form a multiple-node cluster. By default,
# Elasticsearch discovers other nodes when forming a cluster and allows other nodes
# to join the cluster later. If discovery.type is set to single-node, Elasticsearch
# forms a single-node cluster and suppresses the timeout set by cluster.publish.timeout.
discovery.type: single-node
[root@es01 ~]#
ES | MySQL |
---|---|
type | 库 |
index | 表 |
filter | 字段 |
[root@es01 ~]# curl -XPUT 13.13.13.5:9200/vipinfo?pretty
{
"acknowledged" : true,
"shards_acknowledged" : true,
"index" : "vipinfo"
}
[root@es01 ~]#
[root@es01 ~]# firewall-cmd --add-service=elasticsearch
success
[root@es01 ~]# firewall-cmd --reload
success
[root@es01 ~]#
、