SIGINT 라고 가끔 본 적이 있을 것이다.
이 것은 Interrupt 시그널을 의미한다.
Interrupt (^c) 시그널은 2
Quit (^\) 시그널은 3
EOF(or Exit ^D) 시그널은 1
이 중에서 2,3번 시그널이 shell script가 도는 동안에 동작안하게 하고 싶으면..
trap "" 2 3 <- 이렇게 무시를 걸어 놓으면 된다.
trap 2 3 reset <-shell script종료 후에는
SIGINT 라고 가끔 본 적이 있을 것이다.
이 것은 Interrupt 시그널을 의미한다.
Interrupt (^c) 시그널은 2
Quit (^\) 시그널은 3
EOF(or Exit ^D) 시그널은 1
이 중에서 2,3번 시그널이 shell script가 도는 동안에 동작안하게 하고 싶으면..
trap "" 2 3 <- 이렇게 무시를 걸어 놓으면 된다.
trap 2 3 reset <-shell script종료 후에는
Linux c개발시 shm 사용방법.
shmget : malloc 처럼 공유메모리 생성
shmat : 생성된 공유메모리를 해당 프로세서로 가져옴(첨부-attach)
shmdt : 가져온 메모리를 다시 반납. (분리-detach )
Linux를 하다보면, 터미널로 접속해서 프로세스를 실행시키고,
나중에 다시 접속해보면.. 죽어있는 경우가 있다.
- 백그라운드로 실행해도 그러하다..
( 백그라운드 실행은 명령어 뒤에 & 추가=> $shell.sh & )
이럴경우
1. nohup으로 실행 : $nohup shell.sh &
2. screen명령어로 실행.(화면까지 보존)
-------screen 사용법--------------
screen -S 스크린네임.
ctrl+a=>c생성
ctrl+a=>shift+a타이틀변경
ctrl+a=>shift+" 리스트
선택
ctrl+a=>c화면 클리어
ctrl+a=>d 나가기(리스트는 있고, 모드만 종료)
screen -r 모드진입(리스트 출력)
ctrl+a=>shift+" 리스트
ctrl+a=>shift+k 리스트선택 종료.
ctrl+a=>Shift+s 화면 분활 화면
ctrl+a=>tab 으로 화면 이동
ctrl+a=>shift+q 종료
ctr
volatile 키워드는 멀티thread시에 도움이 된다.
1. 읽고 쓰기에 대한 원자성. ( byte단위의 원자화는 보장함. alignment는 맞춰줌. )
2. 컴파일러의 임의 리오더링을 방지.
반면,
synchronized는 블록으로 묶인 부분 혹은 변수를 원자화(makes atomic ) 함.
<Wikipedia singleTon 예제>
public class SingletonDemo {
private static volatile SingletonDemo instance = null;
private SingletonDemo() { }
public static SingletonDemo getInstance() {
if (instance == null) {
synchronized (SingletonDemo.class){
if (instance == null) {
instance = new SingletonDemo();
}
}
}
return instance;
}
}
TDD : Test Driven Development
=> 웹 자동화 테스트툴- Sellinium.
BDD: Behavior Driven Development
=> Cucumber.
멀티코어 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
-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)
$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);
<설치 후, 첫 실행. >
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]
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 제거