elasticsearch
本来不想玩 es 的,索引这玩意,偏向于开发,开发写写,和我们运维没啥关系,但是还是揽过来,先玩一通再说
来一段官方说明:
- 1、索引:数据会放在多个索引中,索引可以理解为database,索引里面存放的基本单位是文档,LES会把索引分片,便于横向扩展,分别可以做备份,多个分片读比较快,备份分片在主的挂掉之后可以自动将自己提升为主分片(实现横向扩展和冗余)2、文档类型:和redis一样,key是有类型的3、节点:一个ELS的实例是一个节点4、集群:多节点的集合组成集群,类似于zookeeper会选举出主节点,客户端不需要关注主节点,连接任何一个都可以,数据会自动同步,因此应用不需要关注那个是主节点。
#---------------- 下面是安装步骤 ---------------
1、获取 elasticsearch-2.4 部署包 http://blog.csdn.net/peibolinux/article/details/37560657
tar -zxvfelasticsearch-0.18.7.tar.gz (解压)
mv elasticsearch-0.18.7 /usr/local/elasticsearch-0.18.7 (把 es 移到 / usr/local 目录下)
修改集群名 (可选): vi/usr/local/elasticsearch-0.18.7/config/elasticsearch.yml ,找到: cluster.name, 去掉前面的 #,修改为 cluster.name:youboy (名字随意)。
修改结点名(可选):同上,找到 node.name,去掉前面的 #,修改为 node.name:yb1
修改分片数 (可选):同上,找到 index.number_of_shards, 去掉前面的 #,修改为 index.number_of_shards:10(默认为 5)
修改备份数 (可选):同上,找到 index.number_of_replicas,去掉前面的 #,修改为 index.number_of_replicas 1(默认也是 1,可不理)。
修改 Es 占用内存:vi /usr/local/elasticsearch-0.18.7/bin/elasticsearch.in.sh,找到 ES_MIN_MEM 和 ES_MAX_MEM,修改 es 最大和最小占用内存值。
(说明:Es 的集群非常简单,只要在同一个局域网内,多台服务器能互相通讯,并且 cluster.name 是一样的,就能自动集在一起。)
运行
运行 Es:
2、修改配置文件
[root@app config]# cat elasticsearch.yml|grep -v "^#"
cluster.name: ES_Cluster
node.name: 192.168.182.6
path.data: /usr/local/elasticsearch-2.4.3/data
path.logs: /usr/local/elasticsearch-2.4.3/logs
bootstrap.memory_lock: true
network.host: 192.168.182.6
http.port: 9200
启动 el,发现权限是 root,报错,新建用户 es,并且 chown -R es:es /usr/local/elasticsearch.... 使用 es 用户启动
cd/usr/local/elasticsearch-0.18.7/bin
./elasticsearch
[es@app bin]$ ./elasticsearch
[2017-01-03 23:21:09,604][WARN][bootstrap] unable to install syscall filter: seccomp unavailable: requires kernel 3.5+ with CONFIG_SECCOMP and CONFIG_SECCOMP_FILTER compiled in
[2017-01-03 23:21:09,618][WARN][bootstrap] Unable to lock JVM Memory: error=12,reason=Cannot allocate memory
[2017-01-03 23:21:09,618][WARN][bootstrap] This can result in part of the JVM being swapped out.
[2017-01-03 23:21:09,618][WARN][bootstrap] Increase RLIMIT_MEMLOCK, soft limit: 65536, hard limit: 65536
[2017-01-03 23:21:09,619][WARN][bootstrap] These can be adjusted by modifying /etc/security/limits.conf, for example:
# allow user 'es' mlockall
es soft memlock unlimited
es hard memlock unlimited
[2017-01-03 23:21:09,619][WARN][bootstrap] If you are logged in interactively, you will have to re-login for the new limits to take effect.
[2017-01-03 23:21:11,005][INFO][node] [192.168.182.6] version[2.4.3], pid[31355], build[d38a34e/2016-12-07T16:28:56Z]
[2017-01-03 23:21:11,006][INFO][node] [192.168.182.6] initializing ...
[2017-01-03 23:21:14,042][INFO][plugins] [192.168.182.6] modules [lang-groovy, reindex, lang-expression], plugins [bigdesk, head], sites [head, bigdesk]
[2017-01-03 23:21:14,177][INFO][env] [192.168.182.6] using [1] data paths, mounts [[/ (/dev/sda2)]], net usable_space [12.5gb], net total_space [17.4gb], spins? [possibly], types [ext4]
[2017-01-03 23:21:14,178][INFO][env] [192.168.182.6] heap size [1015.6mb], compressed ordinary object pointers [true]
[2017-01-03 23:21:14,179][WARN][env] [192.168.182.6] max file descriptors [4096] for elasticsearch process likely too low, consider increasing to at least [65536]
[2017-01-03 23:21:20,848][INFO][node] [192.168.182.6] initialized
[2017-01-03 23:21:20,850][INFO][node] [192.168.182.6] starting ...
[2017-01-03 23:21:20,984][INFO][transport] [192.168.182.6] publish_address {192.168.182.6:9300}, bound_addresses {192.168.182.6:9300}
[2017-01-03 23:21:20,996][INFO][discovery] [192.168.182.6] ES_Cluster/L5H7vnN-QJOpo4uHiCjmEA
[2017-01-03 23:21:24,168][INFO][cluster.service] [192.168.182.6] new_master {192.168.182.6}{L5H7vnN-QJOpo4uHiCjmEA}{192.168.182.6}{192.168.182.6:9300}, reason: zen-disco-join(elected_as_master, [0] joins received)
[2017-01-03 23:21:24,210][INFO][http] [192.168.182.6] publish_address {192.168.182.6:9200}, bound_addresses {192.168.182.6:9200}
[2017-01-03 23:21:24,214][INFO][node] [192.168.182.6] started
[2017-01-03 23:21:24,291][INFO][gateway] [192.168.182.6] recovered [0] indices into cluster_state
报错合计 -----Exception in thread "main" java.lang.UnsupportedClassVersionError: org/elasticsearch/bootstrap/Elasticsearch : Unsupported major.minor version 52.0
一开始使用的是 elasticsearch-2.*,所以惯用 jdk1.7 足以,后来改用 elasticsearch-5.0.0,应该使用 jdk8 了,jdk8 用 es 用户安装并且修改 es 用户环境变量。指定 es jdk 版本为 1.8
---- max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
sysctl -w vm.max_map_count=262144 // 需要 root 权限
sysctl -a|grep vm.max_map_count // 查看修改结果,可选
---- memory locking requested for elasticsearch process but memory is not locked
elasticsearch.yml bootstrap.memory_lock : false
---- max file descriptors [4096] for elasticsearch process likely too low, increase to at least [65536]
vi /etc/profile
ulimit -n 66666
ulimit -u 66666
vi /etc/security/limits.conf
-----------------------------
* soft nofile 65535
* hard nofile 65535
* soft stack 65535
* hard stack 65535
【es 集群配置】
【master】
cluster.name: elasticsearch
node.name: 10.25.250.147
discovery.zen.ping.unicast.hosts: ["10.25.250.147:9300", "10.116.215.30:19300"]
discovery.zen.minimum_master_nodes: 2
path.data: /data/middlewares/es9200/data
path.logs: /data/middlewares/es9200/logs
bootstrap.memory_lock: true
network.host: 10.25.250.147
http.port: 9200
【slave】
cluster.name: elasticsearch
node.name: 10.25.250.147_2
discovery.zen.ping.unicast.hosts: ["10.25.250.147:9300", "10.25.250.147:19300"]
discovery.zen.minimum_master_nodes: 2
path.data: /data/middlewares/es19200/data
path.logs: /data/middlewares/es19200/logs
bootstrap.memory_lock: true
network.host: 10.25.250.147
http.port: 19200
transport.tcp.port: 19300
3 插件及其安装
BigDesk Plugin : 对集群中 es 状态进行监控。
Elasticsearch Head Plugin: 对 ES 进行各种操作,如查询、删除、浏览索引等。
安装 head 插件
进入到节点 elasticsearch-node1/bin 路径,并安装插件。
[zkpk@master bin]$ ./plugin install mobz/elasticsearch-head
2. 安装 bigdesk
[zkpk@master bin]$ ./plugin install lukas-vlcek/bigdesk
关于 bigdesk url http://www.itnpc.com/news/web/1473732577115033.html
https://github.com/mobz/elasticsearch-head/issues/201
来源: