Changes

Jump to: navigation, search

Shared webhosting

4,523 bytes added, 01:54, 16 November 2007
no edit summary
Your MySQL connection id is 9 to server version: 5.0.32-Debian_7etch1-log
</pre>
Edit: ==== Refreshing links to MySQL socket ==== Sharing the MySQL socket works really well until the MySQL database is restarted or the VE running MySQL is restarted. Note that restarting MySQL will remove and recreate When this happens, the socket fileis removed and recreated. Existing In most cases, a different inode will be used, causing existing hard links to the mysql.sock filewill to no longer work . The solution is to relink these sockets.  There are more elegant solutions to this problem, but the following script is a decent hack that can be run via a cron job every minute or two. It will loop through all VEs between START_VEID and STOP_VEID and make sure that the links point to the correct socket. If they do not, the link will be recreated. <pre>#!/bin/sh # Created by Tauren Mills (tauren at tauren dot com) 2007-11-15 #################################### Start of Configuration settings #################################### # Location of private VEs:PRIVATE=/vz/private # Starting VE ID. VEIDs with this ID or greater will have mysql.sock link createdSTART_VEID=1001 # Stopping VE ID. VEIDs with this ID or less will need have mysql.sock link createdSTOP_VEID=2000 # Shared Mysql VE ID:MYSQL_VEID=201 # Location of mysql socket fileMYSQL_SOCK_DIR=/var/lib/mysql # Mysql socket file nameMYSQL_SOCK=mysql.sock ################################## End of Configuration settings ################################## # Display output if quiet is 0QUIET=0 if [ $# -eq 1 -a $1 = "--quiet" ]; then QUIET=1fi # Full path to socketMYSQL_SOCK_FILE=${PRIVATE}/${MYSQL_VEID}${MYSQL_SOCK_DIR}/${MYSQL_SOCK} [ $QUIET -eq 0 ] && echo[ $QUIET -eq 0 ] && echo "Relinking process starting..." # Get current location so we can set it back lateroldDirectory=`pwd` # Check to see if MySQL VE socket existsif [ -S "${MYSQL_SOCK_FILE}" ]; then  # Get inode of MySQL VE socket mysql_inode=`ls -i ${MYSQL_SOCK_FILE} | awk '{ print $1;}'`  # Search through VEs cd $PRIVATE for i in * ; do # The current VE to process veid=$i  # Check if VE should be linked againprocessed if [ $veid -ne $MYSQL_VEID -a $veid -ge $START_VEID -a $veid -le $STOP_VEID ]; then  # Get this VE's socket vesock=${PRIVATE}/${veid}${MYSQL_SOCK_DIR}/${MYSQL_SOCK}  # Make sure folder exists mkdir -p ${PRIVATE}/${veid}${MYSQL_SOCK_DIR}  # Check to see if this VE has a socket already if [ -S "${vesock}" ]; then # Get inode of this VE socket ve_inode=`ls -i ${vesock} | awk '{ print $1;}'`  # Test if sockets are the same if [ $mysql_inode -eq $ve_inode ]; then # No action required [ $QUIET -eq 0 ] && echo "$veid VALID: socket ${vesock}" else # Remove existing file if any if [ -a "${vesock}" ]; then rm ${vesock} fi  # Create hardlink to mysql socket file ln ${MYSQL_SOCK_FILE} ${vesock}  [ $QUIET -eq 0 ] && echo "$veid FIXED: socket ${vesock}" fi else # Socket didn't exist or file wasn't a socket  # Remove existing file if any if [ -a "${vesock}" ]; then rm ${vesock} fi  # Create hardlink to mysql socket file ln ${MYSQL_SOCK_FILE} ${vesock}  [ $QUIET -eq 0 ] && echo "$veid FIXED: socket ${vesock}" fi else [ $QUIET -eq 0 ] && echo "$veid SKIPPED" fi doneelse [ $QUIET -eq 0 ] && echo "${MYSQL_SOCK_FILE} does not exist. Is MySQL running?"fi cd $oldDirectory [ $QUIET -eq 0 ] && echo "Relinking process complete."[ $QUIET -eq 0 ] && echo </pre> The following post on the OpenVZ forum has some other suggestions on how to deal with this issue:[http://forum.openvz.org/index.php?t=rview&goto=23305#msg_23305 Shared webhosting - problem with mysql socket]
=== Proxy webserver ===
2
edits

Navigation menu