티스토리 툴바


1. IEclipsePreferences pref = new DefaultScope().getNode(Application.PLUGIN_ID);

String fontString = pref.get(preferenceName, null);

기본값만 읽어오는 코드 (org.eclipse.core.runtime.preferences 확장점의 PreferenceInitializer.initializeDefaultPreferences 에서 초기화한 것)

-> 변경 사항 저장이 안된다!


2. IEclipsePreferences pref = new ConfigurationScope().getNode(Application.PLUGIN_ID);

String fontString = pref.get(preferenceName, null);

설정값을 저장/읽기가능한 Scope

-> PreferencePage를 한번 띄우기 전엔 값이 NULL 이다.


위 두가지 문제가 있어 아래와 같이 해결하였다.


3. IPreferencesService service = Platform.getPreferencesService();

String fontString = service.getString(Application.PLUGIN_ID, preferenceName, Config.DEFAULT_GRID_FONT, null);

바뀐 값도 잘 읽어오고, 저장도 잘 된다.

(2번의 경우 원래 안되는 것은 아니고 lifecycle이나 구조에 대한 이해의 부족일 듯...)

Posted by Lawmin

SID 인식 불가로 Connection 이 안될 때는 아래와 같이 바꿔주면 될 수(?)도 있다!

jdbc:oracle:thin:@0.0.0.0:1234:TEST

->

jdbc:oracle:thin:@(description=(address_list=(address=(protocol=tcp)(host= 0.0.0.0 )(port=1234)))(connect_data=(service_name=TEST)))


SO Exception 은 위에서 괄호라든지 뭔가 빠뜨리면 나온다.

Posted by Lawmin

rdbms와 nosql db는 그 구조에 차이가 있어 rdb의 table 자체를 넣는 것은 큰 의미가 없을 수 있다.

하지미나 꼭 필요하다면, sstable 형태로 만들어주는 프로그램을 작성해서 sstableloader 등으로 import 해야한다.

아래는, 공식사이트의 소스를 참고하여 범용으로 사용할 있도록 수정한 java 프로그램이다.

모든 컬럼 데이터를 string 으로 넣도록 하였으나, 필요하면 각 타입에 맞게 변환해서 넣으면 된다.

csv (각 컬럼은 콤마로 구분되어 있으며, 첫줄은 column header) 를 sstable 형태로 변환해주며,

sstableloader 로 결과 디렉토리를 지정해주면, load 를 시작하게 된다.

컴파일 전에 cassandra 의 모든 lib 을 클래스패스에 넣어줘야 하고, 실행시엔 운영 cassandra 와 별도로, import 용 node 를 띄워서 load 해야 한다. (loopback 및 다른 포트 이용)


import static org.apache.cassandra.utils.ByteBufferUtil.bytes;


import java.io.BufferedReader;

import java.io.File;

import java.io.FileReader;

import java.io.IOException;

import java.nio.charset.Charset;


import org.apache.cassandra.db.marshal.UTF8Type;

import org.apache.cassandra.io.sstable.SSTableSimpleUnsortedWriter;


public class DataImport {

static String keyspace;

static String columnFamily;

    static String dataFilename;


    public static void main(String[] args) throws IOException {

        if (args.length != 3) {

            System.out.println("Expecting <keyspace> <column_family_name> <csv_DATA_with_column_header_file> as argument");

            System.exit(1);

        }

        keyspace = args[0];

        columnFamily = args[1];

        dataFilename = args[2];

        BufferedReader dataReader = new BufferedReader(new FileReader(dataFilename));

        String line;

        String[] columnHeader = null; 

        if((line = dataReader.readLine()) != null) {

        columnHeader = line.split(",", -1);

        }

        if(columnHeader == null || columnHeader.length == 0) {

        System.out.println("no column header");

        return;

        }


        File directory = new File(keyspace);

        if (!directory.exists())

            directory.mkdir();


        SSTableSimpleUnsortedWriter usersWriter = new SSTableSimpleUnsortedWriter(

                directory,

                keyspace,

                columnFamily,

                UTF8Type.instance,

                null,

                64);


        int lineNumber = 1;

        long timestamp = System.currentTimeMillis() * 1000;

        Charset cs = Charset.forName("UTF-8");

        while ((line = dataReader.readLine()) != null) {

            ++lineNumber;

        String[] columns = line.split(",", -1);

        if (columns.length != columnHeader.length) {

                System.out.println(String.format("Invalid input '%s' at line %d of %s", line, lineNumber, dataFilename));

                continue;

            }

        try {

                usersWriter.newRow(bytes(columns[0].trim(), cs));

                for(int i = 1; i < columns.length; ++i) {

                usersWriter.addColumn(bytes(columnHeader[i], cs), bytes(columns[i], cs), timestamp);

                }

            }

            catch (NumberFormatException e)

            {

                System.out.println(String.format("Invalid number in input '%s' at line %d of %s", line, lineNumber, dataFilename));

                continue;

            }

            if(lineNumber % 10000 == 0)

            System.out.println(lineNumber + " lines processed.");

        }

        usersWriter.close();

        System.out.println(lineNumber + " lines processed.");

        System.exit(0);

    }

}

Posted by Lawmin

아래 쉘을 적당히 만들어 root 권한으로 실행하면, 기존 loopback을 제거하고 192.168.10.1 부터 원하는 개수만큼 만들어 준다.

# sudo apt-get install uml-utilities

내부에서 사용하는 tunctl 을 위해 위 프로그램 설치가 필수 적이다.


tap으로 시작하는 interface 를 모두 loopback 으로 가정하였다.


#!/bin/bash

if [ $# -eq 0 ]

then

echo Usage: $0 loopback_count

exit

fi


modprobe tun


for i in $(ifconfig | grep tap | awk '{print $1}')

do

ifconfig $i down &> /dev/null > /dev/null

tunctl -d $i &> /dev/null > /dev/null

echo loopback $i has been removed.

done


for i in $(seq 1 $1)

do

tunctl &> /dev/null > /dev/null

ifconfig tap$i 192.168.10.$i netmask 255.255.255.0 up

echo loopback tap$i has been created. 

done

Posted by Lawmin

add-apt-repository ppa:tualatrix/ppa

apt-get update

apt-get install ubuntu-tweak

Posted by Lawmin

자동 마운트

Linux (Ubuntu) 2012/03/30 10:32

/etc/fstab


하드디스크의 파티션, 마운트 위치, 파일시스템 타입, 옵션등을 설정하고 및 알 수 있는 곳

fstab은 총 6개의 필드로 구성되어있다.


파일 시스템 장치명(file system)/ 파일 위치directory)/ 파일시스템의 종류(type) / 파일시스템의 옵션(option) / 덤프관련설정(인자)(freq) / 체크 시퀸스 번호(파일점검옵션)(pass)



1. [파일 시스템 장치명] : /etc/fstab파일의 첫번째


파일 시스템의 장치명이나 블럭장치를 명시 또는 설정합니다.

/dev/sda1, /dev/hda2등과 같은 파일시스템 장치명의 자리이며, 만약 파일시스템에 레이블(LABEL)이 설정되어 있다면 장치명 대신 레이블명으로 지정할 수도 있습니다.(label=/root)


2. [파일위치] : /etc/fstab파일의 두번째


파일시스템이 마운트될 위치, 즉 마운트포인트입니다.

tmpfs /dev/shm   tpss  defaults  0 0 -> tmpfs라는 녀석이 /dev/shm에 위치 해있다는 의미입니다.


3. [파일시스템종류] : /etc/fstab파일의 세번째


파일시스템의 종류를 설정하는 항목입니다.

tmpfs /dev/shm   tpss  defaults  0 0  -> tmpfs라는 녀석이 /dev/shm에 위치 해있으며, tpss 파일시스템으로 사용되고 있다는 의미입니다.


- 위치할 수 있는 파일 시스템의 종류

ext - 초기 리눅스에서 사용되었던 파일시스템으로서 현재는 사용하지 않음.

ext2 - 현재 많이 사용하고 있는 파일시스템으로서 긴파일명을 지원하는 것이 특징임.

ext3 - 저널링파일시스템으로서 ext2에 비해 파일시스템 복구기능과 보안부분을 크게 향상시킨 것으로 현재는 ext2보다 ext3을 기본 파일시스템 타입으로 사용하고 있음.

iso9660 - CD-ROM의 표준 파일시스템으로서 Read Only로 사용됨.

nfs - Network File System으로서 원격서버를 마운트할 때 사용함.

swap - 스왑파일시스템으로서 스왑공간으로 사용되는 파일시스템에 사용됨.

ufs - UNIX FileSystem으로서 UNIX SYSTEM 5계열에서는 표준파일시스템임.

vfat - 윈도우 95나 98, 그리고 NT를 지원하기 위한 파일시스템.

msdos - MS-DOS파티션을 사용하기 위한 파일시스템

hpfs - HPFS에 대한 파일시스템.

ntfs - 윈도우NT나 2000의 NTFS파일시스템을 사용하기위한 파일시스템.

sysv - 유닉스시스템 V를 지원하기 위한 파일시스템

hfs - Mac컴퓨터의 hfs 파일시스템을 지원하기 위한 파일시스템.

ramdisk - RAM디스크를 지원하는 파일시스템


adfs, affs, autofs, coda, coherent, cramfs, devpts, efs, iso9660, jfs, minix, ncpfs, proc, qnx4, reiserfs, romfs, smbfs, tmpfs, udf, ufs, umsdos, xenix, xfs등 이외에도 많이 있지만 전부 사용하지는 않습니다.


지원가능한 파일시스템을 확인해 보시려면 /proc/filesystems를 보면 됩니다.


4. [파일시스템의 옵션] : /etc/fstab 파일의 네번째


파일시스템의 마운트 옵션을 나타냅니다.

default - 모든것

noquota - 쿼터 사용안함

nosuid - SUID접근 불가능

quota - 쿼터 사용

ro - 읽기 가능

rw - 읽기 쓰기 가능

suid - SUID접근 가능


5. [덤프관련설정(인자)] : /etc/fstab 파일의 다섯번째


파일시스템이 덤프될 필요가 있는지를 설정합니다.

0 - 덤프될 필요없음

1 - 덤프 필요합


6. [체크시퀸스 번호(파일점검옵션)] : /etc/fstab 파일의 여섯번째


fsck에 의해 수행되는 무결성 검사를 위한 파일시스템 우선순위를 결정합니다.

0 - 체크 안함

1 - 우선적으로 체크

2 - 1번이 끝난 후 체크

Posted by Lawmin
결론: 10M도 안되는 짧은 거리에서는 CAT5 선으로도 기가비트 속도가 나온다.

괜히 CAT6 구입... 
Posted by Lawmin
Ubuntu 10.10 64bit Server
웹에 나오는 대로 해도 안될 경우, 아래 내용으로 /etc/vsftpd.conf 수정
단, chroot_list_file=/etc/vsftpd.chroot_list  부분만 바꿔주거나 생성해서 원하는 id 추가

# Example config file /etc/vsftpd.conf
#
# The default compiled in settings are fairly paranoid. This sample file
# loosens things up a bit, to make the ftp daemon more usable.
# Please see vsftpd.conf.5 for all compiled in defaults.
#
# READ THIS: This example file is NOT an exhaustive list of vsftpd options.
# Please read the vsftpd.conf.5 manual page to get a full idea of vsftpd's
# capabilities.
#
# Allow anonymous FTP? (Beware - allowed by default if you comment this out).
#anonymous_enable=NO
#
# Uncomment this to allow local users to log in.
local_enable=YES
#
# Uncomment this to enable any form of FTP write command.
write_enable=YES
#
# Default umask for local users is 077. You may wish to change this to 022,
# if your users expect that (022 is used by most other ftpd's)
local_umask=022
#
# Uncomment this to allow the anonymous FTP user to upload files. This only
# has an effect if the above global write enable is activated. Also, you will
# obviously need to create a directory writable by the FTP user.
#anon_upload_enable=YES
#
# Uncomment this if you want the anonymous FTP user to be able to create
# new directories.
#anon_mkdir_write_enable=YES
#
# Activate directory messages - messages given to remote users when they
# go into a certain directory.
dirmessage_enable=YES
#
# Activate logging of uploads/downloads.
xferlog_enable=YES
#
# Make sure PORT transfer connections originate from port 20 (ftp-data).
connect_from_port_20=YES
#
# If you want, you can arrange for uploaded anonymous files to be owned by
# a different user. Note! Using "root" for uploaded files is not
# recommended!
#chown_uploads=YES
#chown_username=whoever
#
# You may override where the log file goes if you like. The default is shown
# below.
xferlog_file=/var/log/vsftpd.log
#
# If you want, you can have your log file in standard ftpd xferlog format
xferlog_std_format=YES
#
# You may change the default value for timing out an idle session.
#idle_session_timeout=600
#
# You may change the default value for timing out a data connection.
#data_connection_timeout=120
#
# It is recommended that you define on your system a unique user which the
# ftp server can use as a totally isolated and unprivileged user.
#nopriv_user=ftpsecure
#
# Enable this and the server will recognise asynchronous ABOR requests. Not
# recommended for security (the code is non-trivial). Not enabling it,
# however, may confuse older FTP clients.
#async_abor_enable=YES
#
# By default the server will pretend to allow ASCII mode but in fact ignore
# the request. Turn on the below options to have the server actually do ASCII
# mangling on files when in ASCII mode.
# Beware that on some FTP servers, ASCII support allows a denial of service
# attack (DoS) via the command "SIZE /big/file" in ASCII mode. vsftpd
# predicted this attack and has always been safe, reporting the size of the
# raw file.
# ASCII mangling is a horrible feature of the protocol.
#ascii_upload_enable=YES
#ascii_download_enable=YES
#
# You may fully customise the login banner string:
#ftpd_banner=Welcome to blah FTP service.
#
# You may specify a file of disallowed anonymous e-mail addresses. Apparently
# useful for combatting certain DoS attacks.
#deny_email_enable=YES
# (default follows)
#banned_email_file=/etc/vsftpd/banned_emails
#
# You may specify an explicit list of local users to chroot() to their home
# directory. If chroot_local_user is YES, then this list becomes a list of
# users to NOT chroot().
chroot_list_enable=YES
# (default follows)
chroot_list_file=/etc/vsftpd.chroot_list
chroot_local_user=YES
#
# You may activate the "-R" option to the builtin ls. This is disabled by
# default to avoid remote users being able to cause excessive I/O on large
# sites. However, some broken FTP clients such as "ncftp" and "mirror" assume
# the presence of the "-R" option, so there is a strong case for enabling it.
#ls_recurse_enable=YES
#
# When "listen" directive is enabled, vsftpd runs in standalone mode and 
# listens on IPv4 sockets. This directive cannot be used in conjunction 
# with the listen_ipv6 directive.
listen=YES
#
# This directive enables listening on IPv6 sockets. To listen on IPv4 and IPv6
# sockets, you must run two copies of vsftpd whith two configuration files.
# Make sure, that one of the listen options is commented !!
#listen_ipv6=YES

pam_service_name=vsftpd

Posted by Lawmin
64bit OS 에서 32bit 파일 실행시킬때 주로 발생하는데...

sudo apt-get install ia32-libs

위 명령어로 설치해주면 실행된다. 


Posted by Lawmin

한글 관련

Linux (Ubuntu) 2012/03/15 13:21
한글화설치
apt-get install language-pack-ko language-pack-ko-base 

sudo locale-gen ko_KR.EUC-KR
sudo locale-gen ko_KR.UTF-8

한글입력설치 (ibus 설정에서 태극마크로 설정해야함!)
sudo apt-get install ibus-hangul

Xwindow에서는 System - Language 에서 추가 가능

1. Install korean language package.
# apt-get install language-pack-ko

2. Generate locale.
# locale-gen ko_KR.EUC-KR

3. Modify language setting files.
# vi /var/lib/locales/supported.d/ko
ko_KR.EUC-KR EUC-KR

# vi /etc/environment
LANG = "ko_KR.EUC-KR"
LANGUAGE="ko_KR:ko:en_GB:en"

# vi /etc/default/locale
LANGUAGE="ko_KR.EUC-KR"

4. Reconfigure locales.
# dpkg-reconfigure locales

5. And then, restart the system.
# shutdown -r now
Posted by Lawmin