Ubuntu 安裝 Elasticsearch

1.安裝java

注意:最新版本的elasticsearch(5.6.2)要求安裝java8java

一、sudo apt-add-repository ppa:webupd8team/java
二、sudo apt-get update
三、sudo apt-get install oracle-java8-installerweb

注意:若是以前有安裝老版本的java或者opensdk的,在安裝以後,最好從新設置如下環境變量:export JAVA_HOME=/usr/lib/jvm/java-8-oracle 和 export CLASSPATH=/usr/share/java,最後source /etc/profile使變量生效。oracle

2. 下載elasticsearch

zip安裝:curl

wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.6.2.zip
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.6.2.zip.sha512
shasum -a 512 -c elasticsearch-5.6.2.zip.sha512 
unzip elasticsearch-5.6.2.zip
cd elasticsearch-5.6.2/
 
rpm安裝:
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.5.4.rpm
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.5.4.rpm.sha512
shasum -a 512 -c elasticsearch-6.5.4.rpm.sha512 
sudo rpm --install elasticsearch-6.5.4.rpm
 

注意:須要爲elasticsearch分配一個新的用戶(由於不容許以root帳號啓動)jvm

groupadd elsearchelasticsearch

useradd elsearch -g elsearch -p elasticsearchurl

建立新用戶後,將解壓後的elasticsearch的擁有者更換爲elsearch:chown -R elsearch:elsearch elasticsearchspa

3. 運行elasticsearch

切換到elsearch用戶,切換到elasticsearch目錄,使用命令啓動:./bin/elasticsearchip

另開一個終端,使用curl訪問以下地址便可驗證是否成功安裝:curl 'http://localhost:9200?pretty'內存

技巧1:變動配置內存

新版的elasticsearch配置內存要使用以下指令:ES_JAVA_OPTS="-Xms30g –Xmx30g" ./bin/elasticsearch

相關文章
相關標籤/搜索