Elasticsearch 安装
1 验证java环境,elasticsearch需java环境进行安装。
java -version
java version "1.8.0_191"
Java(TM) SE Runtime Environment (build 1.8.0_191-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.191-b12, mixed mode)
2 下载Elasticsearch安装
下载地址:https://www.elastic.co/downloads/elasticsearch
3 上传elasticsearch-6.5.4.tar.gz至linux并解压文件:
tar –zxvf elasticsearch-6.5.4.tar.gz
mv elasticsearch-6.5.4 /usr/local/elasticsearch
4 创建用户及用户组并更改权限:
groupadd elastic
useradd elastic -g elastic
chown -R elastic:elastic elasticsearch
5 创建数据和日志文件夹:
su - elsearch
cd /usr/local/elasticsearch
mkdir data //数据存放地址
mkdir logs //日志存放地址
6 修改elasticsearch配置文件:
vi /config/elasticsearch.yml
cluster.name: my-application //集群名称
node.name: node-1 //节点名称
path.data: /usr/local/elasticsearch/data //数据存放位置
path.logs: /usr/local/elasticsearch/logs //日志存放位置
network.host: 192.168.***.*** //IP地址
http.port: 9200 //端口
http.cors.enabled: true //跨域访问
http.cors.allow-origin: "*" //跨域网段
7 启动Elasticsearch:
bin/elasticsearch
bin/elasticsearch –d //后台启动
8 安装ik分词器
Elasticsearch默认的是英文分词器,所以我们需要自行安装中文分词器,对我们的字段进行分词,这里选用的是IK分词器:
下载地址:https://github.com/medcl/elasticsearch-analysis-ik/releases
cd /usr/local/elasticsearch/plugins
//下载分词器,需版本一致
wget https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v6.5.4/elasticsearch-analysis-ik-6.5.4.zip
unzip elasticsearch-analysis-ik-6.5.4.zip -d analysis-ik
rm -rf elasticsearch-analysis-ik-6.5.4.zip
//重启Elasticsearch服务
9 集群配置
# --------------------------------- 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"]
discovery.seed_hosts: ["master01", "slave01"]
#
# Bootstrap the cluster using an initial set of master-eligible nodes:
#
cluster.initial_master_nodes: ["master01", "slave01"]
#
# For more information, consult the discovery and cluster formation module documentation.
#
# ---------------------------------- Gateway -----------------------------------
#
# Block initial recovery after a full cluster restart until N nodes are started:
#
gateway.recover_after_nodes: 3
Kibana安装
1 下载与elasticsearch相同版本的kibana:
wget https://artifacts.elastic.co/downloads/kibana/kibana-6.5.4-linux-x86_64.tar.gz
2 解压:
tar -xzf kibana-6.5.4-linux-x86_64.tar.gz
mv kibana-6.5.4-linux-x86_64 /usr/local/kibana
3 修改相关配置
cd /usr/local/kibana
vi confing/kibana.yml
server.host: "192.168.***.***"
elasticsearch.url: "http://192.168.***.***:9200"
4 启动kibana:
bin/kibana
nohup bin/kibana & //后台启动
注:首次后台启动后,不能直接关闭xshell窗口,可先使用exit退出后关闭。
访问地址:192.168.***.***:5601