在CentOS 7上安装Elasticsearch、Kibana以及中文分词器IK,可以按照以下步骤进行:
- 导入Elasticsearch和Kibana的公钥:
rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch
- 创建Elasticsearch的yum仓库文件:
echo "[elasticsearch-7.x]
name=Elasticsearch repository for 7.x packages
baseurl=https://artifacts.elastic.co/packages/7.x/yum
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
enabled=1
autorefresh=1
type=rpm-md" | sudo tee /etc/yum.repos.d/elasticsearch.repo
- 安装Elasticsearch:
sudo yum install --enablerepo=elasticsearch elasticsearch
- 启动并设置Elasticsearch开机自启:
sudo systemctl start elasticsearch.service
sudo systemctl enable elasticsearch.service
- 下载Kibana的yum仓库文件:
echo "[kibana-7.x]
name=Kibana repository for 7.x packages
baseurl=https://artifacts.elastic.co/packages/7.x/yum
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
enabled=1
autorefresh=1
type=rpm-md" | sudo tee /etc/yum.repos.d/kibana.repo
- 安装Kibana:
sudo yum install kibana
- 编辑Kibana配置文件,指定Elasticsearch的地址:
sudo vim /etc/kibana/kibana.yml
找到或添加以下行:
elasticsearch.hosts: ["http://localhost:9200"]
- 启动并设置Kibana开机自启:
sudo systemctl start kibana.service
sudo systemctl enable kibana.service
安装中文分词器IK:
首先,你需要在Elasticsearch的config/elasticsearch.yml
文件中添加以下行来启用插件:
action.auto_create_index: ".security,.monitoring*,.watches,.triggered_watches,.watcher-history*,.ml*,.slm*,logstash*,.kibana*,.kibana_task*,.transform*".superuser_only: false
然后,重新启动Elasticsearch。
接下来,你可以使用Elasticsearch的插件命令来安装IK分词器:
sudo /usr/share/elasticsearch/bin/elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v7.7.0/elasticsearch-analysis-ik-7.7.0.zip
确保替换版本号v7.7.0
为你安装的Elasticsearch版本。
- 重新启动Elasticsearch以应用插件更改。
以上步骤安装了Elasticsearch、Kibana,并为Elasticsearch添加了中文分词器IK。确保你有足够的权限执行这些命令,并且在安装过程中没有遇到网络或权限问题。