All posts by erikberg

The dumbest Microserver yet.

I’ve owned a N40L, I still own and love my Gen8, and recently acquired two Gen10.

This thing has no remote management. NONE.

I installed drives into the drive-bays and it just hangs at post with a code 92 in the bottom right screen. I contacted HPE support. Told me to get HPE drives, as anything else was unsupported. Seriously? Turns out the drives had SMART disabled. So I had to boot the server up from usb, “hot-install” the drives, turn SMART on with “smartctl -s on /dev/sdX”, and hey presto, it boots.

I have the serial number, product code, country of purchase, yet with all that information I’m not able to register my product so I can get that sweet “entitlement” of BIOS/Firmware updates.

I’m probably gonna go with Supermicro for future servers.

/etc/udev/rules.d/70-persistent-net.rules

Doing a lot of manual network configuration on your laptop? Do yourself a favor and make this tiny entry to save time looking up what those crazy interfaces might be called.

SUBSYSTEM=="net",DRIVERS=="?*",ATTR{address}=="01:23:45:67:89:ab",NAME="eth0"
SUBSYSTEM=="net",DRIVERS=="?*",ATTR{address}=="cd:ef:01:23:45:67",NAME="wlan0"
SUBSYSTEM=="net",DRIVERS=="?*",ATTR{address}=="89:ab:cd:ef:01:23",NAME="wwan0"

Slightly securing WordPress with shared SSL

Really short version, edit your wp-config.php;

define('FORCE_SSL_ADMIN', true);
define('WP_HOME',        'http://www.blog-url.com');
define('WP_SITEURL',     'https://secure.host-url.com/~account/wordpress');
define('WP_CONTENT_URL', 'http://www.blog-url.com/wp-content');

This should allow your site to have it’s own address, yet enable secure login via a shared ssl.

The longer version, I really don’t care to explain, but if you break something whilst changing the “WordPress Address (URL)” (WP_SITEURL) and “Site Address (URL)” (WP_HOME) in Settings->General, you’re in a world of pain. Easiest form of recovery is by overriding the values in wp-config.php.

Again, I just want to make a point of “Site Address” uses the WP_HOME variable, “WordPress Address” uses the WP_SITEURL variable. I believe this naming is counter-intuitive, because I actually spent time figuring it out.

ProLiant Microserver raid10

DSC_0031s

When you raid10 breaks, and it will… There doesn’t seem to be a simple solution to fix it in the ROM. Infact I’m pretty sure there’s none at all. When you boot into linux, it’ll probably terminate early and drop you into initramfs, where you could probably spend a couple of hours scratching your head, wondering how you’ll work it out using the dmraid tool, again only to conclude that this tool does jack shit.

The solution to your problem seems remarkably simple however. RAID10 is just two raid1 volumes, striped. In other words, {sda,sdb} is one raid1 set, {sdc,sdd} is your other. In my case sdc broke, and I simply powered down, swapped the disk, powered up, and from initramfs, figured fuck it, let’s just clone the working drive.

dd if=/dev/sdd of=/dev/sdc bs=4096

Initialized the raid10, dmraid -ay; exit and the whole thing resumed booting.

apache2 ajp tomcat6

First off, this post is long, and hideous. It really lacks visual clarity. Only read if really desperate.

Here’s how you put apache2 on port 80, define virtual hosts, proxypass requests over ajp port 8009 to a tomcat6 server running on port 8080 with multiple apps each on their on vhost.
Let me break that down into steps and explain why you’d want to do it like this. Or why I’d want to do it like this.

At work we use some atlassian applications, like jira3, jira4, crowd, fisheye, crucible, and will probably start using bamboo, etc. Most of these come in an easy to install, prepackaged with a tomcat stack. The java-vm that tomcat runs on takes roughly ~130MB per instance, 4-5 instances that’s 500MB on just java-vms. Add the memory consumption per application on top of that. So running 3-4 tomcat instances on one machine does seem wasteful. But wait, there’s more! Each of these tomcat instances need a socket/port to listen for traffic. So, you’ll end up with jira3 on 8080, jira4 on 8081, crowd on 8082, etc. Do you really care to remember a port per application? Think your co-workers are able to?

Shortcut 1! Install apache2, create virtual hosts, and redirect or proxypass to the correct port. That way, you can just type http://fisheye.mycompany.com/ and it’ll do the rest. Fixed forever!

No? Ok, so say we manage to run them all under one tomcat instance. The typical solution would be to give each application it’s own .xml-file in /etc/tomcat6/Catalina/localhost/ Now you can access each application under http://mycompany.com:8080/jira4. Even better, add port 80 to your /etc/tomcat6/server.xml and forget about the portnumbers all together. You’re all set!

Not professional enough? You want those fancy http://crucible.mycompany.com/ URLs, without the /crucible/ after. For this there’s vhosts. Each application will get it’s own host-entry in /etc/tomcat6/server.xml Each application will get it’s own directory for additional configuration under /etc/tomcat6/Catalina/ And each application will deploy to it’s own separate directory, under /var/lib/tomcat6/webapps/

So with tomcat running on port 80, properly defined vhosts, there’s really no need for apache2 at all? Well, yeah. But! Say you really want to push your luck, and install some normal web application. Like phpBB, phpPgAdmin, drupal, sugarcrm, etc. You want it to be the ultimate complete mary-jane-piss-in-your-face webserver. Then you’ll want apache2 aswell.

Below I’ll give a rough outline on vhost on tomcat, and proxypass from apache2. I might even explain what you need to do for the easier paths mentioned.

tomcat6

You might not need sun-java6, but if you do uncomment the “partner” repo in /etc/apt/sources.list

aptitude install tomcat6 libtcnative-1 sun-java6-jre sun-java6-jdk

It’ll probably start up by default.

service tomcat6 stop

Change default java (you’ll want the “java-6-sun” entry.)

update-alternatives --config java

Change it for tomcat also; /etc/default/tomcat6

JAVA_HOME=/usr/lib/jvm/java-6-sun

Depending on the database you’ll be using;

aptitude install libmysql-java libpg-java

If you’re running PostgreSQL 9.0 or higher, maybe you’ll want newer versions. XXX Maybe you need symlinks from tomcat. /usr/share/tomcat6/lib/mysql-connector-java.jar -> ../../java/mysql-connector-java.jar
In /etc/tomcat6/server.xml, I like to modify this line with the addition of /localhost, as it keeps everything neat.

<Host name="localhost" appBase="webapps/localhost"

You’ll also want create a localhost directory, and to move the ROOT directory there, plus set the correct permissions.

mkdir /var/lib/tomcat6/webapps/localhost
mkdir /var/lib/tomcat6/webapps/jira3
mkdir /var/lib/tomcat6/webapps/jira4

mv /var/lib/tomcat6/webapps/ROOT /var/lib/tomcat6/webapps/localhost/

chown -R tomcat6:tomcat6 /var/lib/tomcat6/webapps

Now we can create the vhosts. (To skip this step, just create application.xml file in /etc/tomcat6/Catalina/localhost/) We start by adding entries in /etc/tomcat6/server.xml (Add as many aliases as you’d like.)

<Host name="jira3"  appBase="webapps/jira3"
      unpackWARs="true" autoDeploy="true"
      xmlValidation="false" xmlNamespaceAware="false">
  <Alias>jira.mycompany.com</Alias>
  <Alias>jira3.mycompany.com</Alias>
</Host>

<Host name="jira4"  appBase="webapps/jira4"
      unpackWARs="true" autoDeploy="true"
      xmlValidation="false" xmlNamespaceAware="false">
  <Alias>jira4.mycompany.com</Alias>
</Host>

Next, we need to create directories and configurations under /etc/tomcat6/Catalina

mkdir /etc/tomcat6/Catalina/jira3
ln -s /usr/src/atlassian-jira-professional-3.8/dist-tomcat/tomcat-5.5/jira.xml /etc/tomcat6/Catalina/jira3/ROOT.xml

mkdir /etc/tomcat6/Catalina/jira4
ln -s /usr/src/atlassian-jira-enterprise-4.2/dist-tomcat/tomcat-6/jira.xml /etc/tomcat6/Catalina/jira4/ROOT.xml

atlassian jira

Step by step for configuring, compiling and running war/ear jira3 and jira4.

Jira 3.8 Documentation
Jira 4.2 Documentation

I’ll be providing some gotcha’s and troubleshooting information along the way.
One thing common for both jiras are the need for additional libraries. jira3 guide will provide with a link to jira-jars-tomcat5.zip, jira4 will provide jira-jars-tomcat6.zip The files in both are the same, but jira4 has additional ones, so you might aswell just get jira-jars-tomcat6.zip

cp /usr/share/jira-jars-tomcat6/* /usr/share/tomcat6/lib/

You’ll also need to link up your database connector.

cd /usr/share/tomcat6/lib/
ln -s ../../java/mysql-connector-java.jar
ln -s ../../java/postgresql.jar

Give your tomcat instance lots more memory. And pass a few more options to the JVM. /etc/default/tomcat6

# You may pass JVM startup parameters to Java here. If unset, the default
# options (-Djava.awt.headless=true -Xmx128m) will be used.
JAVA_OPTS="-Djava.awt.headless=true -Xmx2048m -XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=768m"

# Use a CMS garbage collector for improved response time
JAVA_OPTS="${JAVA_OPTS} -XX:+UseConcMarkSweepGC"

# Atlassian JIRA Tweaks
JAVA_OPTS="${JAVA_OPTS} -Dorg.apache.jasper.runtime.BodyContentImpl.LIMIT_BUFFER=true -Dmail.mime.decodeparameters=true"

jira3

edit-webapp/WEB-INF/classes/entityengine.xml For mysql you’ll need/want to remove the schema-name line.

<datasource name="defaultDS" field-type-name="mysql"
      helper-class="org.ofbiz.core.entity.GenericHelperDAO"
      check-on-start="true"
      use-foreign-keys="false"
      use-foreign-key-indices="false"
      check-fks-on-start="false"
      check-fk-indices-on-start="false"
      add-missing-on-start="true"
      check-indices-on-start="true">
  <jndi-jdbc jndi-server-name="default" jndi-name="java:comp/env/jdbc/Jira3DS"/>
</datasource>

For postgresql7.2 and above, use postgres72.

<datasource name="defaultDS" field-type-name="postgres72"
      schema-name="public"
      helper-class="org.ofbiz.core.entity.GenericHelperDAO"
      check-on-start="true"
      use-foreign-keys="false"
      use-foreign-key-indices="false"
      check-fks-on-start="false"
      check-fk-indices-on-start="false"
      add-missing-on-start="true"
      check-indices-on-start="true">
  <jndi-jdbc jndi-server-name="default" jndi-name="java:comp/env/jdbc/Jira3DS"/>
</datasource>

You’ll note I’ve changed the jndi-name for our source to Jira3DS.
Here’s a little workaround. If you see the atlassian-jira.log

cp webapp/WEB-INF/classes/log4j.properties edit-webapp/WEB-INF/classes/log4j.properties

Edit the file, look for this line and modify it.

log4j.appender.filelog.File=/var/local/jira3/log/atlassian-jira.log

Have a look at etc/tomcat-6-jira.xml and perhaps etc/jira.xml

Then create a symlink from dist-tomcat/tomcat-5.5/jira.xml, to /etc/tomcat6/Catalina/jira3/ROOT.xml
mysql version

<!--
A sample configuration file for Tomcat 5.5
Customize the docBase attribute, drop in your $CATALINA_HOME/conf/Catalina/localhost/jira.xml
Note the JOTM dependencies; you'll need to copy various jars to Tomcat's common/lib/ directory.
-->
<Context path="/jira3" docBase="/usr/src/atlassian-jira-professional-3.8/dist-tomcat/atlassian-jira-3.8.war" debug="0">

    <!-- NOTE: If you use a database other than hsqldb:
    * delete the minEvictableIdleTimeMillis and timeBetweenEvictionRunsMillis attributes
    * change the database type in atlassian-jira/WEB-INF/classes/entityengine.xml
    -->
    <Resource name="jdbc/Jira3DS" auth="Container" type="javax.sql.DataSource"
            username="jira3db"
            password="jira3db-password"
            driverClassName="org.gjt.mm.mysql.Driver"
            url="jdbc:mysql://localhost/jira3db?useUnicode=true&characterEncoding=UTF8"
            maxActive="20"
            validationQuery="select 1"/>
<!--        driverClassName="org.mysql.jdbc.Driver" -->

    <Resource name="UserTransaction" auth="Container" type="javax.transaction.UserTransaction"
    factory="org.objectweb.jotm.UserTransactionFactory" jotm.timeout="60"/>
<!--<Manager className="org.apache.catalina.session.PersistentManager" saveOnRestart="false"/>-->
    <Manager pathname=""/>

</Context>

postgres version

<!--
  A sample configuration file for Tomcat 5.5
  Customize the docBase attribute, drop in your $CATALINA_HOME/conf/Catalina/localhost/jira.xml
  Note the JOTM dependencies; you'll need to copy various jars to Tomcat's common/lib/ directory.
  -->
<Context path="/jira3" docBase="/usr/src/atlassian-jira-professional-3.8/dist-tomcat/atlassian-jira-3.8.war" debug="0">

    <!-- NOTE: If you use a database other than hsqldb:
    * delete the minEvictableIdleTimeMillis and timeBetweenEvictionRunsMillis attributes
    * change the database type in atlassian-jira/WEB-INF/classes/entityengine.xml
    -->
    <Resource name="jdbc/Jira3DS" auth="Container" type="javax.sql.DataSource"
            username="jira3db"
            password="jira3db-password"
            driverClassName="org.postgresql.Driver"
            url="jdbc:postgresql://localhost/jira3db"/>

    <Resource name="UserTransaction" auth="Container" type="javax.transaction.UserTransaction"
    factory="org.objectweb.jotm.UserTransactionFactory" jotm.timeout="60"/>
    <Manager className="org.apache.catalina.session.PersistentManager" saveOnRestart="false"/>
</Context>

NOTE: jira3 does not have the “jira.home” entry in jira-application.properties, whilst jira4 does. You’ll be able to specify the jira.home locations during setup of jira3. I recommend the following; (jira4 defaults.)

/var/local/jira3/caches/indexes   # indexing
/var/local/jira3/data/attachments # attachments
/var/local/jira3/export           # backups

The reasonable thing to do is to create two directories, and give ownership to tomcat6. /var/local has default group “staff”.

mkdir /var/local/jira3
mkdir /var/local/jira4

chown -R tomcat6:staff /var/local/jira*

jira4

For postgresql7.2 and above, use postgres72.

<datasource name="defaultDS" field-type-name="postgres72"
      schema-name="public"
      helper-class="org.ofbiz.core.entity.GenericHelperDAO"
      check-on-start="true"
      use-foreign-keys="false"
      use-foreign-key-indices="false"
      check-fks-on-start="false"
      check-fk-indices-on-start="false"
      add-missing-on-start="true"
      check-indices-on-start="true">
  <jndi-jdbc jndi-server-name="default" jndi-name="java:comp/env/jdbc/Jira4DS"/>
</datasource>

You’ll note I’ve changed the jndi-name for our source to Jira4DS.

Editing edit-webapp/WEB-INF/classes/jira-application.properties

jira.home = /var/local/jira4
Have a look at etc/tomcat-6-jira.xml and perhaps etc/jira.xml

<!--
A sample configuration file for Tomcat 6
Customize the docBase attribute, drop in your $CATALINA_HOME/conf/Catalina/localhost/jira.xml
Note the JOTM dependencies; you'll need to copy various jars to Tomcat's common/lib/ directory.
-->
<Context path="/jira4" docBase="/usr/src/atlassian-jira-enterprise-4.2/dist-tomcat/tomcat-6/atlassian-jira-4.2.war" debug="0" useHttpOnly="true">

    <!-- NOTE: If you use a database other than hsqldb:
    * delete the minEvictableIdleTimeMillis and timeBetweenEvictionRunsMillis attributes
    * change the database type in atlassian-jira/WEB-INF/classes/entityengine.xml
    -->
    <Resource name="jdbc/Jira4DS" auth="Container" type="javax.sql.DataSource"
            username="jira4db"
            password="jira4db-password"
            driverClassName="org.postgresql.Driver"
            url="jdbc:postgresql://localhost/jira4db"
            maxActive="20"
            validationQuery="select 1"/>
<!--        driverClassName="org.mysql.jdbc.Driver" -->

    <Resource name="UserTransaction" auth="Container" type="javax.transaction.UserTransaction"
    factory="org.objectweb.jotm.UserTransactionFactory" jotm.timeout="60"/>
<!--<Manager className="org.apache.catalina.session.PersistentManager" saveOnRestart="false"/>-->
    <Manager pathname=""/>
</Context>

and build the damn thing.

cd /usr/src/atlassian-jira-enterprise-4.2/ ./build.sh
Next thing is to configure your jira.xml context. I pretty much just edit the dist-tomcat/tomcat-6/jira.xml, and create a symlink to it called /etc/tomcat6/Catalina/jira4/ROOT.xml

Hopefully you’ll notice I’ve replaced driverClassName. To determine this, I extracted /usr/share/java/mysql-connector-java.jar (it’s a normal zip file), and found mysql-connector-java/org/gjt/mm/mysql/Driver.class

apache2

aptitude install apache2 apache2-mpm-prefork
a2enmod proxy proxy_ajp

add jira3 and jira4 to /etc/hosts

127.0.0.1       jira3.mycompany.com jira3
127.0.0.1       jira4.mycompany.com jira4

This will enable the vhost on tomcat to respont correctly when apache2 proxypasses. /etc/apache/sites-available/jira3

<VirtualHost *:80>
        ServerName jira3.mycompany.com
        ServerAlias jira.mycompany.com

        <Proxy *>
                Order deny,allow
                Allow from all
        </Proxy>

#       ProxyPreserveHost on
        ProxyRequests off

        ProxyPass        / ajp://jira3:8009/
        ProxyPassReverse / ajp://jira3:8009/
</VirtualHost>

Remember to enable the ajp connector in /etc/tomcat6/server.xml

<!-- Define an AJP 1.3 Connector on port 8009 -->
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />