Skip to main content

Posts

Showing posts from 2012

How to send command / input to multiple Putty window simultaneously

Putty is one of the best and must-have freeware for people working on Linux/Unix but use Windows as client like me.  We need to manage many servers and sometimes we are hoping we can run/execute same command on multiple host at same time, or just input same thing to multiple host. I searched online for a tool can do this. And it looks like PuTTYCS (PuTTY Command Sender) is the only one existing. But I’m a little bit disappointing after tried the software, it’s good but not good enough. It can only send command to each window one by one, and you have to wait until last window got input. So I think I should do something, and puttyCluster was born ( https://github.com/mingbowan/puttyCluster ) interface is simple: When you input Windows title pattern in the text box, you will be prompt for how many windows matching the pattern, like this: and you click the edit box under “cluster input”, what ever key you pressed will pass to all those windows simultaneously, even “Ctrl-C”, “Esc” and

enable special character support in Graphite metric name

Problem Graphite doesn’t support special characters like “ “ (empty space), “/” slash etc. Because it expect everything to be just ASCII to split/processing them, and then make directories based on metric name. For example:   Metric:     datacenter1.server1.app1.metric1.abc Will create datacenter1/server1/app1/metric1/abc.wsp But Metric: datacentter1.this is a test/with/path.app.test will fail when create directory So any special name not allow to appear in directory/file name is not supported by Graphite.   What we can do?   We can urlEncode the metric name which has special characters. So like “/var/opt” (not valid file name) will become “%2Fvar%2Fopt”(now valid), using urlEncode instead of others (like BASE64) is because this will keep most of data readable.   So what to change? 1. urlEncode metric name before send to Graphite (if you always sending metrics using text/line mode instead of pickle/batch mode, then you may consider modify Carbon-cache.py), like     metricname=

dynamic snitch and replicationStrategy in Cassandra

What is EndPointSnitch :    Cassandra is a distribute database, and data can be on any of the node or nodes (depends on replication factor).  But one single request from one client can hit only one Cassandra node at a time, so Cassandra needs to locate where is the data (on local node or on remote), then proxy the request to the node, wait for result and then return result to client. EndPointSnitch is used here to determine the sorted list of node Cassandra internally should proxy request to (best node is the first one in list). Coming with Cassandra, there’re 5 EndPointSnitch implementations.   EndPointSnitch also needs to provide “datacenter” and “rack” info for ReplicationStrategy to determine where to put replicas SimpleSnitch:   First get host list from ReplicationStrategy (defined for each keyspace, see below), exclude dead node and then return the node list. This snitch will always return "datacenter1" as datacenter and "rack1" as rack.  

What is node repair doing in Cassandra

here's what will happen when node repair is request (nodetool repair) definition:    neighbors, the node(s) has replica of the data other node(s) has.  For example, you have a 7 node cluster, and token is evenly distributed (that is, each node holds 1/7 range). Assume you set replication factor to 3. That means any data you write should have 3 replicas, under default strategy (SimpleStrategy)  , the next two replicas will be put on the next node along the ring. So if the data you write is on node 4, then node 5 and 6 each will also have one replica. And node 4 should also hold one replica for node 3 and one replica for node 2.  Then the neighbors for node 4 will be node 2,3,4,5 and 6.  Using same logic, node 6’s neighbors will be 4,5,6,7 and 1 (remember it’s a ring, when you reaches end, the next will be the first node) you can do the same calculation for other node or for other replication factor. Steps: for each keyspace in Cassandra DB do below:         skip if it's sys

How Cassandra Hector client load balancing work

Concept: hector connection pool contains other connection pools. The "other connection pool" here is the connection pool to each Cassandra host. Let's call the master hector pool as hector pool and other pools as host pool. So, for example, your cluster has 3 hosts, then the hector pool will contain 3 host connection pools, each host pool has several connections to one of the 3 hosts. Details: come with hector client library, there are 3 load balancing policies (will call them LBP). 1. RoundRobinBalancingPolicy         this LBP always return next host pool in hector pool. So if you have 3 hosts as A, B and C. Then when you request new connection pool, this LBP will give you A, B, C, A, B, C, A …. 2. LeastActiveBalancingPolicy         This LBP keeps track of how many active connections within each host pool. And when you request a new one, it will return then host pool with least active connections . If multiple host pools have same active connections, randomly return on

problem using subversion (svn) with Apache http server and LDAP

My users decided to move from CVS to SVN, and they want to use centralized LDAP server for user authentication, I need to setup a test server for prove of concept test. I found one no longer used server, and installed SVN packages as well as mod_dav_svn. The Apache HTTP server is already there. After I configured Apache HTTP follow the document at http://svnbook.red-bean.com/nightly/en/svn.serverconfig.httpd.html#svn.serverconfig.httpd.prereqs , I tried to use subversion client to connect to it but failed. I checked http server log and found the request was sent to the wrong place: # more error_log ...... [Wed May xx 16:07:36 2012] [error] [client 192.168.128.10] File does not exist: /var/www/html/repos [Wed May xx 16:07:36 2012] [error] [client 192.168.128.10] File does not exist: /var/www/html/favicon.ico [Wed May xx 16:07:49 2012] [error] [client 192.168.128.10] File does not exist: /var/www/html/repos [Wed May xx 16:07:49 2012] [error] [client 192.168.128.10] File d

troubleshooting: gimp 2.8 cannot start up plugin

gimp 2.8 is out, I downloaded Windows version and installed. But when I try to run it, below error pops-up (the procedure entry point gzdirect could not be located in the dynamic link library zlib1.dll):   if I click on OK, the program can continue, but I want to fix it since I don’t want to miss anything, so I fired up Process explore and when the error pops-up, I located the zlib1.dll using Process Explorer’s DDL view   Here’s the output double click on zlib1.dll, and got below info   I did a file search under GIMP’s directory, there are 2 of them (one for 64-bit and one for 32-bit), and the version is different with the one in Windows directory:   seems the dll file within system directory was loaded instead of the one come with Gimp. I located the plugin’s directory by double click on the name (script-fu.exe) in Process Explorer And then copied zlib1.dll from GIMP’s bin directory (in my case, its C:\Program Files\GIMP 2\bin ) into the plug-ins directory and try to
Symptom: When trying to do “edit table” or “query data” (as below) in pl/sql developer or try to run any SQL statement, the program will hang. Although schema browse works and connection to database server can be made withouth issue. Trouble shooting: I updated Oracle client to 11.2.0.3, upgrade pl/sql developer to the lasted version 9.0.6, no help.  I fired up TCPView (from www.sysinternals.com ) and found there were 2 connections to server: While on server side, we only got one: I did a few more test, and turned out, sometimes, the first connection you made to the database may disappear on server side, when that happens, plsqldeveloper will hang.   So I traced server side Oracle process using “strace” as below (the number after –p is process ID as in above picture 32641/oracle….) strace –p 32641 and in the trace file, I got: write(20, "\2\274\0\0\6\0\0\0\0\0ssed\25\1\0\1\7 EHCC Query H"..., 700) = -1 ECONNRESET (Connection reset by peer)

ssh no password expiry prompt with LDAP

I installed and configured 389 directory server (aka redhat directory server), created user/group and configured follow the instruction at http://directory.fedoraproject.org/wiki/Howto:PAM on my Redhat 5.x Linux server I tried to reset user password, and then login with ssh, but no matter if the password is reset or not, there's no prompt for changing the expired password. I tried using command "login testUser", it will prompt me for new password. I checked /etc/pam.d/sshd, found out it missed one entry: auth       include      system-auth and system-auth will include ldap related settings: auth        sufficient    pam_ldap.so use_first_pass then the password change prompt pop out after login with ssh: WARNING: Your password has expired. You must change your password now and login again! Changing password for user testUser. Enter login(LDAP) password: So now I can force user to change their password after password reset or when password expired.

openldap ssl error

After install openldap on redhat, I can startup the process and access using ldapsearch but cannot access via ssl, I hit errors like below # ldapsearch -d 1 -x -D "cn=Manager,dc=example,dc=com" -w secret -H ldaps://192.168.16.88 cn ldap_create ldap_url_parse_ext(ldaps://192.168.16.88) ldap_bind ldap_simple_bind ldap_sasl_bind ldap_send_initial_request ldap_new_connection 1 1 0 ldap_int_open_connection ldap_connect_to_host: TCP 192.168.16.88:636 ldap_new_socket: 3 ldap_prepare_socket: 3 ldap_connect_to_host: Trying 192.168.16.88:636 ldap_connect_timeout: fd: 3 tm: -1 async: 0 TLS trace: SSL_connect:before/connect initialization TLS trace: SSL_connect:SSLv2/v3 write client hello A TLS: can't connect. ldap_perror ldap_bind: Can't contact LDAP server (-1) did a test using openssl to verify if ssl works:  # openssl s_client -connect 192.168.16.88:636 CONNECTED(00000003) 10484:error:140790E5:SSL routines:SSL23_WRITE:ssl handshake failure:s23_lib.c:

Using ssh as proxy to bypass firewall, or use existing server to connect to internet

Prerequisite 1.        You have ssh access to a server, the server has public internet access 2.        On Windows, You can change proxy settings on your web browser or any program you want to access to internet, Or 3.        On Linux, You can compile c program Tech explains: ssh has a feature to enable socks 5 proxy server   on your own local machine when you connect to the server. Then on the local machine, configure proxy settings will let you use the internet access (or intranet access) on that server. There’s also a program on Linux which can use http, socks4 or/and socks5 proxy to proxy any program. For example, you want to FTP to internet but the FTP program didn’t provide proxy settings, then you can use this program to do the proxy in the background for you. Steps (for Windows): 1.        Connect to you server using ssh with below syntax:     a.        ssh –D <local proxy port> -N <yourUserName>@<yourServer or IP address>     b.       example:   ssh

Linux/Unix which command equivalent on Windows

"which" command on Linux can help locate executable files, somethings we need same function on windows. Here's how: if you're using Windows 7, there's a building command "where", so if you want to find where is "notepad.exe" for Microsoft Word, just fire up and command window and type: where notepad.exe you'll get something like: C:\>where.bat notepad.exe C:\WINDOWS\system32\notepad.exe C:\WINDOWS\notepad.exe on Windows XP, there's no build-in command, so create a batch file called where.bat with below content: @echo off for %%i in (%1) do if not ""=="%%~$PATH:i" echo %%~$PATH:i now, run where notepad.exe you'll get something like: C:\>where.bat notepad.exe C:\WINDOWS\system32\notepad.exe you can save the file in windows directory, so you can use it anywhere Attention: only executable list in environment variable PATH can be found just like the way Linux/Unix works.

Write a Message to the Oracle Alert Log

This tip comes from Marco Gilbert, DBA at MRQ, in Ste-Foy, Quebec, Canada. If you want to write a message to the alert log, you can use the undocumented KSDWRT procedure of the DBMS_SYSTEM package. This procedure has two parameters, the first one must be "2" to write to the alert file, the second one is the message you want to write. Here is an example: execute sys.dbms_system.ksdwrt(2,to_char(sysdate)|| ' -- '); (1=Trace, 2=alert, 3=both).

Oracle listener startup failure

Problem: when trying to restart Oracle 11g listener, got below error: TNS-12560: TNS:protocol adapter error TNS-00507: Connection closed Linux Error: 29: Illegal seek checked sqlnet.ora, listener.ora and ORACLE_HOME etc. environment variables, no incorrect/abnormal settings found checked TCP/IP port usage by "lsof -i:1521" and "netstat -anp |grep 1521|grep LISTEN", didn't find any application listen on it. checked /etc/hosts, seems normal #more /etc/hosts 10.11.5.32 host.some.domain host ::1 localhost6.localdomain6 localhost6 #127.0.0.1 localhost.localdomain localhost <===== this is the root cause, but didn't think about it at first checked /etc/nsswitch.conf and /etc/resolv.conf, normal tried to start Oracle 10g listener on same machine, "lsnrctl start" finished without error, but listener was not running: TNS-12541: TNS:no listener TNS-12560: TNS:protocol adapter error TNS-00511: No listener Linux Error: