Ubuntu 安装 Elasticsearch

1.安装java

注意:最新版本的elasticsearch(5.6.2)要求安装java8

1、sudo apt-add-repository ppa:webupd8team/java
2、sudo apt-get update
3、sudo apt-get install oracle-java8-installer

注意:如果之前有安装老版本的java或者opensdk的,在安装之后,最好重新设置以下环境变量:export JAVA_HOME=/usr/lib/jvm/java-8-oracle 和 export CLASSPATH=/usr/share/java,最后source /etc/profile使变量生效。

2. 下载elasticsearch

zip安装:

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账号启动)

groupadd elsearch

useradd elsearch -g elsearch -p elasticsearch

创建新用户后,将解压后的elasticsearch的拥有者更换为elsearch:chown -R elsearch:elsearch elasticsearch

3. 运行elasticsearch

切换到elsearch用户,切换到elasticsearch目录,使用命令启动:./bin/elasticsearch

另开一个终端,使用curl访问如下地址即可验证是否成功安装:curl 'http://localhost:9200?pretty'

技巧1:变更配置内存

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



 

posted @ 2018-12-25 08:50  Nullnullisnull  阅读(195)  评论(0编辑  收藏