如何在Centos上安装ElasticSearch
步骤1:更新CentOS 7 Linux
sudo yum -y update
sudo reboot
步骤2:在CentOS上安装Java
sudo yum -y install java-1.8.0-openjdk java-1.8.0-openjdk-devel
设置JAVA路径
cat <<EOF | sudo tee /etc/profile.d/java8.sh
export JAVA_HOME=/usr/lib/jvm/jre-openjdk
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH=.:$JAVA_HOME/jre/lib:$JAVA_HOME/lib:$JAVA_HOME/lib/tools.jar
EOF
source /etc/profile.d/java8.sh
步骤3:添加ElasticSearch Yum存储库
cat <<EOF | sudo tee /etc/yum.repos.d/elasticsearch.repo
[elasticsearch-7.x]
name=Elasticsearch repository for 7.x packages
baseurl=https://artifacts.elastic.co/packages/oss-7.x/yum
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
enabled=1
autorefresh=1
type=rpm-md
EOF
步骤4:在CentOS上安装ElasticSearch
sudo yum -y install elasticsearch-oss
步骤5:在Centos上启用ElasticSearch
sudo systemctl enable --now elasticsearch
步骤6:检查ElasticSearch是否正在运行
curl http://127.0.0.1:9200
2、如何在Ubuntu上安装ElasticSearch
步骤1:将Elastic source列表添加到sources.list.d
curl -fsSL https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add
echo "deb https://artifacts.elastic.co/packages/7.x/apt stable main" | sudo tee -a /etc/apt/sources.list.d/elastic-7.x.list
步骤2:更新Apt
sudo apt update
步骤3:安装Elasticsearch
sudo apt install elasticsearch
步骤4:在Ubuntu上启用Elasticsearch
sudo systemctl enable --now elasticsearch
步骤5:检查Elasticsearch是否在Ubuntu上运行
curl http://127.0.0.1:9200。