分类 工具源码 下的文章

elasticsearch.yml

##################################################################
# /etc/elasticsearch/elasticsearch.yml
#
# Base configuration for a write heavy cluster
#

# Cluster / Node Basics
cluster.name: logng

# Node can have abritrary attributes we can use for routing
node.name: logsearch-01
node.datacenter: amsterdam

# Force all memory to be locked, forcing the JVM to never swap
bootstrap.mlockall: true

## Threadpool Settings ##

# Search pool
threadpool.search.type: fixed
threadpool.search.size: 20
threadpool.search.queue_size: 100

# Bulk pool
threadpool.bulk.type: fixed
threadpool.bulk.size: 60
threadpool.bulk.queue_size: 300

# Index pool
threadpool.index.type: fixed
threadpool.index.size: 20
threadpool.index.queue_size: 100

# Indices settings
indices.memory.index_buffer_size: 30%
indices.memory.min_shard_index_buffer_size: 12mb
indices.memory.min_index_buffer_size: 96mb

# Cache Sizes
indices.fielddata.cache.size: 15%
indices.fielddata.cache.expire: 6h
indices.cache.filter.size: 15%
indices.cache.filter.expire: 6h

# Indexing Settings for Writes
index.refresh_interval: 30s
index.translog.flush_threshold_ops: 50000

# Minimum nodes alive to constitute an operational cluster
discovery.zen.minimum_master_nodes: 2

# Unicast Discovery (disable multicast)
discovery.zen.ping.multicast.enabled: false
discovery.zen.ping.unicast.hosts: [ "logsearch-01", "logsearch-02", "logsearch-03" ]

vagrant使用中遇到machine already exists,delete the machine with the existing name, and try again

vagrant用了很久了,今天第一次遇到问题,可能是因为Mac合盖导致了虚拟机假死,然后再次vagrant up时出了问题:

QQ20151224-0.png

字面意思是 导入box失败 因为已经存在。。。为啥要重新导入原始的box呢?

我手工打开 virtual box 虚拟机让你后手工关闭了 homestead
QQ20151224-1.png

然后重新执行 vagrant up问题依旧存在,而且还在 virtual box 里产生了新的box。

然后谷歌找到了方法,这里记录一下:

执行 vboxmanage list vms,得到虚拟机的id:
QQ20151224-2.png

把id复制出来,也就是大括号里面那一串,然后写到~/.vagrant/machines/default/virtualbox/id里面(谷歌里面是这么说的)
QQ20151224-3.png

再执行 vagrant up, 还是出错

我自己再尝试修改./.vagrant/machines/default/virtualbox/id(当前目录里面的,发现里面是另外一串id,改为上面正确的那一串)
QQ20151224-4.png

好使了,解决 mark 一记!

字符串全角半角转换

/**
* 字符串全角半角转换
* @param $str
* @param $type TODBC:转换为半角;TOSBC,转换为全角
*/
private function convert_str_type($str, $type)
{
    $dbc = array( //全角字典
        '0' , '1' , '2' , '3' , '4' ,
        '5' , '6' , '7' , '8' , '9' ,
        'A' , 'B' , 'C' , 'D' , 'E' ,
        'F' , 'G' , 'H' , 'I' , 'J' ,
        'K' , 'L' , 'M' , 'N' , 'O' ,
        'P' , 'Q' , 'R' , 'S' , 'T' ,
        'U' , 'V' , 'W' , 'X' , 'Y' ,
        'Z' , 'a' , 'b' , 'c' , 'd' ,
        'e' , 'f' , 'g' , 'h' , 'i' ,
        'j' , 'k' , 'l' , 'm' , 'n' ,
        'o' , 'p' , 'q' , 'r' , 's' ,
        't' , 'u' , 'v' , 'w' , 'x' ,
        'y' , 'z' , '-' , ' ' , ':' ,
        '.' , ',' , '/' , '%' , '#' ,
        '!' , '@' , '&' , '(' , ')' ,
        '<' , '>' , '"' , ''' , '?' ,
        '[' , ']' , '{' , '}' , '\' ,
        '|' , '+' , '=' , '_' , '^' ,
        '¥' , '~' , '`'
    );
    $sbc = array( //半角字典
        '0', '1', '2', '3', '4',
        '5', '6', '7', '8', '9',
        'A', 'B', 'C', 'D', 'E',
        'F', 'G', 'H', 'I', 'J',
        'K', 'L', 'M', 'N', 'O',
        'P', 'Q', 'R', 'S', 'T',
        'U', 'V', 'W', 'X', 'Y',
        'Z', 'a', 'b', 'c', 'd',
        'e', 'f', 'g', 'h', 'i',
        'j', 'k', 'l', 'm', 'n',
        'o', 'p', 'q', 'r', 's',
        't', 'u', 'v', 'w', 'x',
        'y', 'z', '-', ' ', ':',
        '.', ',', '/', '%', '#',
        '!', '@', '&', '(', ')',
        '<', '>', '"', '\'','?',
        '[', ']', '{', '}', '\\',
        '|', '+', '=', '_', '^',
        '¥','~', '`'
    );
    if($type == "TODBC"){
        return str_replace($sbc, $dbc, $str); //半角到全角
    }elseif($type == "TOSBC"){
        return str_replace($dbc, $sbc, $str); //全角到半角
    }else{
        return false;
    }
}

shell同步指定文件

#!/bin/sh
root='/Users/leandre/Desktop/work/test/r2/'
count=0
logpath='/Users/leandre/Desktop/work/test/online.log'
date=$(date +%Y-%m-%d_%H:%M:%S)
echo  $"----------------" >> $logpath
echo $date >> $logpath
for i in $*
    do
        path=$(dirname $i)
        if [ ! -d "${root}${path}" ];then
            mkdir -p ${root}${path}
        fi
        cp -a $i $root$path
        echo $i >> $logpath
        ((count++))
    done
echo $count" files copyed"