Step 1 — Installing Java
Add the Oracle Java PPA to apt:
sudo add-apt-repository -y ppa:webupd8team/java
sudo apt-get update
Install the latest stable version of Oracle Java 8 with this command (and accept the license agreement that pops up):
sudo apt-get -y install oracle-java8-installer
java -version
Step 2 — Downloading and Installing Elasticsearch
Elasticsearch 可以用包管理器通过添加 Elastic 的包源列表进行安装。
用下面的命令来导入 Elasticsearch 公共 GPG 密钥到 apt:
wget -qO - https://packages.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -
创建 Elasticsearch 资源列表:
echo "deb http://packages.elastic.co/elasticsearch/2.x/debian stable main" | sudo tee -a /etc/apt/sources.list.d/elasticsearch-2.x.list
sudo apt-get update
sudo apt-get -y install elasticsearch
安装好了,接下来编辑配置文档:
sudo vi /etc/elasticsearch/elasticsearch.yml
要限制你的Elasticsearch接口(端口9200)外的访问,这样外人无法通过HTTP API读取数据或关闭您的Elasticsearch集群。找到 network.host,取消注释,用 localhost 替换它的值:
network.host: localhost
保存并退出 elasticsearch.yml。
现在,打开 Elasticsearch:
sudo service elasticsearch restart
然后运行以下命令将在系统启动时启动Elasticsearch:
sudo update-rc.d elasticsearch defaults 95 10