一姜盈、【在多臺(tái)機(jī)器上執(zhí)行下面的命令】###
#es啟動(dòng)時(shí)需要使用非root用戶硕蛹,所以創(chuàng)建一個(gè)bigdata用戶:
useradd bigdata
#為hadoop用戶添加密碼:
echo 123456 | passwd --stdin bigdata
#將bigdata添加到sudoers
echo "bigdata ALL = (root) NOPASSWD:ALL" | tee /etc/sudoers.d/bigdata
chmod 0440 /etc/sudoers.d/bigdata
#解決sudo: sorry, you must have a tty to run sudo問題浪漠,在/etc/sudoer注釋掉 Default requiretty 一行
sudo sed -i 's/Defaults requiretty/Defaults:bigdata !requiretty/' /etc/sudoers
#創(chuàng)建一個(gè)bigdata目錄
mkdir /{bigdata,data}
#給相應(yīng)的目錄添加權(quán)限
chown -R bigdata:bigdata /{bigdata,data}
二、切換到bigdata用戶安裝
1朴艰、上傳es安裝包
2观蓄、解壓es
tar -zxvf elasticsearch-2.3.1.tar.gz -C /bigdata/
3、修改配置
vi /bigdata/elasticsearch-2.3.1/config/elasticsearch.yml
#集群名稱祠墅,通過組播的方式通信侮穿,通過名稱判斷屬于哪個(gè)集群
cluster.name: bigdata
#節(jié)點(diǎn)名稱,要唯一
node.name: es-1
#數(shù)據(jù)存放位置
path.data: /data/es/data
#日志存放位置
path.logs: /data/es/logs
#es綁定的ip地址
network.host: 172.16.0.14
#初始化時(shí)可進(jìn)行選舉的節(jié)點(diǎn)
discovery.zen.ping.unicast.hosts: ["node-4.itcast.cn", "node-5.itcast.cn", "node-6.itcast.cn"]
4毁嗦、使用scp拷貝到其他節(jié)點(diǎn)
scp -r elasticsearch-2.3.1/ node-5.itcast.cn:$PWD
scp -r elasticsearch-2.3.1/ node-6.itcast.cn:$PWD
5撮珠、在其他節(jié)點(diǎn)上修改es配置,需要修改的有node.name和network.host
6金矛、啟動(dòng)es(/bigdata/elasticsearch-2.3.1/bin/elasticsearch -h查看幫助文檔)
/bigdata/elasticsearch-2.3.1/bin/elasticsearch -d
7芯急、用瀏覽器訪問es所在機(jī)器的9200端口
node1:9200/
{
"name" : "es-1",
"cluster_name" : "bigdata",
"version" : {
"number" : "2.3.1",
"build_hash" : "bd980929010aef404e7cb0843e61d0665269fc39",
"build_timestamp" : "2016-04-04T12:25:05Z",
"build_snapshot" : false,
"lucene_version" : "5.5.0"
},
"tagline" : "You Know, for Search"
}
kill ps -ef | grep Elasticsearch | grep -v grep | awk '{print $2}'
三、安裝es插件
1驶俊、下載es插件
/bigdata/elasticsearch-2.3.1/bin/plugin install mobz/elasticsearch-head
[hadoop@master es]$ bin/plugin install mobz/elasticsearch-head
-> Installing mobz/elasticsearch-head...
Trying https://github.com/mobz/elasticsearch-head/archive/master.zip ...
Downloading ....................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................DONE
Verifying https://github.com/mobz/elasticsearch-head/archive/master.zip checksums if available ...
NOTE: Unable to verify checksum for downloaded plugin (unable to find .sha1 or .md5 file to verify)
Installed head into /export/servers/es/plugins/head
2娶耍、本地方式安裝head插件
./plugin install file:///home/bigdata/elasticsearch-head-master.zip
3、訪問head管理頁面
http://node1:9200/_plugin/head
四饼酿、安裝IK分詞器
1榕酒、在plugin下創(chuàng)建ik目錄
mkdir ik
2、把ik的壓縮包上傳到虛擬機(jī)故俐,解壓縮放在ik目錄下就可以了
unzip elasticsearch-analysis-ik-1.8.0.zip