2017年5月18日 星期四

[elasticsearch] install elasitcsearch license

x-pack 裝好後預設的 license 是30天,
可以使用 api 查看 license 。
curl -XGET localhost:9200/_xpack/license
{"license": {"status": "active","uid": "300e8b22-5a2a-4def-8e76-3b494eb3638b","type": "trial","issue_date": "2017-05-05T09:35:02.607Z","issue_date_in_millis": 1493976902607,"expiry_date": "2017-06-04T09:35:02.607Z","expiry_date_in_millis": 1496568902607,"max_nodes": 1000,"issued_to": "pg_search","issuer": "elasticsearch","start_date_in_millis": -1}}

想要使用 license 可以到下面網站註冊,目前的free basic plan 有提供基本的功能。
Register | Elastic https://register.elastic.co/
license 的時間是一年。

Your Basic license will expire on May 19, 2018.

申請好,會寄送link 到信箱中,下載後。
使用下面api 去安裝 license
curl -XPUT -u elastic 'http://localhost:9200/_xpack/license' -H "Content-Type: application/json" -d @pc-liao--v5.json

如果出現下面的提示訊息,
Enter host password for user 'elastic':
{"acknowledged":false,"license_status":"valid","acknowledge":{"message":"This license update requires acknowledgement. To acknowledge the license, please read the following messages and update the license again, this time with the \"acknowledge=true\" parameter:","watcher":["Watcher will be disabled"],"security":["The following X-Pack security functionality will be disabled: authentication, authorization, ip filtering, and auditing. Please restart your node after applying the license.","Field and document level access control will be disabled.","Custom realms will be ignored."],"monitoring":["Multi-cluster support is disabled for clusters with [BASIC] license. If you are\nrunning multiple clusters, users won't be able to access the clusters with\n[BASIC] licenses from within a single X-Pack Kibana instance. You will have to deploy a\nseparate and dedicated X-pack Kibana instance for each [BASIC] cluster you wish to monitor.","Automatic index cleanup is locked to 7 days for clusters with [BASIC] license."],"graph":["Graph will be disabled"]}}

可以使用

curl -XPUT -u elastic 'http://localhost:9200/_xpack/license?acknowledge=true' -H "Content-Type: application/json" -d @pc-liao--v5.json




2017年5月8日 星期一

[php] How to curl DELETE method request


要怎麼在 php  中 使用 CURL 送出 DELETE 呢?
可以在 curl_setopt 中 更改 CURLOPT_CUSTOMREQUEST 為 DELETE
        curl_setopt($this->handle, CURLOPT_CUSTOMREQUEST, "DELETE");

下面提供一個範例。

public function curl_del($path)
{

    $url =$this->__url.$path;
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL,$url);
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE");
    $result = curl_exec($ch);
    $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    curl_close($ch);

    return $result;
}
http - PHP CURL DELETE request - Stack Overflow


若是連續curl 發現 request 的 type 並沒有被 reset ,可能出現了下列問題。
試著把 CURLOPT_CUSTOMREQUEST 設成 NULL
curl_setopt($this->handle, CURLOPT_CUSTOMREQUEST, NULL);

Allow NULL as value for CURLOPT_CUSTOMREQUEST option. by datibbaw · Pull Request #531 · php/php-src · GitHub https://github.com/php/php-src/pull/531

[php] solr client install


使用 pecl 安裝

pecl install -n solr

然後在 /etc/php.ini 中 設定好 extension_dir = 的位置

736 extension_dir = "/usr/lib64/php/modules/"

PHP Solr PECL Extension installation - Stack Overflow
http://stackoverflow.com/questions/19750343/php-solr-pecl-extension-installation


途中有遇到兩個問題跟解決方式

configure: error: Please reinstall the libcurl distribution -
easy.h should be in <curl-dir>/include/curl/
安裝 curl-devel yum -y install curl-devel

configure: error: xml2-config not found. Please check your libxml2 installation. 安裝 libxml2 libxml2-devel
yum -y install libxml2 libxml2-devel

[php] PHP Warning: PHP Startup: Unable to load dynamic library 問題



若出現
PHP Warning: PHP Startup: Unable to load dynamic library
很可能是 /etc/php.ini 中 extension= 的位置設錯了或是裡面的so 檔案無法使用



[php] Call to undefined function mb_strlen() 的解決方式


使用 php -m 去看一下有相關的 extension 嗎
或是使用
<?php
phpinfo();

來確認 php 的 extension 有哪些。

若是已經有安裝 extension
可以找出來位置,在 /etc/php.ini 加入位置

 736 extension_dir = "/usr/lib64/php/modules/"

若是沒有
使用 php55w-mbstring.x86_64

$yum install php56w-mbstring
(可以先使用 yum search 去找出適合安裝的 package)

找出 modules 安裝在哪

[root@c1 vagrant]# rpm -ql php56w-mbstring
/etc/php-zts.d/mbstring.ini
/etc/php.d/mbstring.ini
/usr/lib64/php-zts/modules/mbstring.so
/usr/lib64/php/modules/mbstring.so
/usr/share/doc/php56w-mbstring-5.6.30
/usr/share/doc/php56w-mbstring-5.6.30/libmbfl_LICENSE
/usr/share/doc/php56w-mbstring-5.6.30/oniguruma_COPYING
/usr/share/doc/php56w-mbstring-5.6.30/ucgendat_LICENSE

設定好後。

[root@c1 vagrant]# php -m
[PHP Modules]
bz2
calendar
Core
ctype
curl
date
dom
ereg
exif
fileinfo
filter
ftp
gettext
gmp
hash
iconv
igbinary
json
libxml
mbstring
mhash
mysql
mysqli
openssl
pcntl
pcre
PDO
pdo_mysql
pdo_sqlite
Phar
posix
readline
redis
Reflection
session
shmop
SimpleXML
sockets
solr
SPL
sqlite3
standard
sysvmsg
sysvsem
sysvshm
tokenizer
wddx
xml
xmlreader
xmlwriter
xsl
zip
zlib

[Zend Modules]

2017年5月3日 星期三

[linux] ubutnu 16.04 讀取 exfat


插入隨身碟後出現下列訊息

Command-line `mount -t "exfat" -o "uhelper=udisks2,nodev,nosuid,uid=1000,gid=1000,iocharset=utf8,namecase=0,errors=remount-ro,umask=0077" "/dev/sdg3" "/media/peicheng/Elements 2"' exited with non-zero exit status 32: mount: unknown filesystem type 'exfat'

Ubuntu 16.04 預設情況下,不能讀取 exfat ,install exfat 相關的 package 。
$ sudo apt install exfat-utils exfat-fuse