2011-12-29-05.01.05.656543-480 E46743E405 LEVEL: Severe (OS) PID : 29100 TID : 47033606104272PROC : db2 INSTANCE: db2c97 NODE : 000 FUNCTION: DB2 UDB, oper system services, sqloexec, probe:20 MESSAGE : ZRC=0x870F00F2=-2029059854=SQLO_NORES "no resources to create process or thread" CALLED : OS, -, msgget OSERR: ENOSPC (28)You can use "ipcrm -q msgid" to remove them. After removing all those message queues, db2 CLP starts.
Thursday, December 29, 2011
DB21018E DB2 CLP cannot start
Wednesday, December 7, 2011
Input DB2 password using Python openpty()
- You need use openpty() because db2 insists reading from a terminal. You cannot use PIPE for stdin to pass the password.
- You have to read from stdout first. If you write the password through pty before reading, db2 may not read the password because it needs time to start.
- In python, read() will read until EOF. readline() won't work in that db2 prints "Enter " and waits for the input, no new line is present yet.
import os import subprocess m,s = os.openpty() print m,s p = subprocess.Popen("db2.sh", stdin=s, stdout=subprocess.PIPE, stderr=subprocess.PIPE) f = os.fdopen(m, "w") out = p.stdout.read(5) print "OUT: %s" % out if out == "Enter": f.write("mypassword\n") else: exit(-1) print "\nSTDOUT:\n" for line in p.stdout: print line print "\nSTDERR:\n" for line in p.stderr: print line print p.returncode
#!/bin/bash set -e source /home/db2c97/sqllib/db2profile db2 connect to DEVEDW user myname echo $? echo "loading ..." db2 "select count(*) from players" echo $?
Friday, December 2, 2011
Fix "The property zDeviceTemplates does not exist"
I wanted to bind my monitoring templates with my Hadoop devices programmatically. So I wrote a zendmd script like this:
... templates = { "clientnode": [], "secondarynamenode": [ 'HadoopJVM', 'HadoopNameNode', 'HadoopDFS' ], "namenode": [ 'HadoopJVM', 'HadoopNameNode', 'HadoopDFS' ], "jobtracker": [ 'HadoopJVM', 'HadoopJobTracker', 'HadoopFairScheduler' ], "datanode": [ 'HadoopJVM', 'HadoopDataNode', 'HadoopTaskTracker' ], "utility": [] } ... for item in dmd.Devices.Server.SSH.Linux.Ganglia.devices.objectItems(): (name, device) = item bindings = set([ 'Device' ]) rule = findRule(name, rules) if rule: device.zGangliaHost = gmond[rule["cluster"]] for t in rule["kinds"]: bindings = bindings.union(templates[t]) device.zDeviceTemplates = list(bindings) print name, device.zDeviceTemplates commit()
The basic idea is to define a list of templates for each node and set the templates list to zDeviceTemplates.
It worked after running this script in zendmd, and you can find all monitoring templates for the device. But you cannot bind templates in the WebUI any more. If you try to load objects including templates using ImportRM.loadObjectFromXML(xmlfile=f), it will throw this error "The property zDeviceTemplates does not exist".
Another problem is: zGangliaHost won't show up in "Configuration properties" after running the script, but Ganglia ZenPack works well.
I found exactly the same problem http://community.zenoss.org/thread/5812, which suggested "delete the device and create it again".
Actually you should never assign zGangliaHost and zDeviceTemplates directly. You should use device.setZenProperty('zGangliaHost', gmond[rule["cluster"]]) and device.setZenProperty('zDeviceTemplates', list(bindings)). setZenProperty actually maintains a internal property dict. If you assign zGangliaHost or zDeviceTemplates directly (using attribute directly), the property dict will not contain those properties, and you will get the error.
But you cannot call setZenProperty to set the property any more after the error is already thrown. You will kept gotten "the property doesn't exist" error. How should I fix it without delete the device?
It is actually pretty simple: delete attribute from zGangliaHost and zDeviceTemplates. Actually zenoss check if the property name is valid before set the property. If the object already has the attribute, the property name will be invalid because zenoss will add attribute to the object for each property. Unfortunately, the error message is misleading. This is my fix script:
for (id, dev) in dmd.Devices.Server.SSH.Linux.Ganglia.devices.objectItems(): print '----- %s' % id try: gangliaHost = dev.zGangliaHost delattr(dev, 'zGangliaHost') dev.setZenProperty('zGangliaHost', gangliaHost) except: print 'Missing zGangliaHost' devTemplates = dev.zDeviceTemplates delattr(dev, 'zDeviceTemplates') dev.setZenProperty('zDeviceTemplates', devTemplates) print 'zGangliaHost = %s' % dev.zGangliaHost print 'zDeviceTemplates = %s' % dev.zDeviceTemplates commit()
Thursday, November 17, 2011
Invalid artifact issue of Eclipselink Nexus Proxy Repository
<mirrors> <mirror> <id>nexus-public</id> <mirrorOf>*</mirrorOf> <url>http://nexus:8080/nexus/content/groups/public</url> </mirror> </mirrors>Unfortunately it doesn't work well. When maven gets some of artifacts, especially my own artifacts, Nexus returns invalid pom or jar files in this "Eclipselink Maven Mirror", which are actually HTML pages. And the artifacts will be saved into maven local repository, and make my maven builds fail again and again. I don't know how Nexus search the public repositories to locate an artifact. But looks like Nexus tries "EclipseLink Maven Mirror", then access the Eclipselink Repo using the URL listed above. Unfortunately this URL will return a HTML page once the artifact is not found. But Nexus didn't check if it is invalid because I didn't configure it. Here is my solution:
- Setup two mirrors: one for eclipselink and one for the others except eclipselink.
nexus-public *,!eclipselink-repo http://nexus:8080/nexus/content/groups/public nexus-eclipselink eclipselink-repo http://nexus:8080/nexus/content/repositories/eclipselink-maven-mirror
Tuesday, November 8, 2011
Hive Metastore Trick: "get_privilege_set failed"
- Embeded
- Local
- Remote
It seems straight forward. Right? If MySQL metastore database is installed on serverA, and the Hive client is running on serverB, which one you should use? Definitely not Embedded. Should use "Remote"? Does this configuration hive-site.xml work?
<property> <name>hive.metastore.local</name> <value>false</value> <description>controls whether to connect to remove metastore server or open a new metastore server in Hive Client JVM</description> </property> <property> <name>hive.metastore.uris</name> <value>thrift://serverA:8003</value> <description>host and port for the thrift metastore server</description> </property> <property> <name>javax.jdo.option.ConnectionURL</name> <value>jdbc:mysql://chelhadedw002/metastore_dev</value> <description>JDBC connect string for a JDBC metastore</description> </property> <property> <name>javax.jdo.option.ConnectionDriverName</name> <value>com.mysql.jdbc.Driver</value> <description>Driver class name for a JDBC metastore</description> </property> <property> <name>javax.jdo.option.ConnectionUserName</name> <value>username</value> </property> <property> <name>javax.jdo.option.ConnectionPassword</name> <value>password</value> </property>Unfortunately this doesn't work correctly. We could run "show tables", but Hive threw the exception when we run a select statement like this
FAILED: Hive Internal Error: org.apache.hadoop.hive.ql.metadata.HiveException(org.apache.thrift.TApplicationException: get_privilege_set failed: unknown result) org.apache.hadoop.hive.ql.metadata.HiveException: org.apache.thrift.TApplicationException: get_privilege_set failed: unknown result at org.apache.hadoop.hive.ql.metadata.Hive.get_privilege_set(Hive.java:1617) at org.apache.hadoop.hive.ql.security.authorization.DefaultHiveAuthorizationProvider.authorizeUserPriv(DefaultHiveAuthorizationProvider.java:201) at org.apache.hadoop.hive.ql.security.authorization.DefaultHiveAuthorizationProvider.authorizeUserAndDBPriv(DefaultHiveAuthorizationProvider.java:226) at org.apache.hadoop.hive.ql.security.authorization.DefaultHiveAuthorizationProvider.authorizeUserDBAndTable(DefaultHiveAuthorizationProvider.java:259) at org.apache.hadoop.hive.ql.security.authorization.DefaultHiveAuthorizationProvider.authorize(DefaultHiveAuthorizationProvider.java:159) at org.apache.hadoop.hive.ql.Driver.doAuthorization(Driver.java:531) at org.apache.hadoop.hive.ql.Driver.compile(Driver.java:393) at org.apache.hadoop.hive.ql.Driver.run(Driver.java:736) at org.apache.hadoop.hive.cli.CliDriver.processCmd(CliDriver.java:209) at org.apache.hadoop.hive.cli.CliDriver.processLine(CliDriver.java:286) at org.apache.hadoop.hive.cli.CliDriver.main(CliDriver.java:513) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.apache.hadoop.util.RunJar.main(RunJar.java:186) Caused by: org.apache.thrift.TApplicationException: get_privilege_set failed: unknown result at org.apache.hadoop.hive.metastore.api.ThriftHiveMetastore$Client.recv_get_privilege_set(ThriftHiveMetastore.java:2414) at org.apache.hadoop.hive.metastore.api.ThriftHiveMetastore$Client.get_privilege_set(ThriftHiveMetastore.java:2379) at org.apache.hadoop.hive.metastore.HiveMetaStoreClient.get_privilege_set(HiveMetaStoreClient.java:1042) at org.apache.hadoop.hive.ql.metadata.Hive.get_privilege_set(Hive.java:1615) ... 15 more
The problem of our configuration is "We should use LOCAL metastore even the MySQL metastore locates on a different server", in other word, hive.metastore.local=true. If you want to use "Remote" metastore, you need to start the metastore service hive --service metastore. It seems working when we use "serverA:8003", because we install Hue on serverA, and beeswax starts a metastore thrift service on port 8003. That is why you can run show tables successfully, but get the above error when you run select.
Another issue is: when you use remote metastore, you will still have this issue. see https://issues.apache.org/jira/browse/HIVE-2554 and https://issues.apache.org/jira/browse/HIVE-2405.
Tuesday, October 18, 2011
Puppet logs
# Where to log to. Specify syslog to send log messages to the system log. PUPPET_LOG=/var/log/puppet/agent.log # Autoflush logs PUPPET_EXTRA_OPTS=--autoflushand /etc/sysconfig/puppetmaster
PUPPETMASTER_LOG=/var/log/puppet/master.log PUPPETMASTER_EXTRA_OPTS=--autoflushIt is better to add --autoflush. I like to use puppet kick and monitor the log. Without --autoflush, puppet seems not working because the log is not written to disk.
Thursday, October 13, 2011
Set zGangliaHost for a lot of servers
$ zenbatchload dev-cluster.txtHere is the dev-cluster.txt:
/Devices/Server/SSH/Linux/Ganglia devnode001 comments="My Hadoop DEV cluster, client node", zGangliaHost="devnode001", setGroups='/Hadoop/DEV/ClientNode' devnode002 comments="My Hadoop DEV cluster, master node", zGangliaHost="devnode001", setGroups='/Hadoop/DEV/MasterNode' devnode003 comments="My Hadoop DEV cluster, data node", zGangliaHost="devnode001", setGroups='/Hadoop/DEV/DataNode'You can set zGangliaHost and groups in a file. It is perfect. You can generate this file easily using a script. ZENBATCHLOAD HOW TO may be obsolete. My Zenoss version (3.1.0) doesn't use -i. My Zenoss administrator created the devices for my clusters without zGangliaHost. I don't want him to delete those devices and use zenbatchload. Here is my solution.
$ zendmd --script=set_gangliahost.pyHere is set_gangliahost.py:
import re dev = re.compile('(hdcl001|had002|had01[0-2]).*', re.IGNORE CASE) test = re.compile('(hdcledw002|had001|had01[0-2]).*', re.IGNOR ECASE) prod = re.compile('prod.*', re.IGNORECASE) for item in dmd.Devices.Server.SSH.Linux.Ganglia.devices.objectItems(): (name, device) = item if dev.match(name): device.zGangliaHost = 'dev-gmond' elif test.match(name): device.zGangliaHost = 'test-gmond' elif prod.match(name): device.zGangliaHost = 'prod-gmond' commit()dev-gmond is the server name where you run gmond
Zenoss Ganglia ZenPack Fix
diff ZenPacks/jschroeder/GangliaMonitor/datasources/GangliaMonitorDataSource.py /workplace/ws-zenpacks/ZenPacks.jschroeder.GangliaMonitor/ZenPacks/jschroeder/GangliaMonitor/datasources/GangliaMonitorDataSource.py 72c72 < return self.hostname --- > return self.hostBecause I am a newbie of Zenoss, the following may be useful for you:
- Switch to zenoss sudo su - zenoss
- run zenpack --link --install=/tmp/ZenPacks.jschroeder.GangliaMonitor
- If everything is correct, you should see ZenPack in the web page.
Thursday, October 6, 2011
Puppet kick
$ sudo puppet kick -f --debug --host pslave1.puppet-test.com Triggering pslave1.puppet-test.com Host pslave1.puppet-test.com failed: No route to host - connect(2) pslave1.puppet-test.com finished with exit code 2 Failed: pslave1.puppet-test.comThen I run into another problem, I did add the following in /etc/puppet/auth.conf like this (THIS IS WRONG)
# this one is not stricly necessary, but it has the merit # to show the default policy which is deny everything else path / auth any path /run method save allow pmaster.puppet-test.comAnd I did add run this command to create namespaceauth.conf
sudo touch /etc/puppet/namespaceauth.confBut it is still don't allow me to kick the agent:
warning: Denying access: Forbidden request: pmaster.puppet-test.com(192.168.56.101) access to /run/pslave1.puppet-test.com [save] authenticated at line 93 err: Forbidden request: pmaster.puppet-test.com(192.168.56.101) access to /run/pslave1.puppet-test.com [save] authenticated at line 93Finally I found why: because I put "path /run" after "path /". Here is the correct auth.conf
path /run auth any method save allow pmaster.puppet-test.com # this one is not stricly necessary, but it has the merit # to show the default policy which is deny everything else path / auth anyYou can run puppet agent like this to get the debug information:
sudo puppet agent --listen --debug --no-daemonize --verbose
Puppet master, symlink and SELinux
sudo puppet agent --no-daemonize --verbose --onetimeon an agent machine, I got the following error:
err: Could not retrieve catalog from remote server: Error 400 on SERVER: Could not find class p4 at /etc/puppet/manifests/nodes.pp:2 on node pslave1.puppet-test.com
This page is helpful: http://groups.google.com/group/puppet-users/browse_thread/thread/66361418d801a97c. But my situation is different, the permission of module folders is rwxrwxr-x. I ran this command
sudo strace -e trace=file -f puppet master --no-daemonize --debug 2>&1 | tee logIt turned out that there WAS a "permission denied" issue:
[pid 15508] stat("/etc/puppet/modules/p4", 0x7fff44cfb630) = -1 EACCES (Permission denied)
Thursday, September 29, 2011
Install 64-bit CentOS on 64-bit Windows 7 using VirtualBox
But had the error "Your CPU does not suupoort long mode. Use a 32bit distribution."
It turns out that I have to turn off a BIOS setting for VT-d which is enabled by default. After that, when you create a new machine, enable Settings->System->Acceleration->Enable VT-x/AMD-v. Then everything works smoothly.
Wednesday, September 7, 2011
How to find DB2 servers in Windows?
Actually you can use DB2->Set-up Tools->Configuration Assistant. When it starts, click menu Configure -> Export Profile -> All ...
Search the node of your DB in the profile file, then you will find the host name or ip address.
[NODE>MYDB]
ServerType=DB2LINUX
Nodetype=U
Protocol=TCPIP
Hostname=10.116.152.112
Portnumber=50000
Security=0
Chrome and NTLM authentication
Finally I figured out why. Chrome uses Windows "Internet options" for NTLM authentication. If you place the web site in "Trusted sites" and Chrome won't try NTLM authentication. Only the web site in "Local Intranet", Chrome will use NTLM authentication and you can access that site without credentials.
Transfer database connections between two Eclipse workspaces
- Go to workspaceA/.metadata/.plugins/org.eclipse.datatools.connectivity
- Copy ServerProfiles.bak and ServerProfiles.dat to workspaceB/.metadata/.plugins/org.eclipse.datatools.connectivity
- Restart Eclipse
JRuby Rails 3 render a file on a windows server
My environment is jruby 1.6, rails 3.0.5, and tomcat 7.0.11 on windows.
And I found the code from "JRuby cookbook"
PUBLIC_DIR = if defined?($servlet_context)
$servlet_context.getRealPath('/')
else
"#{RAILS_ROOT}" + '/public'
end
Unfortunately this code still didn't work, still got "Missing template".
The reason is windows path. PUBLIC_DIR will be "c:/tomcat/webapps/myapp" and the file is "c:/tomcat/webapps/myapp/401.html". When rails searches the view paths, it tries to add each item in view paths as a prefix of your file. One of the view paths is "c:/", then the path which rails tries to search looks like "c:/c:/tomcat/webapp/myapp/401.html". Of course, Rails cannot find the file.
$servlet_context.getRealPath('/').gsub(/^\w:/, "").gsub(/\\/, "/")
Friday, August 19, 2011
How to debug Pig UDFs in Eclipse?
- Create a maven project using m2eclipse.
- Add org.apache.pig:pig as dependency.
- Click "Debug configurations ...".
- Create a "Java Application".
- Main class "org.apache.pig.Main".
- In Arguments tab, put "-x local" and other arugments in "Program arguments".
- In Environment tab, create a variable "PATH" as "${env_var:path};c:\cygwin\bin" if your OS is Windows.
- Debug your script, and Eclipse will stop at the breakpoint you set in UDF.
How to debug Hadoop MapReduce jobs in Eclipse.
- Create a maven project using m2eclipse.
- Add org.apache.hadoop:hadoop-core as dependency.
- You can set breakpoint at any line in your code.
- Right-click your drive class, Debug As -> Java Application
- In arguments tab of launch configuration, put "-fs file:/// -jt local -Dmapred.local.dir=c:/temp/hadoop your_input_file c:/temp/hadoop/output" in "Program arguments"
- If you run on Windows, you have to use Cygwin because hadoop uses external shell command "chmod". In Environment tab, add environment variable PATH, value is ${env_var:path};c:\cygwin\bin. Then hadoop can find chmod.
- Click debug, you can debug your MapReduce code in eclipse. Hadoop is running in local mode.
Tuesday, August 16, 2011
Friday, May 6, 2011
SyntaxHighlighter Vertical Scrollbar
After several tries, I found that commenting line-height in shCore.css works
.syntaxhighlighter a,
.syntaxhighlighter div,
.syntaxhighlighter code,
.syntaxhighlighter table,
.syntaxhighlighter table td,
.syntaxhighlighter table tr,
.syntaxhighlighter table tbody,
.syntaxhighlighter table thead,
.syntaxhighlighter table caption,
.syntaxhighlighter textarea {
-moz-border-radius: 0 0 0 0 !important;
-webkit-border-radius: 0 0 0 0 !important;
background: none !important;
border: 0 !important;
bottom: auto !important;
float: none !important;
height: auto !important;
left: auto !important;
// line-height: 1.5em !important;
Tuesday, April 19, 2011
ActiveRecord JDBC adapter multiple database bug
After tracing JDBC adapter source, I found the reason for my case: the class method column_types in arjdbc/jdbc/column.rb
@column_types ||= ::ArJdbc.constants.map{|c|
::ArJdbc.const_get c }.select{ |c|
c.respond_to? :column_selector }.map{|c|
c.column_selector }.inject({}) { |h,val|
h[val[0]] = val[1]; h }
Both MsSQL and DB2 are lazy loaded. When you have multiple databases, once @column_types is instantiated for db2, it will never be changed. But it is possible that MsSQL module is not loaded yet and so its column_selector is never called.
def self.column_selector
[/sqlserver|tds|Microsoft SQL/i, lambda {|cfg,col| col.extend(::ArJdbc::MsSQL::Column)}]
end
column_selector extends JdbcColumn with MsSQL version Column, and it defines :identity. If it is not called, "undefined method 'identity='" will be thrown.
The simple way I found to fix this issue: put the following in config/application.rb
# overcome activerecord-jdbc-adapter bug "undefined method 'identity='"
# for multiple databases by preloading the driver
if defined?(ArJdbc::Version::VERSION)
require 'arjdbc/db2'
require 'arjdbc/mssql'
end
Rails filters for Ajax pages
2. for each tab, the content is loaded by ajax call
3. the response of an ajax call is just a segment of html or json data
4. Need an easy way to send a request to the server just like ajax call so that I can debug the issue without load the whole page.
SOLUTION 1:
1. Routing .js or .html
2. ajax always asks for .js
SOLUTION 2: Filter
Friday, April 15, 2011
Get JRE 6 zip
* Download JRE installation exe file
* Launch the installation, but stop when the first dialog is shown
* Go to C:\Users\yourname\AppData\LocalLow\Sun\Java\jre1.6.0_24
* Open Data1.cab in WinRAR
* You will find core.zip.
Friday, April 8, 2011
Warbler configuration
1. Three jars in WEB-INF/lib, jruby-core, jruby-rack and jruby-stdlib, use 12MB
2. All rails dependent gems may use 6MB
And all the above files are not changed too frequently.
1. How to exclude all dependent gems in war
config.gem_dependencies = false
2. How to exclude jruby jars
config.java_libs = []
After
Monday, April 4, 2011
SyntaxHighlighter hints
SyntaxHighlighter.all();
But this method is actually hooked with body's onload() event. When I use some ajax call and want to format the page dynamically, this method won't work. It is actually easy to fix that: use highlight method directly.
SyntaxHighlighter.highlight();
And default font size of SyntaxHighlighter is too small. Found this page by googling
http://www.kerrywong.com/2009/04/05/changing-syntaxhighlighter-font-size/
it works, but there is an issue that the line numbers in gutter won't match the lines. You can fix this use the same font-size as below:
.syntaxhighlighter a,
.syntaxhighlighter div,
.syntaxhighlighter code,
.syntaxhighlighter table,
.syntaxhighlighter table td,
.syntaxhighlighter table tr,
.syntaxhighlighter table tbody,
.syntaxhighlighter table thead,
.syntaxhighlighter table caption,
.syntaxhighlighter textarea {
...
font-size: 1.01em;
...
}
.syntaxhighlighter table td.gutter .line {
text-align: right !important;
padding: 0 0.5em 0 1em !important;
font-size: 1.01em;
}
Thursday, March 24, 2011
IBM_DB ActiveRecord Limit Issue
It is very simple to fix that. I put the following code snippet into my config/application.rb after your application module. And everything works correctly.
Arel 2.0.9 doesn't have an ToSql visitor for DB2. The interesting thing is some versions of DB2 server actually support LIMIT clause. For example:
this windows version supports LIMIT
Database server = DB2/NT64 9.7.2
but this linux version doesn't
Database server = DB2/LINUXX8664 9.7.2
# this is a patch for ibm_db
if defined?(IBM_DB) && !Arel::Visitors::VISITORS.has_key?('ibm_db')
module Arel
module Visitors
class DB2 < Arel::Visitors::ToSql
private
def visit_Arel_Nodes_Limit o
"FETCH FIRST #{visit o.expr} ROWS ONLY"
end
end
VISITORS['ibm_db'] = Arel::Visitors::DB2
end
end
end
Thursday, February 17, 2011
Start Ruby 1.8.7 without setting system path on Windows
When I want to run Ruby-1.8.7-Win32, I can do like this:
C:\Windows\System32\cmd.exe /E:ON /K C:\workplace\apps\Ruby187\bin\setrbvars.bat
You can create a shortcut and pin this on the task bar.
Wednesday, February 9, 2011
Identify the Physical Host of a Virtual Server using PowerShell
http://portal.sivarajan.com/2010/01/identify-physical-host-of-virtual.html
$regPath= "HKLM:\SOFTWARE\Microsoft\Virtual Machine\Guest\Parameters"
$regValue = get-itemproperty -path $regPath
$regValue | fl "VirtualMachineName","PhysicalHostNameFullyQualified"