<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>www.enriquelamastrujillo.com &#187; mysql</title>
	<atom:link href="http://www.enriquelamastrujillo.com/blog/tag/mysql/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.enriquelamastrujillo.com/blog</link>
	<description>Otro sitio creado con WordPress</description>
	<lastBuildDate>Fri, 27 Feb 2026 20:20:53 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>How to configure Distributed Statistics in Openx</title>
		<link>http://www.enriquelamastrujillo.com/blog/2013/05/16/how-to-configure-distributed-statistics-in-openx/</link>
		<comments>http://www.enriquelamastrujillo.com/blog/2013/05/16/how-to-configure-distributed-statistics-in-openx/#comments</comments>
		<pubDate>Thu, 16 May 2013 14:47:55 +0000</pubDate>
		<dc:creator>Quique</dc:creator>
				<category><![CDATA[informática]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[openx]]></category>

		<guid isPermaLink="false">http://www.enriquelamastrujillo.com/blog/?p=375</guid>
		<description><![CDATA[Ver este post en español
People at Openx use &#8220;Distributed Statistics&#8221; as an option to scale the service, but in my opinion the documentation is confuse or wrong, as you can see at this message I wrote as &#8220;raistlink&#8221;.
Distributed Statistics works like this (as I configured):

both computers serve banners
only one of them (or another aditional computer) [...]]]></description>
			<content:encoded><![CDATA[<p><a href="/blog/2013/05/16/como-montar-distributed-statistics-en-openx/">Ver este post en español</a></p>
<p>People at <a href="http://www.openx.com/" target="_blank">Openx</a> use &#8220;Distributed Statistics&#8221; as an option to scale the service, but in my opinion the documentation is confuse or wrong, as you can see at <a href="http://forum.openx.org/index.php?showtopic=503520463" target="_blank">this message I wrote as &#8220;raistlink&#8221;</a>.</p>
<p>Distributed Statistics works like this (as I configured):</p>
<ul>
<li>both computers serve banners</li>
<li>only one of them (or another aditional computer) works also as the admin. I will call &#8220;master&#8221; to the admin computer and &#8220;slave&#8221; to the other.</li>
<li>only one computer executes the maintenance process that calculates the probability of the zones</li>
<li>the replication makes the slave machine revieve those probalities</li>
<li>the slave machine sends it&#8217;s activity to the master executing the maintenance-distributed instead of maintenance</li>
</ul>
<p>It&#8217;s mandatory that you configure crones in the way that when the hourly execution of the maintenance process at the master is running, the activity from the slave has been recieved, in other case this activity will be lost. That&#8217;s why, as we will see in a moment, the master executes the maintenance process at the minute 15 everu hour and the slave executes the maintenance-distributed every five minutes.</p>
<p>Well, I got it at the end so I&#8217;m going to explain a bit how I did it.</p>
<p>The start point is two computers under a balancer serving banners under the same url, lets say my.adserver.com.</p>
<p><b>Master:</b></p>
<ul>
<li>Stop apache</li>
<li>be sure maintenance is not running and stop the cron</li>
<li>Stop mysql</li>
<li>Set this at my.conf</li>
<p>       server-id        = 1<br />
       log-bin=mysql-bin</p>
<li>Start mysql</li>
<li>GRANT REPLICATION SLAVE ON *.* TO &#8217;slave_user&#8217;@'%&#8217; IDENTIFIED BY &#8216;XXXX&#8217;;</li>
<p>   where XXXX is the password used by the slave at replication for connecting to the master.</p>
<li>GRANT ALL PRIVILEGES ON *.* TO &#8216;root&#8217;@'%&#8217; IDENTIFIED BY &#8216;YYYY&#8217;;</li>
<p>	where YYYY is the password used by the slave in order to send its stats to the master<br />
	As you can see you can use two different passwords, no problem.</p>
<li>FLUSH PRIVILEGES;</li>
<li>show master status. <b>TAKE NOTE OF THESE VALUES, YOU&#8217;LL NEED THEM AFTER</b></li>
<p>       <b>mysql-bin.000001 |      417</b></p>
<li>make a dump</li>
<p>       mysqldump -u root -p &#8211;databases openx_2_8_10 > /tmp/openx_2_8_10-201302071719.sql</p>
<li>start apache</li>
<li>execute once again show master status for testing purposes</li>
<p>        mysql-bin.000001 | 24995895<br />
		the number has changed, so the master is replicating
</ul>
<p><b>Slave:</b></p>
<ul>
<li>drop openx database</li>
<li>load the master dump at slave</li>
<p>       mysql -u root -pXXXX < "/tmp/openx_2_8_10-201302071719.sql"</p>
<li>execute these alter commands at openx database</li>
<p>	ALTER TABLE ox_data_raw_ad_click ENGINE=MyISAM;<br />
	ALTER TABLE ox_data_raw_ad_impression ENGINE=MyISAM;<br />
	ALTER TABLE ox_data_raw_ad_request ENGINE=MyISAM;<br />
	ALTER TABLE ox_data_raw_tracker_impression ENGINE=MyISAM;<br />
	ALTER TABLE ox_data_raw_tracker_variable_value ENGINE=MyISAM;<br />
	In fact I don&#8217;t see that the system use this tables but&#8230;</p>
<li>Set these values at my.conf</li>
<p>       server-id        = 2<br />
       log-bin=mysql-bin<br />
       (is order to work as a master if needed)<br />
       replicate-wild-ignore-table=openx_2_8_10.%data_%<br />
       replicate-wild-ignore-table=openx_2_8_10.%tmp_%<br />
       replicate-wild-ignore-table=openx_2_8_10.%lb_local%<br />
       replicate-wild-ignore-table=mysql.%<br />
       replicate-wild-ignore-table=openx_2_8_10.%ox_log_maintenance_priority% (because of a problem a had later)<br />
       replicate-wild-ignore-table=openx_2_8_10.%ox_session% (because of a problem a had later)</p>
<li>start mysql</li>
<li>check if the slave can access the master whith this command for example</li>
<p>       mysqldump &#8211;host=host_master -u root -pYYYY &#8211;databases openx_2_8_10 > /tmp/openx_2_8_10-201302080959.sql</p>
<li>STOP SLAVE;</li>
<li>CHANGE MASTER TO MASTER_HOST=&#8217;host_master&#8217;, MASTER_USER=&#8217;slave_user&#8217;, MASTER_PASSWORD=&#8217;XXXX&#8217;, MASTER_LOG_FILE=&#8217;mysql-bin.000001&#8242;, MASTER_LOG_POS=417;</li>
<p>   (use the values noted before)	   </p>
<li>START SLAVE;</li>
<li>SHOW SLAVE STATUS</li>
<p>As you can see, each time you execute this command, you obtain different values. When this values are the same than the master you will be synchronized.
</ul>
<p>Until now I&#8217;ve configured replication. The next thing is to set the slave to work as a delivery box, that is, it doesn&#8217;t work as admin and it send its activity (stats) to the master.</p>
<p><b>Master:</b></p>
<ul>
<li>If your domain is for example my.adserver.com then you have to create a cname at you domain provider for admin.my.adserver.com pointing to the master computer. I made the master to work as admin and serving banners at the same time.</li>
<li>Disable automatic maintenance at the master from the admin console.</li>
<li>configuration &#8211;> global settings &#8211;> Banner Delivery Settings &#8211;> &#8220;Admin Interface URL&#8221;</li>
<p>   change my.adserver.com for admin.my.adserver.com<br />
   the system redirects to the new url.</p>
<li>change tha maintenance cron to execute every hour at minute 15</li>
</ul>
<p><b>Slave:</b></p>
<ul>
<li>Make these changes at openx conf file by hand
<ol>
<li>set enabled at [ui] empty</li>
<li>set enabled at [lb] to 1</li>
<li>at [database] section set the local database. (It already was)</li>
<li>at [lb] section set the master database</li>
<p>       type=mysql<br />
       host=host_master<br />
       socket=<br />
       port=3306<br />
       username=root<br />
       password=YYYY<br />
       name=openx_2_8_10</p>
<li>change operationInterval at the slave in order to the maintenance-distributed be excecuted every 5 min.</li>
</ol>
</li>
<li>change maintenance-distributed permissions</li>
<p>       chmod 777 [openx_home]/scripts/maintenance/maintenance-distributed.php</p>
<li>set maintenance-distributed cron every 5 min.</li>
</ul>
<p>You can add more slaves following the same instruccions or you can generate a new dump and set the new slave &#8220;listening from this point&#8221;, that is, from a new show master status.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.enriquelamastrujillo.com/blog/2013/05/16/how-to-configure-distributed-statistics-in-openx/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Cómo montar Distributed Statistics en Openx</title>
		<link>http://www.enriquelamastrujillo.com/blog/2013/05/16/como-montar-distributed-statistics-en-openx/</link>
		<comments>http://www.enriquelamastrujillo.com/blog/2013/05/16/como-montar-distributed-statistics-en-openx/#comments</comments>
		<pubDate>Thu, 16 May 2013 14:02:58 +0000</pubDate>
		<dc:creator>Quique</dc:creator>
				<category><![CDATA[informática]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[openx]]></category>

		<guid isPermaLink="false">http://www.enriquelamastrujillo.com/blog/?p=365</guid>
		<description><![CDATA[Read this post in english
La gente de Openx tiene &#8220;Distributed Statistics&#8221; como opción para escalar el servicio, pero en mi opinión tienen la documentación un poco confusa, cuando no equivocada, como se puede ver en este mensaje que escribí yo mismo como &#8220;raistlink&#8221;.
El sistema de Distributed Statistics funciona así resumidamente (como yo lo he montado):

las [...]]]></description>
			<content:encoded><![CDATA[<p><a href="/blog/2013/05/16/how-to-configure-distributed-statistics-in-openx/">Read this post in english</a></p>
<p>La gente de <a href="http://www.openx.com/" target="_blank">Openx</a> tiene &#8220;Distributed Statistics&#8221; como opción para escalar el servicio, pero en mi opinión tienen la documentación un poco confusa, cuando no equivocada, como se puede ver en <a href="http://forum.openx.org/index.php?showtopic=503520463" target="_blank">este mensaje que escribí yo mismo como &#8220;raistlink&#8221;</a>.</p>
<p>El sistema de Distributed Statistics funciona así resumidamente (como yo lo he montado):</p>
<ul>
<li>las dos máquinas sirven banners</li>
<li>sólo una de ellas (u otra adicional) además es el admin. A la que hace de admin la llamaré maestra y a la otra esclava.</li>
<li>sólo la máquina maestra ejecuta el maintenance que calcula las probabilidades de las zonas</li>
<li>la replicación hace que la esclava coja esas probabilidades</li>
<li>la esclava vuelca su actividad en el maestro ejecutando el maintenance-distributed en lugar del maintenance</li>
</ul>
<p>Es fundamental que se configuren los crones de manera que cuando se ejecuta el maintenance de cada hora se haya volcado toda la actividad de la esclava porque si no esa actividad se perderá, por eso como veremos luego el maintenance en la maestra se ejecuta a las y cuarto y el maintenance-distributed en la esclava cada cinco minutos.</p>
<p>Pues bien, al final lo conseguí así que voy a explicar un poco lo que hice.</p>
<p>Partimos de dos máquinas independientes que están bajo un balanceador sirviendo banners bajo la misma url, por ejemplo my.adserver.com </p>
<p><b>En el maestro:</b></p>
<ul>
<li>parar el apache</li>
<li>asegurarme de que no está el maintenance corriendo y quitar el cron</li>
<li>parar el mysql</li>
<li>poner en el my.conf</li>
<p>       server-id        = 1<br />
       log-bin=mysql-bin</p>
<li>arrancar mysql</li>
<li>GRANT REPLICATION SLAVE ON *.* TO &#8217;slave_user&#8217;@'%&#8217; IDENTIFIED BY &#8216;XXXX&#8217;;</li>
<p>   donde XXX es la contraseña con la que accederá el mysql esclavo para la replicación</p>
<li>GRANT ALL PRIVILEGES ON *.* TO &#8216;root&#8217;@'%&#8217; IDENTIFIED BY &#8216;YYYY&#8217;;</li>
<p>	 donde YYYY es la contraseña con la que accederá el mysql esclavo para volcar sus estadísticas en el maestro.<br />
    Ojo hay una contraseña para el la replicación y otra para volcar los datos desde el openx, no debería haber problema. </p>
<li>FLUSH PRIVILEGES;</li>
<li>hacer un show master status. <b>ÉSTE ES EL QUE TENDRÉ QUE USAR LUEGO</b></li>
<p>       <b>mysql-bin.000001 |      417</b></p>
<li>hacer un dump</li>
<p>       mysqldump -u root -p &#8211;databases openx_2_8_10 > /tmp/openx_2_8_10-201302071719.sql</p>
<li>arrancar apache</li>
<li>volver a hacer un show master status por curiosidad</li>
<p>        mysql-bin.000001 | 24995895<br />
        se ve que está replicando porque ha cambiado el número
</ul>
<p><b>En el esclavo:</b></p>
<ul>
<li>eliminar base de datos de openx</li>
<li>volcar el dump del master</li>
<p>       mysql -u root -pXXXX < "/tmp/openx_2_8_10-201302071719.sql"</p>
<li>ejecutar estos alter en la bbdd de datos del openx.</li>
<p>	ALTER TABLE ox_data_raw_ad_click ENGINE=MyISAM;<br />
	ALTER TABLE ox_data_raw_ad_impression ENGINE=MyISAM;<br />
	ALTER TABLE ox_data_raw_ad_request ENGINE=MyISAM;<br />
	ALTER TABLE ox_data_raw_tracker_impression ENGINE=MyISAM;<br />
	ALTER TABLE ox_data_raw_tracker_variable_value ENGINE=MyISAM;<br />
	Realmente yo estas tablas raw yo no he visto que se usen, pero bueno, a lo mejor sí y se purgan en seguida.		</p>
<li>poner en el my.conf</li>
<p>       server-id        = 2<br />
       log-bin=mysql-bin<br />
       para que pudiera funcionar como maestro.<br />
       replicate-wild-ignore-table=openx_2_8_10.%data_%<br />
       replicate-wild-ignore-table=openx_2_8_10.%tmp_%<br />
       replicate-wild-ignore-table=openx_2_8_10.%lb_local%<br />
       replicate-wild-ignore-table=mysql.%<br />
       replicate-wild-ignore-table=openx_2_8_10.%ox_log_maintenance_priority% (por un problema que tuve luego)<br />
       replicate-wild-ignore-table=openx_2_8_10.%ox_session% (por un problema que tuve luego)</p>
<li>arrancar el mysql</li>
<li>comprobar si se puede acceder al mysql del maestro con esto</li>
<p>       mysqldump &#8211;host=host_del_master -u root -pYYYY &#8211;databases openx_2_8_10 > /tmp/openx_2_8_10-201302080959.sql</p>
<li>STOP SLAVE;</li>
<li>CHANGE MASTER TO MASTER_HOST=&#8217;host_del_master&#8217;, MASTER_USER=&#8217;slave_user&#8217;, MASTER_PASSWORD=&#8217;XXXX&#8217;, MASTER_LOG_FILE=&#8217;mysql-bin.000001&#8242;, MASTER_LOG_POS=417;</li>
<p>   (con los valores que dio en los pasos anteriores, ya están puestos)	   </p>
<li>START SLAVE;</li>
<li>SHOW SLAVE STATUS</li>
<p>Se ve que cada vez que lo ejecuto pone que va por un archivo diferente. Cuando ponga lo mismo que el show master status del maestro es que lo ha cogido ya todo. En muy poquito tiempo lo ha hecho.
</ul>
<p>Hasta aquí he configurado la replicación. Lo siguiente va a ser poner a funcionar el openx como delivery box en la esclava, es decir, que no funcione como admin y que vuelque su actividad (estadísticas) en el maestro.</p>
<p><b>En la maestra:</b></p>
<ul>
<li>Si por ejemplo tu dominio es my.adserver.com crear un cname en el registrador de dominios para admin.my.adserver.com que apunte a la máquina maestra. Yo hice que la máquina maestra funcione como admin y sirviendo banners al mismo tiempo.</li>
<li>desactivar el automatic maintenance en el maestro desde el admin</li>
<li>configuration &#8211;> global settings &#8211;> Banner Delivery Settings &#8211;> &#8220;Admin Interface URL&#8221;</li>
<p>   cambiar my.adserver.com por admin.my.adserver.com<br />
   Él solo me redirije de la vieja a la nueva</p>
<li>cambiar el cron del maintenance en el maestro para que se ejecute a las y cuarto</li>
</ul>
<p><b>En la esclava:</b></p>
<ul>
<li>Hacer estos cambios en el conf de openx a mano
<ol>
<li>poner el enabled del [ui] vacío</li>
<li>poner el enabled del [lb] a 1</li>
<li>en la sección [database] poner la bbdd local. (ya estaba)</li>
<li>en la sección [lb] poner la bbdd maestra</li>
<p>       type=mysql<br />
       host=host_del_master<br />
       socket=<br />
       port=3306<br />
       username=root<br />
       password=YYYY<br />
       name=openx_2_8_10</p>
<li>modificar el operationInterval en el esclavo para poder ejecutar el maintenance-distributed más a menudo, cada 5 min.</li>
</ol>
</li>
<li>cambiar permisos al maintenance-distributed</li>
<p>       chmod 777 [openx_home]/scripts/maintenance/maintenance-distributed.php</p>
<li>poner cron del maintenance-distributed cada 5 min</li>
</ul>
<p>Para futuros esclavos se pueden seguir estas mismas intrucciones tal cual o generar un nuevo dump y poner el nuevo esclavo a &#8220;escuchar desde otro punto&#8221;, es decir, a un nuevo show master status.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.enriquelamastrujillo.com/blog/2013/05/16/como-montar-distributed-statistics-en-openx/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
