core 할당

Linux 2015. 3. 11. 14:40

멀티코어 linux에서 코어를 할당하는 방법:


taskset -pc {해당 process를 
기동할 core 번호} process-pid

) taskset -pc 0 {process-pid}




만약 cloud상의 VM상에서

이와 같이 특정 core에 할당한 후에는 해당 VM reboot하여야 하며

isolcpus 옵션grub.conf 파일에 추가되어서 VM이 생성되어야 한다. 


<grub.conf>

# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE: You have a /boot partition. This means that
# all kernel and initrd paths are relative to /boot/, eg.
# root (hd0,0)
# kernel /vmlinuz-version ro root=/dev/mapper/VolGroup-lv_root
# initrd /initrd-[generic-]version.img
#boot=/dev/xvda
default=1
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title CentOS (2.6.32-431.3.1.el6.x86_64)
root (hd0,0)
kernel /vmlinuz-2.6.32-431.3.1.el6.x86_64 ro root=/dev/mapper/VolGroup-lv_root rd_NO_LUKS LANG=en_US.UTF-8 rd_NO_MD console=hvc0 KEYTABLE=us rd_LVM_LV=VolGroup/lv_swap SYSFONT=latarcyrheb-sun16 crashkernel=auto rd_LVM_LV=VolGroup/lv_root rd_NO_DM rhgb quiet isolcpus=0
initrd /initramfs-2.6.32-431.3.1.el6.x86_64.img
title CentOS (2.6.32-358.14.1.el6.x86_64)
root (hd0,0)
kernel /vmlinuz-2.6.32-358.14.1.el6.x86_64 ro root=/dev/mapper/VolGroup-lv_root rd_NO_LUKS LANG=en_US.UTF-8 rd_NO_MD console=hvc0 KEYTABLE=us rd_LVM_LV=VolGroup/lv_swap SYSFONT=latarcyrheb-sun16 crashkernel=auto rd_LVM_LV=VolGroup/lv_root rd_NO_DM rhgb quiet isolcpus=0
initrd /initramfs-2.6.32-358.14.1.el6.x86_64.img
title CentOS (2.6.32-279.2.1.el6.x86_64)
root (hd0,0)
kernel /vmlinuz-2.6.32-279.2.1.el6.x86_64 ro root=/dev/mapper/VolGroup-lv_root rd_NO_LUKS LANG=en_US.UTF-8 rd_NO_MD console=hvc0 KEYTABLE=us rd_LVM_LV=VolGroup/lv_swap SYSFONT=latarcyrheb-sun16 crashkernel=auto rd_LVM_LV=VolGroup/lv_root rd_NO_DM rhgb quiet isolcpus=0
initrd /initramfs-2.6.32-279.2.1.el6.x86_64.img
title CentOS (2.6.32-279.el6.x86_64)
root (hd0,0)
kernel /vmlinuz-2.6.32-279.el6.x86_64 ro root=/dev/mapper/VolGroup-lv_root rd_NO_LUKS LANG=en_US.UTF-8 rd_NO_MD console=hvc0 KEYTABLE=us rd_LVM_LV=VolGroup/lv_swap SYSFONT=latarcyrheb-sun16 crashkernel=auto rd_LVM_LV=VolGroup/lv_root rd_NO_DM rhgb quiet isolcpus=0
initrd /initramfs-2.6.32-279.el6.x86_64.img

Posted by yongary
,

-F_ 없어도 됨(2210)

echo ${JOB_NAME} | awk -F_ '{print $3}' |xargs -I {} rm -rf /tmp/doxygen/{}; 

 

수많은 프로세스들 한방에 죽이기

ps -ef | grep 키워드 | awk '{print $2}' | xargs -I {} sudo kill {}

 

find . -name "*.js" -print  | xargs grep -n         keywordToFind

                   (filename)           (linenumber)   

 

Posted by yongary
,

$mongo 해서 client접속하면..

>show tables 


  //이 중에서  heart  category(테이블)을

  /user:"kim", pic:1, heart:20, date:'20140303'   이러한 테이블(category)로 가정.  (_id는 자동 삽입됨. _class도 간혹 자동삽입-코드일경우)



> db.heart.find()    -> 전체 record list.


> db.heart.find().sort( {pic:1} )    -> 전체 리스트를 pic필드로 asending 소팅.


> db.heart.find().limit(2)  -> 리스트 중 2개만 출력.   

                             =  db.heart.aggregate({ $limit:2 }) 


> db.heart.distinct("user")   ->  [ "kim", "lee" ]

> db.heart.distinct("user").length   ->   2



> db.heart.aggregate({     $group:{_id:"$pic"}      })  ->  pic필드를 기준으로 그루핑.  ({ => ([{ 이렇게 대괄호 추가가능.(이전버전인듯)


db.heart.aggregate({     $group:{ _id:"$pic", heartSum:{$sum:"$heart"} }      })  -> 각 그룹별로 heartSum산출.


   -->복합 aggregate

> db.heart.aggregate(    

{$group:{ _id:"$pic", heartSum:{$sum:"$heart"} }},

{$sort:{"hearts":1}},

{$limit:2}

)



//일반적인  Query .

db.inventory.find( { type: 'food', price: { $lt: 9.95 } } )



//aggregate에 Query  추가.

db.heart.aggregate(

bla.. bla..    ,

{ $match : { score : { $gt : 70, $lte : 90 } } }

)




///////spring-data-mongo에서 적용시에는

    AggregationOperation match = Aggregation.match(Criteria.where("service").is("EFT").and("source").is("MARKUP"));
    AggregationOperation group = Aggregation.group("card_acceptor").and("amount_sum").sum("amount").and("tran_count").count();
    Aggregation aggregation = newAggregation(match, group);
    AggregationResults<StoreSummary> result = this.mongoTemplate.aggregate(aggregation, "eft_transactions", StoreSummary.class);


Posted by yongary
,

hdfs 실행 및 report

Hadoop 2015. 2. 28. 20:34

<설치 후, 첫 실행. >

sudo /usr/local/hadoop-2.5.0/sbin/start-dfs.sh



<상태 check>

 $hdfs dfsadmin -report 



<웹브라우저에서 확인.>

http://localhost:50070/ 



<HDFS 명령어>

$hdfs dfs -ls /

$hdfs dfs -mkdir /myTest


$hdfs dfs -put test.txt /




<Hadoop 명령어>

$hadoop fs -mkdir /wordCount

$hadoop fs -copyFromLocal wordCount.jar /wordCount

$hadoop fs -ls  



$hadoop jar wordCount.jar wordCount[main class]  /wordCount[folder]  /wordCount/output  [out folder]




Posted by yongary
,

sudo apt-get, rpm

Linux 2015. 2. 28. 17:36

openssh-server를 설치하려고 하니..

    openssh-server : Depends: openssh-client (= 1:6.6p1-2ubuntu1)  이런 에러가 뜬다.


이런 경우 다음방식으로 client를 먼저 설치하면 된다.

sudo apt-get install openssh-client=1:6.6p1-2ubuntu1



그외 sudo apt-get 명령어는


sudo apt-get --reinstall install xx

sudo apt-get remove xx


설치된 놈 조회

/var/cache/apt/archives  여기서 ls로 검색.  ?

  안될때는.. 그냥 sudo  apt-cache search blabla  로...하면 됨.



java여러개 깔아서 하나 선택시에는 

 sudo update-alternatives --config java

 sudo update-alternatives --config javac   이렇게 2번.




<서버에서 조회>

sudo apt-cache search xx

sudo apt-cache show xx


(apt-get 이 잘 안될때는)

sudjo apt-get dist-upgrade : 서버목록 업그레이드

sudo apt-get update    : 목록 index update.

 


.deb 파일을 받아서 직접 설치하는 경우는

sudo dpkg -i *.deb   로 하면된다.   참고: http://egloos.zum.com/mcchae/v/10795420



 

<CentOS>에서는


일반적으로는 $yum install blabla로 하면된다.


rpm패키지 파일을 구했을때는 아래와 같이 한다.


rpm -qa | grep xx  정보조회

rpm -ivh xx.rpm  설치

rpm -e xx 제거


 

Posted by yongary
,

Hadoop

Hadoop 2015. 2. 26. 14:15

Hadoop : MapReduce parallelDB 장점을 모두 지님

               (DB가 스키마onWrite이라면, 하둡은 스키마onRead 이다)

  • HDFS : Data Centric Computing - 데이터 사이즈가 크므로 데이터 있는 곳으로 이동해서 계산함

         : write-Once, read-many,   noUpdate-but-Append.
         :
디폴트는 3개의 replica.(다른 racki) - client 가까운데서 읽음.

         : metaData (NameNode=Master라고 부르며- single관리되므로 중요..) 모두 in-Memory.
         :  dataNode=Slave(
들도 각자의 metaData 보관함.)

-디폴트 128Mega block들로 구성

- CRC32체크로 분산데이타체크함.

- 512byte단위로 checksum관리해서 매번 체크함

 

          ?secodary Name Node?



   - Map & Reduce  utubeREF - 카드로설명

                 : Map-데이터 있는 곳으로 프로그램이 가서 동작하는 개념.

                 : Reduce-계산이 끝나면 다시 분리




youtube소개  REF: 25petaByte까지 저장가능, 4500개 머신까지 동작가능.

                     Pig - 컴파일러

Hive - SQL유사 I/F

HBase - top level apache project   -  메신저 메세지는 object형태로 저장가능 


HCatalog - 메타data서버 (Hive에서 분리되어 나옴)

                             



                      기타) Mahout - 머신 러닝 libray for MapReduce

                                Ambari, Galnglia, Nagios - cluster분석 툴

                                Sqoop - RDB와 I/F 툴

Cascading - 트랜스레이팅 툴 for Pig..?

Oozie - 스케줄러. workflow 코디네이션.. 언제 실행할지 등.

Flume - 스트리밍 input for Hadoop

Protobuf, Avro, Thrift 를 지원. 

Fuse-DFS : os 레벨 access지원. 


      


Posted by yongary
,

가상화는 반가상화(para virtualization)과 전가상화(HVM)으로 나뉜다.

(추가적으로 type1:native,bare-metal 방식과 type2:hosted로 나누기도 하는데,

hostOS가 필요없는 type1: Xen, hostOS가 필요한 type2: KVM 이다 :  REF-NEW  REF-SITE )

 

REF-SITE2(AWS guide)


cloudStack + Xen으로 대표되는 반가상화 방식이 우수했으나, 내가 느낀 약간의 단점은

단점1. Xen의 네트웍 delay, 

단점2. fork시 시간지연 



최근 openstack + KVM의 전가상화가  이것을 극복하는 모습니다.


원래는 전가상화가 Mgmt에서 HW와 guestOS간의 바틀넥이 될 수 있으나,

KVM은 linux자체를 변형해서 만든 hypervisor인 만큼 이 문제가 적어 보인다.



openstack + KVM구성도:

(여기서 VM process는 QEMU 위에 올라가게 된다)




Posted by yongary
,

IMS Registration

IMS 2015. 2. 17. 11:05

단말이 IMS 시스템에서 서버에 등록을 하는 절차.

(VoLTE 통화를 위해서, 단말과 서버간의 사전 절차이다.

VoLTE는 데이타망과 유사한 통화전용LTE망  위에서 통화를 하는 것이므로, VoIP라고 볼 수도 있고,

기존의 CS망에서 통화하던게 발전한 것이므로 일반통화라고 볼 수도 있을 것 같은데.. 

아무래도 기본 통화로 상용되다 보니 VoIP라고 잘 부르진 않는다. )


 

1. 단말이 서버로 ID를 보낸다 (First Regi,  integrity_protected필드=no)


2. 서버(CSCF)에서 401 unAuthorized 응답을 보낸다


3. 단말이 401응답속의 nonce(challenge)필드 값을 이용해서 도전과제를 풀어서 올린다. (Second Regi, integrity_protected필드=yes)


4. 서버(CSCF)에서 200OK를 보낸다.




이 중에서 3번 항목을 살펴보면

단말의 SIM에는 PUID(고유ID: From필드에 사용), PRID(인증용 ID: userName 필드에사용) 및 key, ck(암호키), ik(변조체크 키) 가 있는데

3번의 과정에서는 ck,ik,nonce+ 이것들을 이용해서 계산된 결과가 올라간다.

서버는 이 결과가 원하는 답이 맞을 경우 Regi를 해 주게 된다.  



<인증 방식>

인증 방식에는 aka인증과 md5 인증이 있는데

요즘 단말들이 aka인지 md5인지를 결정하여 올려주는 관계로,  차이만 본다면


aka: 위에 언급한 것처럼 sim을 이용해서 인증.  nonce이용

md5: 좀 더 간단한 인증으로 nonce가 아니고 n-nonce 필드를 이용. 

Posted by yongary
,

javascript 상속

javascript 2015. 2. 4. 21:46

javascript에서의 상속은 일반적인 OO와 다르다.

그 이유는 javascript가 OO 언어가 아니고, 함수(prototype)기반 언어라서 그러하다.


대신, prototype과  prototype.constructor를 치환하는 방법으로 상속이 구현 가능하다.



<<예제>>

    function AjaxBasic(){

        if ( window.XMLHttpRequest){

            this.xhr = new XMLHttpRequest();

        }else{

            console.log("NO XHR support maybe ~ IE6");

            return;

        }

        this.xhr.onreadystatechange=function(){

            if (ajaxObj.xhr.readyState==4 && ajaxObj.xhr.status==200)

                document.body.innerHTML=ajaxObj.xhr.responseText;

        }

        //// method..  run()

        this.run = function(){ 

            this.xhr.open("GET", "test_data.txt", true);

            this.xhr.send();

        }

    }


    function MyAjax(){

        this.run = function(fileUrl){

            ajaxObj.xhr.open("GET", fileUrl, true);

            ajaxObj.xhr.send();

        }

    }



   ///Inherit =  prototype + constructor

    MyAjax.prototype = new AjaxBasic();

    MyAjax.prototype.constructor = MyAjax();


Posted by yongary
,

ajax

javascript 2015. 2. 4. 21:31

간단한 ajax .


function makeRequest(url)
{
    var xhr = new XMLHttpRequest();
    xhr.open("GET", url, true);  //true is A of Ajax=Async
    xhr.onreadystatechange = receiveResponse;
    xhr.send();
}
function receiveResponse(e)
{
    if (this.readyState == 4) //4:complete
    {
        if (this.status == 200) //200 ok
        {
            var response = this.responseXML;
            ...
        }
    }
}


웹페이지 버튼 콜백 ajax ( JQuery 경우)  - 아래에서 CDATA는 없어도 됨. 

<script type="text/javascript" th:inline="javascript">
/*<![CDATA[*/
$(function () {
$('.clear-cache').click(function () {
$.ajax({
type: "POST",
url: "/api/internal/v1/clear_cache/banner",
success: function () {
$('#clearCacheModal').modal('show');
}
});
});
});
/*]]>*/
</script>


Posted by yongary
,