Thanks for sharing your experience. I don't experience problem so I think I'll keep with the default params.<div>Could someone from spacewalk team confirm the optimization possibilities?</div><div>Another point about the autovacuum function: BZ 705935 address the fact that vacuum is useless. Is it still a valid BZ?</div>
<div><span class="Apple-style-span" style="font-family: 'DejaVu Sans', 'Liberation Sans', sans-serif; background-color: rgb(255, 255, 255); "><pre class="bz_comment_text" style="font-size: medium; font-family: monospace; white-space: pre-wrap; width: 50em; ">
Description of problem:
Seems like Spacewalk is keeping database transactions open which leads to
unremovable dead rows in tables.</pre></span></div><div><br></div><div>Thanks,</div><div><br></div><div>Pierre<br><br><div class="gmail_quote">2011/9/14 Scott Worthington <span dir="ltr"><<a href="mailto:scott.c.worthington@gmail.com">scott.c.worthington@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Hello,<br>
<br>
I'd like to share my experience with out-of-the-box installation of<br>
Spacewalk 1.5 on CentOS 6.0 x86_64.<br>
<br>
The out-of-the-box default configuration of postgresql is abysmal.<br>
You may be very familiar with MySQL, but postgresql is certainly not<br>
MySQL (install and forget). You _HAVE_ to make configuration changes<br>
and tune postgresql for optimum performance with Spacewalk.<br>
<br>
While reading this, please note that this is for the CentOS 6.0 x86_64<br>
platform.  I cannot speak for Ubuntu, Debian, or other CentOS<br>
releases, etc.<br>
<br>
In my installation, I am using 4GB of server RAM as a virtualized<br>
guest on VMware.  I have NOT changed Java or Tomcat's memory heap<br>
settings (-Xms or -Xmx) and I don't believe it is necessary.  Your<br>
slowness is due to postgresql.<br>
<br>
* Before making the following changes, shutdown Spacewalk and then<br>
Postgresql.  Better yet, run Spacewalk on VMware and take a snapshot<br>
of your current setup for rollbacks (if you're like me, you've spent<br>
hours upon hours loading in Channels and their repo data).<br>
<br>
spacewalk-service stop<br>
service postgresql stop<br>
<br>
== Default postgresql configuration ==<br>
<br>
Auto vacuum is NOT enabled.  This causes the database server to crawl<br>
to a halt during the loading of thousands of RPMs via the "rhnpush"<br>
CLI and also through "spacewalk-repo-syncs --type yum".<br>
<br>
* Turn on autovacuum<br>
<br>
Edit your /var/lib/pgsql/data/postgresql.conf and find...<br>
<br>
#autovacuum=on<br>
<br>
...and uncomment it:<br>
<br>
autovacuum=on<br>
<br>
In the same file, find...<br>
<br>
#track_counts = on<br>
<br>
...and uncomment it:<br>
<br>
track_counts = on<br>
<br>
== Install pgtune ==<br>
<br>
Next, tune postgresql using the pgtune package. I have found that the<br>
package pgtune is excellent for tuning your system.  The following<br>
instructions have you download the .tar.gz file and create an<br>
installable RPM.  I prefer install RPMs, not source.  You can install<br>
source, that is your prerogative.<br>
<br>
* Download and compile pgtune (to install it as an RPM):<br>
<br>
* First, ensure you have rpmbuild installed<br>
<br>
yum install rpmbuild<br>
<br>
# next, download, put files in the correct directories, and build<br>
mkdir -p /usr/local/src/TARGZs/pgtune<br>
cd /usr/local/src/TARGZs/pgtune<br>
wget <a href="http://pgfoundry.org/frs/download.php/2449/pgtune-0.9.3.tar.gz" target="_blank">http://pgfoundry.org/frs/download.php/2449/pgtune-0.9.3.tar.gz</a><br>
tar xvfz pgtune-0.9.3.tar.gz<br>
cp /usr/local/src/TARGZs/pgtune/pgtune-0.9.3.tar.gz /root/rpmbuild/SOURCES<br>
cp /usr/local/src/TARGZs/pgtune/pgtune-0.9.3/pgtune.spec /root/rpmbuild/SPECS<br>
cp /usr/local/src/TARGZs/pgtune/pgtune-0.9.3/pgtune-settingsdir.patch<br>
/root/rpmbuild/SOURCES<br>
cd /root/rpmbuild/SPECS<br>
#the spec file has an incorrect version number, the following command<br>
will fix it<br>
perl -npe 's/0\.9\.2/0.9.3/g' -i /root/rpmbuild/SPECS/pgtune.spec<br>
rpmbuild -ba pgtune.spec<br>
#If your rpmbuild fails, you may need to install dependencies, look at<br>
the output of the rpmbuild<br>
<br>
#install the RPM<br>
rpm -ivh /root/rpmbuild/RPMS/noarch/pgtune-0.9.3-1.el6.noarch.rpm<br>
<br>
After pgtune is installed, run it on your postgresql.conf file:<br>
<br>
cd /var/lib/pgsql/data<br>
pgtune -i postgresql.conf -o postgresql.conf.pgtune<br>
<br>
* Make a backup of your existing, "working" configuration (replace<br>
YYYYMMDD with today's date)<br>
<br>
cp -p postgresql.conf postgresql.conf-working-YYYYMMDD<br>
<br>
* Replace existing config<br>
<br>
cp postgresql.conf.pgtune postgresql.conf<br>
<br>
* I do not believe that the postgresql.conf file contains the<br>
"default" parameters in the lines that are commented out (unlike<br>
packages like postfix).  I recommend that you do not trust the<br>
postgresql.conf default file as a source of "default" parameters.<br>
<br>
* I have also edited by hand and uncommented the entire AUTOVACUUM<br>
PARAMETERS section and increased the autovacuum_max_workers from 3 to<br>
5:<br>
<br>
#------------------------------------------------------------------------------<br>
# AUTOVACUUM PARAMETERS<br>
#------------------------------------------------------------------------------<br>
<br>
autovacuum = on                 # Enable autovacuum subprocess?  'on'<br>
                                        # requires track_counts to also be on.<br>
#log_autovacuum_min_duration = -1       # -1 disables, 0 logs all actions and<br>
                                        # their durations, > 0 logs only<br>
                                        # actions running at least this number<br>
                                        # of milliseconds.<br>
autovacuum_max_workers = 5              # max number of autovacuum subprocesses<br>
autovacuum_naptime = 1min               # time between autovacuum runs<br>
autovacuum_vacuum_threshold = 50        # min number of row updates before<br>
                                        # vacuum<br>
autovacuum_analyze_threshold = 50       # min number of row updates before<br>
                                        # analyze<br>
autovacuum_vacuum_scale_factor = 0.2    # fraction of table size before vacuum<br>
autovacuum_analyze_scale_factor = 0.1   # fraction of table size before analyze<br>
autovacuum_freeze_max_age = 200000000   # maximum XID age before forced vacuum<br>
                                        # (change requires restart)<br>
autovacuum_vacuum_cost_delay = 20ms     # default vacuum cost delay for<br>
                                        # autovacuum, in milliseconds;<br>
                                        # -1 means use vacuum_cost_delay<br>
autovacuum_vacuum_cost_limit = -1       # default vacuum cost limit for<br>
                                        # autovacuum, -1 means use<br>
                                        # vacuum_cost_limit<br>
<br>
* After you have made the above changes, attempt to restart postgresql<br>
(it will most likely fail)<br>
<br>
service postgresql restart<br>
<br>
* Yes, it will FAIL. Why did it fail?  Most likely postgresql needs<br>
more memory now and the default kernel memory setup is too low<br>
(Hopefully you didn't introduce a typo)<br>
<br>
* Examine the contents of postgresql's startup log:<br>
<br>
less /var/lib/pgsql/pgstartup.log<br>
<br>
* You may see something like this at the end:<br>
<br>
FATAL:  could not create shared memory segment: Invalid argument<br>
DETAIL:  Failed system call was shmget(key=5432001, size=1040752640, 03600).<br>
HINT:  This error usually means that PostgreSQL's request for a shared<br>
memory segment exceeded your kernel's SHMMAX parameter.  You can<br>
either reduce the request size or reconfigure the kernel with larger<br>
SHMMAX.  To reduce the request size (currently 1040752640 bytes),<br>
reduce PostgreSQL's shared_buffers parameter (currently 122880) and/or<br>
its max_connections parameter (currently 85).<br>
        If the request size is already small, it's possible that it is<br>
less than your kernel's SHMMIN parameter, in which case raising the<br>
request size or reconfiguring SHMMIN is called for.<br>
        The PostgreSQL documentation contains more information about<br>
shared memory configuration.<br>
<br>
* You have to bump up your Linux kernel.shmmax to the number, in the<br>
example above, the number is "1040752640"<br>
<br>
* First, non-persistently:<br>
<br>
sysctl -w kernel.shmmax=1040752640<br>
<br>
* Try to restart postgresql<br>
<br>
service postgresql restart<br>
<br>
* If it fails, look again inside of /var/lib/pgsql/pgstartup.log and<br>
see if you made a mistake with the shmmax number and fix your<br>
kernel.shmmax<br>
<br>
* Finally, make the number that you ended up using for kernel.shmmax<br>
and make it persistent between boots:<br>
cat >> /etc/sysctl.conf << 'END_OF_FILE'<br>
#YYYY-MM-DD HHMM (your-initials)<br>
kernel.shmmax=1040752640<br>
END_OF_FILE<br>
<br>
I have found that making those changes above makes postgresql and<br>
Spacewalk usable and much much faster.  I have not experienced the<br>
"500 server timeout" error since.<br>
<br>
If you are having problems with loading packages into your Spacewalk,<br>
running top will usually show postgresql is sitting on a "DELETE" or<br>
other process that is taking forever -- the above may help speed up<br>
your postgresql.<br>
<br>
I hope you have the best of luck with your Spacewalk & postgresql<br>
deployment on CentOS 6.0 x86_64, and I hope the above instructions may<br>
benefit you.<br>
<br>
_______________________________________________<br>
Spacewalk-list mailing list<br>
<a href="mailto:Spacewalk-list@redhat.com">Spacewalk-list@redhat.com</a><br>
<a href="https://www.redhat.com/mailman/listinfo/spacewalk-list" target="_blank">https://www.redhat.com/mailman/listinfo/spacewalk-list</a><br>
</blockquote></div><br></div>