Aug 6
Running MySQL Proxy as a daemon
/etc/init.d/mysql-proxy
#!/bin/sh
#
# mysql-proxy This script starts and stops the mysql-proxy daemon
#
# chkconfig: - 78 30
# processname: mysql-proxy
# description: mysql-proxy is a proxy daemon to mysql
# Source function library.
. /etc/rc.d/init.d/functions
PROXY_PATH="/usr/local/sbin"
prog="mysql-proxy"
# Source networking configuration.
. /etc/sysconfig/network
# Check that networking is up.
[ ${NETWORKING} = "no" ] && exit 0
# Set default mysql-proxy configuration.
PROXY_OPTIONS="--daemon"
PROXY_PID=/var/run/mysql-proxy.pid
# Source mysql-proxy configuration.
if [ -f /etc/sysconfig/mysql-proxy ] ; then
. /etc/sysconfig/mysql-proxy
fi
PATH=$PATH:/usr/bin:/usr/local/bin:$PROXY_PATH
# By default it's all good
RETVAL=0
# See how we were called.
case "$1" in
start)
# Start daemon.
echo -n $"Starting $prog: "
daemon $NICELEVEL $PROXY_PATH/mysql-proxy $PROXY_OPTIONS --pid-file $PROXY_PID
RETVAL=$?
echo
if [ $RETVAL = 0 ]; then
touch /var/lock/subsys/mysql-proxy
fi
;;
stop)
# Stop daemons.
echo -n $"Stopping $prog: "
killproc $prog
RETVAL=$?
echo
if [ $RETVAL = 0 ]; then
rm -f /var/lock/subsys/mysql-proxy
rm -f $PROXY_PID
fi
;;
restart)
$0 stop
sleep 3
$0 start
;;
condrestart)
[ -e /var/lock/subsys/mysql-proxy ] && $0 restart
;;
status)
status mysql-proxy
RETVAL=$?
;;
*)
echo "Usage: $0 {start|stop|restart|status|condrestart}"
RETVAL=1
;;
esac
exit $RETVAL
/etc/sysconfig/mysql-proxy
# Options to mysql-proxy # do not remove --daemon PROXY_OPTIONS=" --daemon --proxy-backend-addresses=127.0.0.1:3306 --proxy-backend-addresses=127.0.0.1:3307 --proxy-lua-script=load-balancing.lua"
May 13
(partial) MySQL Proxy API Doc
I have been working a lot with MySQL proxy lately and trying to figure out how it works is a major PITA. There is virtually no documentation for it and the best way to understand how it actually works is to read the source code.
This is a list of API functions discovered by reading plugin.c in the mysql_proxy SVN source. The list may be incomplete or not entirely accurate.
Bear with me as I try to get better <pre> tag stylization, right now this is the best I can do.
[i] = integer based index
[s] = string based index
[proxy]
proxy.global - data structure shared amongst all lua state machines
proxy.global.config - sub structure (possibly added for esthetical reasons only)
proxy.backends - array of backends (shared)
proxy.connection - mysql connection object
[proxy.backends[i]]
proxy.backends[i].connected_clients - connected clients
proxy.backends[i].address - server Address
proxy.backends[i].state - status {BACKEND_STATE_UNKNOWN, BACKEND_STATE_UP, BACKEND_STATE_DOWN}
proxy.backends[i].type - type {BACKEND_TYPE_UNKNOWN, BACKEND_TYPE_RW, BACKEND_TYPE_RO}
proxy.backends[i].pool - connection pool object
[proxy.backends[i].pool]
proxy.backends[i].pool.max_idle_connections - max connections
proxy.backends[i].pool.min_idle_connections - min connections
proxy.backends[i].pool.users - hash table containing sockets hashed by username
[proxy.backends[i].pool.users[s]]
proxy.backends[i].pool.users[s].cur_idle_connections - number of sockets currently in the pool (meaning they are idle)
[proxy.connection]
proxy.connection.backend_ndx - id of active backend (magic value, setting it can trigger server socket changes, i.e: setting it to 0 returns the socket into the connection pool)
proxy.connection.server - server socket object
proxy.connection.client - client socket object
[proxy.connection.client]
proxy.connection.client.default_db - database
proxy.connection.client.username - user
proxy.connection.client.address - ip address (?)
proxy.connection.client.scrambled_password - password as it was sent from the client
[proxy.connection.server]
proxy.connection.server.default_db - database
proxy.connection.server.username - user
proxy.connection.server.address - ip address (?)
proxy.connection.server.scrambled_password - password as it was sent from the client
proxy.connection.server.mysqld_version - mysql version
proxy.connection.server.thread_id - connection id as set during the server handshake
proxy.connection.server.scramble_buffer - password hash (?)
1 comment
May 13
Add a self-generated SSL certificate to the list of trusted certificates
Usually Java only accepts SSL certificates that can be validated with one of the CA providers in JRE’s internal cacerts keystore.
The cacerts keystore is a file located at $JAVA_HOME/lib/security/cacerts
How to import a self generated SSL certificate
First, export the self-generated key 'mywebsite.com' to a file called mywebsite.com.cert on the server keytool -export -keystore ~/mywebsite.com.keystore -alias mywebsite.com -file mywebsite.com.cert Then download the cert file with FTP or SFTP to your local computer. Finally, import the certificate 'mywebsite.com.cert' into a local cacerts keystore: keytool -import -keystore $JAVA_HOME/lib/security/cacerts -storetype jks -alias mywebsite.com -file ./mywebsite.com.cert
References
keytool export command ˆ
keytool import command ˆ
May 12
Activating microphone boost on a Soundblaster Audigy SE in Windows Vista
Note: This is a repost of the same article, which got deleted when my website was hacked.
I just spent over two hours figuring out how to get my microphone to work under windows vista 32bits with my new Soundblaster Audigy SE so I’m writing this blog post in the hopes that it will help someone in my situation.
I started by letting vista install the driver by downloading it from the windows update website but that proved to be a big mistake. The sound actually worked great but my microphone input was way too low to be usable on ventrilo. What you usually do in that case is activate mic boost but there was no +20db check box in my sound control panel and there was absolutely no way to increase the volume of my microphone.
What I tried next is downloading official drivers from the creative website. The file is 60MB and took a while to download but since it was gonna fix all my problems it was worth it. Guess what: Installer doesn’t work; it just tells me that there is already a more recent version of the driver installed. So I then proceeded to uninstall the driver through the Windows Device Manager and restart the installer. This time it tells me no supported hardware is found…
This is where I was only inches away from just taking the card out of my PC and return it to the store where I bought it. But there was one last hope, the files extracted by the installer could provide me with a way to install a working driver. I searched for those files, found the driver and installed it et voila, suddenly there is a +20db mic boost check-box and everything works fine.
So here is how I got my sound card to work:
(I give no guarantee that this will work for you and it might even go wrong so save any open documents)
1. download driver from http://us.creative.com/support/downloads/
2. double click SB24_VTDRV_LB_1_04_0077.exe and let it extract the setup files.
3. wait until installer window is shown, once you see a window where you are asked to chose the setup language go to step 4 DON’T CLOSE THE INSTALLER WINDOW.
4. use “windows key” + R to bring up the run dialog, type %WINDIR%\Temp and hit enter.
5. look for a folder called CRF000, the modified date of that folder should be only minutes from your current system time.
6. open the CRF000 folder and inside open the Drivers folder, inside that folder is file called setup.exe that will happily install the official creative diver.
7. when asked if you want to replace your existing drivers say yes obviously ![]()
8. Back on the original installer window, click close to cancel the installation because you are done installing already.
Enjoy!
No commentsMay 12
Hacked?
It looks like my blog got hacked recently. At some point last week my latest blog post disappeared and I received a bunch of rubbish emails from my WP. I changed my password and upgraded WP to the latest version, hoping that this will prevent any further attacks on my precious blog.
The post that disappeared can’t be restored with Word Press, but thanks to google’s awesomness I was able to copy/paste the post’s contents from the “cached” version of my site.
No comments