我在廉价的VPS上建立了ElasticSearch
环境
靛蓝KVM实例 4核心 4 GB
CentOS 7.5.1804 (核心)
ElasticSearch 7.13.4
kibana 7.13.4
Python 2.7.5
安装ElasticSearch
导入所需的ElasticSearch DL密钥。
sudo rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch
添加ElasticSearch库
将enabled设置为0,不会影响其他安装。
$ sudo vi /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
安装ElasticSearch
使用先前创建的存储库来指定安装ElasticSearch的步骤。
sudo yum install --enablerepo=elasticsearch elasticsearch
在操作系统启动时进行设置,以使其启动。
sudo chkconfig --add elasticsearch
访问设置和集群设置
在AWS或VPS等平台上,需要进行节点设置才能访问全局IP,否则在启动时会出现错误,需要注意。
$ sudo vi /etc/elasticsearch/elasticsearch.yml
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#
- # node.name: node-1
+ node.name: node-1
#
# Add custom attributes to the node:
#
#node.attr.rack: r1
#
# ---------------------------------- Network -----------------------------------
#
# By default Elasticsearch is only accessible on localhost. Set a different
# address here to expose this node on the network:
#
- # network.host: 192.168.0.1
+ network.host: 0.0.0.0
#
# By default Elasticsearch listens for HTTP traffic on the first free port it
# finds starting at 9200. Set a specific HTTP port here:
#
#http.port: 9200
#
# For more information, consult the network module documentation.
# --------------------------------- Discovery ----------------------------------
#
# Pass an initial list of hosts to perform discovery when this node is started:
# The default list of hosts is ["127.0.0.1", "[::1]"]
#
#discovery.seed_hosts: ["host1", "host2"]
#
# Bootstrap the cluster using an initial set of master-eligible nodes:
#
- # cluster.initial_master_nodes: ["node-1", "node-2"]
+ cluster.initial_master_nodes: ["node-1"]
#
# For more information, consult the discovery and cluster formation module documentation.
禁用SELinux
$ sudo vi /etc/selinux/config
- # SELINUX=enforce
+ SELINUX=disabled
启动ElasticSearch
sudo systemctl start elasticsearch
确认运行
访问 http://xxx.xxx.xxx.xxx:9200
如果无法访问,则可能是由于安装了iptables或firewalld防火墙。
安装Kibana
安装Kibana
sudo yum install --enablerepo=elasticsearch kibana
在操作系统启动时设置为自启动。
sudo chkconfig --add kibana
设置访问
在AWS或VPS等服务中,可以访问全球IP。
$ sudo vi /etc/kibana/kibana.yml
# ------------------------------------ Node ------------------------------------
#
# Specifies the address to which the Kibana server will bind. IP addresses and host names are both valid values.
# The default is 'localhost', which usually means remote machines will not be able to connect.
# To allow connections from remote users, set this parameter to a non-loopback address.
- #server.host: localhost
+ server.host: 0.0.0.0
启动Kibana
sudo systemctl start kibana
确认运行
可能需要花一点时间访问 http://xxx.xxx.xxx.xxx:5601。