티스토리 툴바


블로그 이미지
이곳의 자료는 모두 공개입니다. 마음껏 퍼가셔도 되지만 출처는 꼭 표시해주시기 바랍니다.
월리정

Notice

Recent Comment

Recent Trackback

Archive

calendar

1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31        
  • 38,834total
  • 0today
  • 34yesterday
2012/01/27 18:19 System/Linux

1) 각종 환경변수 값 설정

< /etc/redhat-release >
[root@mycent ]# cp /etc/redhat-release /etc/redhat-release.backup
[root@mycent ]# vi /etc/redhat-release
"CentOS release 6.2 (Final)" -> "redhat-4"로 변경

< /etc/hosts >
[root@mycent ]# vi /etc/hosts
"172.20.22.100   mycent" 추가

< /etc/sysctl.conf >
[root@mycent ]# cp /etc/sysctl.conf /etc/sysctl.conf.backup
[root@mycent ]# vi /etc/sysctl.conf
있는 항목은 값 수정
kernel.shmall = 2097152
kernel.shmmax = 536870912
없는 항목은 값 추가
kernel.shmmni = 4096
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.sem = 250 32000 100 128
net.ipv4.ip_local_port_range = 1024 65000
net.core.rmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048586
[root@mycent ]# /sbin/sysctl -p
추가한 내용에 문제가 없는지 확인

< /etc/security/limits.conf >
[root@mycent ]# cp /etc/security/limits.conf /etc/security/limits.conf.backup
[root@mycent ]# vi /etc/security/limits.conf
아래내용 추가
#@student        -       maxlogins       4
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
# End of file

< /etc/selinux/config >
[root@mycent ]# cp /etc/selinux/config /etc/selinux/config.backup
[root@mycent ]# vi /etc/selinux/config
"SELINUX=enforcing" -> "SELINUX=disabled"로 변경

< /etc/pam.d/login >
[root@mycent ]# cp /etc/pam.d/login /etc/pam.d/login.backup
[root@mycent ]# vi /etc/pam.d/login
아래내용 추가
session    required     pam_limits.so

2) 필수 패키지 설치

[root@mycent ]# yum install binutils-2* compat-libstdc++-33* elfutils-libelf* gcc-4.* gcc-c++-4.* glibc-2.* glibc-common-2.* glibc-devel-2.* glibc-headers-2.* ksh* libaio-0.* libaio-devel-0.* libgomp-4.* libgcc-4.* libstdc++-4.* libstdc++-devel-4.* make-3.* sysstat-7.* unixODBC-2.* unixODBC-devel-2.* pdksh*

3) 오라클 계정 및 그룹 생성

[root@mycent ]# groupadd oinstall
[root@mycent ]# groupadd dba
[root@mycent ]# groupadd oper
[root@mycent ]# groupadd asmadmin
[root@mycent ]# useradd -g oinstall -G dba,oper,asmadmin oracle
[root@mycent ]# passwd oracle
[root@mycent ]# mkdir -p /opt/oracle/product/10.2.0/db_1 (설치대상경로)
[root@mycent ]# chown -R oracle:oinstall /opt/oracle
[root@mycent ]# chmod -R 775 /opt/oracle 

4) 오라클 계정 환경변수 설정

[root@mycent ]# su - oracle
[oracle@mycent ]$ vi .bash_profile
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs
export PATH=$PATH:$HOME/bin

TMP=/tmp; export TMP
TMPDIR=$TMP; export TMPDIR
ORACLE_HOSTNAME=localhost.localdomain; export ORACLE_HOSTNAME
ORACLE_BASE=/opt/oracle; export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_1; export ORACLE_HOME
ORACLE_SID=orcl; export ORACLE_SID
ORACLE_TERM=xterm; export ORACLE_TERM
PATH=/usr/sbin:$PATH; export PATH
PATH=$ORACLE_HOME/bin:$PATH; export PATH
TSHLIB_PATH=$ORACLE_HOME/lib:/usr/lib:/lib:/usr/local/lib; export TSHLIB_PATH
LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib:/lib:/usr/local/lib; export LD_LIBRARY_PATH

if [ $USER = "oracle" ]; then
        if [ $SHELL = "/bin/ksh" ]; then
                ulimit -p 16384
                ulimit -n 65536
        else
                ulimit -u 16384 -n 65536
        fi
fi

if [ $USER = "oracle" ]; then
        if [ $SHELL = "/bin/ksh" ]; then
                ulimit -p 16384
                ulimit -n 65536
        else
                ulimit -u 16384 -n 65536
        fi
fi

5) 오라클 설치 프로그램 구동

oralce 계정으로 X-window 로긴
터미널 열고 export LANG=c 수행 (안그러면 설치 프로그램 글자가 다 깨짐)
오라클 설치 프로그램 경로에서 ./runInstaller 실행
설치하는 중간에 두개 정도의 쉘 스크립트를 수동으로 실행해줬던것 같음 (화면에 안내나옴)
X-window 상에서의 설치과정 완료 

6) 오라클 자동 시작/종료 설정

oracle 계정으로 수정
vi /etc/oratab
orcl:/opt/oracle/product/10.2.0/db_1:Y

7) 일반 사용자 계정 환경설정

[userid@mycent ]$ vi .bash_profile
# ORACLE 10g Env
export ORACLE_BASE=/opt/oracle
export ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_1
export ORACLE_SID=orcl
export ORACLE_OWNER=oracle
export ORACLE_TERM=xterm
export TNS_ADMIN=$ORACLE_HOME/network/admin
export TORA_NLS10=$ORACLE_HOME/nls/data
export TNLS_LANG=American_america.KO16KSC5601
export TSHLIB_PATH=$ORACLE_HOME/lib:/usr/lib:/lib:/usr/local/lib
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib:/lib:/usr/local/lib

export PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin

8) 오라클 기동

oracle 계정을 이용하여 실행
< 오라클 리스너 구동 >
[oracle@mycent ~]$ lsnrctl start

LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 27-JAN-2012 12:27:46

Copyright (c) 1991, 2005, Oracle.  All rights reserved.

Starting /opt/oracle/product/10.2.0/db_1/bin/tnslsnr: please wait...

TNSLSNR for Linux: Version 10.2.0.1.0 - Production
System parameter file is /opt/oracle/product/10.2.0/db_1/network/admin/listener.ora
Log messages written to /opt/oracle/product/10.2.0/db_1/network/log/listener.log
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=mycent)(PORT=1521)))

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 10.2.0.1.0 - Production
Start Date                27-JAN-2012 12:27:48
Uptime                    0 days 0 hr. 0 min. 0 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /opt/oracle/product/10.2.0/db_1/network/admin/listener.ora
Listener Log File         /opt/oracle/product/10.2.0/db_1/network/log/listener.log
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=mycent)(PORT=1521)))
Services Summary...
Service "PLSExtProc" has 1 instance(s).
  Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully

< 오라클 DBMS 구동 및 종료 >
[root@mycent ]# sqlplus /nolog
SQL> connect orcl as sysdba
SQL> startup ( 오라클 구동 )
SQL> shutdown immediate  ( 오라클 종료 )

* 일반계정에서 sqlplus 실행 안되는 현상 발생시 권한 설정

< 에러 메시지 >
[userid@mycent ]$ sqlplus /nolog
sqlplus: error while loading shared libraries: libsqlplus.so: cannot open shared object file: No such file or directory

< 해결책 >
root 권한을 이용하여 수행
[root@mycent ]# chmod -R a+rX /opt/oracle/product/10.2.0/db_1

9) 클라이언트의 tnsnames.ora 내용 추가

ORCL =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 오라클 서버 IP주소)(PORT = 1521))
    )
  (CONNECT_DATA =
    (SERVICE_NAME = orcl)
  )
)

10) 오라클 서버 접속 후 기본동작 확인

< scott 계정으로 접속 후 샘플 테이블 확인 >
select * from all_tab_columns
where owner not in ('XDB')
and owner not like '%SYS%'
;
=> BONUS, DEPT, EMP, SALGRADE 테이블이 보이는지 확인

< 한글 입출력 테스트 > 
create table test_table (
num number
, id varchar2(20)
, name varchar2(50)
, address varchar2(100)
);
insert into test_table values(1, 'userid1', '홍길동', '서울');
insert into test_table values(2, 'userid2', '심형래', '부산'); 
insert into test_table values(3, 'userid3', '콩쥐', '대전'); 
insert into test_table values(4, 'userid4', '흥부', '광주'); 
commit;
select * from test_table; 

* 한글이 깨져서 보일 경우 캐릭터 셋 변경

[oracle@mycent ~]$ sqlplus /nolog
SQL*Plus: Release 10.2.0.1.0 - Production on Fri Jan 27 15:09:21 2012
Copyright (c) 1982, 2005, Oracle.  All rights reserved.
SQL> conn orcl as sysdba
Enter password:
Connected.
SQL> select userenv('LANGUAGE') from dual;
USERENV('LANGUAGE')
----------------------------------------------------
AMERICAN_AMERICA.WE8ISO8859P1

SQL> update props$ set value$='KO16KSC5601' where name='NLS_CHARACTERSET';
1 row updated.

SQL> commit;
Commit complete.

SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.

SQL> startup
ORACLE instance started.
Total System Global Area  360710144 bytes
Fixed Size     1219424 bytes
Variable Size   113247392 bytes
Database Buffers   243269632 bytes
Redo Buffers     2973696 bytes
Database mounted.
Database opened.

SQL> select userenv('LANGUAGE') from dual;
USERENV('LANGUAGE')
----------------------------------------------------
AMERICAN_AMERICA.KO16KSC5601

캐릭터 셋이 변경된 것을 확인한 후 다시 한번 < 한글 입출력 테스트 >를 수행해 본다.
저작자 표시
posted by 월리정
2012/01/26 19:51 System/Linux

1) VNC Server 설치

# yum -y install vnc-server


2) 환경파일 수정

# vi /etc/sysconfig/vncservers


-- 2명의 사용자용으로 VNC 세션을 만든다고 가정하면..
VNCSERVERS="2:root 3:otherID"

VNCSERVERARGS[2]="-geometry 1280x960"

VNCSERVERARGS[3]="-geometry 1280x960"


3) 사용자 패스워드 설정

각자 계정으로 아래 과정 수행
# cd
# mkdir .vnc
# cd .vnc
# vncpasswd
암호 입력 
.vnc 디렉토리 밑에 passwd 파일 생성됨
 


4) VNC Server 실행

# service vncserver restart

[root@mycent ~]# service vncserver restart

VNC 서버 종료 중: 2:root 3:otherID                         [  OK  ]

VNC 서버 (을)를 시작 중:
2:root 

New 'mycent:2 (root)' desktop is mycent:2

Starting applications specified in /root/.vnc/xstartup

Log file is /root/.vnc/mycent:2.log


3:otherID 

New 'mycent:3 (otherID)' desktop is mycent:3

Starting applications specified in /home/esjeong/.vnc/xstartup

Log file is /home/esjeong/.vnc/mycent:3.log         [  OK  ]


5) 방화벽 오픈

VNC 기본 포트는 5900이며, 위에 2:root 3:otherID 이 숫자만큼 더한 포트가 각 계정에 할당된 포트임
5902 포트 : root
5903 포트 : otherID 


( VNC 서버 실행 시 에러 )

xauth:  creating new authority file /root/.Xauthority

xauth: (stdin):1:  bad display name "mycent:1" in "add" command


New 'mycent:1 (root)' desktop is mycent:1

( 해결책 )
/etc/hosts, /etc/sysconfig/network 두 파일안에 호스트명이 제대로 입력되어 있는지 확인해 본다. 


저작자 표시
posted by 월리정
2012/01/10 14:38 Programming
아.. 이 간단한 것 때문에 삽질 좀 함 -_-, 어쨌든 정리~

[ CASE 1 ]
- AA.C

char          sServerName[NM_SERVER_LEN+1];
( 전역변수니 초기화는 안해도 좋다 )


- BB.c

extern char   sServerName[];

printf("Server : [%s]\n", sServerName);



[ CASE 2 ]
- AA.C

char          sCenterList[MAX_ARG_CNT][NM_SERVER_LEN+1];
( 전역변수니 초기화는 안해도 좋다 )


- BB.c

extern char   sCenterList[][NM_SERVER_LEN+1];

for ( i=0; i<iCenterCnt; i++ )

printf("Server : [%s]\n", sCenterList[i]);

저작자 표시
posted by 월리정
2012/01/05 13:35 System/Linux
사용자 ID가 8자리를 초과하게 되면 ps 출력결과에서 사용자 ID가 영문자가 아닌 숫자 UID로 출력되는 경우가 있다. 이를 영문자 ID로 출력하려면 아래와 같이 수행

[ 기존 ]

[mycent ~]$ ps -ef
...
500      31225 31223  0 13:27 ?          00:00:00 sshd: myaccount@pts/2

500      31226 31225  0 13:27 pts/2    00:00:00 -bash
... 

 
[ 옵션 사용 ]

[mycent ~]$ ps -e -o uname:13,pid,ppid,c,stime,tty,time,cmd
... 
myaccount     31225 31223  0 13:27 ?          00:00:00 sshd: myaccount@pts/2

myaccount     31226 31225  0 13:27 pts/2    00:00:00 -bash

...


저작자 표시
posted by 월리정
2012/01/03 19:32 Programming
원문출처 :  http://blog.naver.com/endfirst?Redirect=Log&logNo=20018509790 

#include <sys/types.h>
#include <sys/wait.h>

pid_t wait(int *status);
자식 프로세스가 종료할때까지 해당 영역에서 부모 프로세스가 sleep 모드로 기다리게 된다. 이는 자식 프로세스와 부모 프로세스의 동기화를 위한 목적으로 부모 프로세스가 자식 프로세스보다 먼저 종료되어서 자식 프로세스가 고아 프로세스(PPID 가 1)가 되는걸 방지하기 위함이다.
자식 프로세스가 종료되었다면 함수는 즉시 리턴되며, 자식 프로세스가 사용한 모든 시스템 자원을 해제한다. wait()의 인자 status를 통하여 자식 프로세스의 상태를 받아올수 있는데, 자식 프로세스의 상태값은 자식 프로세스의 종료값 * 256(FF) 값이다.

#include <sys/types.h>
#include <sys/wait.h>

pid_t waitpid(pid_t pid, int *status, int options);
waitpid 함수는 인자로 주어진 pid 번호의 자식 프로세스가 종료되거나, 시그널 함수를 호출하는 시그널이전달될때까지 waitpid 호출한 영역에서 sleep모드로 기다리게 된다.

[ 자식 프로세스 상태값 ]

WIFEXITED(status)
 - 자식 프로세스가 정상 종료되었다면 Non-Zero 값 리턴.
 
WEXITSTATUS(status)
 - 자식 프로세스에서 exit()를 호출할 때 인자를 설정하거나, 또는 어떤 return 값을 설정하고, 해당 자식 프로세스가 종료될 경우 return 값의 최하위 8비트를 가져옴.
 - 정상종료 
(즉, WIFEXITED(status)값이 Non-Zero)일때만 사용가능.

WIFSIGNALED(status)
 - 자식 프로세스가 어떤 시그널로 인해 종료되었다면 TRUE 반환.
 
WTERMSIG(status)
 - 자식 프로세스를 종료하도록 한 시그널의 번호를 반환.
 - WIFSIGNALED(status)값이 Non-Zero일 경우에만 사용가능.

WIFSTOPPED(status)
 - 반환의 원인이 된 자식 프로세스가 현재 정지되어 있다면 TRUE 반환.
 
WSTOPSIG(status)
 - 자식 프로세스를 정지하도록 야기한 시그널의 번호를 반환.
 - WIFSTOPPED(status)값이 Non-Zero일 경우에만 사용가능.


[ 샘플 코드 ]

#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
#include <string.h>
int main()
{
    int pid;
    int status;
 
    pid = fork();
 
    if (pid < 0)
    {
        perror("fork error : ");
        exit(0);
    }
    if (pid == 0)
    {
        printf("Im Child\n");
        sleep(10);
        return 2;
    }
    else
    {
        printf("Parent: wait (%d)\n", pid);
        waitpid(pid, &status, 0);
        if (WIFEXITED(status))
        {
            printf("정상종료\n");
            printf("리턴값 %d\n", WEXITSTATUS(status));
        }
        else if (WIFSIGNALED(status))
        {
            printf("신호받았음\n");
            printf("신호번호 %d\n", WTERMSIG(status));
        }
    }
    exit(0);
}

저작자 표시
posted by 월리정
 <PREV 1 2 3 4 5 ... 18    NEXT>