Monday 26 December 2016

[Maria/MySQL] Change Table Storage Engine (테이블 엔진 변경)

1. Check table storage engine (테이블 별 엔진 확인)

SELECT TABLE_SCHEMA,TABLE_NAME,ENGINE FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='[DB_NAME]';




2. Change storage engine (테이블 엔진 변경)

ALTER TABLE [TABLE_NAME] ENGINE='[STORAGE_ENGINE]';


Thursday 10 November 2016

[Infiniflux] Install and setup Infiniflux(Iflux) Database (Infiniflux DB 설치)

1. Setup OS Parameters

# set the maximum number of files
ulimit -Sn
sudo vi /etc/security/limits.conf






# Reboot
#> su - 
$> init 6




#  Check maximum number of files
$> ulimit -Sn





2. Install Packages

# Download RPM Package
$> wget http://www.infiniflux.com/dist/infiniflux-std-3.0.1.8813.official-LINUX-X86-64-release.rpm




# Install RPM Package
$> sudo yum localinstall infiniflux-std-3.0.1.8813.official-LINUX-X86-64-release.rpm




# List installed package up
#> ls -al /opt/ | grep infiniflux
#> ls -al /opt/infiniflux/
#> ls -al /opt/infiniflux/versions/3.0.1




# Setup Enviroment
#> vi .bashrc






3. Start Database

# Command
# service ifluxd {start|stop|kill|restart|createdb|destorydb|check|IWA|console|port|exe|collector|help}


# Start DB
#> sudo service ifluxd start









# Check or change port
#> sudo service ifluxd port



[Oracle] How to check Archive Log Mode (아카이브 로그 모드 확인)






Online Archive log check


------------------------------------------------------------------------------
-- Redo Log Group, Member Information
--
-- CURRENT  : LGWR Process is in use
-- ACTIVE   : LGWR Process is not in use. But Recover is necessary
              because of transaction spending long time
-- INACTIVE : LGWR Process is not in use and Recovery is not necessary
------------------------------------------------------------------------------
SELECT GROUP#
     , MEMBERS
     , BYTES
     , ARCHIVED
     , STATUS
FROM V$LOG;




------------------------------
-- Redo Log File Information
------------------------------
SELECT GROUP#
    ,  STATUS
    ,  MEMBER
FROM V$LOGFILE;

[Linux] Add sudo user (Sudo 사용자 추가)



Sunday 16 October 2016

[ActiveMQ] Force IPv4 stack

As a default, on the Linux platform, if you have IPV6 support enabled in your kernel, the Java Runtime (since 1.4 version) will use IPV6 sockets to communicate.

for forcing IPV4 stack to be used by the Java Runtime.
 -Djava.net.preferIPv4Stack=true




Tuesday 30 August 2016

[H2] How to check table lock in H2 database

SELECT * FROM INFORMATION_SCHEMA.LOCKS;

SELECT * 
  FROM INFORMATION_SCHEMA.LOCKS
 WHERE TABLE_SCHEMA = '<SCHEMA_NAME>'
   AND TABLE_NAME = '<TABLE_NAME>'
;

Monday 29 August 2016

[NodeMCU] Lua Crypto Package and interface with Java program using AES-ECB

NodeMCU is an eLua based firmware for the ESP8266 WiFi SOC from Espressif.
NodeMCU support encrypt and decrypt functions which are in crypto packages.

http://nodemcu.readthedocs.io/en/dev/en/modules/crypto/
This is manual for Crypto package.

crypto.encrypt()

Encrypts Lua strings.

Syntax

crypto.encrypt(algo, key, plain [, iv])

Parameters

  • algo the name of the encryption algorithm to use, one of
    • "AES-ECB" for 128-bit AES in ECB mode
    • "AES-CBC" for 128-bit AES in CBC mode
  • key the encryption key as a string; for AES encryption this MUST be 16 bytes long
  • plain the string to encrypt; it will be automatically zero-padded to a 16-byte boundary if necessary
  • iv the initilization vector, if using AES-CBC; defaults to all-zero if not given

Returns

The encrypted data as a binary string. For AES this is always a multiple of 16 bytes in length.


Crypto package AES-ECB using no padding. So you should make 16 multiple bytes array from plain text. And NodeMCU use EUCKR encoding in crypto package.


NodeMCU

1
2
3
4
5
6
key = "1234567890abcdef"
cipher = crypto.encrypt("AES-ECB", key, "Hi, I'm secret!")
print(crypto.toBase64(cipher))

cipher = crypto.encrypt("AES-ECB", key, "가나다라마바사")
print(crypto.toBase64(cipher))

Result
LQ95s23+t6PK0mmokJFSYg==
w9kOL6y40iVqhuGdWt6vLw==


Java

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
 public static void main( String[] args) throws Exception {

     String keyValue = "1234567890abcdef";
     String encryptedText1 = "LQ95s23+t6PK0mmokJFSYg==";
     String encryptedText2 = "w9kOL6y40iVqhuGdWt6vLw==";
     java.nio.charset.Charset charset = java.nio.charset.Charset.forName( "euckr");

     java.security.Key key = new javax.crypto.spec.SecretKeySpec( keyValue.getBytes( charset), "AES");
     javax.crypto.Cipher cipher = Cipher.getInstance( "AES/ECB/NoPadding");
     cipher.init( Cipher.DECRYPT_MODE, key);
     
     System.out.println( "DecryptedText1=" + new String( cipher.doFinal( org.apache.commons.codec.binary.Base64.decodeBase64( encryptedText1.getBytes( charset))), charset));
     System.out.println( "DecryptedText2=" + new String( cipher.doFinal( org.apache.commons.codec.binary.Base64.decodeBase64( encryptedText2.getBytes( charset))), charset));
     
}


Result

Wednesday 24 August 2016

[CentOS] Setup Mail server (메일 서버 구축)

MTA (Mail Transfer Agent)
ex) Sendmail, Qmail, Microsfot Exchange

MUA (Mail user Agent)
ex) Outlook Express

MDA (Mail Delivery Agent)
ex) POP3, IMAP




Send Protocol
SMTP (Simple Mail Transfer Protocol)
 : TCP/IP mail transfer protocol. Default port 25.


1. Install Sendmail packages

# yum -y install sendmail*












2. Configure SMTP

# vi /etc/mail/sendmail.mc

Remove 'dnl' command





# m4 /etc/mail/sendmail.mc > /ect/mail/sendmail.cf
# vi /etc/mail/snedmail.cf


Cwlocalhost ->Cw[MAIL_SERVER_DOMAIL]




127.0.0.1 (Internal Mail Server) -> 0.0.0.0


3. Configure Mail Access

# vi /ect/mail/access




# makemap hash /etc/mail/access < /etc/mail/access

# vi /etc/mail/local-host-names



4. SASL security module

# service saslauthd start
# chkconfig saslauthd on
# init 6


5. Disable Firewall

# service iptables stop
# chkconfig --level 345 iptables off
# vi /etc/selinux/config
# getenforce
# service iptables status



















6. Install Dovecot packages

# yum -y install dovecot







7. Configure Dovecot

# vi /etc/dovecot/dovecot.conf





# vi /etc/dovecot/conf.d/10-mail.conf







# vi /etc/dovecot/conf.d/10-ssl.conf





# vi /etc/dovecot/conf.d/10-auth.conf





8. Start Dovecot

# service dovecot start
# chkconfig dovecot on




[Java] Convert Hexadeciamal to IP address

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
public static String convertHex2IP( String hex) throws UnknownHostException {
 java.net.InetAddress address = java.net.InetAddress.getByAddress( javax.xml.bind.DatatypeConverter.parseHexBinary( hex));
 return address.getHostAddress();
  
}
 
public static String convertIP2Hex( String ip) throws UnknownHostException {
 java.net.InetAddress address = java.net.InetAddress.getByName( ip);
 byte[] bytes = address.getAddress();
 StringBuilder sb = new StringBuilder();
 for ( int ll = 0; ll < bytes.length; ll++)
  sb.append( String.format( "%02X", bytes[ ll]));
 
 return sb.toString();
  
}


[Java] How to ping IP address in java (자바에서 Ping 구현)

1
2
3
4
5
public static boolean ping( String host, int milisecondTimeout) throws UnknownHostException, IOException {
  java.net.InetAddress address = InetAddress.getByName( host);
  return address.isReachable( milisecondTimeout);
  
}