@zslzxc
2018-03-28T09:41:43.000000Z
字数 4080
阅读 1178
elasticsearch vagrant
安装JDK
sudo yum install java-1.8.0-openjdk.x86_64
测试
[vagrant@localhost vagrant_data]$ java -versionopenjdk version "1.8.0_161"OpenJDK Runtime Environment (build 1.8.0_161-b14)OpenJDK 64-Bit Server VM (build 25.161-b14, mixed mode)
执行以下命令
curl -L -O https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.6.8.tar.gztar -xvf elasticsearch-5.6.8.tar.gzcd elasticsearch-5.6.8/bin./elasticsearch
测试是否安装成功
[vagrant@localhost elasticsearch-5.6.8]$ curl 'http://localhost:9200/?pretty'{"name" : "Lx20sHw","cluster_name" : "elasticsearch","cluster_uuid" : "gnYSlRb9TUqpVnBscm1-GQ","version" : {"number" : "5.6.8","build_hash" : "688ecce","build_date" : "2018-02-16T16:46:30.010Z","build_snapshot" : false,"lucene_version" : "6.6.1"},"tagline" : "You Know, for Search"}
Vagrant内存不足报错
[vagrant@localhost elasticsearch-5.6.8]$ ./bin/elasticsearchOpenJDK 64-Bit Server VM warning: If the number of processors is expected to increase from one, then you should configure the number of parallel GC threads appropriately using -XX:ParallelGCThreads=NOpenJDK 64-Bit Server VM warning: INFO: os::commit_memory(0x0000000085330000, 2060255232, 0) failed; error='Cannot allocate memory' (errno=12)## There is insufficient memory for the Java Runtime Environment to continue.# Native memory allocation (mmap) failed to map 2060255232 bytes for committing reserved memory.# An error report file with more information is saved as:# /vagrant_data/elasticsearch-5.6.8/hs_err_pid22178.log[vagrant@localhost elasticsearch-5.6.8]$ free -mtotal used free shared buff/cache availableMem: 488 101 88 3 297 340Swap: 1535 1 1534
解决方法:
添加如下信息:
config.vm.provider "virtualbox" do |v|v.memory = 2048v.cpus = 2end
重启Vagrant vagrant reload
ElasticSearch 启动报错
ERROR: [2] bootstrap checks failed[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536][2]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
解决方法:
sudo vim /etc/security/limits.conf添加如下信息:[当前用户名] hard nofile 65536[当前用户名] soft nofile 65536保存退出*******************************************************************sysctl -w vm.max_map_count=655360sysctl -a | grep "vm.max_map_count"
version: "3"services:php_pc:image: php:7.2-clicontainer_name: pcsoft_phpports :- "9000:9000"volumes:- ./phpcli:/var/www/html/db_pc:image: mysql:5.7container_name: pcsoft_dbvolumes:- ./dbdata:/var/lib/mysql/ports:- "3306:3306"environment:MYSQL_USER: rootMYSQL_PASSWORD: rootMYSQL_ROOT_PASSWORD: rootelasticsearch_soft:image: registry.cn-hangzhou.aliyuncs.com/amor/elastic:6.2.3container_name: es_pc_softenvironment:- cluster.name=docker-cluster- bootstrap.memory_lock=true- xpack.security.enabled=false- "ES_JAVA_OPTS=-Xms2g -Xmx2g"ulimits:memlock:soft: -1hard: -1volumes:- ./docker_es/esdata_soft:/usr/share/elasticsearch/dataports:- 9200:9200elasticsearch_game:image: registry.cn-hangzhou.aliyuncs.com/amor/elastic:6.2.3container_name: es_pc_gameenvironment:- cluster.name=docker-cluster- bootstrap.memory_lock=true- xpack.security.enabled=false- "ES_JAVA_OPTS=-Xms2g -Xmx2g"- "discovery.zen.ping.unicast.hosts=es_pc_soft"ulimits:memlock:soft: -1hard: -1volumes:- ./docker_es/esdata_game:/usr/share/elasticsearch/datakibana:image: registry.cn-hangzhou.aliyuncs.com/amor/kibana:6.2.3container_name: es_pc_kibanaenvironment:SERVER_NAME: kibana.pc_amor.comELASTICSEARCH_URL: http://elasticsearch_soft:9200XPACK_SECURITY_ENABLED: "false"
grep vm.max_map_count /etc/sysctl.conf# 如果找不到,则在该文件中添加 vm.max_map_count=262144 然后执行 sysctl -p# 临时改变轻执行sysctl -w vm.max_map_count=262144
请检查Elasticsearch挂载的目录是否是root用户创建的
直接通过docker-compose server name链接即可
# 添加以下选项:XPACK_SECURITY_ENABLED: "false"