强大的搜索引擎Elasticsearch安装 - php简单使用

强大的搜索引擎Elasticsearch安装 - php简单使用

本篇笔记记录了CentOS6.9下安装ElasticSearch的过程

安装jdk1.8

yum install java-1.8.0-openjdk

添加elasticsearch用户和组

groupadd elasticsearch
useradd -g elasticsearch elasticsearch

创建目录

mkdir -p /usr/local
cd /usr/local

下载ElasticSearch

wget -c https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.6.0.tar.gz

解压

tar -zxvf elasticsearch-6.6.0.tar.gz

设置权限

chown -R elasticsearch:elasticsearch elasticsearch-6.6.0

进入elasticsearch-6.6.0/bin目录

cd elasticsearch-6.6.0/bin

切换用户

如果用root用户,会报错

su elasticsearch

启动elasticsearch

./elasticsearch

打开新的终端curl测试

curl 127.0.0.1:9200
{
  "name" : "ihfrmHG",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "ZaeOC9IoTviJVT6m-bkWkg",
  "version" : {
    "number" : "6.6.0",
    "build_flavor" : "default",
    "build_type" : "tar",
    "build_hash" : "a9861f4",
    "build_date" : "2019-01-24T11:27:09.439740Z",
    "build_snapshot" : false,
    "lucene_version" : "7.6.0",
    "minimum_wire_compatibility_version" : "5.6.0",
    "minimum_index_compatibility_version" : "5.0.0"
  },
  "tagline" : "You Know, for Search"
}

后台启动方式

elasticsearch -d
#或
elasticsearch &

如果启动发现cup飞快飙。
有可能是内存不足的问题,可以调整一下

OpenJDK 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=N

分析:
看到GC的错误,判断应该是内存问题
free看了服务器的内存本身只有1个G
查看了elasticsearch的内存设定
vim /etc/elasticsearch/jvm.options
当前设置的是需要占用1个g
-Xms1g
-Xmx1g

解决方案:
修改elasticsearch占用的的内存参数
vim /etc/elasticsearch/jvm.options
-Xms512m
-Xmx512m

关于PHP的使用,可以在下一章节查看

你可能感兴趣的:(elasticsearch,Php,Linux)