728x90
반응형

Centos7 설치시 파이썬 버전은 Python 2.7 버전이  Default 설치 됩니다. 

Python3.7 버전 설치 하는 방법에 대해 알아 보겠습니다. 

 

파이썬 다운로드

아래 ftp 경로에 파이썬 여러버전이 업로드 되어 있습니다. 

사용하고자 하는 버전을 확인 합니다. 

https://www.python.org/ftp/python/

 

Index of /ftp/python/

 

www.python.org

 

#설치 경로 이동 
cd /usr/src/

#파이썬 다운로드 
wget https://www.python.org/ftp/python/3.7.1/Python-3.7.1.tgz

#파이썬 압축해제

필수 팩키지 리스트

#필수 설치 팩키지 확인
yum list gcc openssl-devel bzip2-devel libffi-devel

#필수 팩키지 설치 
yum install -y list gcc openssl-devel bzip2-devel libffi-devel

파이썬 설치

 #파이썬 경로 이동 
 cd Python-3.7.1/
 
#파이썬 환경 설정 
 ./configure --enable-optimizations

#설치
make altinstall
  • 정상설치 확인
Looking in links: /tmp/tmp6l2a8r7l
Collecting setuptools
Collecting pip
Installing collected packages: setuptools, pip
Successfully installed pip-10.0.1 setuptools-39.0.1
[root@centos7:/usr/src/Python-3.7.1]$ 

 

파이썬 버전 및 python3.7 환경 설정

설치 후 버전 확인을 하면 여전히 2.7 버전으로 표기 됩니다. 

링크 생성후 범용 적으로 사용 하도록 설정해 줍니다. 

 

[root@centos7:/usr/src/Python-3.7.1]$ python -V
Python 2.7.5
[root@centos7:/usr/src/Python-3.7.1]$ /usr/src/Python-3.7.1/python -V
Python 3.7.1
#bin 경로 이동 
cd /usr/bin
#링크 생성 
ln -s /usr/src/Python-3.7.1/python python3

#profile alias 설정
vi /etc/profile

alias python="python3"

#profile 적용 
. /etc/profile
  • 환경 설정 변경후 설치 버전 재 확인 
[root@centos7:/root]$ python -V
Python 3.7.1

 

728x90
반응형
728x90
반응형

파이썬 메일 보내는 방법 

파이썬에서 메일 보내는 방법에 대한 코드 공유입니다. 

리눅스에 설치된 SendMail 서버를 통해 첨부 파일과 함께 메일을 보내는 예제입니다. 

코드양은 많지 않아 별도로 설명 하지는 않습니다. 

 

조금씩 수정해 보면서 사용자 용도에 맞게 변경해서 적용해 보세요

Python STMT Mail Send 코드

  • python2.7 환경에서 작성되었습니다. 
  • 메일주소는 테스트할 주소에 맞게 수정해서 테스트하세요 
  • 메일서버 구성은 해당 글을 참고 하세요 
#!/usr/bin/python
# -*- coding:utf-8 -*-

import sys
import sys
reload(sys)
sys.setdefaultencoding("utf-8")
import smtplib
from email.mime.text import MIMEText
from email.mime.base import MIMEBase
from email.mime.multipart import MIMEMultipart
from email.header import Header
from email.encoders import encode_base64
from email import Utils
from email import Encoders 
import os

sys.setdefaultencoding("utf-8")

STMT_HOST='localhost'
PORT = 25

COMMASPACE = ", "
class StmtMail:
    def __init__(self):
        self.stmt_host = STMT_HOST
        self.port = PORT
        self.from_user = ''
        self.to_user = ''

    def sendmail(self,from_user, to_user, cc_users, subject, contents, attach):
        
        try:
            print " Mail Send "        
            msg = MIMEMultipart()
            #msg = MIMEMultipart("alternative")
            msg["From"] = from_user
            msg["To"] = to_user
            msg["Cc"] = COMMASPACE.join(cc_users)
            msg["Subject"] = Header(s=subject, charset="utf-8")
            msg["Date"] = Utils.formatdate(localtime = 1)
            msg.attach(MIMEText(contents, "html", _charset="utf-8"))
        
            if (attach != None):
                    part = MIMEBase("application", "octet-stream" ,charset="utf8")
                    part.set_payload(open(attach, "rb").read())
                    Encoders.encode_base64(part)
                    part.add_header("Content-Disposition", 'attachment; filename="%s"' % os.path.basename(attach))
                    msg.attach(part)

            smtp = smtplib.SMTP(self.stmt_host, self.port)
            smtp.sendmail(from_user, cc_users, msg.as_string())
            smtp.close()
        except Exception, e:
            exc_type, exc_value, exc_traceback = sys.exc_info()
            print "[-] Error       : %s " % e
            print "[-] line number :  " , exc_traceback.tb_lineno


if __name__=="__main__":

    try:
        print " Mail Send "
        stmtmail = StmtMail()
        stmtmail.sendmail("example@co.kr", "example@co.kr", ["example@co.kr"] \
                , "Python Send Mail Test " \
                , "TEST MAIL" \
                , None) 

    except Exception, e:
        exc_type, exc_value, exc_traceback = sys.exc_info()
        print "[-] Error       : %s " % e
        print "[-] line number :  " , exc_traceback.tb_lineno

 

테스트 결과 

  • sendmail.py 실행
(py27) [pythontest@centos7:/home/pythontest/venv/py27/test]$ python sendmail.py 
 Mail Send 
 Mail Send 

스팸 메일로 정상적으로 메일이 전송되었습니다. 

728x90
반응형
728x90
반응형

Oracle NLS_LANGUAGE 변경 Scripts

  • 데이터 베이스 NLS_LANGUAGE 변경 방법에 대해 공유 합니다. 
  • 독일어로 변경하는 방법에 대해 알아 보겠습니다. 
-- dba 접속
sqlplus sys/oracle as sysdba

-- 언어셋 변경 
update sys.props$ set value$='AL32UTF8' where name='NLS_CHARACTERSET';  
update sys.props$ set value$='AL16UTF16' where  name='NLS_NCHAR_CHARACTERSET';
update sys.props$ set value$='GERMAN_GERMANY.WE8ISO8859P1  ' where name='NLS_LANGUAGE';
commit;

- db 재기동
SHUTDOWN IMMEDIATE;
STARTUP MOUNT;

ALTER SYSTEM ENABLE RESTRICTED SESSION;

ALTER SYSTEM SET JOB_QUEUE_PROCESSES=0;

ALTER SYSTEM SET AQ_TM_PROCESSES=0;

ALTER DATABASE OPEN;

ALTER DATABASE CHARACTER SET INTERNAL_USE WE8ISO8859P1;

SHUTDOWN IMMEDIATE;

STARTUP;

 

NLS_LANGUAGE 변경 진행 과정

[oracle@153467d4adce ~]$ sqlplus sys/oracle@orclcdb  as sysdba  

SQL*Plus: Release 19.0.0.0.0 - Production on Wed Apr 13 10:04:38 2022
Version 19.3.0.0.0

Copyright (c) 1982, 2019, Oracle.  All rights reserved.


Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0

SQL> update sys.props$ set value$='AL32UTF8' where name='NLS_CHARACTERSET';  

1 row updated.

SQL> update sys.props$ set value$='AL16UTF16' where  name='NLS_NCHAR_CHARACTERSET';

1 row updated.

SQL> update sys.props$ set value$='GERMAN_GERMANY.WE8ISO8859P1  ' where name='NLS_LANGUAGE';

1 row updated.

SQL> commit;

Commit complete.

SQL> SHUTDOWN IMMEDIATE;

Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> SQL> 
SQL> STARTUP MOUNT;
ORACLE instance started.

Total System Global Area 1610609928 bytes
Fixed Size                  9135368 bytes
Variable Size             419430400 bytes
Database Buffers         1174405120 bytes
Redo Buffers                7639040 bytes
Database mounted.
SQL> ALTER SYSTEM ENABLE RESTRICTED SESSION;

System altered.

SQL> ALTER SYSTEM SET JOB_QUEUE_PROCESSES=0;

System altered.

SQL> ALTER SYSTEM SET AQ_TM_PROCESSES=0;

System altered.

SQL> ALTER DATABASE OPEN;

Database altered.

SQL> ALTER DATABASE CHARACTER SET INTERNAL_USE WE8ISO8859P1;

Database altered.

SQL> SHUTDOWN IMMEDIATE;

Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> SQL> STARTUP;
ORACLE instance started.

Total System Global Area 1610609928 bytes
Fixed Size                  9135368 bytes
Variable Size             419430400 bytes
Database Buffers         1174405120 bytes
Redo Buffers                7639040 bytes
Database mounted.

Database opened.

 

변경된 NLS 정보 확인 방법

set linesize 400
set pagesize 100
col PARAMETER for a30
col VALUE for a100

-- 현재 nls 구성정보
SELECT * FROM V$NLS_PARAMETERS;
 
--설치시 nls 정보
SELECT * FROM NLS_DATABASE_PARAMETERS;
 
--인스턴스 nls 정보
SELECT * FROM NLS_INSTANCE_PARAMETERS;​

 

728x90
반응형
728x90
반응형

리눅스 실행중인  프로세스가 없는데도 메모리 점유 하는 상황이 발생하는 경우에 대한 해결방법을 공유 합니다. 

 

시스템 메모리 사용량 확인 

특성 프로세스가 메모리를 점유하지 않음 에도 사용 가능한 free 메모리가 넉넉지 않다. 

  • free -h  : h 옵션은 human read 를 나타낸다.

  • top 명령으로 메모리 사용량 확인 

해결 방법

/proc/sys/vm/drop_caches 수행을 통해  메모리 반환이 가능 하다. 

리눅스 Kernels 2.6.16 이상에서 사용 가능 하며 

명령을 수행 하기 전에 sync 명령을 수행 하면 캐시 메모리에 올라간 데이터를 disk 로 내리는 작업을 진행 한다. 

pagecache 비우기

echo 1 > /proc/sys/vm/drop_caches

dentries and inodes 비우기

echo 2 > /proc/sys/vm/drop_caches

pagecache, dentries and inodes 한번에 비우기

echo 3 > /proc/sys/vm/drop_caches

 

테스트 결과 

[root@centos7:/root]$ sync
[root@centos7:/root]$ free -h
              total        used        free      shared  buff/cache   available
Mem:            15G        982M        2.8G        314M         11G         13G
Swap:          7.8G         15M        7.8G
[root@centos7:/root]$ echo 1 > /proc/sys/vm/drop_caches
[root@centos7:/root]$ free -h
              total        used        free      shared  buff/cache   available
Mem:            15G        981M         14G        314M        447M         13G
Swap:          7.8G         15M        7.8G
[root@centos7:/root]$ echo 2 > /proc/sys/vm/drop_caches 
[root@centos7:/root]$ echo 3 > /proc/sys/vm/drop_caches 
[root@centos7:/root]$ free -h
              total        used        free      shared  buff/cache   available
Mem:            15G        978M         14G        314M        445M         13G
Swap:          7.8G         15M        7.8G
728x90
반응형
728x90
반응형

ODBC 란? 

ODBC 란 Open DataBase Connectivity  약어로 데이터 베이스에 연결하기 위한 공개형 응용 프로그램 인터페이스를 말합니다.  간단히 데이터베이스와 어플리케이션을 연결해주는 인터페이스라고 보면 되겠습니다.   

 

최초 마이크로 소프트에서 데이터베이스에 접근하기 위해 개발된 소프트웨어 규약으로서 DBMS 어플리케이션 인터 페이스(API) 이며 , Unix 계열 운영체제에서도 사용할수있도록 개발한 것이 unixODBC,iodbc 입니다. 

 

 

Tibero 와 ODBC 연동 방법에 대한 설명 자료 입니다. 

 

Tibero iodbc 연동 

1. iodbc 설치 바이너리 다운로드

idobc 홈페이지에서 사용할 버전을 확인후 드라이버를 다운로드를 받습니다.

https://github.com/openlink/iODBC/releases

 

Releases · openlink/iODBC

An open-source ODBC driver manager and SDK that facilitates the development of database-independent applications on linux, freebsd, unix and MacOS X platforms. - openlink/iODBC

github.com

 

2. Install

  • 압축 해제  및 설치 진행
tar xvzf libiodbc-3.52.15.tar.gz

./configure --prefix=/usr/local --sysconfdir=/etc --disable-gui

make

make install

3.환경 파일 작성 

  • odbc.ini
    • 접속할 DBMS DNS 정보를 설정하는 파일 입니다. 
  • .odbc 파일 읽는 순서   : $HOME 아래에 .odbc.ini를 만들면 해당 경로를 먼저 읽음
  • 순서 : $HOME/.odbc.ini -> /etc/odbc.ini
vi .odbc.ini 
[ODBC Data Sources]

Tibero7 = Tibero7 ODBC driver

[ODBC]

Trace = 1

TraceFile = /home/django/unixODBC/unixODBC-2.3.9/trace/odbc.trace

[Tibero7]

Driver = /home/django/tibero7/client/lib/libtbodbc.so

Description = Tibero ODBC driver for Tibero

server = 192.168.xxx.xxxx


#server는(ip,hostname 둘다가능)

port = 17000

#port 는 tibero port

database = tibero

#database 는  DB_NAME 입력 

User =tibero

Password = tmax

 

4.접속 테스트 

$ iodbctest "DSN=Tibero7;UID=tibero;PWD=tmax"
iODBC Demonstration program
This program shows an interactive SQL processor
Driver Manager: 03.52.1521.0607
Driver: 07.00.0218 (libtbodbc.so)

SQL>select * from dual;

DUMMY
-----
X    

 result set 1 returned 1 rows.

 

Tibero unixODBC 연동 

Centos7 기준으로 설명 합니다. 

1.unixODBC 다운로드 

아래 경로에서 다운로드 받습니다. 

http://www.unixodbc.org/download.html

 

unixODBC

Distribution Format unixODBC is currently availible in a gzip, tar format. This means that you should; 1. copy the unixODBC-2.3.9.tar.gz file somewhere you can create files and directories 2. gunzip unixODBC*.tar.gz 3. tar xvf unixODBC*.tar Doing so will c

www.unixodbc.org

2. Install

  • 환경변수를 설정 합니다.
#ODBC 환경변수 설정 
export UNIXODBC_HOME=/home/django/unixODBC-2.3.9
export LD_LIBRARY_PATH=$UNIXODBC_HOME/lib:$LD_LIBRARY_PATH
export PATH=$UNIXODBC_HOME/bin:$PATH
  • 설치를 진행 합니다.
./configure --prefix=$UNIXODBC_HOME --sysconfdir=$UNIXODBC_HOME/etc --with-iodbc-inidir=$UNIXODBC_HOME/etc --disable-gui
&& make
&& make install

 

3.환경 파일 작성

iodbc 설정 사항과 동일 합니다. 

 

4.테스트

 isql -v Tibero7
+---------------------------------------+
| Connected!                            |
|                                       |
| sql-statement                         |
| help [tablename]                      |
| quit                                  |
|                                       |
+---------------------------------------+
SQL> select * from dual;
+------+
| DUMMY|
+------+
| X    |
+------+
SQLRowCount returns 1
1 rows fetched
SQL>
728x90
반응형
728x90
반응형

오라클 샘플 스키마 생성 방법에 대해 알아보겠습니다. 

오라클 설치 시  오라클 스키마는 생성되지 않습니다. 

테스트하기 위한 Sample Schema 생성 방법에 대해 알아보겠습니다. 

 

Oracle Database Sample Schemas 다운로드

먼저 오라클에서 제공하는 샘플 스키마를 다운로드 받습니다. 

https://github.com/oracle/db-sample-schemas/tree/v19c

 

 

git clone https://github.com/oracle/db-sample-schemas.git

다운로드 파일 :db-sample-schemas

합계 128
drwxr-xr-x 11 oracle-docker oracle-docker  4096  3월 22 20:33 .
drwx------ 12 oracle-docker oracle-docker  4096  3월 22 20:33 ..
drwxr-xr-x  8 oracle-docker oracle-docker  4096  3월 22 20:33 .git
-rw-r--r--  1 oracle-docker oracle-docker   117  3월 22 20:33 CONTRIBUTING.md
-rw-r--r--  1 oracle-docker oracle-docker  1050  3월 22 20:33 LICENSE.md
-rw-r--r--  1 oracle-docker oracle-docker  5682  3월 22 20:33 README.md
-rw-r--r--  1 oracle-docker oracle-docker  5263  3월 22 20:33 README.txt
drwxr-xr-x  2 oracle-docker oracle-docker  4096  3월 22 20:33 bus_intelligence
drwxr-xr-x  2 oracle-docker oracle-docker  4096  3월 22 20:33 customer_orders
-rw-r--r--  1 oracle-docker oracle-docker  3633  3월 22 20:33 drop_sch.sql
drwxr-xr-x  2 oracle-docker oracle-docker  4096  3월 22 20:33 human_resources
drwxr-xr-x  2 oracle-docker oracle-docker  4096  3월 22 20:33 info_exchange
-rw-r--r--  1 oracle-docker oracle-docker  2740  3월 22 20:33 mk_dir.sql
-rw-r--r--  1 oracle-docker oracle-docker 27756  3월 22 20:33 mkplug.sql
-rw-r--r--  1 oracle-docker oracle-docker  7166  3월 22 20:33 mksample.sql
-rw-r--r--  1 oracle-docker oracle-docker  6592  3월 22 20:33 mkunplug.sql
-rw-r--r--  1 oracle-docker oracle-docker  6123  3월 22 20:33 mkverify.sql
drwxr-xr-x  3 oracle-docker oracle-docker  4096  3월 22 20:33 order_entry
drwxr-xr-x  2 oracle-docker oracle-docker  4096  3월 22 20:33 product_media
drwxr-xr-x  2 oracle-docker oracle-docker  4096  3월 22 20:33 sales_history
drwxr-xr-x  2 oracle-docker oracle-docker  4096  3월 22 20:33 shipping

sample-schemas scripts 수행 설명 (mksample.sql)

sqlplus sys/oracle@orclcdb as sysdba

@/opt/oracle/oradata/db-sample-schemas/mksample.sql oracle oracle hr oe pm ix sh bi users temp /opt/oracle/oradata/db-sample-schemas/logs/ ora19c

mksample.sql 에 서 입력 받는 인자 값들입니다. 

입력 변수는 볼드체로 표기했습니다. 

 sqlplus system/systempw@connect_string
@mksample systempw syspw hrpw oepw pmpw ixpw shpw bipw users temp /your/path/to/log/ connect_string

$ vi mksample.sql
Rem
Rem $Header: rdbms/demo/schema/mksample.sql.sbs /main/12 2015/03/19 10:23:26 smtaylor Exp $
Rem
Rem mksample.sql
......
......
......

PROMPT specify password for SYSTEM as parameter 1:
DEFINE password_system     = &1
PROMPT 
PROMPT specify password for SYS as parameter 2:
DEFINE password_sys        = &2
PROMPT 
PROMPT specify password for HR as parameter 3:
DEFINE password_hr         = &3
PROMPT
PROMPT specify password for OE as parameter 4:
DEFINE password_oe         = &4
PROMPT
PROMPT specify password for PM as parameter 5:
DEFINE password_pm         = &5
PROMPT
PROMPT specify password for IX as parameter 6:
DEFINE password_ix         = &6
PROMPT
PROMPT specify password for  SH as parameter 7:
DEFINE password_sh         = &7
PROMPT 
PROMPT specify password for  BI as parameter 8:
DEFINE password_bi         = &8
PROMPT 
PROMPT specify default tablespace as parameter 9:
DEFINE default_ts          = &9
PROMPT
PROMPT specify temporary tablespace as parameter 10: 
DEFINE temp_ts             = &10 
PROMPT 
PROMPT specify log file directory (including trailing delimiter) as parameter 11: 
DEFINE logfile_dir         = &11 
PROMPT 
PROMPT specify connect string as parameter 12: 
DEFINE connect_string     = &12 
PROMPT

 

mksample.sql 파일 수정 

스크립트를 수행하면 샘플 유저를 생성하는 과정에서 ORA-65096: invalid common user or role name 에러가 발생합니다 .

에러 발생을 막기 위해 ALTER SESSION SET "_ORACLE_SCRIPT"=true; 적용하겠습니다. 

mksample.sql 스크립트중 CONNECT system/&&password_system@&&connect_string 구문 밑에 ALTER SESSION SET "_ORACLE_SCRIPT"=true; 를 추가합니다. 

SQL> create user hr identified by hr;
create user hr identified by hr
            *
ERROR at line 1:
ORA-65096: invalid common user or role name

mksample.sql 실행 

SQL> @/opt/oracle/oradata/db-sample-schemas/mksample.sql oracle oracle hr oe pm ix sh bi users temp /opt/oracle/oradata/db-sample-schemas/logs/ ora19c

specify password for SYSTEM as parameter 1:

specify password for SYS as parameter 2:

specify password for HR as parameter 3:

specify password for OE as parameter 4:

specify password for PM as parameter 5:

specify password for IX as parameter 6:

specify password for  SH as parameter 7:

specify password for  BI as parameter 8:

specify default tablespace as parameter 9:

specify temporary tablespace as parameter 10:

specify log file directory (including trailing delimiter) as parameter 11:

specify connect string as parameter 12:

Sample Schemas are being created ...

mkdir: cannot create directory '/opt/oracle/oradata/db-sample-schemas/logs/': File exists

정상적으로 수행이 완료되면 log 디렉토리에 수행 스크립트 별로 로그가 남게 되고 

마지막으로 검증 결과가 mkverify_v3.log 와 같은 형태로 남게 됩니다. 

 

db-sample-schemas/logs]$ ll
합계 172
drwxr-xr-x  2         54321         54321  4096  3월 23 19:53 .
drwxrwxrwx 12 oracle-docker oracle-docker  4096  3월 23 20:27 ..
-rw-r--r--  1         54321         54321  6284  3월 23 19:53 bi_v3.log
-rw-r--r--  1         54321         54321  2075  3월 23 19:53 chan_v3.log
-rw-r--r--  1         54321         54321  2318  3월 23 19:53 coun_v3.log
-rw-r--r--  1         54321         54321  3558  3월 23 19:53 cust1v3.log
-rw-r--r--  1         54321         54321  2751  3월 23 19:53 dem1v3.log
-rw-r--r--  1         54321         54321  2622  3월 23 19:53 dmsal_v3.log
-rw-r--r--  1         54321         54321  5508  3월 23 19:53 ext_1v3.log
-rw-r--r--  1         54321         54321  6199  3월 23 19:52 hr_main.log
-rw-r--r--  1         54321         54321  7038  3월 23 19:53 ix_v3.log
-rw-r--r--  1         54321         54321 59687  3월 23 19:53 mkverify_v3.log
-rw-r--r--  1         54321         54321  5985  3월 23 19:52 oe_oc_v3.log
-rw-r--r--  1         54321         54321   599  3월 23 19:53 pm_main.log
-rw-r--r--  1         54321         54321  5119  3월 23 19:53 pm_p_lob.log
-rw-r--r--  1         54321         54321  3616  3월 23 19:53 prod1v3.log
-rw-r--r--  1         54321         54321  2667  3월 23 19:53 prom1v3.log
-rw-r--r--  1         54321         54321  3104  3월 23 19:53 sale1v3.log
-rw-r--r--  1         54321         54321  6049  3월 23 19:53 sh_v3.log
-rw-r--r--  1         54321         54321  4743  3월 23 19:53 time_v3.log

 

mkverify_v3.log

The Customer Orders(CO) schema 스크립트 수행 

mksample 에서는 co 생성 스크립트가 포함되어 있지 않습니다. 

별도 스크립트로 수행해야 테스트 샘플 스키마가 생성 되게 됩니다. 

수행 파일은  db-sample-schemas/customer_orders/co_main.sql 입니다. 

 

SQL> @co_main
Enter value for 1: co
Enter value for 2: orclcdb
Enter value for 3: users
Enter value for 4: temp
Dropping user
drop user co
          *
ERROR at line 1:
ORA-01918: user 'CO' does not exist


Creating user

Grant succeeded.


User altered.


User altered.

Connected.
Running DDL
Creating tables, constraints and views for Customer Orders
Creating tables

Table created.


Table created.


Table created.

 

Scott 계정 생성 

오라클 12c? 이후 부터는 scott 계정이 기본 적으로 생성되지 않습니다. 

livesql 사이트에서 테이블 정보와 데이터 확인후 샘플데이터를 생성하면 됩니다.

 

https://livesql.oracle.com/apex/livesql/file/content_O5AEB2HE08PYEPTGCFLZU9YCV.html

 

Scott 계정 스크립트

create user scott identified by tiger;
grant dba to scott;

conn scott/tiger

DROP TABLE DEPT;
CREATE TABLE DEPT
       (DEPTNO NUMBER(2) CONSTRAINT PK_DEPT PRIMARY KEY,
	DNAME VARCHAR2(14) ,
	LOC VARCHAR2(13) ) ;
	
DROP TABLE EMP;
CREATE TABLE EMP
       (EMPNO NUMBER(4) CONSTRAINT PK_EMP PRIMARY KEY,
	ENAME VARCHAR2(10),
	JOB VARCHAR2(9),
	MGR NUMBER(4),
	HIREDATE DATE,
	SAL NUMBER(7,2),
	COMM NUMBER(7,2),
	DEPTNO NUMBER(2) CONSTRAINT FK_DEPTNO REFERENCES DEPT);
INSERT INTO DEPT VALUES
	(10,'ACCOUNTING','NEW YORK');
INSERT INTO DEPT VALUES (20,'RESEARCH','DALLAS');
INSERT INTO DEPT VALUES
	(30,'SALES','CHICAGO');
INSERT INTO DEPT VALUES
	(40,'OPERATIONS','BOSTON');
INSERT INTO EMP VALUES
(7369,'SMITH','CLERK',7902,to_date('17-12-1980','dd-mm-yyyy'),800,NULL,20);
INSERT INTO EMP VALUES
(7499,'ALLEN','SALESMAN',7698,to_date('20-2-1981','dd-mm-yyyy'),1600,300,30);
INSERT INTO EMP VALUES
(7521,'WARD','SALESMAN',7698,to_date('22-2-1981','dd-mm-yyyy'),1250,500,30);
INSERT INTO EMP VALUES
(7566,'JONES','MANAGER',7839,to_date('2-4-1981','dd-mm-yyyy'),2975,NULL,20);
INSERT INTO EMP VALUES
(7654,'MARTIN','SALESMAN',7698,to_date('28-9-1981','dd-mm-yyyy'),1250,1400,30);
INSERT INTO EMP VALUES
(7698,'BLAKE','MANAGER',7839,to_date('1-5-1981','dd-mm-yyyy'),2850,NULL,30);
INSERT INTO EMP VALUES
(7782,'CLARK','MANAGER',7839,to_date('9-6-1981','dd-mm-yyyy'),2450,NULL,10);
INSERT INTO EMP VALUES
(7788,'SCOTT','ANALYST',7566,to_date('13-JUL-87')-85,3000,NULL,20);
INSERT INTO EMP VALUES
(7839,'KING','PRESIDENT',NULL,to_date('17-11-1981','dd-mm-yyyy'),5000,NULL,10);
INSERT INTO EMP VALUES
(7844,'TURNER','SALESMAN',7698,to_date('8-9-1981','dd-mm-yyyy'),1500,0,30);
INSERT INTO EMP VALUES
(7876,'ADAMS','CLERK',7788,to_date('13-JUL-87')-51,1100,NULL,20);
INSERT INTO EMP VALUES
(7900,'JAMES','CLERK',7698,to_date('3-12-1981','dd-mm-yyyy'),950,NULL,30);
INSERT INTO EMP VALUES
(7902,'FORD','ANALYST',7566,to_date('3-12-1981','dd-mm-yyyy'),3000,NULL,20);
INSERT INTO EMP VALUES
(7934,'MILLER','CLERK',7782,to_date('23-1-1982','dd-mm-yyyy'),1300,NULL,10);

DROP TABLE BONUS;
CREATE TABLE BONUS
	(
	ENAME VARCHAR2(10)	,
	JOB VARCHAR2(9)  ,
	SAL NUMBER,
	COMM NUMBER
	) ;
	
DROP TABLE SALGRADE;
CREATE TABLE SALGRADE
      ( GRADE NUMBER,
	LOSAL NUMBER,
	HISAL NUMBER );
INSERT INTO SALGRADE VALUES (1,700,1200);
INSERT INTO SALGRADE VALUES (2,1201,1400);
INSERT INTO SALGRADE VALUES (3,1401,2000);
INSERT INTO SALGRADE VALUES (4,2001,3000);
INSERT INTO SALGRADE VALUES (5,3001,9999);
COMMIT;

샘플 스키마 ERD Diagrams 

자세한 자료는 오라클 자료를 참고하시기 바랍니다. 

https://docs.oracle.com/en/database/oracle/oracle-database/19/comsc/schema-diagrams.html#GUID-D268A4DE-BA8D-428E-B47F-80519DC6EE6E

728x90
반응형
728x90
반응형

gui 환경에서 프로그램 실행시 어떤 프로그램도 실행 되지 않을 때가 있습니다. 

기록 차원에서 공유 합니다. 

syslog 에러 확인 

root@ubuntu2004:/var/log# tail -f  syslog 에서 확인 가능 합니다. 

 

7826 Apr 10 12:34:02 ubuntu2004 gnome-shell[221717]: Settings panel for desktop file gnome-network-panel.desktop could not be loaded!
7827 Apr 10 12:34:08 ubuntu2004 gnome-shell[221717]: Settings panel for desktop file gnome-display-panel.desktop could not be loaded!
7828 Apr 10 12:35:03 ubuntu2004 gnome-shell[221717]: Settings panel for desktop file gnome-display-panel.desktop could not be loaded!
7829 Apr 10 12:36:09 ubuntu2004 dbus-daemon[220829]: [session uid=0 pid=220829] Reloaded configuration
7830 Apr 10 12:36:09 ubuntu2004 dbus-daemon[221153]: [session uid=1000 pid=221153] Reloaded configuration
7831 Apr 10 12:36:09 ubuntu2004 dbus-daemon[220829]: [session uid=0 pid=220829] Reloaded configuration
7832 Apr 10 12:36:09 ubuntu2004 dbus-daemon[221153]: [session uid=1000 pid=221153] Reloaded configuration

조치 사항 

gnome-control-center  설치 

[root@ubuntu2004:/root]$ apt-get install gnome-control-center  
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  libcdio-cdda2 libcdio-paranoia2 libnfs13
Use 'apt autoremove' to remove them.
The following additional packages will be installed:
  libsmbclient
Suggested packages:
  gnome-software | gnome-packagekit gnome-user-share realmd libcanberra-gtk-module
The following NEW packages will be installed:
  gnome-control-center libsmbclient
0 upgraded, 2 newly installed, 0 to remove and 3 not upgraded.
Need to get 1,775 kB of archives.
After this operation, 6,076 kB of additional disk space will be used.
Do you want to continue? [Y/n] y​

728x90
반응형
728x90
반응형

메일 전송을 위한 프로 시져 작성 

DROP DIRECTORY ATTACH_FILE;
CREATE DIRECTORY ATTACH_FILE AS '/data1/attach_dir';
GRANT READ ,WRITE ON DIRECTORY ATTACH_FILE TO TIBERO;

CREATE OR REPLACE PROCEDURE send_mail (p_to   IN VARCHAR2,
             p_from  IN VARCHAR2,
             p_subject  IN VARCHAR2,
             p_text_msg IN VARCHAR2 DEFAULT NULL,
             p_attach_dir IN VARCHAR2 DEFAULT NULL,
             p_attach_name IN VARCHAR2 DEFAULT NULL,
             p_attach_mime IN VARCHAR2 DEFAULT NULL,
             p_smtp_host IN VARCHAR2,
             p_smtp_port IN NUMBER DEFAULT 25)
AS
    l_mail_conn UTL_SMTP.connection;
    l_boundary VARCHAR2(50) := '----=*#tmaxSendmailBoundary#*=';
      

    vf_buffer RAW(32767);
    vf_raw    RAW(32767); --반환할 파일
    vf_type  UTL_FILE.FILE_TYPE;
      
BEGIN
    l_mail_conn := UTL_SMTP.open_connection(p_smtp_host, p_smtp_port);
    UTL_SMTP.helo(l_mail_conn, p_smtp_host);
    UTL_SMTP.mail(l_mail_conn, p_from);
    UTL_SMTP.rcpt(l_mail_conn, p_to);

    UTL_SMTP.open_data(l_mail_conn);

    UTL_SMTP.write_data(l_mail_conn, 'Date: ' || TO_CHAR(SYSDATE, 'DD-MON-YYYY HH24:MI:SS') || UTL_TCP.crlf);
    UTL_SMTP.write_data(l_mail_conn, 'To: ' || p_to || UTL_TCP.crlf);
    UTL_SMTP.write_data(l_mail_conn, 'From: ' || p_from || UTL_TCP.crlf);
    UTL_SMTP.write_data(l_mail_conn, 'Subject: ' || p_subject || UTL_TCP.crlf);
    UTL_SMTP.write_data(l_mail_conn, 'Reply-To: ' || p_from || UTL_TCP.crlf);
    UTL_SMTP.write_data(l_mail_conn, 'MIME-Version: 1.0' || UTL_TCP.crlf);
    UTL_SMTP.write_data(l_mail_conn, 'Content-Type: multipart/mixed; boundary="' || l_boundary || '"' || UTL_TCP.crlf || UTL_TCP.crlf);

    IF p_text_msg IS NOT NULL THEN
    UTL_SMTP.write_data(l_mail_conn, '--' || l_boundary || UTL_TCP.crlf);
    UTL_SMTP.write_data(l_mail_conn, 'Content-Type: text/plain; charset="euc-kr"' || UTL_TCP.crlf || UTL_TCP.crlf);

    UTL_SMTP.write_data(l_mail_conn, p_text_msg);
    UTL_SMTP.write_data(l_mail_conn, UTL_TCP.crlf || UTL_TCP.crlf);
    END IF;

    IF p_attach_name IS NOT NULL THEN
    UTL_SMTP.write_data(l_mail_conn, '--' || l_boundary || UTL_TCP.crlf);
    UTL_SMTP.write_data(l_mail_conn, 'Content-Type: ' || p_attach_mime || '; name="' || p_attach_name || '"' || UTL_TCP.crlf);
    UTL_SMTP.write_data(l_mail_conn, 'Content-Transfer-Encoding: base64' || UTL_TCP.crlf);
    UTL_SMTP.write_data(l_mail_conn, 'Content-Disposition: attachment; filename="' || p_attach_name || '"' || UTL_TCP.crlf || UTL_TCP.crlf);


      -- 파일을 바이트모드로 읽는다.
      -- p_dir : 디렉토리명, p_file : 파일명, rb: 바이트모드로 읽기
      vf_type := UTL_FILE.FOPEN ( p_attach_dir, p_attach_name, 'rb');

      -- 파일이 오픈됐는지 IS_OPEN 함수를 이용해 확인.
      IF UTL_FILE.IS_OPEN ( vf_type ) THEN
         -- 루프를 돌며 파일을 읽는다.
         LOOP
         BEGIN
           -- GET_RAW 프로시저로 파일을 읽어 vf_buffer 변수에 담는다.
           UTL_FILE.GET_RAW(vf_type, vf_buffer, 32767);
           -- 반환할 RAW 타입 변수에 vf_buffer를 할당.
           vf_raw := vf_raw || vf_buffer;
            -- BASE64 인코딩을 한 후 파일내용 첨부
            UTL_SMTP.WRITE_RAW_DATA(l_mail_conn, UTL_ENCODE.BASE64_ENCODE ( vf_buffer));
            UTL_SMTP.WRITE_DATA(l_mail_conn,  UTL_TCP.CRLF );
         EXCEPTION
             -- 더 이상 가져올 데이터가 없으면 루프를 빠져나간다.
               WHEN NO_DATA_FOUND THEN
               EXIT;
         END;
         END LOOP;
      END IF;

      -- 파일을 닫는다.
      UTL_FILE.FCLOSE(vf_type);


    UTL_SMTP.write_data(l_mail_conn, UTL_TCP.crlf || UTL_TCP.crlf);
    END IF;

    UTL_SMTP.write_data(l_mail_conn, '--' || l_boundary || '--' || UTL_TCP.crlf);
    UTL_SMTP.close_data(l_mail_conn);

    UTL_SMTP.quit(l_mail_conn);
END;
/

 

첨부 테스트 파일 생성 

$ echo "TEST TESTEST Mail" > test.txt
[root@centos7:/data1/attach_dir]$ vi test.txt
TEST TESTEST Mail

메일전송 테스트

메일 서버는 리눅스 sendmail 서버를 사용 하여 테스트 하였습니다. 

리눅스 Sendmail 설치는 https://growupcoding.tistory.com/47 글을 참고 하세요 

begin
tibero.send_mail( 'example@test.com'
,'example@test.com'
,'첨부파일 테스트'
,'테스트 메일입니다. '
,'ATTACH_FILE'
,'test.txt'
,'application/octet-stream'
,'centos7',25);
end;
/

 

Gmail 메일 확인

728x90
반응형

'05.DB > Tibero' 카테고리의 다른 글

Tibero TAC 설치  (0) 2023.03.13
Tibero RODBC 연동 방법  (1) 2023.03.02
Tibero JDBC Clob 조회 예제  (0) 2022.07.18
[TDP.net] Tibero TDP.net 테스트 방법  (0) 2022.04.28
[Tibero]Tibero ODBC 연동  (0) 2022.04.11
728x90
반응형

VSFTPD 이란?

vsftpd는 Linux를 포함한 Unix 계열 시스템 용 FTP 서버이며

very secure FTP daemon 의 약어 입니다. 

자세한 기능은 아래 페이지를 참고 하세요 

https://security.appspot.com/vsftpd.html

 

vsftpd - Secure, fast FTP server for UNIX-like systems

Probably the most secure and fastest FTP server for UNIX-like systems. About vsftpd vsftpd is a GPL licensed FTP server for UNIX systems, including Linux. It is secure and extremely fast. It is stable. Don't take my word for it, though. Below, we will see

security.appspot.com

 

1.VSFTPD 설치 팩키지 확인 및 설치 

rpm -qa | grep vsftpd
yum -y install vsftpd

2.vsftpd 상태확인

  • service vsftpd status
$ service vsftpd status
Redirecting to /bin/systemctl status vsftpd.service
* vsftpd.service - Vsftpd ftp daemon
   Loaded: loaded (/usr/lib/systemd/system/vsftpd.service; disabled; vendor preset: disabled)
   Active: inactive (dead)

 

3.vsftpd Command

 

systemctl restart vsftpd
systemctl enable vsftpd

 

 

 

 

728x90
반응형

'06.OS > Linux' 카테고리의 다른 글

[Ubuntu]우분투 gif 움짤 프로그램 설치  (0) 2022.04.16
[Linux] 리눅스 캐쉬 메모리 비우기  (0) 2022.04.12
[SendMail] Centos7 SendMail 설치  (0) 2022.04.07
[Centos] Telnet 설치  (0) 2022.04.05
[Ubuntu] 우분투 ROOT 접속  (0) 2022.03.31
728x90
반응형

Nginx 웹서버 설치 방법

Django 웹서버에 배포 하기 위해 Nginx 설치방법에 대해 알아 보겠습니다. 

1.Nginx 저장소 추가

/etc/yum.repos.d/ 경로에 nginx 레파지 토리 추가 합니다. 

 

$ cd /etc/yum.repos.d/
$ vi   nginx.repo
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/7/$basearch/
gpgcheck=0
enabled=1

 

2. 설치

 yum install -y nginx

 

3.Nginx 설정 파일 수정 

Nginx 설정 관련한 파일을 수정합니다. 

  • /etc/nginx/conf.d/default.conf 
  • nginx 에서 사용할 포트를 수정합니다. 사용하고자 하는 포트를 정해서 변경해주세요 
  • 저는 80 -> 8088 포트를 사용하겠습니다.
server {
    listen       8088;
    server_name  localhost;

    #access_log  /var/log/nginx/host.access.log  main;

    location / {
        root   /usr/share/nginx/html;
        index  index.html index.htm;
    }

    #error_page  404              /404.html;

    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }

    # proxy the PHP scripts to Apache listening on 127.0.0.1:80
    #
    #location ~ \.php$ {
    #    proxy_pass   http://127.0.0.1;
    #}

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    #location ~ \.php$ {
    #    root           html;
    #    fastcgi_pass   127.0.0.1:9000;
    #    fastcgi_index  index.php;
    #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
    #    include        fastcgi_params;
    #}

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    #location ~ /\.ht {
    #    deny  all;
    #}
}

4. 방화벽 설정

Nginx 포트 방화벽 해제를 합니다. 

테스트를 위해 방화벽을 중지 시켰습니다.

보안이 걱정 된다면 방화벽 활성화 이후 Nginx 리스너 포트를 개방해 주세요 

$ firewall-cmd --state       
running
# 방확벽 중지 
systemctl stop firewalld

# 방확벽 시작 
systemctl start  firewalld

# 방화벽 상태 확인 
firewall-cmd --state

# 포트 개방
firewall-cmd --permanent --zone=public --add-port=8088/tcp

# 방화벽 재시작
firewall-cmd --reload

# 개방된 포트 목록 확인
firewall-cmd --list-ports

5. Nginx 서비스 시작

#nginx 서비스 활성화
systemctl enable nginx

#Nginx 서비스 시작 
systemctl start nginx

#Nginx 서비스 상태 확인
systemctl status nginx
  • nginx 서비스 상태 확인

$ systemctl status nginx
* nginx.service - nginx - high performance web server
   Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; vendor preset: disabled)
   Active: active (running) since 금 2022-04-08 11:21:58 KST; 1min 9s ago
     Docs: http://nginx.org/en/docs/
  Process: 23340 ExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.conf (code=exited, status=0/SUCCESS)
 Main PID: 23341 (nginx)
    Tasks: 5
   Memory: 3.2M
   CGroup: /system.slice/nginx.service
           |-23341 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf
           |-23342 nginx: worker process
           |-23343 nginx: worker process
           |-23344 nginx: worker process
           `-23345 nginx: worker process

6. Nginx  웹페이지 접속 

http://localhost:8088/ 로 접속 해서 정상 적으로 설치 되었는지 확인 합니다.

Nginx  접속

728x90
반응형

+ Recent posts