Dec 17, 2013

Install Vertica on CentOS Guide

OS:                          CentOS 6.5 64bit
Vertica:                    7.0 Community Edition

Part 1: OS Configurations Before Install Vertica

1. Disk Readahead

/sbin/blockdev --setra 2048 /dev/sda1
echo '/sbin/blockdev --setra 2048 /dev/sda1' >> /etc/rc.local

Note: I also have sda2 so I also need to execute

/sbin/blockdev --setra 2048 /dev/sda2
echo '/sbin/blockdev --setra 2048 /dev/sda2' >> /etc/rc.local

2. TZ

vi /etc/profile
add the following line
export TZ="Asia/Shanghai"
For all the valid time zone names, please refer to

3. NTP

$ chkconfig --list ntpd
/sbin/service ntpd restart
/sbin/chkconfig ntpd on

4. Disable SELInux

1). Edit /etc/selinux/config and change setting for SELINUX to disabled
(SELINUX=disabled). This disables SELinux at boot time.
2). As root/sudo, type setenforce 0 to disable SELinux immediately.

5. Disable Transparent HugePages

You can check the current setting using the following command, which is displaying the default value of "enabled=[always]".

# cat /sys/kernel/mm/transparent_hugepage/enabled
[always] madvise never

The preferred method to disable Transparent HugePages is to add "transparent_hugepage=never" to the kernel boot line in the "/etc/grub.conf" file.

vi /etc/grub.conf

and add transparent_hugepage=never

For example: 
title Oracle Linux Server (2.6.39-400.24.1.el6uek.x86_64)
        root (hd0,0)
        kernel /vmlinuz-2.6.39-400.24.1.el6uek.x86_64 ro root=/dev/mapper/vg_ol6112-lv_root rd_NO_LUKS  KEYBOARDTYPE=pc KEYTABLE=uk
LANG=en_US.UTF-8 rd_NO_MD SYSFONT=latarcyrheb-sun16  rd_NO_DM rd_LVM_LV=vg_ol6112/lv_swap rd_LVM_LV=vg_ol6112/lv_root rhgb quiet numa=off
transparent_hugepage=never
        initrd /initramfs-2.6.39-400.24.1.el6uek.x86_64.img

6. Change I/O Scheduler

echo deadline > /sys/block/sda/queue/scheduler
echo 'echo deadline > /sys/block/sda/queue/scheduler' >> /etc/rc.local

7. Single Node Install Vertica

rpm -ivh vertica-7.0.0-0.x86_64.RHEL5.rpm

8. Run install_vertica to complete installation

cd /opt/vertica/sbin
./install_vertica --hosts 127.0.0.1 --dba-user vertica --dba-user-password vertica

This installs a vertica instance in localhost (127.0.0.1), and create a dba names vertica, and the password is vertica

9. Accept Vertica License

cd /opt/vertica/bin
./adminTools   (The T is uppercase)

and accept the license and EULA etc. Here please note that you can use mouse click to check and accept the EULA.

10. Install VMart example database

cd /opt/vertica/sbin
./install_example VMart

I mainly followed the installation guide, which is difficult to understand. :)
http://my.vertica.com/docs/7.0.x/PDF/HP_Vertica_7.0.x_Install_Guide.pdf
I also referenced the post here: 

Aha! All Set.

You can try to connect to database





You can also connect it from a windows environment, for example:
 vsql -h 192.168.136.63 -U vertica

If you find this blog is useful, please kindly click the ads on this page to help. Thank you very much.

How to install Chrome on CentOS 6.4 and 6.5

I have been always using Chrome, and even I am quite new to linux, I still want to use Chrome even it's not supported in CentOS 6.4 and 6.5, and below are the steps.

First of all, thanks to Rihard, he provides a script to install Chrome, which does 99.9% of the work. It's great!
 http://chrome.richardlloyd.org.uk/

But when I use the script, I still met some problems, maybe it's because I am using the company's internet proxy, or because in China, we cannot access some websites due to great firewall. Anyway, I need to do something to finish the 0.1% work left.

Step1: Follow the instructions here: http://chrome.richardlloyd.org.uk/ , download install_chrome.sh (http://chrome.richardlloyd.org.uk/install_chrome.sh)

Step2: It's better that you switch to root account to run the script, or use sudo ./install_chrome.sh. Assume you are running a root account:

chmod u+x install_chrome.sh
./install_chrome.sh

In this step, I met several problems:
a. connection to https://dl.google.com failed...
I solved this by using a no proxy internet. In our company, we always using proxy. But the connection just failed, so I run the command at home where no proxy is used.

b. download is very slow as shown in the screenshot below

The time estimation goes up to several hours and the progress always hung.
I solved this by using Ctrl C to stop the ./install_chrome.sh, and run this command again. Sometimes it hang at another package, but tried several times, the installation succeeded.


Note for CentOS 6.4: In CentOS 6.4, I see the script installed successfully. But when I click the icon, nothing happened. Then I open a terminal:

cd /usr/bin
./google-chrome

It shows the error:
[sai@localhost bin]$ ./google-chrome
./google-chrome: /usr/lib64/libnss3.so: version `NSS_3.14.3' not found (required by ./google-chrome)

I tried to follow the instructions here but didn't work.
http://www.linuxquestions.org/questions/slackware-14/google-chrome-30-error-nss-4-13-5-upgrade-4175482053/

What I did to solve this problem is: 
I searched and find a link here:
And I download and installed it. Now the problem solved. 

[Update on 2014/2/25] Sorry I didn't know the package link will be removed so I didn't save a copy of the package. I tried to find one and put it in the share folder below. Please try it and let me know whether it works for you:
https://drive.google.com/file/d/0B_ZDNNkWG1dYVXpHeDBwaHNBTXc/edit?usp=sharing
Last but not least, 
to uninstall Chrome, please run:
./install_chrome.sh -u

to update Chrome, please run:
sudo yum update google-chrome-stable



If you find this blog is useful, please kindly click the ads on this page to help. Thank you very much.

Dec 13, 2013

How to Visualize Vertica Query Plan

Vertica uses EXPLAIN command to return the query plan execution strategy to standard output.

Syntax
EXPLAIN { SELECT... | INSERT... | UPDATE...}

Returns
A compact representation of the query plan, laid out hierarchically.

Let's have an example here.
1. Prepare a table
This is preparation work, and if you know a table you can select please skip this step.

1. CREATE SCHEMA SAI;
2. CREATE TABLE T1(c INT);
3. INSERT INTO T1 VALUES(3);
4. INSERT INTO T1 VALUES(4);
5. INSERT INTO T1 VALUES(5);
2. In Vertica console, or a third party tool like DBVisualizer, execute
EXPLAIN SELECT * FROM SAI.T1;
You will get the output like below


3. Install GraphViz and launch GVEdit
For how to install GraphViz and launch GVEdit, please check another POST of mine.
http://sai1983.blogspot.com/2013/12/how-to-install-graphviz-and-launch.html

4. Use GVEdit
a. Copy the code in highlighted in step 2, the codes start from digraph G and all contents in {}
b. click the new icon of GVEdit and paste the content

c. click the right most "Run" button

If you think this article is useful, please click the ads on this page to help. Thank you very much.

How to install GraphViz and launch GVEdit

When study Vertica query plan, it's the first time I hear about GraphViz, it turns out to be a project with history. The official site and a brief introduction is as below:
http://www.graphviz.org/

ClusterGraphviz - Graph Visualization Software

GraphvizDrawing graphs since 1988

Graphviz is open source graph visualization software. Graph visualization is a way of representing structural information as diagrams of abstract graphs and networks. It has important applications in networking, bioinformatics,  software engineering, database and web design, machine learning, and in visual interfaces for other technical domains. 


Question is: if I got an GraphViz codes, how to make it displayed?

Step 1: Please download a package here
There are many versions and I downloaded Windows msi package






Step 2: launch a command window with administrator access






Please run a command

msiexec /a graphviz-x.xx.msi

And install the software as normal.

Step 3: open a command shell, go to GraphViz installation path, for example mine is:
D:\Program Files (x86)\Graphviz2.34\
Go to the bin folder, and run gvedit.exe







And you will see GVEdit launched!































If you think this article is useful, please click the ads on this page to help. Thank you very much.

Dec 11, 2013

SkyDrive How to Share to Everyone

I have been using Microsoft MSN space to manage my photos, and it's called SkyDrive now. SkyDrive now provides more functions and the UI are improved a lot. However, in MSN space it was very easy to share the picture or album you created to others, with SkyDrive it's not easy to find it out. Luckily, I figured out how to make it work:

1. in SkyDrive click "Files"
This will list all your files and folders

2. Check the folder you want to share (it's on the top right corner) and on the right there will display a link button called "Share" on the right
3. It will pop up a modal dialog, and click Get a link and choose "Public" in the option drop down list, 

4. Then click "Crate link", You can see it's now shared with Everyone. All Set!
I am now able to share my pictures and even send the URL to people I know. 

If you think this article is useful, please click the ads on this page to help. Thank you very much.




Dec 10, 2013

A Good Regular Expression Tutorial

Regular Expression is powerful and it's one of the tools that all programmers should grasp.














I just started the trip and get into the world, and I found the tutorial by Java website is very useful.
http://docs.oracle.com/javase/tutorial/essential/regex/index.html


The most interesting part is about Quantifiers. There are three types: greedy, reluctant and possessive.

GreedyReluctantPossessiveMeaning
X?X??X?+X, once or not at all
X*X*?X*+X, zero or more times
X+X+?X++X, one or more times
X{n}X{n}?X{n}+X, exactly n times
X{n,}X{n,}?X{n,}+X, at least n times
X{n,m}X{n,m}?X{n,m}+X, at least n but not more than m times

But it doesn't very clearly say how the match works underline. And there is an interesting stack overflow website about it.

I found this excellent tutorial on regular expressions and while I intuitively understand what "greedy", "reluctant" and "possessive" quantifiers do, there seems to be a serious hole in my understanding.
Specifically, in the following example:
Enter your regex: .*foo  // greedy quantifier
Enter input string to search: xfooxxxxxxfoo
I found the text "xfooxxxxxxfoo" starting at index 0 and ending at index 13.

Enter your regex: .*?foo  // reluctant quantifier
Enter input string to search: xfooxxxxxxfoo
I found the text "xfoo" starting at index 0 and ending at index 4.
I found the text "xxxxxxfoo" starting at index 4 and ending at index 13.

Enter your regex: .*+foo // possessive quantifier
Enter input string to search: xfooxxxxxxfoo
No match found.
The explanation mentions eating the entire input string, letters been consumed, matcher backing off, rightmost occurrence of "foo" has been regurgitated, etc.
Unfortunately, despite the nice metaphors, I still don't understand what is eaten by whom... Do you know of another tutorial that explains (concisely) how regular expressions engines work?
Alternatively, if someone can explain in somewhat different phrasing the following paragraph, that would be much appreciated:
The first example uses the greedy quantifier .* to find "anything", zero or more times, followed by the letters "f" "o" "o". Because the quantifier is greedy, the .* portion of the expression first eats the entire input string. At this point, the overall expression cannot succeed, because the last three letters ("f" "o" "o") have already been consumed (by whom?). So the matcher slowly backs off (from right-to-left?) one letter at a time until the rightmost occurrence of "foo" has been regurgitated (what does this mean?), at which point the match succeeds and the search ends.
The second example, however, is reluctant, so it starts by first consuming (by whom?) "nothing". Because "foo" doesn't appear at the beginning of the string, it's forced to swallow (who swallows?) the first letter (an "x"), which triggers the first match at 0 and 4. Our test harness continues the process until the input string is exhausted. It finds another match at 4 and 13.
The third example fails to find a match because the quantifier is possessive. In this case, the entire input string is consumed by .*+, (how?) leaving nothing left over to satisfy the "foo" at the end of the expression. Use a possessive quantifier for situations where you want to seize all of something without ever backing off (what does back off mean?); it will outperform the equivalent greedy quantifier in cases where the match is not immediately found.
The best answer is: 

greedy quantifier first matches as much as possible. So the .* matches the entire string. Then the matcher tries to match the f following, but there are no characters left. So it "backtracks", making the greedy quantifier match one less thing (leaving the "o" at the end of the string unmatched). That still doesn't match the f in the regex, so it "backtracks" one more step, making the greedy quantifier match one less thing again (leaving the "oo" at the end of the string unmatched). That still doesn't match the fin the regex, so it backtracks one more step (leaving the "foo" at the end of the string unmatched). Now, the matcher finally matches the f in the regex, and the o and the next o are matched too. Success!
reluctant or "non-greedy" quantifier first matches as little as possible. So the .* matches nothing at first, leaving the entire string unmatched. Then the matcher tries to match the f following, but the unmatched portion of the string starts with "x" so that doesn't work. So the matcher backtracks, making the non-greedy quantifier match one more thing (now it matches the "x", leaving "fooxxxxxxfoo" unmatched). Then it tries to match the f, which succeeds, and the o and the next o in the regex match too. Success!
In your example, it then starts the process over with the remaining unmatched portion of the string, following the same process.
possessive quantifier is just like the greedy quantifier, but it doesn't backtrack. So it starts out with.* matching the entire string, leaving nothing unmatched. Then there is nothing left for it to match with the f in the regex. Since the possessive quantifier doesn't backtrack, the match fails there.
Thanks to the people who provide the question and answer on the stack verflow website. 

If you think this article is useful, please click the ads on this page to help. Thank you very much.

How to install custom recovery Team Win Recovery Project (TWRP) in Android

Team Win Recovery Project (TWRP) custom recovery is one of the best recovery tool to use. I suggest everyone to install it, it can help you install update, backup, wipe cache and support many nice features, and it support touch screen which is very convenient. Its official website is: http://teamw.in/project/twrp2


To install TWRP, there are two ways:
The easiest way is to install an app called "GooManager" from Google Play.
https://play.google.com/store/apps/details?id=com.s0up.goomanager

But in case your network doesn't support you very well to download rom via GooManager, you need to manually install TWRP, and below are the steps:
1. Go to official site http://teamw.in/project/twrp2 to find the TWRP image for your device

2. Download it

For example, mine is: openrecovery-twrp-2.6.3.4-hammerhead.img

3. go to the android SDK installation folder, go to directory platform tools
for example, mine is: D:\Program Files (x86)\Android\android-sdk\platform-tools

4. Copy the download image into this folder

5. Press Shift key and at the same time, right click your mouse you will see a menu item "Open Command Window here"





















6. boot your device to fast boot mode and connect it to USB
For my device, I power off my device, and then simultaneously press power and volume down button button it will to go fast boot mode

7 execute command fastboot flash recovery recoveryfilename.img
for example, I execuste
fastboot flash recovery openrecovery-twrp-2.6.3.4-hammerhead.img

8. In fast boot mode, select Recovery mode



9. Go! You will now see the TWRP installed.
10. Last you can delete the img file in the SDK platform-tools folder.

If you think this article is useful, please click the ads on this page to help. Thank you very much.




Dec 4, 2013

OK, Google! How to enable Google Now in China

I have got the Nexus 5 and it's very cool that you say "OK Google" to trigger voice search function, you can also speak to use Google Now to find interesting things for you. But Google Now is not available in China, and by default you will see in Android system settings it says Google Now is not supported in China. But the great fire wall cannot stop us, and below is the way you can do it.






















The prerequisite is that you have a rooted device. 

1. Please download a third party market app and install it. I recommend Cool Market, the best one I have ever used.
Download link: cool market

2. After installation, search in cool market an app called "market unlocker". Run it and turn on
1) Enable Unlocker
2) Auto Unlocker

3. Turn off location
Go to Settings, under "PERSONAL" there is "Location" icon, click it and turn it off.

4. Clear Data and Cache of Google apps
Very importantly, please turn off your WiFi in this step
Go to Settings-->Apps, slice to ALL apps, clear cache of three Google apps
1) Google Play services (Click manage space, and then clear all data)

2) Google Play Store (Click clear data)

3) Google Search (Clear data)

Now reboot your device

1. go to Google Play to initialize it.
2. long lick the "Up" icon in home screen and click Google now.

Wait Google Now to be initialized. After this, you can enable locations service and google now will be there with you.

OK, Google!




Nov 19, 2013

IE Cannot Access localhost

I recently installed Internet Explorer 11 and today when debugging and I found that I could not access localhost website.


But at the same time, Chrome and Firefox both work very well. I tried to re-install IE, go to factory settings etc., but the problem still exists.

Luckily I found out the solution:
It turns out to be that I have used proxy, and the proxy settings needs to be further set. Please notice that even I clicked "Bypass proxy server for local addresses", which means localhost will certainly not use the proxy settings, it doesn't work.


The solution is: Click the "Advanced" button, and add "localhost" in the exception list, please notice that you need to use a semicolon to separate items.


If you think this article is useful, please click the ads on this page to help. Thank you very much.

Oct 23, 2013

Eclipse Cannot Start "Failed to load the JNI shared library ** jvm.dll" problem

Today I downloaded the latest eclipse (R4.3.1 Kepler Service Release 1) 64bit. When I tried to start eclipse, it failed and poped up an error message

Failed to load the JNI shared library "C:\Program Files(x86)\Java\jdk1.6.0_45\bin..\jre\bin\client\jvm.dll"


It turns out that in my system environment variables, JAVA_HOME was setting to 32bit version, which makes 64bit eclipse cannot start up. Setting JAVA_HOME to 64bit version java path makes it work.

If you think this article is useful, please click the ads on this page to help. Thank you very much.

Oct 12, 2013

Eclipse Breakpoint Is Not Hit

Today I was debugging a Java web application, and I met a strange problem:

In the javascript side, it is written in this way:
 var helpers = { 
 executeQuery: function(a) {               
  var param = {sQuery : a.sqlquery, sTitle: ""};
  REST.postObject('resources/whiteboardsql/executeQuery/'+a.instanceId+"/"+a.timestamp,param, a);
 }

And in the java side, I am sure that the code below it the rest call will invoke, so that I set a breakpoint there. But what's weird is that I executed the rest call many times but the breakpoint is never hit.

Finally I figured out the reason, it is so simply but I would like to share with those who might experience the same scenario.
The reason is "Hot Code Replace Failed"

I was modified the program, and the modification was deleting a comment, but eclipse pops up the "Hot Code Replace Failed" dialog. And I clicked "Continue".

Then when I come to debug the problem, the breakpoint is not hit. Terminate and restart the application solves the problem.

If you think this article is useful, please click the ads on this page to help. Thank you very much.

Oct 11, 2013

[Solved] How to Change and Config Yum Repository Source in RedHat 6 (No Package Available Problem)

I am using Red Hat Enterprise Linux Workstation 6.1, as it is a enterprise version. When I tried to install a software, for example I run: yum install vim
It returns that I "No package vim available".

I run:
1. cd  /ect/yum.repos.d
2. ls
The redhat.repo is empty.

Only after got a valid license, it will have the right value. For people don't have purchased a license, I have to find a way to config another source. Fortunately I figured out how to do it.

Then general solution is to:

  1. Unistall the original yum in Red Hat 
  2. Download yum rpm packages 
  3. Install Yum 
  4. Config Repository Source
  5. Run Yum and Test Install
The following are the details. 

1. Uninstall The Original Yum in Red Hat

rpm -aq|grep yum|xargs rpm -e --nodeps

2. Download yum rpm packages
You can manually go to the URL http://mirrors.163.com/centos/6/os/x86_64/Packages/ to find what's the right package version:

I have done this and find out them, so run these commands in terminal:

wget http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-3.2.29-40.el6.centos.noarch.rpm

wget http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-metadata-parser-1.1.2-16.el6.x86_64.rpm

wget http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.30-14.el6.noarch.rpm

wget http://mirrors.163.com/centos/6/os/x86_64/Packages/python-iniparse-0.3.1-2.1.el6.noarch.rpm

3. Install Yum


rpm -ivh python-iniparse-0.3.1-2.1.el6.noarch.rpm
rpm -ivh yum-metadata-parser-1.1.2-16.el6.x86_64.rpm 
rpm -ivh yum-3.2.29-40.el6.centos.noarch.rpm yum-plugin-fastestmirror-1.1.30-14.el6.noarch.rpm

Please notice that the in the last command it installs two packages together, because the two packages have dependencies on each other.

4. Update the repo configuration
a. cd /etc/yum.repos.h
b. backup original redhat.repo
mv redhat.repo redhat.repo.repo.bak
c. download a copy of CentOS repo, for example our version is verson 6
wget http://mirrors.163.com/.help/CentOS6-Base-163.repo
d. modify CentOS6-base-163.repo
vi CentOS6-Base-163.repo

the repo file contains 5 sections: [base], [updates], [exras], [centoplus], [contrib]

For each section, you need to replace with the the values in your environment
$releaserver means the version, in our case it's 6
$basearch means which branch, in our case it's x86_64, (another branch is i386

Modify each of the 5 sections.

The result looks like below:

# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client.  You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#

[base]
name=CentOS-$releasever - Base - 163.com
baseurl=http://mirrors.163.com/centos/6/os/x86_64
#mirrorlist=http://mirrorlist.centos.org/?release=6&arch=x86_64&repo=os
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6

#released updates
[updates]
name=CentOS-$releasever - Updates - 163.com
baseurl=http://mirrors.163.com/centos/6/updates/x86_64
                                                           
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras - 163.com
baseurl=http://mirrors.163.com/centos/6/extras/x86_64/
#mirrorlist=http://mirrorlist.centos.org/?release=6&arch=x86_64&repo=extras
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus - 163.com
baseurl=http://mirrors.163.com/centos/6/centosplus/x86_64/
#mirrorlist=http://mirrorlist.centos.org/?release=6&arch=x86_64&repo=centosplus
gpgcheck=1
enabled=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6

#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib - 163.com
baseurl=http://mirrors.163.com/centos/6/contrib/x86_64/
#mirrorlist=http://mirrorlist.centos.org/?release=6&arch=x86_64&repo=contrib
gpgcheck=1
enabled=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6


f. the last step is to replace the original redhat.repo
mv CentOS6-Base-163.repo redhat.repo

[Note] In my case, I am using the mirror located in China which is hosted by Netease (163), people can also use the website http://mirrors.fedoraproject.org/publiclist/ to find one that good for yourself.
For example http://mirror.overthewire.com.au/pub/centos/6/
It has the same structure.

5. Run Yum and Test Install
run yum:
yum clean all

test install
yum install vim


hallelujah!

If you think this article is useful, please click the ads on this page to help. Thank you very much.

Sep 9, 2013

How to take screenshot in android device without a third party app?

I have been using android for three years and it's first time that I know how to screenshot in android device, and without using a third party application. Below is the way to do it:

Press and hold down the Power and Volume-down buttons simultaneously
And you will hear a "Beep" sound and see an animation that let you know that the screenshot is taken, and you can use Gallery app or any image app to view it.

Simple as it is!

If you think this article is useful, please click the ads on this page to help. Thank you very much.

Good Email App for Pad: TouchDown HD

Our company's email account will force a security setting, which will compel you to use a screen lock with PIN or password etc. This is to say, every time the screen is turned on and off, you need to type the PIN to unlock it.


We understand that this is very important for company security, because the device may contain sensitive information. But it needs to frequently input the password, which is so inconvenient. How can we overcome it? Now we have found a tool that can both satisfy the security needs and avoid the inconvenience of typing the password.

The solution is to use a app called: TouchDown HD.

It contains calendar, email and contacts tabs, and it has powerful configuration settings.
And most importantly, when you configure the email account using TouchDown HD, it only locks itself. The device is not locked, so that you don't need to input password every time you turn on the device.



If you find this article is useful, please click the ads on this page to help. Thank you very much.