'분류 전체보기'에 해당되는 글 24건
- 2018.11.01 OpenSSL을 이용하여 사설 SSL 인증서 만들기 1
- 2015.02.03 script 명령어 (LINUX 사용자간 명령어 전달 및 실행 로그 저장)
- 2014.05.08 HTTPD(Apache) 설치
- 2013.08.28 CentOS PnP 명령어 (kudzu)
- 2013.05.16 MySQL Show 명령어 정리
- 2013.04.17 InnoDB 설정
- 2011.02.07 mysqldump 간단사용법
- 2011.01.18 Sipp 설치 ( Linux - fedora9 )
- 2011.01.18 Sipp 설치 ( Windows )
- 2010.11.25 CentOS 5.5 + Asterisk 1.8 구축 2
웹 서비스용 사설 SSL 인증서 만들기
1. RootCA 인증서 카 생성 (RSA)
#> openssl genrsa -aes256 -out /home/Kimos/WebSSL/kimos-rootca.key 2048
Generating RSA private key, 2048 bit long modulus ..............................+++ .....................................................+++ e is 65537 (0x10001) Enter pass phrase for /home/Kimos/WebSSL/kimos-rootca.key: Verifying - Enter pass phrase for /home/Kimos/WebSSL/kimos-rootca.key: |
2. RootCA 인증서 생성을 위한 환결 설정 파일 생성
#> vim kimos-rootca.conf
[ req ] default_bits = 2048 default_md = sha1 default_keyfile = kimos-rootca.key distinguished_name = req_distinguished_name extensions = v3_ca req_extensions = v3_ca [ v3_ca ] basicConstraints = critical, CA:TRUE, pathlen:0 subjectKeyIdentifier = hash ##authorityKeyIdentifier = keyid:always, issuer:always keyUsage = keyCertSign, cRLSign nsCertType = sslCA, emailCA, objCA [req_distinguished_name ] countryName = Country Name (2 letter code) countryName_default = KR countryName_min = 2 countryName_max = 2 # 회사명 입력 organizationName = Organization Name (eg, company) organizationName_default = KimosWork # SSL 서비스할 domain 명 입력 commonName = Common Name (eg, your name or your server's hostname) commonName_default = ssl.kimos.com commonName_max = 64 |
3. RootCA 인증서 생성 요청
#> openssl req -new -key /home/Kimos/WebSSL/kimos-rootca.key -out /home/Kimos/WebSSL/kimos-rootca.csr -config kimos-rootca.conf
Enter pass phrase for /home/Kimos/WebSSL/kimos-rootca.key: You are about to be asked to enter information that will be incorporated into your certificate request. What you are about to enter is what is called a Distinguished Name or a DN. There are quite a few fields but you can leave some blank For some fields there will be a default value, If you enter '.', the field will be left blank. ----- Country Name (2 letter code) [KR]: Organization Name (eg, company) [KimosWork]: Common Name (eg, your name or your servers hostname) [ssl.kimos.com]: |
4. 인증 기간 10년 self-signed RootCA 인증서 생성
#> openssl x509 -req -days 3650 -extensions v3_ca -set_serial 1 \
-in /home/Kimos/WebSSL/kimos-rootca.csr \
-signkey /home/Kimos/WebSSL/kimos-rootca.key \
-out /home/Kimos/WebSSL/kimos-rootca.crt \
-extfile kimos-rootca.conf
Signature ok subject=/C=KR/O=KimosWork/CN=ssl.kimos.com Getting Private key Enter pass phrase for /home/Kimos/WebSSL/kimos-rootca.key: |
5. RootCA 인증서 생성 확인
#> openssl x509 -text -in /home/Kimos/WebSSL/kimos-rootca.crt
6. SSL 인증서 RSA 키 생성
#> openssl genrsa -aes256 -out /home/Kimos/WebSSL/kimos-ssl.key 2048
Generating RSA private key, 2048 bit long modulus ...............................+++ ..............+++ e is 65537 (0x10001) Enter pass phrase for /home/Kimos/WebSSL/kimos-ssl.key: Verifying - Enter pass phrase for /home/Kimos/WebSSL/kimos-ssl.key: |
7. SSL 인증서 생성을 위한 환결 설정 파일 생성
#> vim kimos-ssl.conf
[ req ] default_bits = 2048 default_md = sha1 default_keyfile = kimos-rootca.key distinguished_name = req_distinguished_name extensions = v3_user [ v3_user ] basicConstraints = CA:FALSE authorityKeyIdentifier = keyid,issuer subjectKeyIdentifier = hash keyUsage = nonRepudiation, digitalSignature, keyEncipherment extendedKeyUsage = serverAuth,clientAuth subjectAltName = @alt_names [ alt_names] DNS.1 = ssl.kimos.com #DNS.2 = kimos.com #DNS.3 = *.kimos.com [req_distinguished_name ] countryName = Country Name (2 letter code) countryName_default = KR countryName_min = 2 countryName_max = 2 organizationName = Organization Name (eg, company) organizationName_default = KimosWork organizationalUnitName = Organizational Unit Name (eg, section) organizationalUnitName_default = Solutions R&D Team # SSL 서비스할 domain 명 입력 commonName = Common Name (eg, your name or your server's hostname) commonName_default = ssl.kimos.com commonName_max = 64 |
8. SSL 인증서 생성 요청
#> openssl req -new -key /home/Kimos/WebSSL/kimos-ssl.key -out /home/Kimos/WebSSL/kimos-ssl.csr -config kimos-ssl.conf
Enter pass phrase for /home/Kimos/WebSSL/kimos-ssl.key: You are about to be asked to enter information that will be incorporated into your certificate request. What you are about to enter is what is called a Distinguished Name or a DN. There are quite a few fields but you can leave some blank For some fields there will be a default value, If you enter '.', the field will be left blank. ----- Country Name (2 letter code) [KR]: Organization Name (eg, company) [KimosWork]: Organizational Unit Name (eg, section) [Solutions R&D Team]: Common Name (eg, your name or your servers hostname) [ssl.kimos.com]: |
9. 인증 기간 10년 self-signed SSL 인증서 생성
#> openssl x509 -req -days 3650 -extensions v3_user \
-in /home/Kimos/WebSSL/kimos-ssl.csr \
-CA /home/Kimos/WebSSL/kimos-rootca.crt -CAcreateserial \
-CAkey /home/Kimos/WebSSL/kimos-rootca.key \
-out /home/Kimos/WebSSL/kimos-ssl.crt \
-extfile kimos-ssl.conf
Signature ok subject=/C=KR/O=KimosWork/OU=Solutions R&D Team/CN=ssl.kimos.com Getting CA Private Key Enter pass phrase for /home/Kimos/WebSSL/kimos-rootca.key: |
10. SSL 인증서 생성 확인을 위한 인증서 정보 출력
#> openssl x509 -text -in /home/Kimos/WebSSL/kimos-ssl.crt
11. Web에 SSL 인증서 적용을 위한 p12 형식의 파일로 변환
#> openssl pkcs12 -export -in /home/Kimos/WebSSL/kimos-ssl.crt -inkey /home/Kimos/WebSSL/kimos-ssl.key -out kimos-ssl.p12
Enter pass phrase for /home/Kimos/WebSSL/kimos-ssl.key: Enter Export Password: Verifying - Enter Export Password: |
내가 사용하고 있는 화면을 리눅스에 접속하고 있는 다른 사용자에게 공유하고 할 때 사용
간단한 사용법
#> who am i
AAAA pts/0 2015-02-03 10:21 (1.1.1.1)
#> who
AAAA pts/0 2015-02-03 10:21 (1.1.1.1)
BBBB pts/1 2015-02-03 10:38 (2.2.2.2)
#> script /dev/pts/1
.
.
#> who
AAAA pts/0 2015-02-03 10:21 (1.1.1.1)
BBBB pts/1 2015-02-03 10:38 (2.2.2.2)
AAAA pts/3 2015-02-03 10:55
.
.
#> exit
위의 명령어를 사용할 경우, AAAA가 사용하는 명령어 및 실행되고 있는 화면이 BBBB에게도 동일하게 보여진다.
이 경우, BBBB에서 다른 명령어 및 키보드를 입력할 경우 잠시 AAAA에게는 전달 되지 않는다.
AAAA가 script를 이용하여 공유하고 있을 경우, BBBB에서는 작업을 하지 않는 것이 좋다.
작업이 완료된 이후, AAAA에서 exit 명령어를 실행하면 script 작업이 완료된다.
이 외에 script 명령어를 이용하여 자신이 사용한 명령어의 화면은 특정 파일에 LOG를 남기는 것도 가능하다.
설명
- Script 명령은 터미날에서 보여지는 모든 내용을 파일에 기록한다. 이것은 쉘에서의 사용자와 컴과의 작업 상태를 기록하고, 그것을 다시 살펴 보아야할 경우에 아주 유용하게 쓰인다. 또한 파이프 기능을 이용하여 다른 작업을 하고 있으면서이 기록 내용을 인쇄할 수도 있다.
script 옵션 정리
- 파일인자가 있으면, 그 파일에 모든 내용을 기록하고, 없으면, typescript 파일에 기록한다.
- a : 지정한 file 혹은 typescript라는 파일이 존재할 경우 파일을 새로 생성하여 저장하는 것이 아니라 추가되어 저장된다.
- c : script 실행시 실행될 명령어를 입력한다. 입력한 명령어가 종료되면 script도 종료된다.
- f : 사용하는 명령어들이 실시간으로 파일에 저장된다. -f 명령어를 사용하지 않으면 -t 옵션에 설정된 시간에 사용했던 명령어및 화면이 파일에 저장되나 -f 옵션을 사용하면 실시간으로 파일에 저장된다.
- q : 조용한 모드 실행 옵션으로, script 실행 시 및 종료 시에 상태 메세지 출력을 생략한다.
- t : 스크립트 실행 명령어 및 화면이 파일에 저장되는 시간을 설정한다. 미설정 시 기본값은 30초이다.
#> man script
NAME
script - make typescript of terminal sessionSYNOPSIS
script [-a] [-c COMMAND] [-f] [-q] [-t] [file]DESCRIPTION
Script makes a typescript of everything printed on your terminal. It is useful for students who need a hardcopy record of an interactive session as proof of an assignment, as the typescript file can be printed out later with lpr(1). If the argument file is given, script saves all dialogue in file. If no file name is given, the typescript is saved in the file typescript. Options: -a Append the output to file or typescript, retaining the prior con- tents. -c COMMAND Run the COMMAND rather than an interactive shell. This makes it easy for a script to capture the output of a program that behaves differently when its stdout is not a tty. -f Flush output after each write. This is nice for telecooperation: One person does 'mkfifo foo; script -f foo' and another can supervise real-time what is being done using 'cat foo'. -q Be quiet. -t Output timing data to standard error. This data contains two fields, separated by a space. The first field indicates how much time elapsed since the previous output. The second field indi- cates how many characters were output this time. This information can be used to replay typescripts with realistic typing and out- put delays. The script ends when the forked shell exits (a control-D to exit the Bourne shell (sh(1)), and exit, logout or control-d (if ignoreeof is not set) for the C-shell, csh(1)). Certain interactive commands, such as vi(1), create garbage in the type- script file. Script works best with commands that do not manipulate the screen, the results are meant to emulate a hardcopy terminal.ENVIRONMENT
The following environment variable is utilized by script: SHELL If the variable SHELL exists, the shell forked by script will be that shell. If SHELL is not set, the Bourne shell is assumed. (Most shells set this variable automatically).SEE ALSO
csh(1) (for the history mechanism), scriptreplay(1).HISTORY
The script command appeared in 3.0BSD.BUGS
Script places everything in the log file, including linefeeds and
backspaces. This is not what the naive user expects.
CentOS에서 Lan Card 변경 및 하드웨어가 추가 및 변경, 또는 제거되었을 경우,
아래의 명령어를 사용하여 적용 시킬수 있다.
아래의 명령어는 Windows 시스템의 PnP 기능을 수행하는 명령어 이다.
$> kudzu
MySQL Show 명령어 정리
1. show database [like ‘%패턴%”];
- 현재 접속한 계정의 권한으로 제어가능한 DataBase 목록
- [like ‘%패턴%”] 옵션으로 패턴 검색 가능
2. show [open] tables [from DB명] [like ‘%패턴%”];
- 접속되어 있는 DB(선택한 DB)의 table 리스트
- [from db명] 옵션으로 DB를 지정하여 실행 가능
- [like ‘%패턴%”] 옵션으로 패턴 검색 가능
- open 옵션으로 열려있는 table만 검색 가능
3. show index from table명 [from DB명];
- 선택한 table의 Index 정보
- [from db명] 옵션으로 DB를 지정하여 실행 가능
4. show [full] columns from table명 [from DB명] [like ‘%패턴%”];
- desc 명령어 같음
- 선택한 table의 테이블 구조 정보
- [from db명] 옵션으로 DB를 지정하여 실행 가능
- [like ‘%패턴%”] 옵션으로 패턴 검색 가능
- [full] 옵션으로 모든 정보 검색 가능
5. show table status [from DB명] [like ‘%패턴%”];
- 접속되어 있는 DB안의 모든 table의 상세 정보 표시
- [from db명] 옵션으로 DB를 지정하여 실행 가능
- [like ‘%패턴%”] 옵션으로 패턴 검색 가능
- Name : 테이블 이름
- Engine : 테이블의 Storage Engine
- Version :테이블의 .frm파일 버전
- Type : 테이블 타입
- Row_format : 열저장 형태 (fixed,Dynamic,Compressed)
- Rows : 열의 수
- Avg_row_length : 열의 평균 길이
- Data_length : 데이타파일의 길이
- Max_data_length : 데이타파일의 최대길이
- Index_length : 인덱스 파일의 길이
- Data_free : 사용되지않는 bytes 에 할당된 수
- Auto_increment : 다음 자동증가 변수
- Create_time : 테이블이 생성된 시간
- Update_time : 데이타파일의 마지막 UPDATE 시간
- Check_time : 테이블의 마지막 체크시간
- Collation : 테이블의 캐릭트셋과 collation
- Create_options : 테이블 생성시의 기타옵션
- Comment : 테이블 생성시의 명령어
6. show create database DB명;
- DB 생성 정보
7. show create table table명;
- table 생성 정보
8. show [storage] engines;
- MySQL의 DB Engine들의 정보 및 사용 가능 여부 확인
9. show erroes [limit [offset,] row_count];
- 실행했던 명령어의 error 리스트
10. show innodb status;
- innodb 설정 정보 및 현재 상태 정보
11. show [bdb] logs;
- 로그파일의 상태정보를 출력
12. show privileges;
- 서버가 지원하는 다른 권한 출력
13, show [full] processlist;
- mysql 클라이언트에 연결되어있는 클라이언트의 정보를 출력
- [full] 옵션으로 현재 실행되고 있는 SQL문 전체 문장 확인 가능, 기본 10자만 표시
14. show [global | session] status [like ‘%패턴%”];
- 현재 MySQL 가동 상태를 알 수 있는 변수값(상태 변수)
- [like ‘%패턴%”] 옵션으로 패턴 검색 가능
15 show [global | session] variables [like ‘%패턴%”];
- 수치를 조정해서 MySQL의 상태를 제어할 수 있는 변수값(환경 변수)
- [like ‘%패턴%”] 옵션으로 패턴 검색 가능
1. InnoDB 설치
가. configure 시에 “--without-innodb” 옵션을 제거하고 설치
나. “--without-innodb” 옵션 제거 후에도 제대로 설치가 안 될 경우 “--with-innodb” 옵션 추가
2. InnoDB 구성
가. 설치 후 /etc/my.cnf 파일을 수정
나. [mysqld] 부분에 아래의 옵션들 추가
[mysqld] …… innodb_data_home_dir = /usr/local/mysql/data/innordb/ innodb_log_group_home_dir = /usr/local/mysql/data/innordb/ innodb_data_file_path = innordata1:256M:autoextend:max:2000M innodb_autoextend_increment = 10M innodb_file_per_table innodb_buffer_pool_size = 2G innodb_additional_mem_pool_size = 20M innodb_flush_log_at_trx_commit = 2 innodb_log_file_size = 512M innodb_log_buffer_size = 2M innodb_lock_wait_timeout = 50 innodb_flush_method = O_DSYNC max_connections = 500 |
다. 옵션 설명
A. innodb_data_home_dir
: 테이블스페이스 파일의 생성 위치 설정
B. innodb_data_file_path
: 테이블스페이스 파일 명 및 크기, 옵션 설정
innordata1:256M:autoextend:max:2000M
innordata1라는 파일명으로 생성되고 256MB의 고정크기로 최초 생성되며, 용량이 256MB가 넘을 경우 “autoextend”라는 옵션으로 자동으로 파일 크기가 확장되며, 최대 확장되는 크기는 MAX 옵션의 설정 값만큼 확장
C. innodb_autoextend_increment
: autoextend 옵션으로 자동 확장되는 크기 지정, 디폴트는 8M
D. innodb_file_per_table
: 공용 테이블스페이스 사용 대신에 테이블 별 테이블스페이스 사용 옵션
TableName.idb 파일 생성
E. innodb_log_group_home_dir
: 로그 파일에 대한 디렉토리 경로 설정
F. innodb_buffer_pool_size
: 자신의 테이블에 있는 데이터와 인덱스를 캐시하기 위해 사용하는 메모리 버퍼의 크기, 이 값을 크게 설정하면 할수록, 테이블에 있는 데이터를 접속하는데 필요한 I/O가 덜 생김, 전체 메모리의 60~80%로 설정
G. innodb_additional_mem_pool_size
: InnoDB가 데이터 디렉토리 정보와 다른 내부 데이터 구조를 저장하기 위해 사용하는 메모리 풀의 크기
H. innodb_flush_log_at_trx_commit
: 자신의 테이블에 있는 데이터와 인덱스를 캐시하기 위해 사용하는 메모리 버퍼의 크기, 이 값을 크게 설정하면 할수록, 테이블에 있는 데이터를 접속하는데 필요한 I/O가 덜 생김, 전체 메모리의 60~80%로 설정
I. innodb_flush_log_at_trx_commit
: commit 을 하였을때 그 즉시 commit 된 데이터를 log file 에 기록할지 안할지를 설정
0 - log buffer내용이 1초 간격으로 로그파일에 쓰여지고 flush, commit시 미동작
1 - log buffer내용이 commit할 때에 로그 파일에 쓰여지고 flush
2 - log buffer내용이 commit할 때에 로그 파일에 쓰여지고 flush는 1초 간격으로 동작
J. innodb_log_buffer_size
: InnoDB가 로그 파일을 디스크에 쓰기 위해 사용하는 버퍼의 크기. 사용 가능한 크기는 1~8MB, 디폴트는1MB.
K. innodb_log_file_size
: 로그 파일의 크기 설정, 디폴트는 5MB, 로그 파일은 하나의 파일에 계속 저장되는 것이 아니고 순차적으로 파일이 일정한 크기와 용량으로 순환식으로 생성, innodb_buffer_pool_size의 25% 정도로 설정.
L. innodb_lock_wait_timeout
: 트랜젝션의 타임아웃은 롤백이 진행되기 전에 락을 대기하는 시간, 디폴트는 50.
M. innodb_flush_method
: Flush 명령어 방식 설정, 디폴트는 fdatasync.
fdatasync - fsync()를 사용해서 데이터와 로그 파일을 flush
O_SYNC - 로그 파일을 열고 flush하지만, 데이터 파일을 flush하기 위해서는 fsync()를 사용
O_DIRECT - O_DIRECT를 사용해서 데이터 파일을 열고, 데이터 파일과 로그 파일을 flush (몇몇 GNU/Linux 버전에서 사용 가능함)
※ Windows에서는 flush 방식은 항상 async_unbuffered 사용
N. innodb_thread_concurrency
: InnoDB 내부에 OS 쓰레드의 숫자 설정, 설정된 값과 같거나 적게 유지, 권장하는 값은 여러분이 사용하는 시스템의 프로세스와 디스크의 전체 합, 설정 값의 범위는 0~100.
3. InnoDB Table 생성(Default Engine이 InnoDB가 아닐 경우)
가. Table 생성시
: InnoDB 테이블을 생성하기 위해서는, CREATE TABLE 명령문에서 ENGINE = InnoDB 옵션을 지정한다:
CREATE TABLE customers (a INT, b CHAR (20), INDEX (a)) ENGINE=InnoDB;
나. MyISAM 테이블을 InnoDB로 변환
: Alter문 사용하여 변경
ALTER TABLE tablename ENGINE=INNODB;
Sipp를 Linux에 설치 시, Pcap 및 authentication을 사용 할 것이 아니라면 sipp만 받아서 설치하시면 됩니다.
그러나 두 기능을 사용하시려면 각각 라이브러리가 설치가 되어 있어야 합니다.
1. Pcap
1.1 리눅스에서 sipp 실행시 Pcap play를 하기 위해서는 Libpcap이 sipp설치 전에 설치되어 있어야 합니다.
1.2 홈페이지
http://www.tcpdump.org
1.3 설치 확인
$> ls -l /usr/include/pcap.h
$> ls -l /usr/local/include/pcap.h
$> locate pcap.h
1.4 libpcp 파일 (libpcap-1.1.1)
http://www.tcpdump.org/release/libpcap-1.1.1.tar.gz
1.4 설치
$> tar -zxvf libpcap-1.1.1.tar.gz
$> cd libpcap-1.1.1/
$> ./configure
$> make
$> make install
2. authentication
2.1 authentication를 사용하기 위해서는 OpenSSL 라이브러리가 설치 되어있어야 합니다.
2.2 홈페이지
http://www.openssl.org/
2.3 설치 확인
$> which openssl
/usr/bin/openssl
$> locate openssl
2.3 OpenSSL 파일 (openssl-1.0.0c)
http://www.openssl.org/source/openssl-1.0.0c.tar.gz
2.4 설치
$> tar -zxvf openssl-1.0.0c.tar.gz
$> cd openssl-1.0.0c
$> ./config --prefix=/usr/local
$> make
$> make install
3. Sipp
3.1 홈페이지
http://sipp.sourceforge.net
3.2 Sipp 파일
http://sourceforge.net/projects/sipp/files/sipp/3.2/sipp.svn.tar.gz/download
3.3 설치
$> tar -zxvf sipp.svn.tar.gz
$> cd sipp.svn
$> make pcapplay_ossl
▶ Without TLS(No pcap, No authentication) : make
▶ With TLS(No pcap) : make ossl
▶ With Pcap, Without TLS(No authentication) : make pcapplay
▶ With Pcap, With TLS : make pcapplay_ossl
Sipp를 Windows에 설치하기
1. Sipp에서 pcap을 사용하기 위해서는 WinPcap을 받아 미리 Sipp 설치하기 전에 먼저 설치가 되어있어야 합니다.
현재 최신버전인 WinPcap 4.1.2 버전을 받아 설치를 합니다.
설치 버젼 : http://www.winpcap.org/install/bin/WinPcap_4_1_2.exe
2. WinPcap 홈페이지에서 받은 WpdPack_4_1_2.exe 파일을 실행하여 설치합니다.
3. Sipp 홈페이지에서 윈도우 설치용 최신 버전 파일을 받아 설치합니다.
윈도우용 설치 버전 : http://sourceforge.net/projects/sipp/files/sipp/3.2/sipp-win32-3.2-setup.exe/download
4. 받은 파일 sipp-win32-3.2-setup.exe을 실행하여 설치합니다.
5. C:\Program Files\Sipp_3.2안에 sipp.exe 파일을 실행하면 됩니다.
Sipp 홈페이지 : http://sipp.sourceforge.net/
WinPcap 홈페이지 : http://www.winpcap.org/default.htm
PBX 서버를 구축하기 전 리눅스 환경설정을 먼저 설정합니다.
1. 패키지 업데이트
: 설치된 패키지를 업데이트를 해줍니다.
$> yum -y update
2. 리눅스 text모드로 실행 ( X 윈도우 미사용 )
: inittab을 설정을 변경하여 부팅시 text 모드로 부팅되게끔 수정합니다.
$> vi /etc/inittab
id:5:initdefault: -> id:3:initdefault: 로 변경
3. 터미널 접속시 한글설정
: 기본적으로 설치시 한글은 utf-8로 지정되어 있어 euc-kr을 쓰는 터미널 프로그램에서는 한글이 깨져 나옵니다.
해서 시스템 자체의 한글 설정을 euc-kr로 변경해줍니다.
$> vi /etc/sysconfig/i18n
LANG="ko_KR.eucKR" |
4. 필요한 추가 패키지 설치
: yum을 이용하여 필요한 패키지를 설치하여 줍니다.
(xinetd, vsftpd, lm_sensons, sysstat… etc…)
5. ntsysv 를 이용하여 불필요한 패키지 비활성화 시켜줍니다.
이 정도까지 기본 설정은 완료된 것으로 보입니다.
추가 설정은 각자 자신의 판단으로 하면 될 것 같습니다.