2020년 3월 29일 일요일

라즈베리파이 병렬 컴퓨터 - 구성 및 설치

1. 하드웨어 구성
구성도 <그림.1>
구성품

  • 라즈베리 파이 4EA
  • 케이스 및 쿨러 4EA
  • 전원 케이블 4EA
  • USB 허브 유전원 
  • MicroSD CARD 4EA

2. 기본 설정(라즈베리파이는 설치가 완료 된 상태) - $ sudo raspi-config

  • hostname 변경
hostname 변경 <그림.2>

hostname 변경 <그림.3>

hostname 변경 <그림.4>
  • wifi
wifi 설정 <그림.5>

wifi 설정 <그림.6>
  • locale 설정

locale 설정 <그림.7>

locale 설정 <그림.8>

locale 설정 <그림.9>

locale 설정 <그림.10>

locale 설정 <그림.11>
  • ssh 설정
ssh 설정 <그림.12>

ssh 설정 <그림.13>

ssh 설정 <그림.13>

3. 소프트웨어 설치
  • /etc/apt/source.list 변경
deb http://raspbian.raspberrypi.org/raspbian/ buster main contrib non-free rpi
to 
deb http://ftp.kaist.ac.kr/raspbian/raspbian/ buster main contrib non-free rpi
  • sudo apt-get update
  • sudo apt-get upgrade
  • sudo apt-get install python3-numpy python3-scipy python3-matplotlib python3-ipython python3-sklearn python3-pandas python3-mpi4py nmap
여기까지 진행 한 후에 win32diskimager를 이용해서 img 생성. 나머지 sdcard에는 만들어 놓은 img로 쓰기작업.

4. 테스트

  • 각 장비별로 hostsname 변경(그림2 ~ 3 참고)
  • ssh-keygetn 키 교환 (https://webdir.tistory.com/200 참고)
  • 이후 부터는 01번 호스트에 접속해서 실행
$ sudo nmap -sn 1929.168.0.*
  • nmap 결과로 mpihosts 파일 생성

$ cat mpihosts
192.168.0.20
192.168.0.23
192.168.0.24
192.168.0.19

  • mpi 테스트

$ mpirun -hostfile mpihosts -np -4 hostname
mpi01
mpi03
mpi02
mpi04

hostname 말고 다른 명령어도 가능

2020년 3월 11일 수요일

Mongodb - 1. 설치

ubuntu 18.04 기준으로 설명

$ cat /etc/issue.net
Ubuntu 18.04.4 LTS

1. gpk 등록

$ sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 4B7C549A058F8B6B

Executing: /tmp/apt-key-gpghome.qUP0BHP71y/gpg.1.sh --keyserver hkp://keyserver.ubuntu.com:80 --recv 4B7C549A058F8B6B
gpg: key 4B7C549A058F8B6B: public key "MongoDB 4.2 Release Signing Key " imported
gpg: Total number processed: 1
gpg:               imported: 1

# source list 추가

$ echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb.list

2. 설치

$ sudo apt update
$ sudo apt install mongodb-org

# 4.2.1 버전 설치 방법
sudo apt install mongodb-org=4.2.1 mongodb-org-server=4.2.1 mongodb-org-shell=4.2.1 mongodb-org-mongos=4.2.1 mongodb-org-tools=4.2.1


3. mongodb service  관리

# 부팅시 실행(disable - 삭제)

$ sudo systemctl enable mongod
$ sudo systemctl start mongod
$ sudo systemctl stop mongod
$ sudo systemctl restart mongod
$ sudo systemctl status mongod
 ● mongod.service - MongoDB Database Server  
   Loaded: loaded (/lib/systemd/system/mongod.service; enabled; vendor preset: enabled)  
   Active: failed (Result: exit-code) since Mon 2020-03-09 21:40:37 KST; 30s ago    
    Docs: https://docs.mongodb.org/manual
Process: 12286 ExecStart=/usr/bin/mongod --config /etc/mongod.conf (code=exited, status=62)  Main PID: 12286 (code=exited, status=62)

 # status 확인 시 에러가 발생했다. 원인은 mongodb-org를 설치한게 아니고 mongodb-server 패키지를 설치했다가 삭제 했는데 이전 mongodb 데이터가 남아있어서 에러가 발생

$ sudo mv /var/lib/mongodb/ /var/lib/mongodb_bak/
$ sudo mkdir /var/lib/mongodb
$ sudo chmod 700 /var/lib/mongodb
$ sudo chown mongodb.daemon /var/lib/mongodb
$ sudo systemctl restart mongod
$ sudo systemctl status mongod
● mongod.service - MongoDB Database Server
   Loaded: loaded (/lib/systemd/system/mongod.service; enabled; vendor preset: enabled)
   Active: active (running) since Mon 2020-03-09 21:52:24 KST; 4s ago
     Docs: https://docs.mongodb.org/manual
 Main PID: 12693 (mongod)
   CGroup: /system.slice/mongod.service
           └─12693 /usr/bin/mongod --config /etc/mongod.conf

$ mongod --version
db version v4.2.3
git version: 6874650b362138df74be53d366bbefc321ea32d4
OpenSSL version: OpenSSL 1.1.1  11 Sep 2018
allocator: tcmalloc
modules: none
build environment:
    distmod: ubuntu1804
    distarch: x86_64
    target_arch: x86_64

2020년 3월 9일 월요일

Rc Car - 1

이전부터 진행하고 싶었던 라즈베리파이 Rc Car를 만들어 보았다.

1. 부품
  • 라즈베리파이3, 휴대용 배터리, L298N, RC 자동차 키트, 카메라
  • 휴대용 배터리는 출력이 2A는 재부팅이 되어서 DC 5V/3A 용량 구매
  • RC 자동차 키트, L298N 및 기타
2. RcCar 구성



RcCar 모형 <그림.1>



안드로이드 휴대폰 <그림.2>
3. 기본구성
  • 라즈베리파이 : python twisted socket server, gpio(서보, DC모터 제어), motion streaming
  • 안드로이드 : xamarin, 자이로(서보 모터), socket client
  • wifi를 이용한 socket 통신
4. 회로도
  • 라즈베리 파이 - gpio BCM 0 : ENA, 5 : IN1, 6 : ENB 연결
  • 라즈베리 파이 - gpio Physical 2, 6, 12 : +, -, 서보모터 신호 연결
gpio <그림.3>
  • L298N - 배터리에서 +, - (라즈베리파이 Physical 39번과 같이 연결)
  • IN1, IN2는 모터에 연결



L298N <그림.4>
4. 프로그램 설명
  • <그림 2>의 휴대폰을 좌우로 움직이면 자이로 값을 받아 서보모터로 X, Y 축 신호 전송 
  • <그림 2>의 F, R, STOP 버튼은 전, 후, 정지 신호 전송
  • 소스 (https://github.com/daniel-isj/RcCar.git)
5. 기타
  • 부품 및 참조 : 메카솔루션
  • dc 모터 및 톱니바퀴 연결 부분이 부실함(보완 필요)
  • 추가 사항 : motion streaming 및 xamarin 소스 업로드

2020년 2월 28일 금요일

apache mod_proxy active standby 설정

OS : Centos 7
webserver : apache2
was : tomcat8

내가 원하는 서버 구성은 아래 그림과 같다.




apache 에서 mod_proxy 설정으로 tomcat server 2개로 연결해서 사용하고 있는데 was1이 active고

was1이 서비스 중단 되었을때 바로  was2로 연결해서 무중단(?) 서비스를 설정하려고 한다.


  • apache module 확인

      # httpd -M | grep proxy
      proxy_module (shared)
      proxy_ajp_module (shared)
      proxy_balancer_module (shared)
      proxy_connect_module (shared)
      proxy_express_module (shared)
      proxy_fcgi_module (shared)
      proxy_fdpass_module (shared)
      proxy_ftp_module (shared)
      proxy_http_module (shared)
      proxy_scgi_module (shared)
      proxy_wstunnel_module (shared)


  • tomcat8/conf/server.xml
      context에 sessionCookieName="test_JSESSIONID" 추가
  • conf.d/vhost.conf

     VirtualHost *:80
       ServerName test.com
       ProxyRequests Off
          
         
             Order deny,allow
             Allow from all
             # Balancer member 1
             BalancerMember http://localhost:8080 loadfactor=1 retry=2
             # Balancer member 2
             BalancerMember http://localhost:9090 status=+H retry=0
       

       ProxyPass / balancer://mycluster/ stickysession=test_JSESSIONID|jsessionid
       ProxyPassReverse /4  http://localhost::8080/
       ProxyPassReverse /4  http://localhost::9090/

       ProxyPreserveHost On
       ProxyStatus On
     VirtualHost

     # systemctl restart httpd

  • 에러 분석
      error_log에 proxy:error Permission denied 에러 발생

      # 분석
      # audit2why < /var/log/audit/audit.log

      # semanage port -l |grep http_port_t
      http_port_t                    tcp      28009, 18009, 80, 81, 443, 488, 8008, 8009, 8443, 9000
      pegasus_http_port_t            tcp      5988

  • 처리
      semanage 에 해당 포트가 없으면 등록을 해줘야 한다.

      # semanage port -a -p tcp -t http_port_t  8080
      # semanage port -a -p tcp -t http_port_t  9090

      이미 등록 되어있다는 에러가 나오면

      # semanage port -m -p tcp -t http_port_t  8080
      # semanage port -m -p tcp -t http_port_t  9090

  • 테스트 
      was1 shutdown  후 test.com 접속 후 was2 접속 로그 확인
      was1 startup 후 test.com 접속 후 was1 접속 로그 확인

  • 참고





2020년 2월 8일 토요일

ubuntu python 설정

python 3.6을 기본으로 사용하기

$ cat /etc/issue.net
Ubuntu 18.04.3 LTS

$ sudo update-alternatives --config python
update-alternatives: error: no alternatives for python

$ ls -lart /usr/bin/python*
-rwxr-xr-x 1 root root    1342 May  2  2016 /usr/bin/python3-jsonpointer
-rwxr-xr-x 1 root root    3661 Oct 29  2017 /usr/bin/python3-jsonpatch
-rwxr-xr-x 1 root root    1018 Oct 29  2017 /usr/bin/python3-jsondiff
-rwxr-xr-x 1 root root     398 Nov 16  2017 /usr/bin/python3-jsonschema
lrwxrwxrwx 1 root root       9 Apr 16  2018 /usr/bin/python2 -> python2.7
lrwxrwxrwx 1 root root      17 Oct 25  2018 /usr/bin/python3m-config -> python3.6m-config
lrwxrwxrwx 1 root root      10 Oct 25  2018 /usr/bin/python3m -> python3.6m
lrwxrwxrwx 1 root root      16 Oct 25  2018 /usr/bin/python3-config -> python3.6-config
lrwxrwxrwx 1 root root       9 Oct 25  2018 /usr/bin/python3 -> python3.6
lrwxrwxrwx 1 root root      34 Oct  7 21:59 /usr/bin/python3.6m-config -> x86_64-linux-gnu-python3.6m-config
-rwxr-xr-x 2 root root 4526456 Oct  7 21:59 /usr/bin/python3.6m
lrwxrwxrwx 1 root root      33 Oct  7 21:59 /usr/bin/python3.6-config -> x86_64-linux-gnu-python3.6-config
-rwxr-xr-x 2 root root 4526456 Oct  7 21:59 /usr/bin/python3.6
-rwxr-xr-x 1 root root 3641704 Oct  8 02:39 /usr/bin/python2.7
lrwxrwxrwx 1 root root      24 Jan 31 00:08 /usr/bin/python -> /etc/alternatives/python

$ sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.6 1
update-alternatives: using /usr/bin/python3.6 to provide /usr/bin/python (python) in auto mode

$ sudo update-alternatives --install /usr/bin/python python /usr/bin/python2.7 2
update-alternatives: using /usr/bin/python2.7 to provide /usr/bin/python (python) in auto mode

$ sudo update-alternatives --config python
There are 2 choices for the alternative python (providing /usr/bin/python).

  Selection    Path                Priority   Status
------------------------------------------------------------
* 0            /usr/bin/python2.7   2         auto mode
  1            /usr/bin/python2.7   2         manual mode
  2            /usr/bin/python3.6   1         manual mode

Press to keep the current choice[*], or type selection number: 2

$ python -V
Python 3.6.8


RecalBox 설치

1. RecalBox 다운로드

2. Etcher 다운로드(portable)

4. ResberryPi 구동(전원연결), wifi 설정

5. Mame roms  추가
  • RecalBox ip -> 192.168.0.100인 경우
  • 웹 브라우저 -> http://RecalBox ip 접속
  • Roms/Mame 메뉴에 롬 업로드



6. 조이스틱 설정
  • 가지고 있던 조이스틱이 아무리 해도 설정이 안되는 경우.
  • 가상 게임패드는 http://RecalBox ip:8080


그냥 저냥 할만하다. (조이스틱 사야지..)

2020년 2월 7일 금요일

c# invoke, backgroundworker, socket client sample(돌아가기만 하는 코드)

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace PiCalendar
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            this.bgw1.WorkerSupportsCancellation = true;
            this.bgw1.RunWorkerAsync();
        }

        private void Form1_FormClosed(object sender, FormClosedEventArgs e)
        {
            if (this.bgw1.IsBusy)
            {
                this.bgw1.CancelAsync();
            }
        }

        private void bgw1_DoWork(object sender, DoWorkEventArgs e)
        {
            // Data buffer for incoming data.
            byte[] bytes = new byte[1024];
            string data = null;
            // Connect to a remote device.
            try
            {
                // Establish the remote endpoint for the socket.
                // This example uses port 11000 on the local computer.
                IPHostEntry ipHostInfo = Dns.GetHostEntry(Dns.GetHostName());
                IPEndPoint remoteEP = new IPEndPoint(ipAddress, 62000);

                // Create a TCP/IP  socket.
                Socket client = new Socket(ipAddress.AddressFamily,
                    SocketType.Stream, ProtocolType.Tcp);

                // Connect the socket to the remote endpoint. Catch any errors.
                try
                {
                    client.Connect(remoteEP);

                    Console.WriteLine("Socket connected to {0}",
                        client.RemoteEndPoint.ToString());

                    // Encode the data string into a byte array.
                    byte[] msg = Encoding.ASCII.GetBytes("hello\r\n");

                    // Send the data through the socket.
                    int bytesSent = client.Send(msg);

                    int cnt = 0;
                    while (true)
                    {
                        if (this.bgw1.CancellationPending)
                        {
                            break;
                        }
                        bytes = new byte[4096];
                        int bytesRec = client.Receive(bytes);
                        data += Encoding.UTF8.GetString(bytes, 0, bytesRec);
                        if (data.IndexOf("\r\n") > -1)
                        {
                            if (data == "quit")
                            {
                                break;
                            }
                            cnt++;
                            if (this.InvokeRequired)
                            {
                                this.richTextBox1.Invoke(new Action(delegate ()
                                {
                                    if (cnt == 50)
                                    {
                                        this.richTextBox1.ResetText();
                                        cnt = 0;
                                    }
                                    this.richTextBox1.AppendText(data);
                                    this.richTextBox1.ScrollToCaret();

                                }));
                            }
                            data = string.Empty;
                        }
                    }

                    // Release the socket.
                    client.Shutdown(SocketShutdown.Both);
                    client.Close();

                }
                catch (ArgumentNullException ane)
                {
                    Console.WriteLine("ArgumentNullException : {0}", ane.ToString());
                }
                catch (SocketException se)
                {
                    Console.WriteLine("SocketException : {0}", se.ToString());
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Unexpected exception : {0}", ex.ToString());
                }

            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }

        private void bgw1_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            Console.WriteLine("bgw1 completed");
        }
    }
}

라즈베리 파이 pihole plex cups

1. 모니터 상하 변경 && wifi
 $ sudo vi /boot/config.txt

 lcd_rotate=2

 # wifi는 그냥 디폴트 사용 - 국가를 바꾸면 접속 안됨.

2.  vim && locale && fonts
 $ sudo apt-get update && sudo apt-get upgrade
 $ sudo apt-get install vim
 # locale 설정 sudo dpkg-reconfigure locales or gui화면에서 설정 폰트 설치
 $ sudo apt-get install fonts-unfonts-core

3. pihole 설치

 # 소스 설치
 $ sudo curl -sSL https://install.pi-hole.net | bash

 # pihole 관리자 페이지 password 변경
 $ sudo pihole -a -p

 # 포트 변경
 $ sudo vi /etc/lighttpd/lighttpd.conf
 # server.port = 80
 server.port = 9090

 여기서 확인하고 설정

 https://godpeople.or.kr/board/3411168

 daum 추가 했더니 동영상 재생이 안되어 삭제

 # windows 공유폴더
 https://webnautes.tistory.com/721

4. plex
 $ echo "deb https://downloads.plex.tv/repo/deb public main" | sudo tee  /etc/apt/sources.list.d/plexmediaserver.list

 $ curl https://downloads.plex.tv/plex-keys/PlexSign.key | sudo apt-key add -

 $ sudo apt-get update && sudo apt-get install plexmediaserver

 # http://respi-ip:32400/ 접속 - plex  가입한 후 로그인 필요.(전에는 안그랬던 거 같은데...)

5. cups - HP Color LaserJet Pro MFP M180n
 $ sudo apt-get install cups

 # 그룹, 권한
 $ sudo usermod -a -G lpadmin pi
 $ sudo cupsctl --remote-any

 # http://respi-ip:631/admin/ 접속

 # admin 접속이 안 될 경우
 $ sudo vi /etc/cups/cupsd.conf
 # Location Allow ip 추가

 # driver는 설치 안해도 됨.(유사한 거 선택) - HP Color LaserJet CM2320N MFP
 # scan test 필요 xsane or sane

2017년 1월 13일 금요일

oracle delete 데이터 복구(flashback query)

SQL> show parameter undo;

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
undo_management                      string      AUTO
undo_retention                       integer     900
undo_tablespace                      string      UNDOTBS1
-- 현재 900초로 되어있음

SQL> alter system set undo_retention = 7200;

System altered.

SQL> show parameter undo;

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
undo_management                      string      AUTO
undo_retention                       integer     7200
undo_tablespace                      string      UNDOTBS1


SELECT *
FROM TABLE_NAME
AS OF TIMESTAMP(SYSTIMESTAMP - INTERVAL '120' MINUTE)
WHERE FILED_NAME = ?;
으로 검색해서 삭제된 데이터를 찾을 수 있다. 복구는 알아서...

2016년 12월 23일 금요일

bash shell 색상


export LS_COLORS="di=01;33":"fi=01;37":"ex=01;32":"ln=01;36":"so=01;33"

2012년 6월 19일 화요일

oracle 전화번호에 '-' 삽입하기


'^02.{0}|^01.{1}|[[:digit:]]{3})([[:digit:]]+)([[:digit:]]{4})', '\1-\2-\3'
뭐 보면 금방 이해할것이고 문제는 어디서 봤는지 원본 url을 못찾겠다는게 문제네요. REGEXP_REPLACE를 이용하면 해결 됨. 암튼 좋은 정보 주신분 감사합니다.

2011년 8월 31일 수요일

oracle dbms_job

dbms_job을 이용해서 dblink가 되있는 oracle server에 특정 쿼리를 날려야 된다.

5분 단위로 select 쿼리를 날린다.


check.sql
begin
dbms_job.submit(:jobno,'begin declare aaa number := 0; begin select 1 into aaa from dual@aaa; end; end;',sysdate,'sysdate + 5/24/60');
end;
/

sqlplus test/test

@check
print jobno
111 -- jobno 확인
exec dbms_job.run(jobno);
commit;

exec  dbms_job.run(jobno); -- 다시시작
exec  dbms_job.broken(jobno, TRUE); -- disable
exec  dbms_job.remove(jobno); -- 삭제



참고 url : http://www.oracleclub.com/article/32789

2011년 3월 17일 목요일

jquery 이것저것

전체 체크박스 전체 선택-해제

$('#allcheck').click(function() {
    if ($('#allcheck:checked').length > 0) {
        $('.delcheck').attr('checked', 'checked');
    } else {
        $('.delcheck').attr('checked', '');
    }
});

동일한 이름의 input name="test"인걸 하나의 문자열로 변환
var ret = []; 
var cnt = 0;
$('input[name*=test]').each(function() {
    ret[cnt] = $(this).val();
    cnt += 1;
});
alert(ret.join());

select box 관련

var testcode = 2;
$('#testid option:eq('+testcode+')').attr('selected', 'selected');
alert($('#testid option:selected').val());
alert($('#testid option:selected').text());

input box 추가 및 삭제
input type="button" value="추가" id="addButton"
var addhtml = "div id=\"addHtml\" input type=\"text\" name=\"test\" value=\"\" input type=\"button\" value=\"삭제\" class=\"delhtml\" /div "; $('#addButton').click(function () { $('#addHtml').append(addhtml); $('.delhtml').bind('click', function () { $(this).parent().remove(); }); });

jquery autocomplete

jquery autocomplete 간단한 사용법

우선 사용하고자 하는 페이지의 자바스크립트
$('#name').autocomplete(uid, {
    minChars: 1,
    width: 210,
    max: 50,
    matchContains: true,
    autoFill: false,
    formatItem: function(row, i, max) {
        return i + "/" + max + ": \"" + row.name + "\" [" + row.to + "]";
    },
    formatMatch: function(row, i, max) {
        return row.name + " " + row.to;
    },
    formatResult: function(row) {
        return row.name;
    }
});

$('#name').result(function(event, row, formatted) {
    $('#to').val(row.to);
});

uid가 있는 자바스크립트
var uid = [
 { name: "Peter Pan", to: "peter@pan.de" },
 { name: "Molly", to: "molly@yahoo.com" },
 { name: "Forneria Marconi", to: "live@japan.jp" },
 { name: "Master Sync", to: "205bw@samsung.com" },
 { name: "Dr. Tech de Log", to: "g15@logitech.com" },
 { name: "Don Corleone", to: "don@vegas.com" },
 { name: "Mc Chick", to: "info@donalds.org" },
 { name: "Donnie Darko", to: "dd@timeshift.info" },
 { name: "Quake The Net", to: "webmaster@quakenet.org" },
 { name: "Dr. Write", to: "write@writable.com" }
];

name id를 가지고 있는 곳에서 입력하면 uid의 name과 일치하는 것들이 나타난다.

이때 해당하는 것을 선택하면 result 함수를 호출하게 된다.

여기서 필요한 작업을 하면 끝.

참조 url : http://bassistance.de/jquery-plugins/jquery-plugin-autocomplete/

2010년 11월 30일 화요일

php soap

lighttpd냐 nginx냐 고민하다가 lighttpd로 결정했다. 이유는 nginx는 사용해 보지 않아서...

lighttpd + php5.2 + pear soap으로 서비스를 하는데 pear soap에서 complex type 선언할때

방법을 찾는데 좀 헤맸다.

$this->__dispatch_map['hello'] =  array(  'in' => array('name' => 'string'),  'out' => array('ret' => '{'.$this->__ns.'}ArrayOfIHello'));
$this->__typedef['{'.$this->__ns.'}StringOfHello'] = array( 'a' => 'int', 'b' => 'string', 'c' => 'string', 'd' => 'string', 'e' => 'string' );
$this->__typedef['{'.$this->__ns.'}ArrayOfHello'] = array(array('StringOfHello'=>'{'.$this->__ns.'}StringOfHello'));

요런식으로 선언하면 c# 에서는 StringOfHello 로 받아서 처리하면된다. 편하다 -_-;

aaa.StringOfHello[] strs = svr.hello(tname);
    String[] temp = new String[5];
    foreach (aaa.StringOfHello str in strs)
    {
        temp[0] = str.a.ToString();
        temp[1] = str.b;
        temp[2] = str.c;
        temp[3] = str.d;
        temp[4] = str.e;
        // dataGridView1.Rows.Add(temp);
    }

2010년 7월 7일 수요일

windows7_64 gvim

구입한 노트북의 OS가 windows7_64  버전이다.

gvim을 설치 했더니 우측에 context menu에 추가가 안된다.

추가 방법은 reg 파일을 만들어서 추가하는 것과 sendto를 이용하는 방법이 있다.

reg파일의 내용은

Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\*\shell\Edit with Vim]
[HKEY_CLASSES_ROOT\*\shell\Edit with Vim\command]
@="C:\\Program Files (x86)\\Vim\\vim72\\gvim.exe \"%1\""
이 파일을 등록하면 마우스 우측버튼 클릭후에  Edit With Vim이 보인다.

2010년 5월 4일 화요일

oracle to sql server

이 자료는 oracle에서 sql server 2008로 db link를 통해 접속 하는 방법을 설명하는 자료이다.

platform
unbuntu 8.04
Oracle Database 10g r2
MS Sql Server 2008

필요한 package
# apt-get install unixodbc unixodbc-dev tdsodbc
freetds driver를 unixODBC에 인식
# odbcinst -i -d -f /usr/share/tdsodbc/odbcinst.ini
tamplate 생성후 unixODBC에 추가
# vi ms.ini
[MS]
Driver = TDS
Description = SQL Server
Trace = No
Server = 192.168.x.x
Database = test
# odbcinst -i -s -f mydsn.ini -h
또는 /etc/odbc.ini, /etc/odbcinst.ini에 직접 추가
/etc/odbc.ini
[TDS]
Description = freetds
Driver = /usr/lib/odbc/libtdsodbc.so
FileUsage = 1

/etc/odbcinst.ini
[MS]
Driver = TDS
Description = SQL Server
Trace = No
Server = 192.168.x.x
Database = test
접속 테스트
# isql -v MS userid password
+---------------------------------------+
| Connected!                            |
|                                       |
| sql-statement                         |
| help [tablename]                      |
| quit                                  |
|                                       |
+---------------------------------------+ 
여기 까지가 unixODBC와 freetds연동을 위한 설정이다. Oracle hs(Heterogeneous Services)를 추가해야 한다.

여기서 부터는 oracle 계정으로 :-)

Oracle listerner 추가(listener.ora)
SID_LIST_HSODBC =
(SID_LIST =
    (SID_DESC =
        (SID_NAME=hsodbc)
        (ORACLE_HOME=/opt/oracle/product/10r2)
        (PROGRAM=/opt/oracle/product/10r2/bin/hsodbc)
        (ENVS=LD_LIBRARY_PATH=/opt/oracle/product/10r2/lib:/usr/lib/) # lib from freetds
    )
) 
 HSODBC =
(DESCRIPTION_LIST =
    (DESCRIPTION =
        (ADDRESS_LIST =
            (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.x.x)
            (PORT = 1522))
        )
    )
)
tnsnames.ora 추가
hs =
(DESCRIPTION =
    (ADDRESS_LIST =
        (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.x.x)(PORT = 1522))
    )
    (CONNECT_DATA =
        (ORACLE_HOME = /opt/oracle/product/10r2)
        (SID = hsodbc)
    )
    (HS = OK)
)
listener hsodbc 실행
$ lsnrctl start hsodbc
$ tnsping hs 
Oracle hs 설정
vi $ORACLE_HOME/hs/admin/inithsodbc.ora
HS_FDS_CONNECT_INFO = MS
HS_FDS_TRACE_LEVEL = 4
HS_FDS_TRACE_FILE_NAME = /tmp/ms.trc
HS_FDS_SHAREABLE_NAME = /usr/lib/libodbc.so # lib from unixODBC
set ODBCINI=/etc/odbc.ini
Oracle database link 설정 및 테스트
SQL> create database link ms connect to "userid" identified by "password" using 'hs';
ok
SQL> select * from test@ms;
...
...
...
SQL>
isql로는 연결이 되는데 hs에서는 안 될 경우 환경변수를 확인해보거나 unixODBC와 freetds를 소스로 설치해서 해보길 바란다.

2010년 4월 13일 화요일

oracle merge into

mysql의 replace into 기능을 oracle에서 찾아 봤더니 merge into가 있다.

MERGE INTO table_name alias
USING (table | view | subquery) alias -- 한개의 테이블 사용시 DUAL
ON (join condition) -- WHERE
WHEN MATCHED THEN 
UPDATE SET col1 = val1[, ...] 
WHEN NOT MATCHED THEN 
INSERT (column) VALUES (values); 

2009년 12월 29일 화요일

perl soap

perl SOAP::Lite 설치
# cpan -MCPAN -e shell
cpan> get SOAP::Lite
# cd ~/.cpan/build/SOAP-Lite
# perl Makefile.PL
# make;sudo make install;

soap client
$ vi cli.pl
#!/usr/bin/perl

use strict;
use warnings;
use SOAP::Lite;

print SOAP::Lite->service('http://locahost/wsdl')->hello("test"), "\n";
$ perl cli.pl
hello test


물론 서버는 hello를 호출 하면 hello + string을 돌려준다.

2009년 8월 25일 화요일

mod_deflate, mod_expire



AddOutputFilterByType text/html text/plain text/css text/javascript application/x-javascript application/xml     application/xhtml+xml text/xml




apache1은 mod_gzip apache2는 mod_deflate

mod_expire는
debian 또는 ubuntu를 사용하기에 a2enmod를 이용해서 추가후 설정


ExpiresActive On
ExpiresByType image/jpg "access plus 1 day"
ExpiresByType image/gif "access plus 1 day"
ExpiresByType image/jpeg "access plus 1 day"
ExpiresByType image/png "access plus 1 day"
ExpiresByType text/css "access plus 1 day"

#ExpiresByType text/js "access plus 1 day"
#ExpiresByType text/javascript "access plus 1 day"
#ExpiresByType application/javascript "access plus 1 day"
#ExpiresByType application/x-javascript "access plus 1 day"


뭐 간단히 요런식으로... 심심하시면 header까서 확인까지...

참조 url : http://httpd.apache.org/docs/2.0/ko/mod/mod_deflate.html