== Setting up general environment == sudo aptitude install mysql-server sun-java6-jdk sysstat gnuplot sudo aptitude install apache2 php5 pushd /etc/apache2/sites-enabled sudo ln -sf ~/sandbox/txcache/src/RUBiS-1.4.3/apache-rubis-austin 001-rubis popd ./make-properties small short errors export JAVA_HOME=/usr/lib/jvm/java-6-sun-1.6.0.10 make client # Set up a SSH agent in the usual way == Setting up MySQL == sudo aptitude install mysql-server php5-mysql sudo /etc/init.d/apache2 restart echo "CREATE USER cecchet" | mysql -u root echo "GRANT ALL ON rubis.* TO 'cecchet'@'localhost'" | mysql -u root echo "DROP DATABASE rubis" | mysql -u root cat database/{rubis.sql,categories.sql,regions.sql} | mysql -u root == Setting up Postgres == sudo aptitude install postgresql-8.3 php5-pgsql sudo /etc/init.d/apache2 restart # If running a Postgres built from source instead of a package, # you might need to do the following: ln -s /tmp/.s.PGSQL.* /var/run/postgresql/ initdb -D main Edit postgresql.conf (for example /etc/postgresql/8.3/main/postgresql.conf in Debian). Set enable_bitmapscan to off. Set enable_tidscan to off. Set default_transaction_isolation to 'serializable'. Run either postgres -D db or /etc/init.d/postgresql-8.3 restart sudo -u postgres createuser -SdR cecchet # Add the following line to the top of /etc/postgresql/8.3/main/pg_hba.conf # local all cecchet trust sudo /etc/init.d/apache2 reload dropdb -U cecchet rubis psql -U cecchet -f database/rubis.postgres.sql postgres cat database/{categories.sql,regions.sql} | sed 's/#.*//;s/(NULL/(DEFAULT/' | psql -U cecchet rubis == Running RUBiS == make initDB PARAM=all psql -U cecchet -f database/update_old_items.sql rubis make emulator == Running the whole system == pg/bin/postgres -D pg/db src/pincusion/pincushion src/server/server -s 512M sudo /etc/init.d/apache2 restart make emulator == Porting to Postgres == database/rubis.postgres.sql needs two fixes 1. connect should be replaced with \connect 2. DATETIME should be replaced with TIMESTAMP RUBiS uses only a few MySQL functions # g mysql_ | sed -e 's/.*\(mysql_[^(]*\).*/\1/' | sort | uniq mysql_close mysql_error mysql_fetch_array mysql_free_result mysql_num_rows mysql_pconnect mysql_query mysql_select_db I think mysql_select_db is the only problematic function because Postgres folds connecting to the database and selecting a database into one function. However, mysql_pconnect and mysql_select_db occur in only a single function in RUBiS, so this shouldn't be a problem. The queries all look fairly simple, though differing semantics (e.g., NULL's) might cause problems. # g mysql_query | sed -e 's/.*mysql_query("\(.*\)/\1/' LOCK TABLES has different syntax in MySQL and Postgres, though the three uses look easy to translate. Postgres has no UNLOCK TABLES equivalent. I simply don't run [UN]LOCK TABLES on Postgres. Various syntax differences. Postgres uses single quoted strings. Most, but not all of the RUBiS code uses doubled quoted strings. Suck. I unconditionaly replace double quotes with single quotes when running a query on Postgres and depend on PHP magic quotes to escape single quotes. Postgres strictly requires timestamps to be "Y-m-d H:i:s", which isn't the form RUBiS uses. MySQL datetime's accept RUBiS' "Y:m:d H:i:s" and rewrite it as the other form. I reformated everything to Postgres style, since MySQL can take that, too. RUBiS uses LIMIT x,y syntax, but Postgres requires LIMIT y OFFSET x. I changed evreything to Postgres syntax since MySQL supports both. Postgres SERIAL fields replace MySQL AUTO_INCREMENT fields, but SERIAL fields need to have DEFAULT inserted into them instead of NULL. I store the appropriate syntax in $ID_DEFAULT.