Linux下安装Elasticsearch
下载Elasticsearch最新版本
Elasticsearch官网地址:https://www.elastic.co/cn/downloads/elasticsearch
下载好了上传到服务器上。
解压到指定目录并将其重命名
tar -xvf elasticsearch-7.15.1-linux-x86_64.tar.gz -C /usr/local
mv /usr/local/elasticsearch-7.15.1 /usr/local/elasticsearch
创建一个普通用户elk用来运行elasticsearch
useradd elk
passwd elk
[root@localhost local]# useradd elk
[root@localhost local]# passwd elk
更改用户 elk 的密码 。
新的 密码:
无效的密码: 密码少于 8 个字符
重新输入新的 密码:
passwd:所有的身份验证令牌已经成功更新。
创建一个elasticsearch数据存储目录
mkdir -p /usr/local/elasticsearch/data
赋予elk用户拥有elasticsearch所属权限
chown elk:elk -R /usr/local/elasticsearch
修改elasticsearch配置文件
cd /usr/local/elasticsearch/config/
vim elasticsearch.yml
在elasticsearch文件下添加以下内容:
cluster.name: my-application
node.name: node-1
path.data: /usr/local/elasticsearch/data
path.logs: /usr/local/elasticsearch/logs
network.host: 0.0.0.0
cluster.initial_master_nodes: ["node-1"]
修改相关内核参数
echo "vm.max_map_count=655360" >> /etc/sysctl.conf
sysctl -p
vim /etc/security/limits.conf
在limits.conf文件最后一行添加以下内容:
* soft nproc 65536
* hard nproc 65536
* soft nofile 65536
* hard nofile 65536
切换用户elk来运行elasticsearch
su - elk
cd /usr/local/elasticsearch/
./bin/elasticsearch -d
[root@localhost ~]# su - elk
上一次登录:二 10月 26 16:23:47 CST 2021pts/2 上
[elk@localhost ~]$ cd /usr/local/elasticsearch/bin/
[elk@localhost bin]$ ./elasticsearch -d
检查elasticsearch状态
如下则表示正常运行
curl http://0.0.0.0:9200
[elk@localhost bin]$ curl http://0.0.0.0:9200
{
"name" : "node-1",
"cluster_name" : "my-application",
"cluster_uuid" : "5gr_iJaPTkKpEv5B5qUZPA",
"version" : {
"number" : "7.15.1",
"build_flavor" : "default",
"build_type" : "tar",
"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"
}