一、【在多台机器上执行下面的命令】###
#es启动时需要使用非root用户,所以创建一个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
#创建一个bigdata目录
mkdir /{bigdata,data}
#给相应的目录添加权限
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
#集群名称,通过组播的方式通信,通过名称判断属于哪个集群
cluster.name: bigdata
#节点名称,要唯一
node.name: es-1
#数据存放位置
path.data: /data/es/data
#日志存放位置
path.logs: /data/es/logs
#es绑定的ip地址
network.host: 172.16.0.14
#初始化时可进行选举的节点
discovery.zen.ping.unicast.hosts: ["node-4.itcast.cn", "node-5.itcast.cn", "node-6.itcast.cn"]
4、使用scp拷贝到其他节点
scp -r elasticsearch-2.3.1/ node-5.itcast.cn:$PWD
scp -r elasticsearch-2.3.1/ node-6.itcast.cn:$PWD
5、在其他节点上修改es配置,需要修改的有node.name和network.host
6、启动es(/bigdata/elasticsearch-2.3.1/bin/elasticsearch -h查看帮助文档)
/bigdata/elasticsearch-2.3.1/bin/elasticsearch -d
7、用浏览器访问es所在机器的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下创建ik目录
mkdir ik
2、把ik的压缩包上传到虚拟机,解压缩放在ik目录下就可以了
unzip elasticsearch-analysis-ik-1.8.0.zip