1、 安裝JDKjava
1.1下載安裝
node
cd /usr/local/srclinux
tar -zxvf jdk-8u131-linux-x64.tar.gzgit
mv jdk1.8.0_131 /usr/local/javagithub
1.2修改配置文件npm
vim /etc/profile //最後面添加vim
export JAVA_HOME=/usr/local/java CLASSPATH=/usr/local/java/lib/dt.jar/usr/local/java/lib/tools.jar PATH=/usr/local/java/bin:$PATH export PATH JAVA_HOMECLASSPATH
source /etc/profile //導入配置文件
跨域
java -version //查看java版本瀏覽器
2、安裝Elasticsearchbash
官網:https://www.elastic.co/downloads
參考:http://blog.csdn.net/u013365215/article/details/70159159
2.1下載安裝
cd /usr/local/src/
curl -L -O https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.4.0.tar.gz
tar -xvf elasticsearch-5.4.0.tar.gz
mv elasticsearch-5.4.0 /usr/local/
cd /usr/local/elasticsearch-5.4.0/
2.2系統調優
1)配置系統最大打開文件描述符數
vim /etc/sysctl.conf
vm.max_map_count = 262144
執行如下命令生效
sysctl -p
2)配置進程最大打開文件描述符
vim /etc/security/limits.conf //文件最後
* soft nofile 65536 * hard nofile 65536
2.3編寫ES Master節點配置文件
vim config/elasticsearch.yml
cluster.name: my-es node.name: node-1 network.host: 192.168.19.141 http.port: 9200 transport.tcp.port: 9300 discovery.zen.ping.unicast.hosts: ["192.168.19.141","192.168.19.142","192.168.19.143"] discovery.zen.minimum_master_nodes: 2 #避免出現跨域問題 http.cors.enabled: true http.cors.allow-origin: "*"
第二個、第三個節點的配置只需修改爲對應的便可。
2.4啓動ES
用root帳號啓動會報錯:java.lang.RuntimeException: can not runelasticsearch as root
由於Elasticsearch5.0以後,不能使用root帳戶啓動,咱們先建立一個elasticsearch組和帳戶:
groupadd elsearch
useradd elsearch -g elsearch -p elasticsearch
chown -R elsearch.elsearch /usr/local/elasticsearch-5.4.0/
後臺啓動:
su - elsearch -c "/usr/local/elasticsearch-5.4.0/bin/elasticsearch -d"
2.5安裝head開源插件
參考:http://blog.csdn.net/ronmy/article/details/63685254
只在master上安裝插件便可。elasticsearch5不能夠直接經過plugin -install mobz/elasticsearch-head安裝,而且head須要在node環境下運行,具體步驟以下:
第一步:安裝node
curl -sL -o /etc/yum.repos.d/khara-nodejs.repohttps://copr.fedoraproject.org/coprs/khara/nodejs/repo/epel-7/khara-nodejs-epel-7.repo
yum install -y nodejs nodejs-npm
查看安裝版本
第二步:安裝grunt
cd /usr/lib/node_modules/npm/
npm install grunt-cli
npm install grunt
查看版本:
/usr/lib/node_modules/npm/node_modules/.bin/grunt -version
第三步:安裝head
yum install -y git
cd /usr/local/
git clone git://github.com/mobz/elasticsearch-head.git
cd elasticsearch-head/
npm install
注意:這步能夠會有一些報錯信息,能夠忽略。
vim _site/app.js
# 修改 『http://localhost:9200』字段到本機ES端口與IP
第四步:啓動head並在後臺運行
./node_modules/grunt/bin/gruntserver &
瀏覽器訪問:
注意:若不能造成集羣,多是 iptables 或者 selinux 的緣由
2.6開機自啓
vim /etc/rc.local
su - elsearch -c "/usr/local/elasticsearch-5.3.1/bin/elasticsearch -d" /usr/local/elasticsearch-head/node_modules/grunt/bin/grunt server &
保存退出後,給自啓文件賦予執行權限(若不加,Centos7不會開機執行)
chmod +x /etc/rc.d/rc.local