<?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>Pervasive Code &#187; MySQL</title>
	<atom:link href="http://www.pervasivecode.com/blog/category/mysql/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.pervasivecode.com/blog</link>
	<description>Jamie Flournoy's Software Development Blog</description>
	<lastBuildDate>Mon, 26 Jul 2010 05:29:53 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Sphinx Search init script for Centos 5.1</title>
		<link>http://www.pervasivecode.com/blog/2008/04/14/sphinx-search-init-script-for-centos-51/</link>
		<comments>http://www.pervasivecode.com/blog/2008/04/14/sphinx-search-init-script-for-centos-51/#comments</comments>
		<pubDate>Mon, 14 Apr 2008 06:18:11 +0000</pubDate>
		<dc:creator>Jamie Flournoy</dc:creator>
				<category><![CDATA[CentOS]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[databases]]></category>
		<category><![CDATA[postgresql]]></category>
		<category><![CDATA[servers]]></category>
		<category><![CDATA[sql]]></category>

		<guid isPermaLink="false">http://www.pervasivecode.com/blog/2008/04/14/sphinx-search-init-script-for-centos-51/</guid>
		<description><![CDATA[Sphinx search is pretty new, and as a result I was unable to find a nice convenient package for it for CentOS 5.1. This is problematic since there is no init script included with the source tarball, and the issue of updating the index is the sysadmin and developer&#8217;s problem, and cannot be configured to [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.sphinxsearch.com/">Sphinx search</a> is pretty new, and as a result I was unable to find a nice convenient package for it for CentOS 5.1. This is problematic since there is no init script included with the source tarball, and the issue of updating the index is the sysadmin and developer&#8217;s problem, and cannot be configured to simply update the index when the data changes.<br />
<span id="more-65"></span><br />
The second problem (updates) is one I punted on; for now I have a cron job rebuilding the entire index every 5 minutes, which will probably be replaced with something smarter and lower-latency at a later time.</p>
<p>The first problem (no init script) is easy to solve, but apparently nobody has done so for CentOS 5.1 and published it. So, here is <a href="/code/centos_sphinx_init_script.txt">my CentOS 5.1 init script for the Sphinx Search server</a>. It is known to work with version 0.9.8-rc2.</p>
<p>BTW, the alternative solution to the problem of a daemon not having a System V init script is to just put some extra junk in <code>/etc/rc.local</code>. That is the quick and dirty solution, and is undesirable for several reasons:</p>
<ol>
<li>You can&#8217;t easily stop or restart the service, because it&#8217;s not a service as far as the OS knows; it&#8217;s just some junk in a script that got run a while ago.</li>
<li>You can&#8217;t use <a href="http://www.centos.org/docs/5/html/5.1/Deployment_Guide/s1-services-chkconfig.html">chkconfig</a> or its GUI cousin with the creative name, <a href="http://www.centos.org/docs/5/html/5.1/Deployment_Guide/s1-services-serviceconf.html">The Services Configuration Tool</a>, to control it and tie it to specific runlevels.</li>
</ol>
<p>(System V runlevels and init scripts are useful, even if you don&#8217;t need all of the runlevel functionality. The stop/start/restart PID stuff is useful by itself.)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pervasivecode.com/blog/2008/04/14/sphinx-search-init-script-for-centos-51/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Making SELinux allow a nonstandard MySQL port number on Centos 5.1</title>
		<link>http://www.pervasivecode.com/blog/2008/03/29/making-selinux-allow-a-nonstandard-mysql-port-number-on-centos-51/</link>
		<comments>http://www.pervasivecode.com/blog/2008/03/29/making-selinux-allow-a-nonstandard-mysql-port-number-on-centos-51/#comments</comments>
		<pubDate>Sat, 29 Mar 2008 18:36:30 +0000</pubDate>
		<dc:creator>Jamie Flournoy</dc:creator>
				<category><![CDATA[CentOS]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[SELinux]]></category>
		<category><![CDATA[databases]]></category>
		<category><![CDATA[servers]]></category>

		<guid isPermaLink="false">http://www.pervasivecode.com/blog/2008/03/29/making-selinux-allow-a-nonstandard-mysql-port-number-on-centos-51/</guid>
		<description><![CDATA[SELinux is a recently added security system that&#8217;s installed by default with CentOS 5.1 (and Red Hat Enterprise Linux 5, and others). Since it&#8217;s newer than the classic &#8220;Discretionary Access Control&#8221; Unix security model, it&#8217;s not nearly as well documented, and unfamiliar to many. I had never even heard of it until this week.
After a [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://en.wikipedia.org/wiki/SELinux">SELinux</a> is a recently added security system that&#8217;s installed by default with CentOS 5.1 (and Red Hat Enterprise Linux 5, and others). Since it&#8217;s newer than the classic &#8220;Discretionary Access Control&#8221; Unix security model, it&#8217;s not nearly as well documented, and unfamiliar to many. I had never even heard of it until this week.</p>
<p>After a lot of reading about it, and debating disabling it entirely, I figured out how to do some minor SELinux customization to fit my needs for a MySQL database server. Hopefully this will help folks who are in a similar situation.</p>
<p><span id="more-64"></span></p>
<p>Fortunately, although SELinux is sophisticated, it&#8217;s not too obtrusive as implemented in CentOS 5.1. In configuring it, Red Hat has picked an admirable position somewhere between ironclad security with a huge administrative burden, and toothless security that is easy to use because it isn&#8217;t doing anything to protect you. This is important, because if the configuration process were too odious from the point of view of a typical junior sysadmin, it&#8217;s very likely that people would get in the habit of just turning it off entirely. As it is, SELinux on RHEL 5 / CentOS 5.1 is now becoming part of the landscape of what a modern Linux looks like; based on what I&#8217;ve read on relevant forums lately, admins are taking the time to try and customize its default configuration to their needs (with some success) rather than just turning it off.</p>
<p>The nicely balanced default configuration that Red Hat has chosen is called the <a href="http://www.centos.org/docs/5/html/5.1/Deployment_Guide/rhlcommon-section-0003.html">Targeted Policy</a>, which means that if the SELinux configuration files know about a specific daemon, then it will be subject to specific rules; otherwise, the classic Unix security model applies. So if you stay with the standard configuration of those targeted daemons, SELinux is providing an additional level of security containment around them, and as long as it does what it&#8217;s supposed to, you&#8217;ll never notice it.</p>
<p>In my case, I&#8217;m running MySQL and OpenSSH, and have configured them to listen on nonstandard ports. SSH is not targeted, so this was trivial to do. MySQL is targeted, so it didn&#8217;t work right away.</p>
<p>Specifically, MySQL wouldn&#8217;t start, and in /var/log/messages I saw something like this:<br />
<code>kernel: audit(1206710000.178:12): avc:  denied  { name_bind } \<br />
for  pid=8591 comm="mysqld" src=1234 scontext=user_u:system_r:mysqld_t:s0 \<br />
tcontext=system_u:object_r:port_t:s0 tclass=tcp_socket</code><br />
In plain English, &#8220;I denied process 8591&#8217;s request to bind to port 1234&#8243;. So SELinux needs to be told that MySQL should be allowed to bind to port 1234.</p>
<p>Here&#8217;s what I had to do: (assuming a mysqld port number of 1234, and that the iptables firewall is already adjusted for this)<br />
<code>sudo /usr/sbin/semanage port -a -t mysqld_port_t -p tcp 1234</code></p>
<p>This means &#8220;Change the SELinux policy for ports by adding one, of mysqld_port_t type, protocol TCP, port number 1234.&#8221;</p>
<p>Now you should be able to see the standard port (3306) and the new one (1234) with this:<br />
<code>sudo /usr/sbin/semanage port -l | grep mysql</code></p>
<p>That should output something like &#8220;mysqld_port_t tcp 1234,3306&#8243;.</p>
<p>(These changes are persisted in &#8216;/etc/selinux/targeted/modules/active/ports.local&#8217;, so they will still be active after a reboot.)</p>
<p>Now, MySQL starts happily and I can connect and use it as I had expected. But I didn&#8217;t have to disable SELinux, which means that this and other daemons are still running inside a security container that will help to limit the damage if their security is compromised.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pervasivecode.com/blog/2008/03/29/making-selinux-allow-a-nonstandard-mysql-port-number-on-centos-51/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
