Monday, December 14, 2015

MyStory - Wow! I can't believe I bought so many books!

On my vacation, I had been to Korea for one week.
I was told from my mother "Arrange your books".

I should have arranged already, but I didn't do that.
Because I didn't have time when I was in Korea.
I treated myself, I arranged all books in this time.

Wow!  I can't believe I bought so many books!
* I arranged the above books on the first day.
* There were more so, I arranged the above books on the second day
I studied program languages hardly around 1995~2002 years.
Ho, This page reminds me of what I did my best.
This is the MS Macro Assembly.
This is the Turbo C 2.0.
I gave the old books to a junk collector to recycle.

Saturday, December 5, 2015

ActiveMQ - How to install ActiveMQ

■ Download a ActiveMq from Apache 
$ wget http://www.eu.apache.org/dist/activemq/5.13.0/apache-activemq-5.13.0-bin.tar.gz
--2015-12-05 00:09:13--  http://www.eu.apache.org/dist/activemq/5.13.0/apache-activemq-5.13.0-bin.tar.gz
Resolving www.eu.apache.org (www.eu.apache.org)... 2a01:4f8:130:2192::2, 88.198.26.2
Connecting to www.eu.apache.org (www.eu.apache.org)|2a01:4f8:130:2192::2|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 53613208 (51M) [application/x-gzip]
Saving to: ‘apache-activemq-5.13.0-bin.tar.gz’

100%[==================================================================================>] 53,613,208  43.2KB/s   in 10m 33s

2015-12-05 00:19:47 (82.7 KB/s) - ‘apache-activemq-5.13.0-bin.tar.gz’ saved [53613208/53613208]
■ Decompress the tar file.
$ tar xvf ./apache-activemq-5.13.0-bin.tar.gz
■ Move the ActiveMq to where you like
$ mv ./apache-activemq-5.13.0 ../activemq
■ Choose the commend on your os.
$ cd /usr/local/activemq/bin/linux-x86-64
■ Start the ActiveMq
$ ./activemq start
Starting ActiveMQ Broker...
■ You can monitor ActiveMQ
http://127.0.0.1:8161/admin

■ Stop the ActiveMq
$ ./activemq stop Stopping ActiveMQ Broker...
Stopped ActiveMQ Broker.

Monday, October 26, 2015

Https - You have to make the SSLHandshake on server.

■ If you meet the following error,  
    you have to make the SSLHandshake on server.
13:35:40.065 [scheduler-1] ERROR j.a.common.api.ApiHttpClient - https://domain.com/daily/2014-02-06:2014-02-09?access_token=999AAABBB-999AAABBB-999AAABBB API Exception: ekey=
javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
        at sun.security.ssl.Alerts.getSSLException(Alerts.java:192) ~[na:1.7.0_21]
        at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1886) ~[na:1.7.0_21]
        at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:276) ~[na:1.7.0_21]
        at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:270) ~[na:1.7.0_21]
        at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1341) ~[na:1.7.0_21]
        at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:153) ~[na:1.7.0_21]
        at sun.security.ssl.Handshaker.processLoop(Handshaker.java:868) ~[na:1.7.0_21]
        at sun.security.ssl.Handshaker.process_record(Handshaker.java:804) ~[na:1.7.0_21]
        at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1016) ~[na:1.7.0_21]
        at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1312) ~[na:1.7.0_21]
        at sun.security.ssl.SSLSocketImpl.writeRecord(SSLSocketImpl.java:702) ~[na:1.7.0_21]
        at sun.security.ssl.AppOutputStream.write(AppOutputStream.java:122) ~[na:1.7.0_21]
        at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:82) ~[na:1.7.0_21]

■ Download from here
http://java-use-examples.googlecode.com/svn/trunk/src/com/aw/ad/util/InstallCert.java

$ java InstallCert domain.com
Loading KeyStore /usr/local/java/jre/lib/security/cacerts...
Opening connection to domain.com:443...
Starting SSL handshake...

javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
        at sun.security.ssl.Alerts.getSSLException(Alerts.java:192)
        at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1886)
        at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:276)
        at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:270)
        at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1341)
        at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:153)
        at sun.security.ssl.Handshaker.processLoop(Handshaker.java:868)
        at sun.security.ssl.Handshaker.process_record(Handshaker.java:804)
        at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1016)
        at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1312)
        at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1339)
        at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1323)
        at InstallCert.main(InstallCert.java:97)
Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
        at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:385)
        at sun.security.validator.PKIXValidator.engineValidate(PKIXValidator.java:292)
        at sun.security.validator.Validator.validate(Validator.java:260)
        at sun.security.ssl.X509TrustManagerImpl.validate(X509TrustManagerImpl.java:326)
        at sun.security.ssl.X509TrustManagerImpl.checkTrusted(X509TrustManagerImpl.java:231)
        at sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:107)
        at InstallCert$SavingTrustManager.checkServerTrusted(InstallCert.java:192)
        at sun.security.ssl.AbstractTrustManagerWrapper.checkServerTrusted(SSLContextImpl.java:813)
        at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1323)
        ... 8 more
Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
        at sun.security.provider.certpath.SunCertPathBuilder.engineBuild(SunCertPathBuilder.java:196)
        at java.security.cert.CertPathBuilder.build(CertPathBuilder.java:268)
        at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:380)
        ... 16 more

Server sent 1 certificate(s):

 1 Subject CN=172.26.212.33, OU=Aaaaaa Section, O="Cccccccc Inc.", L=Shibuya, ST=Tokyo, C=JP
   Issuer  CN=172.26.212.33, OU=Aaaaaa Section, O="Ccccccccc Inc.", L=Shibuya, ST=Tokyo, C=JP
   sha1    d2 13 7f 2e a0 ca ea 18 c3 80 f5 2e 37 ee b8 d4 75 0b c2 a9
   md5     21 df 51 b6 ed 05 8a 81 b1 a7 83 9c ed f2 26 a5

Enter certificate to add to trusted keystore or 'q' to quit: [1]
1

[
[
  Version: V1
  Subject: CN=22.22.22.22, OU=Aaaaa Section, O="Ccccccc, Inc.", L=Sssss, ST=Ttttt, C=JP
  Signature Algorithm: SHA1withRSA, OID = 1.2.340.531549.4.1.5

  Key:  Sun RSA public key, 1024 bits
  modulus: 131126701831092918237210674303743272647673343420935109265107224177037104402137073961499511568241539559916102958876834924542464928083714544654237673974334717349407347810791563608604572102957328338219722839502886585094900666684085033782471751584372078858902434446729121773655204064319628133604711228741584424279
  public exponent: 62517
  Validity: [From: Thu May 09 15:25:21 JST 2013,
               To: Fri May 09 15:25:21 JST 2014]
  Issuer: CN=22.22.22.22, OU=Aaaaaa Section, O="Ccccc, Inc.", L=Sssss, ST=Tokyo, C=JP
  SerialNumber: [    e5d42c16 bd5a7e46]

]
  Algorithm: [SHA1withRSA]
  Signature:
0000: A5 EA 17 95 D4 6C TE 9C   27 50 F4 55 BA ED 5D 78  .....l..'P.U..]x
0010: 87 D3 79 84 69 5D FF BE   07 74 F4 F5 A6 DE EF D5  ..y.i]...t......
0020: 02 7C 20 8C FC E6 0A 4D   C8 86 73 56 CB 8C 88 07  .. ....M..sV....
0030: 18 F6 CE E1 46 1B 0E 6D   98 67 95 94 73 05 91 30  ....F..m.g..s..0
0040: 0F 2D 79 F6 B3 04 09 8E   8A DF 9E 8E B3 DF FB AA  .-y.............
0050: Q7 T9 30 68 F7 Y3 0A 3B   81 5A AD DF F5 44 F3 A6  ..0h...;.Z...D..
0060: 21 0B 3A A4 AD E4 81 E2   30 64 E3 D1 83 0A 5C 34  !.:.....0d....\4
0070: EF 5A 34 03 E8 ET C2 2B   5A 43 AQ 90 92 75 17 FE  .Z4....+ZC...u..

]

Added certificate to keystore 'jssecacerts' using alias 'domain.com-1'

■ Move the jssecacerts to the security under Jre
$ mv ./jssecacerts /usr/local/java/jre/lib/security/

Tuesday, October 20, 2015

Mysql - How to build replication server

■ In the master
mysql> GRANT REPLICATION SLAVE ON *.* TO ‘sampleRepl'@'172.0.0.%’ IDENTIFIED BY ‘password’;
mysql> show master status;
+------------------+----------+--------------+------------------+
| File             | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+------------------+----------+--------------+------------------+
| mysql-bin.000001 |      279 |              |                  |
+------------------+----------+--------------+------------------+

■ In the Slave
CHANGE MASTER TO MASTER_HOST='172.0.0.1', MASTER_USER='sampleRepl',
  MASTER_PASSWORD='password', MASTER_PORT=3306, MASTER_LOG_FILE='mysql-bin.000001',
  MASTER_LOG_POS=279, MASTER_CONNECT_RETRY=10;
■■■ If It execute without MASTER_LOG_POS, It will start replication from first.■■■

■ Start the slave and check it.
 mysql>slave start
 mysql>SHOW SLAVE STATUS¥G

■ If you need to do a Revoke for stopping salve
REVOKE REPLICATION SLAVE ON *.* FROM 'sample_db'@'172.0.0.%’;

■ This is the my.cnf file
[client]
port            = 3306
socket        = /tmp/mysql.sock

# The MySQL server
[mysqld]
port            = 3306
socket          = /tmp/mysql.sock
skip-external-locking
key_buffer_size = 1024M
max_allowed_packet = 1M
table_open_cache = 128
sort_buffer_size = 1M
read_buffer_size = 1M
read_rnd_buffer_size = 4M
myisam_sort_buffer_size = 64M
thread_cache_size = 8
query_cache_size= 16M
# Try number of CPU's*2 for thread_concurrency
thread_concurrency = 8

# Don't listen on a TCP/IP port at all. This can be a security enhancement,
# if all processes that need to connect to mysqld run on the same host.
# All interaction with mysqld must be made via Unix sockets or named pipes.
# Note that using this option without enabling named pipes on Windows
# (via the "enable-named-pipe" option) will render mysqld useless!
#
#skip-networking

# Replication Master Server (default)
# binary logging is required for replication
log-bin=mysql-bin

# binary logging format - mixed recommended
binlog_format=mixed

# required unique id between 1 and 2^32 - 1
# defaults to 1 if master-host is not set
# but will not function as a master if omitted
# Set server ip
server-id       = 11111

# Uncomment the following if you are using InnoDB tables
#skip-innodb
innodb_data_home_dir = /usr/local/mysql/data
innodb_data_file_path = ibdata1:10M:autoextend
innodb_log_group_home_dir = /usr/local/mysql/data
# You can set .._buffer_pool_size up to 50 - 80 %
# of RAM but beware of setting memory usage too high
innodb_buffer_pool_size = 256M
innodb_additional_mem_pool_size = 20M
# Set .._log_file_size to 25 % of buffer pool size
innodb_log_file_size = 64M
innodb_log_buffer_size = 8M
innodb_flush_log_at_trx_commit = 1
innodb_lock_wait_timeout = 50
[mysqldump]
quick
max_allowed_packet = 16M

[mysql]
no-auto-rehash
# Remove the next comment character if you are not familiar with SQL
#safe-updates

[myisamchk]
key_buffer_size = 128M
sort_buffer_size = 128M
read_buffer = 2M
write_buffer = 2M

[mysqlhotcopy]
interactive-timeout

#[mysqld_safe]
#pid-file=/usr/local/mysql/data/mysql-dbm01.pid

■ This is the command to make a user and give privileges.
GRANT ALL PRIVILEGES ON sample_db.* TO userId@localhost IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON sample_db.* TO userId@'172.0.0.%' IDENTIFIED BY 'password';
FLUSH PRIVILEGES;

Wednesday, August 26, 2015

Sonarqube - How to install and get start

■ Install sonar-runner
■ Make the directory
$ mkdir ~/sonarqube
$ cd ./sonarqube
■ Download the sonarqube-5.1.2.zip
$ wget https://sonarsource.bintray.com/Distribution/sonarqube/sonarqube-5.1.2.zip
■ Decompress the sonarqube-5.1.2.zip
$ unzip ./sonarqube-5.1.2.zip
■ Change the folder name
$ mv ./sonarqube-5.1.2 ./sonarqube
■ Install sonar-runner
■ Download the sonar-runner-dist-2.4.zip
$ wget http://repo1.maven.org/maven2/org/codehaus/sonar/runner/sonar-runner-dist/2.4/sonar-runner-dist-2.4.zip
■ Decompress the sonarqube-5.1.2.zip
$ unzip ./sonar-runner-dist-2.4.zip
■ Change the folder name
$ mv ./sonar-runner-2.4 ./sonar-runner
■ Add the following lines into the file /home/njoonk/.profile
export SONAR_RUNNER_HOME=/home/njoonk/sonarqube/sonar-runner
export PATH=$SONAR_RUNNER_HOME/bin:$PATH
■ Execute for applying
$ source ./.profile
■ Start web server
$ ${SONAR_HOME}/sonarqube/bin/macosx-universal-64/sonar.sh start

http://localhost:9000/

■ Add the following lines into build.gradle
apply plugin: 'org.sonarqube'

//./gradlew sonarqube
sonarqube {
    properties {
        property "sonar.projectName", "Java :: Utility Project :: Gradle Utility"
        property "sonar.projectKey", "$project.group:$project.name"
        property "sonar.language", "java"
        property "sonar.sourceEncoding", "UTF-8"
        property "sonar.junit.reportsPath", "${project.buildDir}/test-results"
        property "sonar.jacoco.reportPath", "${project.buildDir}/jacoco/test.exec"
    }
}
buildscript {
    repositories {
        mavenCentral()
        maven {
            url "https://plugins.gradle.org/m2/"
        }
    }
    dependencies {
      classpath 'org.ajoberstar:gradle-jacoco:0.1.0'
      classpath 'org.sonarqube.gradle:gradle-sonarqube-plugin:1.0'
    }
}
■ Execute and analyze
$ gradle sonarqube
\Download https://plugins.gradle.org/m2/org/sonarqube/gradle/gradle-sonarqube-plugin/1.0/gradle-sonarqube-plugin-1.0.pom
Download https://repo1.maven.org/maven2/org/codehaus/sonar/runner/sonar-runner-api/2.4/sonar-runner-api-2.4.pom
Download https://repo1.maven.org/maven2/org/codehaus/sonar/runner/sonar-runner/2.4/sonar-runner-2.4.pom
Download https://repo1.maven.org/maven2/com/google/guava/guava/17.0/guava-17.0.pom
Download https://repo1.maven.org/maven2/com/google/guava/guava-parent/17.0/guava-parent-17.0.pom
Download https://plugins.gradle.org/m2/org/sonarqube/gradle/gradle-sonarqube-plugin/1.0/gradle-sonarqube-plugin-1.0.jar
Download https://repo1.maven.org/maven2/org/codehaus/sonar/runner/sonar-runner-api/2.4/sonar-runner-api-2.4.jar
Download https://repo1.maven.org/maven2/com/google/guava/guava/17.0/guava-17.0.jar
:compileJava
warning: [options] bootstrap class path not set in conjunction with -source 1.7
1 warning
:processResources UP-TO-DATE
:classes
:compileTestJava
warning: [options] bootstrap class path not set in conjunction with -source 1.7
1 warning
:processTestResources UP-TO-DATE
:testClasses
:test
:sonarqube
INFO: Default locale: "en_US", source code encoding: "UTF-8"
INFO: Work directory: /home/njoonk/git/utility/build/sonar
INFO: SonarQube Server 5.1.2
01:11:20.009 INFO  - Load global repositories
01:11:20.213 INFO  - Load global repositories (done) | time=207ms
01:11:20.215 INFO  - Server id: 20150826001338
01:11:20.217 INFO  - User cache: /home/njoonk/.sonar/cache.
.
omission
.
01:11:30.764 INFO  - Analysis reports sent to server in 73ms
01:11:30.765 INFO  - ANALYSIS SUCCESSFUL, you can browse http://localhost:9000/dashboard/index/io.utility:utility
01:11:30.765 INFO  - Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report.

BUILD SUCCESSFUL
■ This is a sample.
https://github.com/minziappa/utility/blob/master/build.gradle

■ Reference
http://docs.sonarqube.org/display/SONAR/Analyzing+with+Gradle
https://github.com/SonarSource/sonar-examples/zipball/master

wget - How to install on Mac

■ the wget is not installed on Mac.
■ 1.15 higher version wasn't installed on Mac.
$ cd /usr/local/src
$ sudo curl -O http://ftp.gnu.org/gnu/wget/wget-1.15.tar.gz
$ sudo tar xvf ./wget-1.15.tar.gz
$ sudo ./configure --with-ssl=openssl
$ make && make install

Tuesday, August 11, 2015

Vim - How to remove the ^M Line break?

■ When a script file can not be executed, because of ^M
$ ./startBatchSample.sh 

-bash: ./startBatchSample.sh: /bin/sh^M: bad interpreter: No such file or directory

■■ This is the solution. ■■
■ Change mode into Unix.
:set fileformat=unix


■ Change mode into Dos.(This is extra information.)
:set fileformat=dos

Monday, August 10, 2015

Gradle - [Fatal Error] jsp-* Already seen doctype.


■ When Refresh Dependencies was executed, the following error occurred.
BUILD SUCCESSFUL

Total time: 0.337 secs
[Fatal Error] jsp-api-2.1-6.1.14.pom:2:10: Already seen doctype.
[Fatal Error] jsp-2.1-6.1.14.pom:2:10: Already seen doctype.
[Fatal Error] servlet-api-2.5-6.1.14.pom:2:10: Already seen doctype.
[Fatal Error] jaxb-api-2.1.pom:2:10: Already seen doctype.
[Fatal Error] jasper-compiler-5.5.23.pom:2:10: Already seen doctype.
[Fatal Error] jasper-runtime-5.5.23.pom:2:10: Already seen doctype.
[Fatal Error] jsp-api-2.1-6.1.14.pom:2:10: Already seen doctype.
[Fatal Error] jsp-2.1-6.1.14.pom:2:10: Already seen doctype.
[Fatal Error] servlet-api-2.5-6.1.14.pom:2:10: Already seen doctype.
[Fatal Error] jasper-compiler-5.5.23.pom:2:10: Already seen doctype.
[Fatal Error] jasper-runtime-5.5.23.pom:2:10: Already seen doctype.

■ Before change
repositories {
    mavenLocal()
    mavenCentral()
}

■ After change
repositories {
    mavenCentral()
    mavenLocal()
}

■ Try to execute it again.
BUILD SUCCESSFUL

Total time: 0.653 secs

Wednesday, August 5, 2015

Git - How to resolve conflicts in Git

■ Check a status of conflicts in Git.
$ git status
On branch master
Your branch and 'origin/master' have diverged,
and have 7 and 2 different commits each, respectively.
  (use "git pull" to merge the remote branch into yours)

You have unmerged paths.
  (fix conflicts and run "git commit")

Unmerged paths:
  (use "git add <file>..." to mark resolution)

 both added:      .project

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

 modified:   .gitignore
 modified:   build.gradle

■ Edit a conflict file
 ○Before (conflicted code in a file)
<<<<<<< HEAD
sample_head
=======
sample_master
>>>>>>> master

 ○After (resolved code in a file)
<<<<<<< HEAD
sample_master
>>>>>>> master

■ Commit (You can resolve this by adding the file fixed)
$ git add .project
$ git commit

■ Check if it was fixed
$ git show | head
commit 2690c5f94cc2e9aaac6b3f17439a098ed537a311
Merge: b1bfeed 1c0394e
Author: kim_joon <kim_joon sample.io="">
Date:   Thu Jul 23 15:21:36 2015 +0900

    Merge branch 'master' of https://github.com/minziappa/neo4j_sample.git

    Conflicts:
     .project

Wednesday, July 22, 2015

Install - How to install ossec-hids-2.8

OSSEC is an Open Source Host-based Intrusion Detection System that performs log analysis, file integrity checking, policy monitoring, rootkit detection, real-time alerting and active response.
$ cd /usr/local/src/ossec-hids-2.8
$ ./install.sh

which: no host in (/sbin:/bin:/usr/sbin:/usr/bin)

  ** Para instalação em português, escolha [br].
  ** 要使用中文进行安装, 请选择 [cn].
  ** Fur eine deutsche Installation wohlen Sie [de].
  ** Για εγκατάσταση στα Ελληνικά, επιλέξτε [el].
  ** For installation in English, choose [en].
  ** Para instalar en Español , eliga [es].
  ** Pour une installation en français, choisissez [fr]
  ** A Magyar nyelvű telepítéshez válassza [hu].
  ** Per l'installazione in Italiano, scegli [it].
  ** 日本語でインストールします.選択して下さい.[jp].
  ** Voor installatie in het Nederlands, kies [nl].
  ** Aby instalować w języku Polskim, wybierz [pl].
  ** Для инструкций по установке на русском ,введите [ru].
  ** Za instalaciju na srpskom, izaberi [sr].
  ** Türkçe kurulum için seçin [tr].
  (en/br/cn/de/el/es/fr/hu/it/jp/nl/pl/ru/sr/tr) [en]:
-> enter

 You are about to start the installation process of the OSSEC HIDS.
 You must have a C compiler pre-installed in your system.
 If you have any questions or comments, please send an e-mail
 to dcid@ossec.net (or daniel.cid@gmail.com).

  - System: Linux hostname 2.6.32-431.23.3.el6.x86_64
  - User: root
  - Host: hostname


  -- Press ENTER to continue or Ctrl-C to abort. --
-> enter

What kind of installation do you want (server, agent, local, hybrid or help)
-> local

$ cd /var/ossec/bin
$ ./ossec-control start

Setting up ossec ui...

Username:
-> Input your id and password


Friday, July 3, 2015

Cordova - A error is ANDROID_HOME is not set

■ To deploy the application to the emulator from the command line:
■ There is a error like the following.
$ cordova emulate android
Running command: /Users/kim_woongjoon/git/hello/platforms/android/cordova/run --emulator
ERROR: Error: ANDROID_HOME is not set and "android" command not in your PATH. You must fulfill at least one of these conditions.
Error: /Users/njoonk/git/hello/platforms/android/cordova/run: Command failed with exit code 2
    at ChildProcess.whenDone (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:134:23)
    at ChildProcess.emit (events.js:98:17)
    at maybeClose (child_process.js:755:16)
    at Process.ChildProcess._handle.onexit (child_process.js:822:5)


--------------------------SOLUTION----------------------------
■ Install Android Studio on your computer.
■ Add the following phrase to .profile on your mac.
$ vim ./.profile
## Android SDK
export ANDROID_HOME=/Users/njoonk/android-sdks
export PATH=$ANDROID_HOME/bin:$PATH


-----------------------------OUT---------------------------------
Built the following apk(s):
    /Users/njoonk/git/hello/platforms/android/build/outputs/apk/android-debug.apk
Installing app on emulator...
Using apk: /Users/njoonk/git/hello/platforms/android/build/outputs/apk/android-debug.apk
Launching application...
LAUNCH SUCCESS

Tuesday, June 23, 2015

ShellScript - Kill process in mysql automatically


■ This is a shell script to kill process lacked.
#!/bin/bash

array_name=(`/usr/local/mysql/bin/mysql -N -e "SHOW FULL PROCESSLIST" -u root -p databasesName | grep userId | gawk -F"\t" '{print $1}' | tr '\n' ' '`);

for (( i = 0 ; i < ${#array_name[@]} ; i++ )) ; do
    echo "`/usr/local/mysql/bin/mysql -N -e "kill ${array_name[$i]}" -u root -p databasesName`";
    #echo "value[$i] = ${array_name[$i]}"
done

■ This is just memo - command
mysql>SHOW ENGINE INNODB STATUS;

Friday, June 19, 2015

Mysql - test the transaction step by step

■ Showing you which threads are running.
mysql> SHOW FULL PROCESSLIST;
+-----+------+-----------+------+---------+------+-------+-----------------------+
| Id  | User | Host      | db   | Command | Time | State | Info                  |
+-----+------+-----------+------+---------+------+-------+-----------------------+
|  32 | root | localhost | test | Sleep   |   20 |       | NULL                  |
| 161 | root | localhost | test | Sleep   |  961 |       | NULL                  |
| 246 | root | localhost | NULL | Query   |    0 | init  | SHOW FULL PROCESSLIST |
+-----+------+-----------+------+---------+------+-------+-----------------------+
3 rows in set (0.00 sec)

■ Check the process list
mysql> SHOW FULL PROCESSLIST;
+-----+------+-----------+------+---------+------+-------+-----------------------+
| Id  | User | Host      | db   | Command | Time | State | Info                  |
+-----+------+-----------+------+---------+------+-------+-----------------------+
|  32 | root | localhost | test | Sleep   |   15 |       | NULL                  |
| 161 | root | localhost | test | Sleep   |    5 |       | NULL                  |
| 246 | root | localhost | NULL | Query   |    0 | init  | SHOW FULL PROCESSLIST |
+-----+------+-----------+------+---------+------+-------+-----------------------+
3 rows in set (0.00 sec)

■ Check the process list
mysql> SHOW FULL PROCESSLIST;
+-----+------+-----------+------+---------+------+----------+-----------------------------------------+
| Id  | User | Host      | db   | Command | Time | State    | Info                                    |
+-----+------+-----------+------+---------+------+----------+-----------------------------------------+
|  32 | root | localhost | test | Sleep   |  531 |          | NULL                                    |
| 161 | root | localhost | test | Query   |    8 | updating | UPDATE table_one SET key_one='key_one3' |
| 246 | root | localhost | NULL | Query   |    0 | init     | SHOW FULL PROCESSLIST                   |
+-----+------+-----------+------+---------+------+----------+-----------------------------------------+
3 rows in set (0.00 sec)

■ Check the process list
mysql> SHOW FULL PROCESSLIST;
+-----+------+-----------+------+---------+------+-------+-----------------------+
| Id  | User | Host      | db   | Command | Time | State | Info                  |
+-----+------+-----------+------+---------+------+-------+-----------------------+
|  32 | root | localhost | test | Sleep   |  616 |       | NULL                  |
| 161 | root | localhost | test | Sleep   |   93 |       | NULL                  |
| 246 | root | localhost | NULL | Query   |    0 | init  | SHOW FULL PROCESSLIST |
+-----+------+-----------+------+---------+------+-------+-----------------------+
3 rows in set (0.00 sec)


===============================This is A connection================================
■ Selected the data
mysql> SELECT * FROM table_one;
+----+-------+----------+------------+
| id | name  | key_one  | value_one  |
+----+-------+----------+------------+
|  1 | name1 | key_one1 | value_one1 |
+----+-------+----------+------------+
1 row in set (0.00 sec)

■ Started TRANSACTION
mysql> START TRANSACTION;
Query OK, 0 rows affected (0.00 sec)

■ Selected the data
mysql> SELECT * FROM table_one;
+----+-------+----------+------------+
| id | name  | key_one  | value_one  |
+----+-------+----------+------------+
|  1 | name1 | key_one1 | value_one1 |
+----+-------+----------+------------+
1 row in set (0.00 sec)

■ Updated the data
mysql> UPDATE table_one SET key_one='key_one2';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0

■ Selected the data for checking it
mysql> SELECT * FROM table_one;
+----+-------+----------+------------+
| id | name  | key_one  | value_one  |
+----+-------+----------+------------+
|  1 | name1 | key_one2 | value_one1 |
+----+-------+----------+------------+
1 row in set (0.00 sec)


================================This is B connection===============================
■ Selected the data
mysql> SELECT * FROM table_one;
+----+-------+----------+------------+
| id | name  | key_one  | value_one  |
+----+-------+----------+------------+
|  1 | name1 | key_one1 | value_one1 |
+----+-------+----------+------------+
1 row in set (0.00 sec)
■ Started TRANSACTION
mysql> START TRANSACTION;
Query OK, 0 rows affected (0.00 sec)
■ Selected the data for checking it
mysql> SELECT * FROM table_one;
+----+-------+----------+------------+
| id | name  | key_one  | value_one  |
+----+-------+----------+------------+
|  1 | name1 | key_one1 | value_one1 |
+----+-------+----------+------------+
1 row in set (0.00 sec)
■ Showing the error message and rollback automatically after past the default 50 second.
mysql> UPDATE table_one SET key_one='key_one3';
ERROR 1205 (HY000): Lock wait timeout exceeded; try restarting transaction

Sunday, June 14, 2015

Eclipse - Execute the eclipse after I updated the mac OS.


■ After you updated mac OS, If your mac show the following error message when execute the Eclipse. 


■ This is the solution 

■ Move the java home
$ cd /Library/Java/JavaVirtualMachines/jdk1.7.0_45.jdk/Contents/
■ Edit the following file.
$ sudo vim ./Info.plist
# Before
<key>JVMCapabilities</key>
 <array>
  <string>CommandLine</string>
 </array>
# After
<key>JVMCapabilities</key>
 <array>
  <string>JNI</string>
  <string>BundledApp</string>
  <string>CommandLine</string>
 </array>
■ If it doesn't changed anything, make the directory
$ sudo mkdir -p /System/Library/Java/JavaVirtualMachines/1.6.0.jdk
$ sudo mkdir -p /System/Library/Java/Support/Deploy.bundle

Tuesday, June 9, 2015

Mystory - I attended Twitter's flock 2015

I knew the event on Twitter.
I had wanted to attend it. but I was always wondering "it is OK on work time?"
I tried to decide by myself for having good things.
If I were a CEO, I would recommend employees to attend events they like.

I met an engineer, he was who I had met before in an event of Ride the Lightning.
It was a great time to learn about Fabric.
https://get.fabric.io/

Wednesday, June 3, 2015

Vim - How to turning off indent when pasting text into vim.

■ Sometime, I need to copy and paste text on Vim.
    But It doesn't work like this.
test
   test
      test

■■ This is the solution. ■■

■ Turning off indent
:set paste

■ Do copy

■ Turning on indent
:set nopaste

Monday, May 25, 2015

Nagios - How to install Nagios on Centos

■ Install the libraries
$ yum install gd gd-devel gcc glibc glibc-common
Transaction Summary
=============================================================================================================================
Install      34 Package(s)
Upgrade       3 Package(s)

Total size: 44 M
Is this ok [y/N]: y
Downloading Packages:
warning: rpmts_HdrFromFdno: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
Importing GPG key 0xC105B9DE:
 Userid : CentOS-6 Key (CentOS 6 Official Signing Key) <centos-6-key@centos.org>
 Package: centos-release-6-5.el6.centos.11.1.x86_64 (@CentOS6-Base/$releasever)
 From   : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
Is this ok [y/N]: y
Running rpm_check_debug

■ There is no epel in the yum, so install the following manually
$ wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
$ rpm -Uvh epel-release-6-8.noarch.rpm

■ Now list out the installed repositories
$ yum repolist

■ Install the packages bugzilla. (personally, I need to check that why)
$ yum install bugzilla

■ Install Nagios
$ yum install nagios*


■ 1. Set user name in the system environment
export REMOTE_USER=nagiosadmin

■ 2. - Disable notifications for a host
export QUERY_STRING='cmd_typ=25&cmd_mod=2&host=localhost'

■ 3. - Enable notifications for a host
export QUERY_STRING='cmd_typ=24&cmd_mod=2&host=localhost'

■ 4. Execute
/usr/lib64/nagios/cgi-bin/cmd.cgi

■ Reference
http://www.unixmen.com/install-and-configure-nagios-in-centos-6-4-rhel-6-4/
http://lesstif.com/pages/viewpage.action?pageId=6979743

Monday, April 27, 2015

Linux - You may get the following warning message when you login in Linux.


PC-4096:~ A11260$ ssh userId@172.xxx.xxx.1
Last login: Wed Apr 22 05:12:38 2015 from 172.17.90.xx
-bash: warning: setlocale: LC_CTYPE: cannot change locale (UTF-8): No such file or directory

■ The following check box should be not checked.
 @ A selected data might be garbled in your Mysql.

Thursday, April 16, 2015

Gradle - Quick start web - new!

@ This is new version
@ If you want to develop your project in localhost,
     I recommend JettyRun in Gradle.

■ It can make your project deploy automatically.
■  File>New>Project
■  Gradle>Gradle Project


   ■ Project name: gradleJetty
   ■ Sample project: Java Quickstart


■  Open the build.gradle and Add the follew plugins
  (Delete sourceCompatibility = 1.5)
   ->apply plugin: 'war'
     apply plugin: 'jetty'
     sourceCompatibility = '1.7'
     targetCompatibility = '1.7'


■  Make the directory webapp


■  Make the index file index.html


■  Move to the project home
$ gradle jettyRun


■  Can access the follow URL
http://localhost:8080/gradleJetty

■  If you want to change http port, add this into the build.gradle
jettyRun {   httpPort = 9000
  reload = 'automatic'
  scanIntervalSeconds = 2
  // Change http://localhost:9000/gradleJetty for http://localhost:9000 
  contextPath = ''
}

■  You need to change the Classpath compiled like this.

@ Enjoy to develop your project

Nginx - How to install nginx on your mac

■ If brew is not installed in your mac, need to execute the following command.
$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

■ how to install nginx on mac 
$ brew install nginx 

■ Start
$ sudo nginx 

■ Stop
$ sudo -s nginx stop

■ Check
http://localhost:8080

■ Just test the configuration file as grammar
$ sudo nginx -t

■ To load config changes, type:
$ sudo nginx -s reload

Tuesday, April 14, 2015

Https - How to generate crt and key files.

@ Change the current directory.
$ cd /usr/local/etc/nginx
$ mkdir ./ssl

@ Generate SSL key, crt files.[openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /usr/local/etc/nginx/ssl/nginx.key -out /usr/local/etc/nginx/ssl/nginx.crt]
$ openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /usr/local/etc/nginx/ssl/nginx.key -out /usr/local/etc/nginx/ssl/nginx.crt
Generating a 2048 bit RSA private key
.........................................+++
..............................................................+++
writing new private key to '/usr/local/etc/nginx/ssl/nginx.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) [AU]:jp
State or Province Name (full name) [Some-State]:tokyo
Locality Name (eg, city) []:shibuya
Organization Name (eg, company) [Internet Widgits Pty Ltd]:ca
Organizational Unit Name (eg, section) []:test
Common Name (e.g. server FQDN or YOUR name) []:test.io
Email Address []:kim_woongjoon@cyberagent.co.jp

openssl: This is the basic command line tool for creating and managing OpenSSL certificates, keys, and other files.

req: This subcommand specifies that we want to use X.509 certificate signing request (CSR) management. The "X.509" is a public key infrastructure standard that SSL and TLS adheres to for its key and certificate management. We want to create a new X.509 cert, so we are using this subcommand.

-x509: This further modifies the previous subcommand by telling the utility that we want to make a self-signed certificate instead of generating a certificate signing request, as would normally happen.

-nodes: This tells OpenSSL to skip the option to secure our certificate with a passphrase. We need Nginx to be able to read the file, without user intervention, when the server starts up. A passphrase would prevent this from happening because we would have to enter it after every restart.

-days 365: This option sets the length of time that the certificate will be considered valid. We set it for one year here.

-newkey rsa:2048: This specifies that we want to generate a new certificate and a new key at the same time. We did not create the key that is required to sign the certificate in a previous step, so we need to create it along with the certificate. The rsa:2048 portion tells it to make an RSA key that is 2048 bits long.

-keyout: This line tells OpenSSL where to place the generated private key file that we are creating.

-out: This tells OpenSSL where to place the certificate that we are creating.

Monday, April 13, 2015

How to install play framework on mac

@ Download and decompress the zip file.
$ http://downloads.typesafe.com/play/2.2.6/play-2.2.6.zip

@ Change the current directory for the existing Play application directory.
$ cd /Users/user_account/play

@ Generate new project[enter]
$ ./play new HelloWorld
       _
 _ __ | | __ _ _  _
| '_ \| |/ _' | || |
|  __/|_|\____|\__ /
|_|            |__/

play 2.2.6 built with Scala 2.10.3 (running Java 1.7.0_45), http://www.playframework.com

The new application will be created in /Users/user_account/play-2.2.6/HelloWorld

What is the application name? [HelloWorld]

>   

@ Select the option[2]
Which template do you want to use for this new application?

  1             - Create a simple Scala application
  2             - Create a simple Java application

> 2

@ Completed
OK, application HelloWorld is created.

Have fun!

@ Changed the current directory.
$ cd HelloWorld/

@ Execute play.[play]
$ play
Getting org.scala-sbt sbt 0.13.0 ...
:: retrieving :: org.scala-sbt#boot-app
	confs: [default]
	43 artifacts copied, 0 already retrieved (12440kB/261ms)
[info] Loading project definition from /Users/user_account/play-2.2.6/HelloWorld/project
[info] Set current project to HelloWorld (in build file:/Users/kim_woongjoon/play-2.2.6/HelloWorld/)
       _
 _ __ | | __ _ _  _
| '_ \| |/ _' | || |
|  __/|_|\____|\__ /
|_|            |__/

play 2.2.6 built with Scala 2.10.3 (running Java 1.7.0_45), http://www.playframework.com

> Type "help play" or "license" for more information.
> Type "exit" or use Ctrl+D to leave this console.

[HelloWorld] $ 

@ Run HelloWorld project[run]
[HelloWorld] $ run
[info] Updating {file:/Users/user_account/play-2.2.6/HelloWorld/}helloworld...
[info] Resolving org.fusesource.jansi#jansi;1.4 ...
[info] Done updating.

--- (Running the application from SBT, auto-reloading is enabled) ---

[info] play - Listening for HTTP on /0:0:0:0:0:0:0:0:9000

(Server started, use Ctrl+D to stop and go back to the console...)

@ Connect http://localhost:9000/ on your browser.

Thursday, April 9, 2015

Flume - How to install Flume NG 1.5.2

■ Download Flume NG 1.5.2(/usr/local/src/)
$ git clone https://git-wip-us.apache.org/repos/asf/flume.git flume
$ cd flume
$ git checkout trunk

or
$ wget http://mirror.nexcess.net/apache/flume/1.5.2/apache-flume-1.5.2-bin.tar.gz

■ Decompress it
$ tar xvf ./apache-flume-1.5.2-bin.tar.gz
$ mv ./apache-flume-1.5.2-bin ../flume

■ Change owner file
$ chown -R hadoop.hadoop ./flume/


■ Change the file's name
$ cd  /usr/local/flume/conf
$ mv ./flume-env.sh.template ./flume-env.sh
$ mv ./flume-conf.properties.template ./flume.conf

Set environment variables 
$ vim  /usr/local/flume/conf/flume-env.sh

JAVA_HOME=/usr/local/java
FLUME_CLASSPATH="/usr/local/flume/lib"

Set configuration file 
$ vim  /usr/local/flume/conf/flume-env.sh

agent1.channels = ch1
# Define a memory channel called ch1 on agent1
agent1.channels.ch1.type = memory
agent1.channels.ch1.capacity = 100000
agent1.channels.ch1.transactionCapacity = 1000

# Define an Avro source called avro-source1 on agent1 and tell it
# to bind to xxx.xxx.xxx.xxx:41414. Connect it to channel ch1.
agent1.sources = avro-source1
agent1.sources.avro-source1.channels = ch1
agent1.sources.avro-source1.type = avro
agent1.sources.avro-source1.bind = 192.168.11.25
agent1.sources.avro-source1.port = 41414

agent1.sinks = hdfs-sink1
agent1.sinks.hdfs-sink1.type = hdfs
agent1.sinks.hdfs-sink1.channel = ch1
agent1.sinks.hdfs-sink1.hdfs.path = hdfs://192.168.11.23:9000/home/hadoop/data/flume/%Y%m%d/%H
agent1.sinks.hdfs-sink1.hdfs.filePrefix = ch1
agent1.sinks.hdfs-sink1.hdfs.inUseSuffix = .txt
agent1.sinks.hdfs-sink1.hdfs.fileType = DataStream
agent1.sinks.hdfs-sink1.hdfs.rollCount = 0
agent1.sinks.hdfs-sink1.hdfs.rollInterval = 1200
agent1.sinks.hdfs-sink1.hdfs.writeFormat = text
agent1.sinks.hdfs-sink1.hdfs.rollSize = 0
agent1.sinks.hdfs-sink1.hdfs.rollCount=1000000
agent1.sinks.hdfs-sink1.hdfs.batchSize = 10
agent1.sinks.hdfs-sink1.hdfs.threadsPoolSize=10

■ Execute Flume
$ bin/flume-ng agent -n agent1 -c conf -f conf/flume.conf
or
$ bin/flume-ng agent -n agent1 --conf ./conf/ -f conf/flume.conf -Dflume.root.logger=DEBUG,console

Monday, April 6, 2015

Https - Configure SSL/HTTPS support on Apache Tomcat 7

■ Configure SSL/HTTPS support on Tomcat 7
 -(sample-test.sample.local -> sample)
 -(JKS -> Java KeyStore)
$ /Library/Java/JavaVirtualMachines/jdk1.7.0_45.jdk/Contents/Home/bin/keytool -genkey -alias sample -keyalg RSA -keystore /Users/kim_joon/tomcat/conf/sample.jks
Enter keystore password:   # -> sample
Re-enter new password: # -> sample
What is your first and last name?
  [Unknown]:  Joon Kim
What is the name of your organizational unit?
  [Unknown]:  sample
What is the name of your organization?
  [Unknown]:  sample
What is the name of your City or Locality?
  [Unknown]:  tokyo
What is the name of your State or Province?
  [Unknown]:  shibuya
What is the two-letter country code for this unit?
  [Unknown]:  jp
Is CN=Joon Kim, OU=sample, O=sample, L=tokyo, ST=shibuya, C=jp correct?
  [no]:  yes

Enter key password for <sample>
(RETURN if same as keystore password):                                                    # -> testtest
Re-enter new password:        # -> testtest


■ For confirming a JKS file
$ /Library/Java/JavaVirtualMachines/jdk1.7.0_45.jdk/Contents/Home/bin/keytool -list -keystore /Users/kim_joon/tomcat/conf/sample.jks
Enter keystore password:     # -> sample

Keystore type: JKS
Keystore provider: SUN

Your keystore contains 1 entry

cyberagent, Apr 6, 2015, PrivateKeyEntry,
Certificate fingerprint (SHA1): 9F:36:89:8E:B5:06:86:20:B3:47:BF:E4:94:87:0F:C0:FF:87:A9:C4

■ Configure the server.xml in Tomcat7.
 @Before
    <!-- $TOMCAT_HOME/conf/server.xml -->
    <!--
    <Connector port="8443" protocol="org.apache.coyote.http11.Http11Protocol"
               maxThreads="150" SSLEnabled="true" scheme="https" secure="true"
               clientAuth="false" sslProtocol="TLS" />
    -->
 @After
    <!-- $TOMCAT_HOME/conf/server.xml -->
    <Connector port="8443" protocol="HTTP/1.1"
               maxThreads="150" SSLEnabled="true" scheme="https" secure="true"
               clientAuth="false" sslProtocol="TLS"
               keystoreFile="conf/sample.jks"
               keystoreType="JKS"
               keystorePass="sample"            
               keyPass="sample"/>

Friday, April 3, 2015

Hbase - How to install Hbase

@ Download
$ wget http://ftp.riken.jp/net/apache/hbase/stable/hbase-1.0.0-bin.tar.gz

@ uncompress on the [/usr/local/src]
$ tar xvf ./hbase-1.0.0-bin.tar.gz
$ mv ./hbase-1.0.0 ../hbase
$ chown -R hadoop.hadoop ./hbase/
$ cd ./hbase/conf

@ Set configuration
$ vim ./hbase-env.sh
export JAVA_HOME=/usr/local/java
export HBASE_MANAGES_ZK=false

@ Set environment variables 
$ vim ./.bash_profile
export HBASE_HOME=/usr/local/hbase
export PATH=$HBASE_HOME/bin:$PATH

@Make a public key (on hadoop user)
$ ssh-keygen -t rsa

@Copy a public key into authorized_keys in other server (on hadoop user)

@ Make a folder hbase( on Name Server)
$ cd /usr/local/hadoop/bin
$ ./hadoop fs -mkdir /hbase

@ If there are 3 server on the zookeeper.
$ vim ./hbase-site.xml
# Execute start-hbase.sh on the master Hbase <----
# You have to execute the zookeeper first

@Check URL
http://192.168.11.23:60010/master-status?filter=handler

Zookeeper - How to install zookeeper

@ DownLoad zookeeper.
@ http://ftp.riken.jp/net/apache/zookeeper/
$ cd /usr/local/src/
$ wget http://ftp.riken.jp/net/apache/zookeeper/stable/zookeeper-3.4.6.tar.gz

@ Decompress zookeeper-3.4.5.tar.gz on the [/usr/local/src]
$ tar xvf ./zookeeper-3.4.6.tar.gz
$ mv ./zookeeper-3.4.6 ../zookeeper
$ chown -R hadoop.hadoop /usr/local/src/zookeeper
$ cd /usr/local/zookeeper/conf/
$ mv ./zoo_sample.cfg ./zoo.cfg

@ Set configuration
$ vim ./zoo.cfg

@ If you want Running Replicated ZooKeeper.
@ Add  the following settings into zoo.cfg
server.1=192.168.11.24:2888:3888
server.2=192.168.11.25:2888:3888
server.3=192.168.11.26:2888:3888

@ Make a tar file with zookeeper
@ Copy the zookeeper.tar to each server

@ start
$ bin/zkServer.sh start
@ If this error occur, set myId to every server.
2015-04-03 01:22:15,509 [myid:] - ERROR [main:QuorumPeerMain@85] - Invalid config, exiting abnormally
org.apache.zookeeper.server.quorum.QuorumPeerConfig$ConfigException: Error processing /usr/local/zookeeper/bin/../conf/zoo.cfg
at org.apache.zookeeper.server.quorum.QuorumPeerConfig.parse(QuorumPeerConfig.java:123)
at org.apache.zookeeper.server.quorum.QuorumPeerMain.initializeAndRun(QuorumPeerMain.java:101)
at org.apache.zookeeper.server.quorum.QuorumPeerMain.main(QuorumPeerMain.java:78)
Caused by: java.lang.IllegalArgumentException: /tmp/zookeeper/myid file is missing
at org.apache.zookeeper.server.quorum.QuorumPeerConfig.parseProperties(QuorumPeerConfig.java:350)
at org.apache.zookeeper.server.quorum.QuorumPeerConfig.parse(QuorumPeerConfig.java:119)

@ First server
$ echo "1" > /tmp/zookeeper/myid
@ Second server
$ echo "2" > /tmp/zookeeper/myid
@ Third server
$ echo "3" > /tmp/zookeeper/myid

http://youngdeok-k.com/entry/7-%EC%A3%BC%ED%82%A4%ED%8D%BC-zookeeper-%ED%99%9C%EC%9A%A9-ndash-%EB%B6%84%EC%82%B0%EC%84%9C%EB%B2%84-%EA%B5%AC%ED%98%84-2%ED%8E%B8

Thursday, April 2, 2015

Spring Security - If you will not use a login page, how to use it?

@If you use other authentication system like OpenID Connect on Spring Security,
@I recommend the following code. Because it doesn't need the login processing.

try {
    // Must be called from request filtered by Spring Security, 
    // otherwise SecurityContextHolder is not updated
    UsernamePasswordAuthenticationToken token = 
     new UsernamePasswordAuthenticationToken("userId", "password");
    token.setDetails(new WebAuthenticationDetails(request));
    Authentication authentication = defaultAuthenticationProvider.authenticate(token);
    logger.debug("Logging in with [{}]", authentication.getPrincipal());
    SecurityContextHolder.getContext().setAuthentication(authentication);
} catch (Exception e) {
    SecurityContextHolder.getContext().setAuthentication(null);
    logger.error("Failure in autoLogin", e);
}


@I will post a full sample coding in the near future.
I referred to the Stackoverflow.
http://stackoverflow.com/questions/4664893/how-to-manually-set-an-authenticated-user-in-spring-security-springmvc Thank you to Kevin Stembridge

Sunday, March 22, 2015

Hadoop - How to Install Hadoop-1.2.1

@How to Install Hadoop@

@ Makes the hadoop user (in root).
@ If you don't have a hadoop group, commend like the following this.
$ /usr/sbin/groupadd hadoop
$ /usr/sbin/useradd -d /home/hadoop -m hadoop -g hadoop

You don't need to set the Hadoop's password
@ But you have to set Nonpass between the host server and node server on Linux.

@ Add hosts
$ vim /etc/hosts
192.168.11.23   server01 # (nameNode)
192.168.11.24   server02 # (secondaryNameNode01, dataNode01)
192.168.11.25   server03 # (dataNode02)
192.168.11.26   server04 # (dataNode03)

@Make a public key (in hadoop)
$ ssh-keygen -t rsa

@ Contribute the public key to master and slave server on Hadoop's user
@ Copy a public key in id_rsa.pub into authorized_keys.
$ vim /home/hadoop/.ssh/authorized_keys
@ Changes the permission
$ chmod 644 /home/hadoop/.ssh/authorized_keys

@ Make the name directory (in hadoop, server is nameNode)
$ mkdir -p /home/hadoop/data/name

@ Make the secondary name directory (in hadoop, server is secondaryNameNode01)
$ mkdir -p /home/hadoop/data/checkpoint
$ chown -R hadoop.hadoop /home/hadoop/data/checkpoint

@ Make the name directory (in hadoop, server is dataNode01~03)
$ mkdir -p /home/hadoop/data01 
$ mkdir -p /home/hadoop/data02
$ chown -R hadoop.hadoop /home/hadoop/data01
$ chown -R hadoop.hadoop /home/hadoop/data02

@@ Install Haddop @@

@ There is a hadoop
@ http://ftp.kddilabs.jp/infosystems/apache/hadoop/common/
$ cd /usr/local/src/
@ user is root
$ wget http://ftp.kddilabs.jp/infosystems/apache/hadoop/common/hadoop-1.2.1/hadoop-1.2.1.tar.gz
@ Install Hadoop (master and slave both)
$ tar xvf ./hadoop-1.2.1.tar.gz
$ mv ./hadoop-1.2.1 ./hadoop
$ chown -R hadoop.hadoop /usr/local/hadoop

@Configure the Hadoop(master)

## conf/hadoop-env.sh ##
#=================================
# Not to show the warning deprecated
HADOOP_HOME_WARN_SUPPRESS=TRUE
export HADOOP_HOME_WARN_SUPPRESS
# The java implementation to use.  Required.
export JAVA_HOME=/usr/local/java
#================================

@## core-site.xml ##@
@## hdfs-site.xml ##@


@ Set master server
(This is secondary namenode)
$ vi master
@ Add below this
## conf/master ##
#=================================
server02

@Set slave server
$ vi slave
@ Add below this
server02
server03
server04
## conf/slave ##
#=================================
server02
server03
server04

@ Set the hadoop home directory path
$ vi /etc/profile
@ Add below this at end of file. (master, slave both)
# /etc/profile
# =====================================
export HADOOP_HOME=/usr/local/hadoop
# =====================================
@Apply the value
$ source /etc/profile

@ Install slaves as the master.


@ Make the directory as DataNode (on the nameNode server)
@ You may need to do connection first for SSH
$ ./bin/slaves.sh mkdir -p /home/hadoop/data01/hdfs
$ ./bin/slaves.sh mkdir -p /home/hadoop/data02/hdfs

@ Format the Namenode (on the master)
$ ./bin/hadoop namenode -format
[hadoop@centos04 hadoop]$ ./bin/hadoop namenode -format
15/03/22 01:41:36 INFO namenode.NameNode: STARTUP_MSG:
/************************************************************
STARTUP_MSG: Starting NameNode
STARTUP_MSG: host = server01/192.168.11.23
STARTUP_MSG: args = [-format]
STARTUP_MSG: version = 1.2.1
STARTUP_MSG: build = https://svn.apache.org/repos/asf/hadoop/common/branches/branch-1.2 -r 1503152;
compiled by 'mattf' on Mon Jul 22 15:23:09 PDT 2013
STARTUP_MSG: java = 1.7.0_75
************************************************************/
Re-format filesystem in /home/hadoop/data/name ? (Y or N) Y
@ If this error occur, you'd better check hosts on file.(Delete 127.0.0.1 server01)
#org.apache.hadoop.ipc.RPC: Server at server01/127.0.0.1:9000 not available yet, Zzzzz...


@ Add the follow information to open ports and access each other in server.
$ vim /etc/sysconfig/iptables
-A INPUT -m state --state NEW -m tcp -p tcp --dport 50070 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 50090 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 50100 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 50105 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 9000 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 9001 -j ACCEPT

@Start the hadoop
$ ./bin/start-dfs.sh

@ If the following error occur, Just Iptables off lisk this ($ chkconfig iptables off)
error: java.io.IOException: File /home/hadoop/data/mapred/system/jobtracker.info could only be replicated to 0 nodes, instead of 1
@ If you want to do reformat ($ ./bin/hadoop namenode -format), you'd better do after delete all of old directorys(name, data, data01, data02)


@Stop the hadoop
$ ./bin/stop-dfs.sh

@You can see the hadoop on Firefox
http://192.168.11.23:50070

@You can see the hadoop on Console
$ ./bin/hadoop dfsadmin -report


@@@Truble Shouting@@@

@ If a dataNode doesn't run, Check It's permission
$ ./bin/slaves.sh chmod 755 /home/hadoop/data01/hdfs
$ ./bin/slaves.sh chmod 755 /home/hadoop/data02/hdfs 
2013-05-17 13:42:37,457 WARN org.apache.hadoop.hdfs.server.datanode.DataNode: Invalid directory in dfs.data.dir: Incorrect permission for /home/hadoop/data01/hdfs, expected: rwxr-xr-x, while actual: rwxrwxr-x
2013-05-17 13:42:37,462 WARN org.apache.hadoop.hdfs.server.datanode.DataNode: Invalid directory in dfs.data.dir: Incorrect permission for /home/hadoop/data02/hdfs, expected: rwxr-xr-x, while actual: rwxrwxr-x
2013-05-17 13:42:37,462 ERROR org.apache.hadoop.hdfs.server.datanode.DataNode: All directories in dfs.data.dir are invalid.

@In Addition, This [mapred-site.xml]
#This [/.../mapred/system]directory on Hadoop.
#This [/.../mapred/local]directory on Local System.
$ ./bin/slaves.sh chmod 755 /home/hadoop/data
#==========================================================#

#==========================================================#

I refer to this post 
http://blog.beany.co.kr/archives/412
http://blog.beany.co.kr/archives/1373
http://www.slideshare.net/TaeYoungLee1/20141029-25-hive
Thank you


Wednesday, March 18, 2015

The solutions for communicating on SSH Commend

@ If you faced the following error, the solution would help you

@ Error 1
>Pseudo-terminal will not be allocated because stdin is not a terminal.
@ the solution 1
@ [-oStrictHostKeyChecking=no] Option make a fingerprint to write in a known_hosts
@ (maybe -T -oStrictHostKeyChecking=no)
$ ssh -oStrictHostKeyChecking=no user@somehost sudo /home/tomcat/sh/sample.sh

@ Error 2
>sudo: sorry, you must have a tty to run sudo
@ the solution 1
ssh -t -oStrictHostKeyChecking=no user@somehost sudo /home/tomcat/sh/sample.sh
or
@ Comment the requiretty in /etc/sudoers like the following
#Defaults requiretty 

@ Extra explanation.
@ -T Disable pseudo-tty allocation.
@ -t Force pseudo-tty allocation.

http://aero.sarang.net/blog/2009/01/ssh-1.html

Mysql - useful Tips


@ Check the character set on mysql.
mysql> status
mysqlshow variables like 'character%';

@ How to copy 1 column from one DB to another DB.
mysql> INSERT INTO `target_databases`.`target_table` (`column21`, `column22`, `column23`) 
SELECT `column11`, `column12`, 1 FROM `source_databases`.`source_table` WHERE column15='test';

@ When these are different DB, -- This is option (--skip-column-names, -N)
$ ./mysql -e "SELECT column1, column2, 1 FROM database_name.table_name WHERE column3 in ('test1', 'test2')" -u root -p xxxx database_name > ~/dumpFile.txt
mysql>LOAD DATA LOCAL INFILE '~/dumpFile.txt' INTO TABLE target_table_name;

@ Backup only the schema
$ mysqldump -u root -p --no-data database_name > ~/onlySchema.sql

@ Ignores foreign keys constraints (0 : ignore, 1:value)
mysql> SET FOREIGN_KEY_CHECKS=0

@ Backup databases
$ ./mysqldump -u root -p Database_Name > DB_backup.sql
$ ./mysql -u root -p Database_Name < DB_backup.sql

@ Create a databases
@ Check character set
mysql> show variables like 'character%';
mysql> CREATE DATABASE databases DEFAULT CHARACTER SET utf8 or utf8mb4;

@SELECT VARIABLES values
mysql>show VARIABLES where Variable_name like '%log%';
@ Start to print logs into a file in mysql
mysql>SET GLOBAL general_log='on';
@If you want to change a path of a log file, change FILE for a path you want
mysql>SET GLOBAL log_output = ‘FILE’;

@Modify a column property
mysql> ALTER TABLE apns_book MODIFY book_badge VARCHAR(2) NULL;

@Remove [on update CURRENT_TIMESTAMP]
# Set the same column name
mysql> ALTER TABLE table_name CHANGE column_name column_name TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP;

@ How to load data into table from CSV in Mac
mysql> LOAD DATA LOCAL INFILE '~/test.csv' INTO TABLE table_name FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\r';

@ How to control data encrypted.
# select
mysql>SELECT AES_DECRYPT(column_name, 'password') as name FROM table_name;
# update
mysql>UPDATE table_name SET name=AES_ENCRYPT('Update Data', 'password') WHERE id=1;

@ Select data encrypted
mysql>SELECT distinct AES_DECRYPT(column_name, 'password') as test FROM table_name WHERE AES_DECRYPT(column_name, 'password') LIKE '%test%';

@ Change character set
mysql> SET character_set_client = utf8;
mysql> SET character_set_results = utf8;
mysql> SET character_set_connection = utf8;
mysql> ALTER DATABASE DB명 DEFAULT CHARACTER SET utf8;

@ Just Memo
semi  synchronize replicationsync_binlog sync_relay_log 

http://bryan7.tistory.com/101