1、下载 Elasticsearch:
官网地址: https://www.elastic.co/cn/downloads/elasticsearch
或者:https://download.csdn.net/download/qq_45463633/83800077
2、解压:
tar -zxvf elasticsearch-7.16.1-linux-x86_64.tar.gz
解压后文件:
3、修改配置 进入 /elasticsearch-7.16.1/config 目录,修改 elasticsearch.yml,添加以下内容
cluster.name: elasticsearch
path.data: /path/to/data #存储数据路径,不添加会默认存储到/elasticsearch-7.16.1/data
path.logs: /path/to/logs #存储日志,不添加会默认存储到/elasticsearch-7.16.1/logs
network.host: 192.168.0.1 # 192.168.0.1 是服务器ip,修改为自己本机的服务器ip
http.port: 9200 # es 端口号
cluster.initial_master_nodes: ["node-1"] #只有一台 es 服务,不集群
http.cors.enabled: true #支持跨域,默认不支持
http.cors.allow-origin: "*" #当设置允许跨域,默认为*,表示支持所有域名,如果我们只是允许某些网站能访问,那么可以使用正则表达式。比如只允许本地地址。 /https?:\/\/localhost(:[0-9]+)?/
4、启动ES,创建 es 用户,并切换es用户,不能使用管理员用户,否则会启动失败
进入 /elasticsearch-7.16.1/bin 目录
elasticsearch -d # 加上 -d 是后台运行
5、验证:浏览器输入: http://ip:9200,显示以下内容,启动成功
{
"name" : "WIN-A4TP7TQO95M",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "4e73NyrZRIm0Ijl2rEjbFA",
"version" : {
"number" : "7.16.1",
"build_flavor" : "default",
"build_type" : "zip",
"build_hash" : "83c34f456ae29d60e94d886e455e6a3409bba9ed",
"build_date" : "2021-10-07T21:56:19.031608185Z",
"build_snapshot" : false,
"lucene_version" : "8.9.0",
"minimum_wire_compatibility_version" : "6.8.0",
"minimum_index_compatibility_version" : "6.0.0-beta1"
},
"tagline" : "You Know, for Search"
}
6、elasticsearch 安装 ik 分词器
下载地址:https://download.csdn.net/download/qq_45463633/83799109
解压,上传到 /elasticsearch-7.8.1/plugins 目录下
7、elasticsearch 安装 kibana
官网地址:https://www.elastic.co/cn/downloads/kibana
或者:https://download.csdn.net/download/qq_45463633/83805810
解压
修改 /kibana/config/kibana.yml 文件
server.port: 5601 # 端口号
server.host: "172.16.17.88" # kibana 安装服务器 IP
elasticsearch.hosts: ["http://172.16.17.88:9200"] # http://172.16.17.88:920 是安装 ES 的服务器
i18n.locale: "zh-CN" # 开启中文,默认英文
启动:
./bin/kibana
验证:通过浏览器访问
http://172.16.17.88:5601
8、安装启动 elasticsearch 常见问题以及解决办法
# 问题 1
max number of threads [2047] for user [wlsadmin] is too low, increase to at least [4096]
# 解决
vim /etc/security/limits.d/20-nproc.conf
* soft nproc 2047 修改为 * soft nproc 4096
# 问题 2
max virtual memory areas vm.max_map_count [65535] is too low, increase to at least [262144]
# 解决
vim /etc/sysctl.conf
新增 vm.max_map_count=262144