ELK入门(1)Elasticsearch安装
1 下载ES安装包
解压并移动至/usr/local目录下
$ wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-8.2.0-linux-x86_64.tar.gz
$ tar -zxvf elasticsearch-8.2.0-linux-x86_64.tar.gz
$ mv elasticsearch-8.2.0 /usr/local/elasticsearch
2 新建用户
出于安全考虑,elasticsearch不能使用root启动,输入两次elasticsearch密码
$ useradd elasticsearch
$ passwd elasticsearch
3 更改文件夹属性
将elasticsearch文件夹所属用户改成elasticsearch
$ chown -R elasticsearch /usr/local/elasticsearch/
$ cd /usr/local/elasticsearch/
4 修改ES配置文件
更改下面三项配置
$ vim ./config/elasticsearch.yml
node.name: node-1
network.host: 0.0.0.0
cluster.initial_master_nodes: ["node-1"]
5 修改文件描述限制
$ vim /etc/security/limits.conf
* soft nofile 65536
* hard nofile 131072
* soft nproc 2048
* hard nproc 4096
6 修改最大虚拟内存区域数量
$ vim /etc/sysctl.conf
vm.max_map_count=655360
$ sysctl -p
7 创建ES服务
$ vim /usr/lib/systemd/system/elasticsearch.service
[Unit]
Description=elasticsearch
[Service]
User=elasticsearch
LimitNOFILE=100000
LimitNPROC=100000
ExecStart=/usr/local/elasticsearch/bin/elasticsearch
[Install]
WantedBy=multi-user.target
8 启动ES服务,并设置开机自启
$ systemctl start elasticsearch
$ systemctl enable elasticsearch
9 开放防火墙端口
防火墙放行9200和9300端口,9200用于外部访问,9300用于ES集群之间通讯。
$ firewall-cmd --permanent --add-port=9200/tcp
$ firewall-cmd --permanent --add-port=9300/tcp
$ firewall-cmd --reload
10 访问测试
$ curl -l http://192.168.102.123:9200
curl: (52) Empty reply from server
[2022-05-04T16:22:39,385][WARN ][o.e.x.s.t.n.SecurityNetty4HttpServerTransport] [node-1] received plaintext http traffic on an https channel, closing connection Netty4HttpChannel{localAddress=/192.168.102.123:9200, remoteAddress=/192.168.102.123:44182}
11 关闭安全验证
$ vim ./config/elasticsearch.yml
xpack.security.enabled: false
$ systemctl enable elasticsearch
12 访问测试
$ curl -l http://192.168.102.123:9200
{
"name" : "node-1",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "02MNR5EYRbOC2kp6j7R0Hg",
"version" : {
"number" : "8.2.0",
"build_flavor" : "default",
"build_type" : "tar",
"build_hash" : "b174af62e8dd9f4ac4d25875e9381ffe2b9282c5",
"build_date" : "2022-04-20T10:35:10.180408517Z",
"build_snapshot" : false,
"lucene_version" : "9.1.0",
"minimum_wire_compatibility_version" : "7.17.0",
"minimum_index_compatibility_version" : "7.0.0"
},
"tagline" : "You Know, for Search"
}
版权声明:
本站所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自
运维小记!
喜欢就支持一下吧
打赏
微信
支付宝