服务器资源:
2台ec2做es存储计算实例,master:10.168.87.90,salve:10.168.234.220;
1台Redis实例,做队列服务;
1台ec2做web server,提供操作界面和网关服务;
以下主要记录下搭建es的步骤:
1、安装JDK
版本:1.8.0
cd /alidata/server
wget http://download.oracle.com/otn-pub/java/jdk/8u91-b14/jdk-8u91-linux-x64.tar.gz?AuthParam=1465871729_39876c3a3f37079ef42e1862e80c43ac
tar zxvf jdk-8u91-linux-x64.tar.gz
2、设置环境变量
vim /etc/profile
export JAVAHOME=/alidata/server/jdk1.8.091
export CLASSPATH=.:$JAVAHOME/lib/dt.jar:$JAVAHOME/lib/tools.jar
export PATH=$PATH:$JAVA_HOME/bin
source /etc/profile
3、安装elasticsearch
版本: 2.3.2
cd /alidata/server
wget https://download.elastic.co/elasticsearch/release/org/elasticsearch/distribution/tar/elasticsearch/2.3.2/elasticsearch-2.3.2.tar.gz
tar zxvf elasticsearch-2.3.2.tar.gz
4、安装集群管理工具head插件
cd /alidata/server/elasticsearch-2.3.2
./bin/plugin install mobz/elasticsearch-head
5、创建启动用户以及数据目录
groupadd data
useradd -d /home/data -m -s /bin/bash -g data data
mkdir /mnt/elastic/
mkdir -p /mnt/logs/elastic/
chown -R data:data /mnt/elastic/
chown -R data:data /mnt/logs/elastic/
chown -R data:data /alidata/server/elasticsearch-2.3.2
chmod 755 -R /mnt/elastic/
chmod 777 -R /mnt/logs/elastic/
vim /etc/security/limits.conf
data soft memlock unlimited
data hard memlock unlimited
6、配置elasticsearch
cluster.name: fruitday
node.name: da-note1
node.master: true
node.data: true
node.rack: r1
path.data: /mnt/elastic/
path.logs: /mnt/logs/elastic/
bootstrap.mlockall: true
http.port: 9200
network.host: 10.168.87.90
discovery.zen.ping.multicast.enabled: false
discovery.zen.ping.unicast.hosts: ["10.168.234.220"]
index.refresh_interval: 30s
discovery.zen.fd.ping_timeout: 120s
discovery.zen.fd.ping_retries: 6
discovery.zen.fd.ping_interval: 30s
discovery.zen.minimummasternodes: 2
http.enabled: true
7、启动命令
su data
cd /alidata/server/elasticsearch-2.3.2
./bin/elasticsearch -d
8、检查服务状态
curl -i -XGET 'http://10.0.10.93:9200/?pretty
curl -i -XGET 'http://10.168.87.90:9200/?pretty'
curl -i -XGET 'http://10.168.234.220:9200/?pretty'
9、设置Mapping(可参考)
curl -XDELETE 10.168.87.90:9200/_template/template?pretty
curl -XDELETE 10.168.234.220:9200/_template/template?pretty
curl -XPUT 10.168.87.90:9200/_template/template?pretty -d '{
curl -XPUT 10.168.234.220:9200/template/template?pretty -d '{ "template" : "", "settings" : { "numberofshards" : 2, "numberofreplicas":0 }, "mappings" : { "default" : { "dynamictemplates": [ { "template1": { "match": "", "matchmappingtype": "string", "mapping": { "type": "string", "index": "notanalyzed" } } }, { "template2": { "match": "preid", "mapping": { "type": "string", "index": "notanalyzed" } } }, { "template3": { "match": "actionname", "mapping": { "type": "string", "index": "notanalyzed" } } }, { "template4": { "match": "prename", "mapping": { "type": "string", "index": "notanalyzed" } } }, { "template5": { "match": "platform", "mapping": { "type": "string", "index": "notanalyzed" } } }, { "template6": { "match": "userid", "mapping": { "type": "integer" } } }, { "template7": { "match": "regionid", "mapping": { "type": "integer" } } }, { "template8": { "match": "connectid", "mapping": { "type": "string", "index": "notanalyzed" } } }, { "template9": { "match": "devicenum", "mapping": { "type": "string", "index": "notanalyzed" } } }, { "template10": { "match": "reportedtype", "mapping": { "type": "integer" } } }, { "template11": { "match": "finshtime", "mapping": { "type": "integer" } } }, { "template12": { "match": "channel", "mapping": { "type": "string", "index": "notanalyzed" } } }, { "template13": { "match": "version", "mapping": { "type": "string", "index": "notanalyzed" } } }, { "template14": { "match": "actiontime", "mapping": { "type": "date", "format": "dateOptionalTime" } } }, { "template15": { "match": "reportedtime", "mapping": { "type": "date", "format": "dateOptionalTime" } } }, { "template16": { "match": "inserttime", "mapping": { "type": "date", "format": "dateOptionalTime" } } }, { "template17": { "match": "productid", "mapping": { "type": "string", "index": "notanalyzed" } } }, { "template18": { "match": "targetid", "mapping": { "type": "integer" } } }, { "template19": { "match": "payid", "mapping": { "type": "integer" } } }, { "template20": { "match": "payparentid", "mapping": { "type": "integer" } } }, { "template21": { "match": "ordername", "mapping": { "type": "string", "index": "notanalyzed" } } }, { "template22": { "match": "keyword", "mapping": { "type": "string", "index": "notanalyzed" } } }, { "template23": { "match": "topcategory", "mapping": { "type": "string", "index": "notanalyzed" } } }, { "template24": { "match": "seccategory", "mapping": { "type": "string", "index": "notanalyzed" } } }, { "template25": { "match": "title", "mapping": { "type": "string", "index": "notanalyzed" } } }, { "template26": { "match": "url", "mapping": { "type": "string", "index": "notanalyzed" } } }, { "template27": { "match": "branch", "mapping": { "type": "string", "index": "notanalyzed" } } } ] } } } '