您的位置:首页 > 编程语言 > PHP开发

mac下elasticsearch安装日记

2016-07-27 16:18 731 查看
1,安装java运行环境

2,下载elasticsearch
https://download.elastic.co/elasticsearch/elasticsearch/elasticsearch-1.6.0.tar.gz

3,启动elas

./bin/elasticsearch -d


4,laravel 下安装扩展包,安装elasticsearch-php,添加php api扩展
composer安装报错
[Composer\Downloader\TransportException] 
  Content-Length mismatch 

是因为默认请求的是国外的数据源,解决,在composer.json中添加composer扩展包中国镜像,
"repositories": {
        "packagist": {
            "type": "composer",
            "url": "https://packagist.phpcomposer.com"
        }
    }
然后再更新
php composer.phar require "elasticsearch/elasticsearch:~2.0"

使用
use Elasticsearch;
use Elasticsearch\ClientBuilder;

$client = Elasticsearch\ClientBuilder::create()->build();

        $params = [
            'index' => 'twitter',
            'type' => 'tweet',
            'id' => '1'
        ];

        $response = $client->get($params);
5,安装marvel监控
进入elastic目录,
cd /Users/xxx/Downloads/elasticsearch/bin/
./plugin -i elasticsearch/marvel/latest

查看监控
http://localhost:9200/_plugin/marvel/kibana/index.html#/dashboard/file/marvel.overview.json

开发者控制台
http://localhost:9200/_plugin/marvel/sense/
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  elasticsearch php composer