在CentOS 7上搭建Elasticsearch 8.12.2集群并安装Kibana 8.12.2的步骤如下:
- 安装Java,Elasticsearch需要Java运行环境:
sudo yum install java-11-openjdk-devel
- 添加Elasticsearch用户:
sudo useradd elasticsearch
- 设置内存锁定,为Elasticsearch系统进程分配固定的内存地址,减少被攻击的风险:
sudo vim /etc/sysctl.conf
# 添加以下内容:
vm.memory_lock = 1
# 应用设置:
sudo sysctl -p
- 下载并安装Elasticsearch 8.12.2:
wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -
echo "deb https://artifacts.elastic.co/packages/8.x/apt stable main" | sudo tee -a /etc/apt/sources.list.d/elastic-8.x.list
sudo apt-get update && sudo apt-get install elasticsearch
- 配置Elasticsearch集群,编辑
/etc/elasticsearch/elasticsearch.yml
:
cluster.name: my-cluster
node.name: node-1
network.host: 192.168.1.10 # 替换为你的IP地址
http.port: 9200
discovery.seed_hosts: ["192.168.1.10", "192.168.1.11"] # 替换为集群节点IP
cluster.initial_master_nodes: ["node-1", "node-2"] # 根据节点名称替换
- 启动并使Elasticsearch服务开机自启:
sudo systemctl start elasticsearch
sudo systemctl enable elasticsearch
- 对第二个节点进行相同的安装步骤,只是需要更改节点名称和配置文件中的
node.name
和discovery.seed_hosts
。 - 安装Kibana 8.12.2:
wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -
echo "deb https://artifacts.elastic.co/packages/8.x/apt stable main" | sudo tee -a /etc/apt/sources.list.d/elastic-8.x.list
sudo apt-get update && sudo apt-get install kibana
- 配置Kibana连接到Elasticsearch,编辑
/etc/kibana/kibana.yml
:
server.host: "192.168.1.10" # 替换为你的IP地址
elasticsearch.hosts: ["http://192.168.1.10:9200"] # 替换为Elasticsearch节点地址
- 启动并使Kibana服务开机自启:
sudo systemctl start kibana
sudo systemctl enable kibana
确保防火墙设置允许访问9200端口(Elasticsearch默认端口)和5601端口(Kibana默认端口)。
这样,你就在CentOS 7上搭建了Elasticsearch 8.12.2集群并安装了Kibana 8.12.2。