Archive

Posts Tagged ‘tech’

This is the worst zpool I’ve ever seen

September 16th, 2009 No comments

  pool: exportpool
 state: ONLINE
status: The pool is formatted using an older on-disk format.  The pool can
        still be used, but some features are unavailable.
action: Upgrade the pool using 'zpool upgrade'.  Once this is done, the
        pool will no longer be accessible on older software versions.
 scrub: none requested
config:

        NAME        STATE     READ WRITE CKSUM
        exportpool  ONLINE       0     0     0
          c0t0d0s7  ONLINE       0     0     0
          c0t1d0    ONLINE       0     0     0

errors: No known data errors

So, for a verbal explanation, it’s a striped pool made up of one whole disk, plus one partition on c0t0d0, which also happens to be the root disk, where there are numerous other partitions housing the ufs filesystems.  Those partitions are completely unmirrored.  Oh, and it’s out of date, to boot.

If either disk goes, the whole system goes.  The performance for the zpool will be completely weird depending on which disk it hits.  And to top it all off, they are forever entangled now.  This is set in stone, unless a complete system wipe can be performed.

Good job.

Categories: news Tags: , , , ,

IP Multipathing

May 13th, 2009 No comments

It may be a day late and a dollar short, since I replaced the bad cat 5 cable that kept causing my colo’ed server to get disconnected, but it’d be a shame to let that extra interface go to waste.

May 13 14:39:54 holcasaur.us in.mpathd[25625]: [ID 832587 daemon.error] Successfully failed over from NIC bge0 to NIC bge1
May 13 14:40:20 holcasaur.us in.mpathd[25625]: [ID 620804 daemon.error] Successfully failed back to NIC bge0

So I say, go ahead, treat my cables roughly.  Jiggle the connections, come what may!  Let me not bother the poor support staff any longer.

It was so easy to set up I’m not even going to write about it.  Just go to the docs.

Wordpress permalink follow-up

May 5th, 2009 No comments

So regarding my previous post on generating pretty links with wordpress.  After reexamining the Apache way, and reading a bit more about how sun web server does rewriting and expressions, I finally figured out the “right” way to do it.

Behold the true form:

<If not -e"$path">
PathCheck fn="restart" uri="/index.php"
</If>

No wacky server.xml variables, no regular expressions, and no rewriting before we should.

First of all, I got rid of the expensive (?) ~= that matched everything after the first / in the uri.  In this case we don’t need it, because secondly, we always just want to redirect to /index.php.  Wordpress figures out the rest of the arguments from other magic variables that I don’t fully understand yet (probably PATH_INFO).  Thirdly, I changed it to a PathCheck fn=restart since at the PathCheck stage it is possible to determine if $path exists as a physical file.  We just restart the whole shebang with a new uri if it’s not.  And for cleanliness sake, fourthly, I switched from not -f and not -d to one simple not -e which accomplishes the same thing.

Hope this helps someone besides me.  I’m planning a follow up post describing some of the performance characteristics.  I’ve tried fastcgi vs the nsapi plugin with php and as a preview: the plugin is hella fast, but hella leaky as well, whereas the fastcgi is rock solid but can’t scale past the number of child processes I give it.  Also APC makes a HUGE difference, especially with the nsapi plugin.  Too bad about those leaks…

Rewritten Wordpress Pretty Permalinks under Sun/Open Webserver 7

April 26th, 2009 9 comments

aka, why bother?  but seriously folks…

Wordpress is blogging software.  This blog is powered by wordpress in fact.  It uses php and a database to construct web pages that then get served out.  One of the “features” it has is that it can use “pretty” links, or define permalinks such that the links will be the same for all time.  I won’t go into it in too much detail (see here) but what this means is, let’s say you write an article about your cat called “My cat is the super duper bestest stop making fun of him!”  The link to this individual post will look something like “http://mycatrules.com/?p=148″ or something else unintelligible.  But if you use the permalinks feature you can make it more sane and give the prospective reader a better idea of what the post is about.  Without rewriting, you can usually get as far as something like “http://mycatrules/index.php/my-cat-is-the-super-duper-bestest-stop-making-fun-of-him” which is okay, but that index.php leaves a lot to be desired.  What if you move your blog to something that isn’t running on php?  Plus it’s ugly.

So you need to change the url to get rid of the index.php, but that’s basically impossible to do within php (without including an index.php in a bunch of just-in-time created directories or something which would be a solution worse than the problem).  Fortunately web servers can help by rewriting the url internally.  If you were using apache, which is how 99.99999% of the wordpress setups in the world are doing this, you just need a .htaccess file that invokes the magic of mod_rewrite.  that .htaccess would look something like this, depending on just how pretty you wanted to make your links:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

What this does is basically convert your request for /archives/blah into a request for /index.php/archives/blah behind the scenes, where the /archives/blah parts are really arguments that get passed to index.php to be processed.  But only if /archives/blah doesn’t actually exist in the docroot as either a file or directory.  That way things like the actual html/images/css used by your theme, or the wp-admin interface, are served up as-is, but things that exist only in the weird world inside of the code for wordpress such as the concept of archives or tags, things for which there is no physical representation in the filesystem, are passed as arguments to index.php.

If however, you are running sun web server 7 (or now open web server?), it is slightly different.  The same idea applies but mod_rewrite doesn’t exist.  Instead there are “NameTrans” “SAFs” to handle rewriting/redirecting of urls based on criteria.  A full explanation of how this all works is beyond the scope of this post.  I’m not here to flame about which is better, mod_rewrite is certainly more popular, but from what I’ve read the sun web server can do it all and more and faster.  What I’m trying to do here is the simplest possible rewrite though, and they are both more than up to the task.  Plus if I was doing it with apache, this wouldn’t be much of a post since the work is already done and the howto can be found in 8 million places.

So what we want is, simply enough, the “rewrite” function.  So firstly let’s try the simple base case and see what happens.  In our virtual server’s obj.conf, define a rule that will map requests for /* to /index.php/* behind the scenes:

<If $uri =~ "^/(.*)">
NameTrans fn="rewrite" path="/index.php/$1"
</If>

Or in english “hey, if the request from the client matches the regular expression ^/(.*) (and all will), stick an /index.php in front of whatever (.*) matches (which is everything after the first slash).”  The uri and path variables are as defined here.  And this works!  Well, sort of.  Basically everything gets translated into /index.php/blah.  This prevents the theme from loading since that is componsed of  physical files in wp-content/theme/blah, but that gets translated into /index.php/wp-content/theme/blah which is gibberish.  But the home page will load, as will any permalink you set up, without /index.php in front of it!  So that’s some progress, and more or less what was expected.

So we need to fix the same problem that is handled by the RewriteCond lines in mod_rewrite from above.  The way to go about this is to modify the If in obj.conf to exclude files that actually do exist in the docroot.  And it even seems like there’s a variable to help us determine that, namely $ppath.  This is described as the physical path to the file in the request.  When combined with the -f and -d tests in the If syntax, we should be able to achieve the same thing as mod_rewrite.  So, second try:

<If $uri =~ "^/(.*)" and not -f $ppath and not -d $ppath>
NameTrans fn="rewrite" path="/index.php/$1"
</If>

Except, this doesn’t work either.  In fact it looks exactly like our more naive example from above.  Without being an expert on debugging the values of variables in the web server, I kind of banged my head against the wall for awhile on this one.  Eventually I just tried to manually put the full path to the request in like so:

<If $uri =~ "^/(.*)" and not -f "/var/SUNWwbsvr7/holcasaur.us/docs/$uri" and not -d "/var/SUNWwbsvr7/holcasaur.us/docs/$uri">
NameTrans fn="rewrite" path="/index.php/$1"
</If>

And it worked!  So $ppath must not be working as advertised.  Except it is.  From the variable reference:

$ppath:
Requested path (either URI, partial path, or file system path depending on stage).The predefined variable path is the value of pathrq->vars. If path isn’t set in rq->vars (for example, if NameTrans hasn’t completed), path gets the value of ppathrq->vars.

Notice that “depending on the stage” part.  Turns out, this is all happening in the NameTrans stage, whose whole purpose is to determine the actual physical path to the request (see the stages of request processing).  So we can’t use the physical path until it’s been determined, and that’s the last thing that happens so we can’t rewrite afterwards.

As glad as I am that the above is working, having absolute paths like that is ugly, kludgey, and will break if the actual docroot ever gets changed.  So surely we should be able to substitute some variable for the docroot.  I swear to you I have searched everywhere, and I am usually pretty good at searching, and this is just not possible.  There’s no $root or $docroot that can be used in our If.  So the only thing I can think of is to define one manually in server.xml.  You can actually do this through the admin interface so, assuming one were changing the actual docroot, as long as you were careful and also changed the variable definition of $docroot, you could leave obj.conf alone (always a good practice to leave as much configuration as possible alone).

Basically in server.xml we have:

<virtual-server>
<name>holcasaur.us</name>
...
<document-root>/var/SUNWwbsvr7/holcasaur.us/docs</document-root>
<variable>
<name>docroot</name>
<value>/var/SUNWwbsvr7/holcasaur.us/docs</value>
</variable>

This defines a variable, $docroot, that matches the document root as defined for the virtual server.  Then in obj.conf we can use it like so:

<If $uri =~ "^/(.*)" and not -f"$docroot$uri" and not -d"$docroot$uri">
NameTrans fn="rewrite" path="/index.php/$1"
</If>

And voila, everything works as expected!

I am almost positive there has to be a better way to do this.  Maybe something along the lines of using PathCheck fn=restart once $ppath gets defined properly (I tried this and got myself into a rewrite loop but it seems promising), or using objectype to define some custom logic, or going ahead with our rewrite then rewriting again later if ppath doesn’t actually exist or something, but I am not an expert on how it’s all supposed to work together, yet.  Please let me know if you know, though…

Categories: news Tags: , , , ,

The last line is the most important

April 10th, 2008 No comments

People still use NIS+?

Keep reading and think about that last line.  This means you.

Categories: news Tags: ,

SJSWS7.0U2

March 18th, 2008 No comments

It seems like this might actually be working.

I can hear you though… But Brian, WHY?!

I have no idea.  Just wanted to experiment. I have certainly learned a lot about web serving in general.  Turns out the world of web servers is just like the world of OS’s, email, etc, a lot of products make a lot of assumptions about using a particular one.  PHP is poop to begin with, but the fact that it’s holding back multi-threaded web serving in general boils my blood.  Right now I’ve got it running through fastcgi which is suboptimal to say the least.

Having said all this, the site is going down for a bit while I tune things.

Categories: news Tags: , ,

Sick and other viscera

January 25th, 2008 No comments

Yes. I have a full-on sore throat. Though I guess viscera implies actual metaphorical meat. Maybe minutea would be more accurate.

Ween: awesome. They really know how to put on a show. Pardon the vulgarity, but Dean put it best: “You can’t just stick it in, you have to get it wet first.” Allison was a bit shocked at some of the lyrics, and annoyed at most of the concert-goers, but it was still a good time. They are consummate performers.

Went to a mysql seminar yesterday… mysql for the oracle dba. I’ve never really touched oracle, but that doesn’t matter. Because what the “for the oracle dba” part means is, “for people who have a clue what they’re talking about.” It wasn’t a lot of marketing fluff and we barely talked about the Sun buyout. It was actually pretty informative about what can, can’t, should, and shouldn’t be done by/with mysql. I still think for oracle people, postgresql might be a better first step into commodity hardware and open source, but mysql does seem to have some strong points in terms of replication and clustering. Plus wordpress doesn’t work with postgres. Assholes.

Juno is an okay movie. Though very dishonest. Here’s how I saw it:

Juno: Hey Brian, come watch this funny movie.
Me: Okay
Juno: Haha check out my funny sass-mouth and witty rejoinders. I sure am hip and in touch with today’s pop-culture.
Me: LOL
Juno: *punches me in the stomach, kicks my body while I heave in pain*
Me: WTF?!?
Juno: Sad shit, eh?

At least there will be blood was completely honest.  It starts kicking your nuts in the first 5 minutes.

Categories: news Tags: , , , ,

A letter to Sun…

January 23rd, 2008 No comments

Now that you’ve purchased MySQL, I’m guessing that you’ll want to include it in Solaris. I know it’s in SFW now, but the version is really old, and getting it started is an arduous process. Well not so much arduous as silly.

At any rate, the /etc/init.d script for this should disappear pronto. With smf, why would you have _anything_ in the old-style init scripts? Moreover, when migrating to smf, don’t just copy the init script as the service method. Think about it… that whole mysqld_safe thing? That’s just a special case of smf for one particular process. It’s a restarter and something to set options/privileges. So I say nix it! Here’s the (abridged) svcprop dump of my mysql manifest:

holcomb@unit3021[~]$ svcprop mysql

start/group astring :default
start/limit_privileges astring :default
start/privileges astring :default
start/project astring web
start/resource_pool astring :default
start/supp_groups astring :default
start/timeout_seconds count 60
start/type astring method
start/use_profile boolean false
start/user astring mysql
start/working_directory astring :default
start/exec astring /usr/sfw/sbin/mysqld &
stop/exec astring :kill -TERM
stop/project astring :default
stop/resource_pool astring :default
stop/timeout_seconds count 60
stop/type astring method
stop/working_directory astring :default
refresh/exec astring :kill -HUP
refresh/project astring :default
refresh/resource_pool astring :default
refresh/timeout_seconds count 120
refresh/type astring method
refresh/working_directory astring :default
tm_common_name/C ustring Mysql database server

As you can see it sets the user to “mysql” (and project web) and just runs mysqld & (all options are in the my.cnf – though any command line options could be set by a svc method and arbitrary svcprops). I have tested killing off the daemon and svc.startd does its duty. It is still kind of rough in that you can’t specify multiple instances, the documentation isn’t there, I’m not exactly sure if kill -HUP works, etc, but is a far cry from lrc:/etc/rc3_d/S99mysql.

Yeah I suppose this isn’t all that important. I just thought that what I did was really clever and had to tell somebody. Why won’t you people leave me alone?

Categories: news Tags: , , ,

zfs: the bacon saver™

September 30th, 2007 No comments

With apologies to mentos.

So wordpress 2.3 is out now. I thought, might as well upgrade, why the fuck not. But just to be sure, I took a snapshot of the filesystems on which apache and mysql live.

First, I shut down the services…


svcadm disable -t apache2
svcadm disable -t mysql

Then took a snapshot of the data…


zfs snapshot data/apache2@pre-2.3
zfs snapshot data/mysql@pre-2.3

Performed the upgrade…


Hello.

Re-enabled the services…


svcadm enable mysql
svcadm enable apache2

Got a bunch of SQL errors… Well fuck, now what. My blog is hosed. Oh wait…

Re-disabled the services…


svcadm disable -t apache2
svcadm disable -t mysql

Roll back the snapshots…


zfs rollback data/mysql@pre-2.3
zfs rollback data/apache2@pre-2.3

Re-re-enabled the services…


svcadm enable mysql
svcadm enable apache

Viola! errr Voila! I knew those french classes would come in handy.

Categories: news Tags: , ,

something so cool, those with weak hearts should not continue reading

September 26th, 2007 No comments

omgwtfbbq:

holcomb@gary[~]$ uname -a
SunOS gary 5.11 snv_72 i86pc i386 i86pc
holcomb@gary[~]$ ifconfig ath0
ath0: flags=201004843 mtu 1500 index 3
        inet 10.0.0.14 netmask ffffff00 broadcast 10.0.0.255
holcomb@gary[~]$ pfexec dladm show-wifi
LINK       STATUS            ESSID               SEC    STRENGTH   MODE   SPEED
ath0       connected         torgo-net           wpa    good       g      54Mb
Categories: news Tags: ,