'2016/06'에 해당되는 글 6건

  1. 2016.06.30 [Jenkins] Jenkins CLI 사용
  2. 2016.06.28 [Elasticsearch] This Week in Elasticsearch and Apache Lucene - 2016-06-27
  3. 2016.06.27 [Javascript] English to Korean (영문 한글 전환)
  4. 2016.06.24 [AWS] Instance register/deregister on AWS ELB
  5. 2016.06.20 [Elasticsearch] Aggregation name ?
  6. 2016.06.07 [AWS] JVM 타임존 설정 이슈

[Jenkins] Jenkins CLI 사용

ITWeb/개발일반 2016. 6. 30. 20:05

aws 를 이용하다 보니 배포를 터미널에서 해야할 일이 종종 있습니다.

그래서 기록해 봅니다.


Jenkins에서 제공하는 CLI 기능을 이용합니다.

보통 Jenkins 를 설치 하시면 admin 으로 로그인 하셔서 Jenkins 관리로 들어 갑니다.

들어 가면, 바로 Jenkins CLI 메뉴가 눈에 들어 옵니다.


[SSH Public Key 등록]

jenkins user 설정 에서 ssh key 등록을 하셔야 합니다.


[Jenkins CLI 링크]

http://localhost:8080/jenkins/cli/


[Jenkins 기본 배포]

$ java -jar jenkins-cli.jar -s http://localhost:8080/jenkins/ build ${JOB_NAME} -s -v --username ${LOGIN_ID} --password ${LOGIN_PASSWORD}

- ${JOB_NAME} 은 처음에 item 만들때 작성하신 이름입니다. (jenkins view에 나오는 목록의 이름)



[Jenkins 기본 배포 + 파라미터 설정]

$ java -jar jenkins-cli.jar -s http://localhost:8080/jenkins/ build ${JOB_NAME} -s -v -p ${PARAM_NAME}="${PARMA_VALUE}" --username ${LOGIN_ID} --password ${LOGIN_PASSWORD}


[jenkins-cli.jar 위치]

jenkins 설치한 위치에서 webapps/jenkins/WEB-INF 아래 위치해 있습니다.


링크를 클릭하면 아래와 같은 화면을 보실 수 있습니다.


[Jenkins CLI 화면]

You can access various features in Jenkins through a command-line tool. See the Wiki for more details of this feature.To get started, download jenkins-cli.jar, and run it as follows:

java -jar jenkins-cli.jar -s http://52.196.187.249:8181/jenkins/ help

Available Commands

add-job-to-viewAdds jobs to view.
buildBuilds a job, and optionally waits until its completion.
cancel-quiet-downCancel the effect of the "quiet-down" command.
clear-queueClears the build queue.
connect-nodeReconnect to a node(s)
consoleRetrieves console output of a build.
copy-jobCopies a job.
create-credentials-by-xmlCreate Credential by XML
create-credentials-domain-by-xmlCreate Credentials Domain by XML
create-jobCreates a new job by reading stdin as a configuration XML file.
create-nodeCreates a new node by reading stdin as a XML configuration.
create-viewCreates a new view by reading stdin as a XML configuration.
delete-buildsDeletes build record(s).
delete-credentialsDelete a Credential
delete-credentials-domainDelete a Credentials Domain
delete-jobDeletes job(s).
delete-nodeDeletes node(s)
delete-viewDeletes view(s).
disable-jobDisables a job.
disconnect-nodeDisconnects from a node.
enable-jobEnables a job.
get-credentials-as-xmlGet a Credentials as XML (secrets redacted)
get-credentials-domain-as-xmlGet a Credentials Domain as XML
get-gradleList available gradle installations
get-jobDumps the job definition XML to stdout.
get-nodeDumps the node definition XML to stdout.
get-viewDumps the view definition XML to stdout.
groovyExecutes the specified Groovy script.
groovyshRuns an interactive groovy shell.
helpLists all the available commands or a detailed description of single command.
install-pluginInstalls a plugin either from a file, an URL, or from update center.
install-toolPerforms automatic tool installation, and print its location to stdout. Can be only called from inside a build.
keep-buildMark the build to keep the build forever.
list-changesDumps the changelog for the specified build(s).
list-credentialsLists the Credentials in a specific Store
list-credentials-context-resolversList Credentials Context Resolvers
list-credentials-providersList Credentials Providers
list-jobsLists all jobs in a specific view or item group.
list-pluginsOutputs a list of installed plugins.
loginSaves the current credential to allow future commands to run without explicit credential information.
logoutDeletes the credential stored with the login command.
mailReads stdin and sends that out as an e-mail.
offline-nodeStop using a node for performing builds temporarily, until the next "online-node" command.
online-nodeResume using a node for performing builds, to cancel out the earlier "offline-node" command.
quiet-downQuiet down Jenkins, in preparation for a restart. Don’t start any builds.
reload-configurationDiscard all the loaded data in memory and reload everything from file system. Useful when you modified config files directly on disk.
reload-jobReload job(s)
remove-job-from-viewRemoves jobs from view.
replay-pipelineReplay a Pipeline build with edited script taken from standard input
restartRestart Jenkins.
safe-restartSafely restart Jenkins.
safe-shutdownPuts Jenkins into the quiet mode, wait for existing builds to be completed, and then shut down Jenkins.
session-idOutputs the session ID, which changes every time Jenkins restarts.
set-build-descriptionSets the description of a build.
set-build-display-nameSets the displayName of a build.
set-build-parameterUpdate/set the build parameter of the current build in progress.
set-build-resultSets the result of the current build. Works only if invoked from within a build.
set-external-build-resultSet external monitor job result.
shutdownImmediately shuts down Jenkins server.
update-credentials-by-xmlUpdate Credentials by XML
update-credentials-domain-by-xmlUpdate Credentials Domain by XML
update-jobUpdates the job definition XML from stdin. The opposite of the get-job command.
update-nodeUpdates the node definition XML from stdin. The opposite of the get-node command.
update-viewUpdates the view definition XML from stdin. The opposite of the get-view command.
versionOutputs the current version.
wait-node-offlineWait for a node to become offline.
wait-node-onlineWait for a node to become online.
who-am-iReports your credential and permissions.


:

[Elasticsearch] This Week in Elasticsearch and Apache Lucene - 2016-06-27

Elastic/Elasticsearch 2016. 6. 28. 09:53

몇 가지 눈에 들어 오는게 있어서 scrap 합니다.


[원문]

https://www.elastic.co/blog/this-week-in-elasticsearch-and-apache-lucene-2016-06-27


[요점]

- low-level Java REST client has landed.

별도의 http client 를 이용해서 만들지 않고 es 에서 제공하는거 사용하면 될 것 같습니다.


- index.store.preload

warmmer 기능이 이걸로 대체 되는 것 같습니다.


- no longer turns red when creating an index

순간 red 나올 때가 있었는데 false alarm 이 줄어 들겠내요.


- default similarity is now BM25

TF/IDF 에서 BM25로 넘어 가는 군요.


- wait for status yellow

yellow 도 간혹 발생을 하는데 앞으로 status 에 대해서 다시 점검을 해야 겠내요.


Elasticsearch Core

Changes in 2.x:


Changes in master:


Ongoing changes:

    Apache Lucene


    :

    [Javascript] English to Korean (영문 한글 전환)

    ITWeb/검색일반 2016. 6. 27. 23:51

    필요해서 구글링으로 퍼왔습니다.

    기본적으로는 한글 자모 분리 기능 구현을 사용한다고 보시면 됩니다.


    아래 코드 중 구글링으로 퍼온 코드에서 읽기 쉽도록 약간의 변수명등 수정을 했습니다.

    자바스크립트에서 function 선언에 대한 기본 이해를 하시면 코드 보기가 더 쉽습니다.


    <html>

    <head></head>

    <script>

    var convertEngToKor = function(args) {

    var engChosung = "rRseEfaqQtTdwWczxvg"

    var engChosungReg = "[" + engChosung + "]";

    var engJungsung = {k:0,o:1,i:2,O:3,j:4,p:5,u:6,P:7,h:8,hk:9,ho:10,hl:11,y:12,n:13,nj:14,np:15,nl:16,b:17,m:18,ml:19,l:20};

    var engJungsungReg = "hk|ho|hl|nj|np|nl|ml|k|o|i|O|j|p|u|P|h|y|n|b|m|l";

    var engJongsung = {"":0,r:1,R:2,rt:3,s:4,sw:5,sg:6,e:7,f:8,fr:9,fa:10,fq:11,ft:12,fx:13,fv:14,fg:15,a:16,q:17,qt:18,t:19,T:20,d:21,w:22,c:23,z:24,x:25,v:26,g:27};

    var engJongsungReg = "rt|sw|sg|fr|fa|fq|ft|fx|fv|fg|qt|r|R|s|e|f|a|q|t|T|d|w|c|z|x|v|g|";

    var regExp = new RegExp("("+engChosungReg+")("+engJungsungReg+")(("+engJongsungReg+")(?=("+engChosungReg+")("+engJungsungReg+"))|("+engJongsungReg+"))","g");


    var converter = function (args, cho, jung, jong) {

    return String.fromCharCode(engChosung.indexOf(cho) * 588 + engJungsung[jung] * 28 + engJongsung[jong] + 44032);

    };

    var result = args.replace(regExp, converter);

    console.log(result);

    return result;

    }


    function run(engStr) {

    convertEngToKor(engStr);

    }


    var convertEngToKor2 = (function () {

    var engChosung = "rRseEfaqQtTdwWczxvg"

    var engChosungReg = "[" + engChosung + "]";

    var engJungsung = {k:0,o:1,i:2,O:3,j:4,p:5,u:6,P:7,h:8,hk:9,ho:10,hl:11,y:12,n:13,nj:14,np:15,nl:16,b:17,m:18,ml:19,l:20};

    var engJungsungReg = "hk|ho|hl|nj|np|nl|ml|k|o|i|O|j|p|u|P|h|y|n|b|m|l";

    var engJongsung = {"":0,r:1,R:2,rt:3,s:4,sw:5,sg:6,e:7,f:8,fr:9,fa:10,fq:11,ft:12,fx:13,fv:14,fg:15,a:16,q:17,qt:18,t:19,T:20,d:21,w:22,c:23,z:24,x:25,v:26,g:27};

    var engJongsungReg = "rt|sw|sg|fr|fa|fq|ft|fx|fv|fg|qt|r|R|s|e|f|a|q|t|T|d|w|c|z|x|v|g|";

    var regExp = new RegExp("("+engChosungReg+")("+engJungsungReg+")(("+engJongsungReg+")(?=("+engChosungReg+")("+engJungsungReg+"))|("+engJongsungReg+"))","g");


    var converter = function (args, cho, jung, jong) {

    return String.fromCharCode(engChosung.indexOf(cho) * 588 + engJungsung[jung] * 28 + engJongsung[jong] + 44032);

    };


    return (function (args) {

    var result = args.replace(regExp, converter); 

    console.log(result);

    return result; 

    });

    })();


    function run2(engStr) {

    convertEngToKor2(engStr);

    }

    </script>

    <body>

    <input id="eng" value="skdlzl">

    <button onclick="run(document.getElementById('eng').value)">run</button>

    <button onclick="run2(document.getElementById('eng').value)">run2</button>

    </body>

    </html>


    코드를 보시면 아시겠지만, 영문으로 작성한 skdlrl(나이키) 를 한글 나이키로 변환해서 리턴해 주도록 해줍니다.

    보통 검색에서 자동완성 기능 구현 시 client side 에서 한영변환에 대한 기능으로 활용하기 위해 사용 합니다.


    :

    [AWS] Instance register/deregister on AWS ELB

    ITWeb/개발일반 2016. 6. 24. 18:19

    AWS에서 ELB 사용 시 instance 를 넣고 빼고 하는 CLI 예제 입니다.

    제가 필요해서 그냥 기록해 봅니다.


    [참조문서]

    http://docs.aws.amazon.com/cli/latest/reference/elb/index.html



    [AWS CLI 구성]

    https://aws.amazon.com/ko/cli/



    [AWS Configure]

    이 작업은 aws cli를 사용하기 위한 access key 와 secret access key 그리고 region 등록을 하게 됩니다.

    설정을 완료 하게 되면 user home 아래 .aws/config 파일이 생성 됩니다.


    # .awc/config
    [default]
    region = ap-northeast-1
    aws_secret_access_key = xxxxxxxxx
    aws_access_key_id = xxxxxxxx
    output = json


    - 여기서 주의 하실 점은 region 정보에 tokyo 에 있다고 tokyo 로 하시면 못찾습니다. 위 예시와 같이 작성해 주셔야 합니다.




    [AWS ELB 등록 정보]

    $ aws elb describe-load-balancers --load-balancer-name kr-search-memebox-com



    [AWS ELB 인스턴스 등록]

    $ aws elb register-instances-with-load-balancer
     --load-balancer-name
     ELB명 --instances INSTANCE명



    [AWS ELB 인스턴스 제거]

    $ aws elb deregister-instances-from-load-balancer

     --load-balancer-name ELB명 --instances INSTANCE명


    :

    [Elasticsearch] Aggregation name ?

    Elastic/Elasticsearch 2016. 6. 20. 18:09

    aggregation 을 많이 사용하시는 분들은 잘 아실것 같구요.

    그냥 기본만 사용하시는 분들에게는 생소할 수 있어서 그냥 정리해 봤습니다.


    참고문서)

    https://www.elastic.co/guide/en/elasticsearch/reference/2.3/search-aggregations.html#_structuring_aggregations


    "aggregations" : { "<aggregation_name>" : { "<aggregation_type>" : { <aggregation_body> } [,"meta" : { [<meta_data_body>] } ]? [,"aggregations" : { [<sub_aggregation>]+ } ]? } [,"<aggregation_name_2>" : { ... } ]* 

    }


    여기서 "<aggregation_name>" 에 대한 내용입니다.

    이 값은 기본적으로 aggs 수행 후 return 될 때 사용되는 변수명을 지정하게 됩니다.

    간혹 aggregation_name 에 field 명을 주시는 경우가 있을 수 있는데요. 안되는 것은 아니지만 해당 변수에 대한 정확한 용도를 알고 사용하시면 더 좋겠다 싶어서 글 남겨 봤습니다.


    /**

     * Constructs a new aggregation builder.

     *

     * @param name  The aggregation name

     * @param type  The aggregation type

     */

    public AggregationBuilder(String name, Type type) {

        if (name == null) {

            throw new IllegalArgumentException("[name] must not be null: [" + name + "]");

        }

        if (type == null) {

            throw new IllegalArgumentException("[type] must not be null: [" + name + "]");

        }

        this.name = name;

        this.type = type;

    }


    ...중략...


    @Override

    public final XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {

        builder.startObject(name);


        if (this.metaData != null) {

            builder.field("meta", this.metaData);

        }

        builder.field(type.name());

        internalXContent(builder, params);


        if (factoriesBuilder != null && (factoriesBuilder.count()) > 0) {

            builder.field("aggregations");

            factoriesBuilder.toXContent(builder, params);


        }


        return builder.endObject();

    }


    소스 코드를 보셔도 아시겠죠?

    XContentBuilder 에서 최상위 object name 에 aggregation_name 값을 지정하고 있습니다.


    그냥 제가 기억하기 위해 글 남기고 마무리 하겠습니다.


    :

    [AWS] JVM 타임존 설정 이슈

    ITWeb/개발일반 2016. 6. 7. 14:52

    aws 에서 인스턴스 생성 후 java program 에서 사용하던 Date 클래스에서의 시간이 잘 못 나오는 경우가 발생했습니다.

    shell 에서 $ date 하면 정상적으로 KST 기준으로 시간이 잘 표시되지만 java application 에서는 GMT 0 로 시간이 표시 되는 문제 입니다.


    해결 방법은 크게 두 가지 입니다.


    1) 소스 코드에서 timezone 지정을 해서 date 설정을 하는 것입니다.

    TimeZone timeZone;

    Date date = new Date();

    SimpleDateFormat simpleDateFormat = new SimpleDateFormat("MM.dd HH:mm");


    timeZone = TimeZone.getTimeZone("Asia/Seoul");

    simpleDateFormat.setTimeZone(timeZone);


    LOG.debug("{}", simpleDateFormat.format(date));


    2) 서버 인스턴스 상에서 timezone 설정을 다시 하는 것입니다.

    $ sudo tzselect


    5) Asia

    ...

    23) Korea (South)

    ...

    1) Yes

    ...


    $ vi .profile

     

    TZ='Asia/Seoul'

    export TZ


    - 우분투로 구성 하였기 때문에 timezone 구성은 위와 같이 진행 하였습니다.

    :