Search This Blog

Powered by Blogger.

Pages

Browsing "Older Posts"

Installing DB2 on ubuntu

By TY → Saturday, October 17, 2015

1. Uncomment the Partner repository lines by editing the /etc/apt/sources.list file
Look for the word "partner" in the file /etc/apt/sources.list
Uncomment the line for (by removing the "#") character
# deb http://archive.canonical.com/ubuntu lucid partner
# deb-src http://archive.canonical.com/ubuntu lucid partner
If your Ubuntu release is not lucid, add in the two lines above into the sources.list file

2. Update the package list
$ sudo apt-get update

3. Install DB2 using apt-get
$ sudo apt-get install db2exc

Reference:
http://www.db2teamblog.com/2010/09/db2-express-c-packages-for-ubuntu-1004.html

Backup and Restore DB2 to Another Machine

By TY →

TL;DR;
Use db2look to export DDL and db2move to export data.

The name of the database is "mydb" as an example
On source machine:
$ mkdir migrate
$ cd migrate
$ db2look -d mydb -e -a -o db2look.sql
$ db2move mydb export
$ cd ..
$ tar cf migrate.tar migrate
$ gzip migrate.tar

Transfer migrate.tar.gz to destination machine.
Note: Make sure that the database is created.
If not create it with the following:
Create database [db name, eg:mydb]

On destination machine:
$ gunzip migrate.tar.gz
$ tar xf migrate.tar
$ cd migrate
$ db2 -tvf db2look.sql
$ db2move mydb load

You may encounter -668 error when your application runs on the restored database. You can fix that with SET INTEGRITY.

If you have cyclic dependencies of the tables when you are trying to do SET INTEGRITY, the solution is at this post "Solving cyclic dependency for DB2 SET INTEGRITY".

References:
https://www-01.ibm.com/support/knowledgecenter/SSEPGG_9.7.0/com.ibm.db2.luw.admin.cmd.doc/doc/r0002079.html
http://www.ibm.com/developerworks/data/library/techarticle/dm-0403melnyk/

Solving cyclic dependency for DB2 SET INTEGRITY

By TY → Wednesday, October 14, 2015

While I am trying to resolve -668 error for DB2, the solution is to set integrity on the related tables.
However, I ended up trying to set integrity on a set of tables with cyclical dependencies. So the command 
SET INTEGRITY for <table> immediate checked
does not work.

Searching more, I found that the solution is actually the same command, but all the dependent table should be comma separated. Something like the below.

SET INTEGRITY for table_a, table_b, table_c immediate checked

Hope this helps!

DB2 SQL Error: SQLCODE=-668. Fixed with SET INTEGRITY

By TY → Tuesday, October 13, 2015

After I migrated my DB2 data to a new machine, I encountered "DB2 SQL Error: SQLCODE=-668".
At first, I thought that I can do a table reorg to fix it.  However, when I issue the reorg command, the same error code -668 was returned.

After some searching, the solution is to set integrity for the affected tables.

1. To find all the affected tables.
select 'set integrity for '||rtrim(tabschema)||'.'||tabname||' immediate checked' from syscat.tables where status = 'C'

2. Copy and paste the generated statements into db2 console.

3. Repeat a few times to clear all the tables so that the SQL from step 1 returns no more row.

Note, you may experience cyclic dependency on your tables that you are not able to clear. You can check out this post on cyclical dependencies and set integrity for db2.

Snap Circuits Alternative Energy Green, from Amazon

By TY → Monday, October 12, 2015

I have previously given "Snap Circuits Jr. SC-100 Electronics Discovery Kit" as presents and it was very well received.

So this time round, I thought that the kids can have and extension to their base "Snap Circuits Jr. SC-100 Electronics Discovery Kit" and learn about alternative energy.

The original set shipped in free from Amazon without any issues. However, for the Snap Circuit Alternative Energy set,  I was not able to select the free international shipping, even though this product appear when I have selected "International Shipping" and "Free International Shipping".

So I contacted Amazon's customer service for support, the customer service explained that there is a limit to the size of the package for free international shipping which "Snap Circuit Alternative Energy" set exceeds.

Then I asked politely, if there is anything that the customer service can do to help me with this. And the customer service graciously offered to waive the shipping for me! Woo Hoo!
Thank you Amazon.

Moving Docker's Directory

By TY → Sunday, October 11, 2015


We have an AWS instance that is running docker images. The AWS instance came with 8 GB of free space and we have mounted another data partition of 100 GB.

However, by default, the docker images are consuming space from within the 8 GB, which will not be sufficient, so we have got to move docker directory to the data partition that was mounted. The following steps worked for me.

  1. Default directory /var/lib/docker
  2. Stop docker service and move docker to data partition (in this case is "/data", you can mount your data partition anywhere, just replace "/data" with what you have)
    $ sudo stop docker
    $ sudo mv /var/lib/docker /data/docker
    
  3. Edit docker config, look for DOCKER_OPTS, add "-g /data/docker". Docker config can be found at /etc/default/docker.

    Final DOCKER_OPTS should be similar to the following:
    $ cat /etc/default/docker
    # Use DOCKER_OPTS to modify the daemon startup options.
    DOCKER_OPTS="--dns 8.8.8.8 --dns 8.8.4.4 -g /data/docker"
    
  4. Start docker service.

JDK8 java.lang.NoClassDefFoundError: com/sun/tools/javac/code/TypeTags

By TY →

Java build fail after update to jdk8 java.lang.NoClassDefFoundError: com/sun/tools/javac/code/TypeTags

Some projects continue to build successfully while some others failed after upgrading JDK.
Looking deeper into it and comparing the projects, those that failed are projects that are using lombok. It has been a while since I have upgraded lombok version. (which was still at 0.XXX)

After downloading the latest version of lombok and rebuild, the build completes successfully!

How to show sent mail in Thunderbird threaded conversation

By TY →
To see our sent mail in threaded conversation view in Thunderbird, we have to first enable unified view for folders.

After the unified inbox appear, right click on it and select "properties"
Click "Choose" to select the sent folder from the mail accounts that you want to have the sent mail appear in threaded view.

Reference:
http://superuser.com/questions/67488/can-mozilla-thunderbird-show-sent-replies-in-threaded-view

Gmail to allow less secure app to connect

By TY →


Some of my old java application that used to be able to send out email via Gmail fails. This seems to be due to a security enhancement sometime back in Gmail.

We now need to explicitly allow less secure applications to connect to Gmail. In order to do that, we will have to


  1. Go to
    https://www.google.com/settings/security/lesssecureapps
  2. Check "Allow access for less secure apps"
Note that, this feature is not available for google account with 2-steps verifications enabled.

For more information:
https://support.google.com/accounts/answer/6010255?hl=en

Unable to build in intellij idea when using lombok

By TY →
When using lombok with intellij, there is a great lombok plugin that enable Intellij to pick up the getter setter methods within the editor. However, when trying to build within Intellij, the build will fail.

To solve this, we only need to configure Intellij to process the annotations.
Go to Settings and type in "Enable annotation processing" in the search field and click "Annotation Processors" in the result.


Then just check "Enable annotation processing"

Reference : 
http://stackoverflow.com/questions/9424364/cant-compile-project-when-im-using-lombok-under-intellij-idea

Mac OS profile not loading in terminal

By TY →


This issue happened for me after installing google cloud engine for kubernetes.
After some search, This have helped me resolved it. The profile was not loaded in the terminal because .bash_profile exist.


  1. Move the following into the end of your "~/.profile"
    # The next line updates PATH for the Google Cloud SDK.
    source '/opt/App/google-cloud-sdk/path.bash.inc'
    
    # The next line enables bash completion for gcloud.
    source '/opt/App/google-cloud-sdk/completion.bash.inc'
    
  2. Rename "~/.bash_profile" as "~/.bash_profile_old"

Reference :
http://stackoverflow.com/questions/11498070/bash-profile-not-loading

Docker client and server don't have same version

By TY →


This can happen if you have updated docker, but the service has not been restarted. You will then try to connect to the docker daemon with the updated client, while the daemon (that was already running before the update) is still running the older version.
To fix this, restart the service:
sysV init:
service docker restart
systemd:
systemctl daemon-reload
systemctl restart docker

Reference:
http://stackoverflow.com/questions/24586573/docker-error-client-and-server-dont-have-same-version