Difference between revisions of "History:Development/Search server setup"

From MusicBrainz Wiki
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{Note}} '''This information is probably outdated. For up-to-date setup instructions see https://bitbucket.org/metabrainz/search-server'''
+
{{Status|'''This Page is Glorious History!'''
  
The following instructions are aimed at getting a search server up and running as a developer; I will assume you are installing things into your home directory, and running under your current user account. If you're looking for a more production ready setup follow the instructions in the README included with the search_server.
+
This how-to guide was for the previous search server system. See [https://github.com/metabrainz/mb-solr the new server's readme] instead.}}
  
Some of the instructions below are taken from the search_server README.
+
 
 +
The Search Server provides the indexed search functions for MusicBrainz.
 +
 
 +
Its source code lives here: https://github.com/metabrainz/search-server
  
 
==Requirements==
 
==Requirements==
 +
------------
  
 
This server can be run on linux/osx/windows, but these instructions assume  
 
This server can be run on linux/osx/windows, but these instructions assume  
that you will be running linux and will be using the tomcat6 server to host
+
that you will be running linux and will be using the tomcat7 server to host
 
the servlet.
 
the servlet.
 +
 +
It also assumes you have created a user called search with a home folder of /home/search
  
 
To run this search server you will also need to have a MusicBrainz database
 
To run this search server you will also need to have a MusicBrainz database
 
with the core data set loaded. Please see  
 
with the core data set loaded. Please see  
  
  FIXME: link to ngs server install here.
+
    https://github.com/metabrainz/musicbrainz-server/blob/master/INSTALL.md
  
 
for details on how to setup at least a "database only install". This  
 
for details on how to setup at least a "database only install". This  
 
document assumes that you have completed the setup of this server.
 
document assumes that you have completed the setup of this server.
  
You will also need a freedb dump, which you can download from http://www.freedb.org/en/download__database.10.html .
+
You will also need these tools:
  
And you will need these tools:
+
    - Java complete with JDK 1.6, not just the JRE
 +
    - Apache Tomcat 7
 +
    - Maven 2
  
* Java complete with JDK 1.6 or later, not just the JRE
+
In a recent Ubuntu, you can install these with this command:
* Apache Tomcat 7    ( http://tomcat.apache.org )
 
* Maven version 2    ( http://maven.apache.org/download.html )
 
  
Ensure that your Java installation is at least 1.6, and that you have the
+
    apt-get install openjdk-6-jdk maven2 tomcat7
JDK installed (not just the JRE).
 
  
    java -version
+
Alternatively if you're not on Ubuntu, install the required tools from the following links
  
If you've installed java manually (instead of using the package system of your distribution), you may need to set JAVA_HOME to the correct path in your shell.
+
    - Java complete with JDK 1.6, not just the JRE (http://www.oracle.com/technetwork/java/javase/downloads/index.html)
 +
    - Apache Tomcat 6    ( http://tomcat.apache.org )
 +
    - Maven version 2    ( http://maven.apache.org/download.html )
 +
 
 +
setup Java Home directory in your profile (not needed on ubuntu):
  
 
     export JAVA_HOME="/usr/bin/java"
 
     export JAVA_HOME="/usr/bin/java"
  
To build you need to install Maven, if you haven't already got it. Download it from http://maven.apache.org/download.html .
 
  
==Download the search server and schemas==
+
==Check out and build server code==
 +
 
 +
Check out the mmd-schema and search-server repositories using Git as follows:
 +
    git clone https://github.com/metabrainz/mmd-schema.git
 +
    git clone https://bitbucket.org/metabrainz/search-server.git
 +
 
 +
Build and install the model:
 +
 
 +
    cd mmd-schema/brainz-mmd2-jaxb
 +
    mvn install
 +
 
 +
By default the search server home will be at: /home/search and the indexes will live in /home/search/indexdata.
 +
But the index location can be overridden by editing
 +
 
 +
    ... /webapps/ROOT/WEB-INF/web.xml
 +
 
 +
so that the index dir is correct:
 +
 
 +
    <param-value>/home/search/indexdata</param-value>
 +
 
 +
Then build the indexer and the search application as follows:
 +
 
 +
    cd search-server
 +
    mvn package
 +
 
 +
This step will download any required java components and then compile and test the whole server.
 +
 
 +
==Development==
 +
 
 +
For development environments there is a much simpler deployment possible
 +
 
 +
    mvn install  (because jetty will uses the installed index.jar, not work directly from the code like the servlet code)
 +
    cd search-server/servlet
 +
    mvn jetty:run
 +
 
 +
This will start the Jetty servlet container (instead of Tomcat), then just use the underlying url on port 8080
  
You will obviously need the search server, but you also need the musicbrainz schema files:
+
    http://localhost:8080/?type=artist&query=fred
  
git clone https://github.com/metabrainz/mmd-schema.git
 
svn co http://svn.musicbrainz.org/search_server/trunk search_server
 
  
==Install the schema classes==
+
==Deploy the Search Server Code==
 +
Unjar the search server webapp into the ROOT directory under webapps for your tomcat installation. If you installed
 +
Tomcat using apt this will be
  
Enter the brainz-mmd2-jaxb directory in mmd-schema, and run "mvn install".
+
    /var/lib/tomcat7/webapps
  
  warp@bo-bomb:~/code/mmd-schema/brainz-mmd2-jaxb$ mvn install
+
If you installed tomcat manually the webapps directory is directly within the folder tomcat has been installed to.
  
You should see it install mmd2-2.0.0.jar in a directory where maven2 will be able to find it later:
+
Automatic deployment of search apps didn't work so well in practice, so it is recommended that you
 +
stop tomcat before upgrading the search application.
  
  [INFO] Installing /home/warp/code/mmd-schema/brainz-mmd2-jaxb/target/mmd2-2.0.0.jar to
+
On Ubuntu this will work:
    /home/warp/.m2/repository/org/musicbrainz/mmd2/mmd2/2.0.0/mmd2-2.0.0.jar
 
  
==Build the search server servlet==
+
    sudo /etc/init.d/tomcat7 stop
 +
    cd /var/lib/tomcat6/webapps
 +
    rm -rf ROOT/*
 +
    cd ROOT
 +
    jar -xf <your lucene java src dir>/servlet/target/searchserver.war
 +
    sudo /etc/init.d/tomcat7 start
  
Enter the search_server directory and run "mvn package" to build the servlet (you can also run "mvn package -Dmaven.test.skip=true" if you want to skip the included tests).
 
  
You should see a line like this when it's done:
+
==Build Indexes==
  
  [INFO] Building war: /home/warp/code/search_server/servlet/target/searchserver.war
+
Copy the Index building code
  
==Build the indexes==
+
    cp /home/search/searchserver/index/target/index-2.0-SNAPSHOT-jar-with-dependencies.jar /home/search
  
To build the indexes, the search server will need access to both your MusicBrainz database and the freedb dump. First enter the index/target directory and run "java -Xmx512M -jar index-2.0-SNAPSHOT-jar-with-dependencies.jar -?" to see the options. 
+
Download the latest freedb dump (in tar.bz2 format) from:
  
Figure out your database name and login details (if you already have mb_server running you can find them in lib/DBDefs.pm in the mb_server directory), and run the indexer like this (all on one line):
+
    http://www.freedb.org/en/download__database.10.html
  
  warp@bo-bomb:~/code/search_server/index/target$ java -Xmx512M -jar index-2.0-SNAPSHOT-jar-with-dependencies.jar
+
The file you download should be a complete dump and should look like this:
    --indexes-dir /home/warp/indexdata --db-name musicbrainz_db --db-user warp --db-password mypassword
 
    --freedb-dump ~/Downloads/freedb-complete-20100201.tar.bz2 --test
 
  
Adding '--test' at the end will build a small test index. After you are done with this setup, you may want to re-run this command without the '--test' option to build the full indexes.
+
    freedb-complete-20090901.tar.bz2
  
When it is done you should have the following index directories in the index directory you specified:
+
Place the downloaded file into /home/search.
  
  warp@bo-bomb:~/indexdata$ ls
+
Now build indexes with these commands:
  annotation_index  cdstub_index label_index releasegroup_index  work_index
 
  artist_index   freedb_index recording_index  release_index
 
  
==Install the servlet==
+
    cd /home/search
 +
    java -Xmx512M -jar index-2.0-SNAPSHOT-jar-with-dependencies.jar --indexes-dir /home/search/indexdata
 +
        --freedb-dump /home/search/<freedb tar.bz2 file>
  
To install the servlet in Apache Tomcat, you obviously need a tomcat install.  I downloaded a binary distribution and extracted in ~/opt. If you have java in your path you should be able to start it right away.
+
This will build all of the indexes using upto 512mb of memory using all of the defaults for connecting
 +
to the database servers. If your database isn't on the same server and named according to the
 +
defaults you will need to give the command line more options. To see the options execute this:
  
  warp@bo-bomb:~/opt$ tar xfz apache-tomcat-6.0.24.tar.gz
+
    java -Xmx512M -jar index-2.0-SNAPSHOT-jar-with-dependencies.jar --help
  warp@bo-bomb:~/opt$ cd apache-tomcat-6.0.24
 
  warp@bo-bomb:~/opt/apache-tomcat-6.0.24$ bin/startup.sh
 
  Using CATALINA_BASE:  /home/warp/opt/apache-tomcat-6.0.24
 
  Using CATALINA_HOME:  /home/warp/opt/apache-tomcat-6.0.24
 
  Using CATALINA_TMPDIR: /home/warp/opt/apache-tomcat-6.0.24/temp
 
  Using JRE_HOME:        /usr
 
  Using CLASSPATH:      /home/warp/opt/apache-tomcat-6.0.24/bin/bootstrap.jar
 
  warp@bo-bomb:~/opt$
 
  
Try connecting to http://localhost:8080, and you should see the tomcat startup page. 
+
Usually you will want to build the freedb index at a different time to the other indexes so you can also
 +
build it separately. If you want to build just the freedb_index, you can specify
  
Shut down tomcat again by running "bin/shutdown.sh".  To install the search server, enter the "webapps" directory, remove the current ROOT, and copy over the servlet as the new ROOT webapp:
+
    --indexes freedb
  
  warp@bo-bomb:~/opt/apache-tomcat-6.0.24$ cd webapps/
+
Building the search indexes will take some time -- even on a fast machine it will still take an hour.
  warp@bo-bomb:~/opt/apache-tomcat-6.0.24/webapps$ ls
+
Once indexes are built, ensure that your tomcat instance has the permissions to access your data.
  docs  examples host-manager  manager  ROOT
+
In Ubuntu:
  warp@bo-bomb:~/opt/apache-tomcat-6.0.24/webapps$ rm -rf ROOT
 
  warp@bo-bomb:~/opt/apache-tomcat-6.0.24/webapps$ cp ~/code/search_server/servlet/target/searchserver.war ROOT.war
 
  warp@bo-bomb:~/opt/apache-tomcat-6.0.24/webapps$ cd ..
 
  warp@bo-bomb:~/opt/apache-tomcat-6.0.24$ bin/startup.sh
 
  
You should see a new ROOT directory tree appear under webapps, stop tomcat again to configure the indexes for the search server.
+
    chown -R tomcat7:tomcat7 /home/search
  
  warp@bo-bomb:~/opt/apache-tomcat-6.0.24$ bin/shutdown.sh
+
==Update Indexes using the Live Data Feed==
  warp@bo-bomb:~/opt/apache-tomcat-6.0.24$ $EDITOR webapps/ROOT/WEB-INF/web.xml
 
  warp@bo-bomb:~/opt/apache-tomcat-6.0.24$ bin/startup.sh
 
  warp@bo-bomb:~/opt/apache-tomcat-6.0.24$
 
  
In web.xml, you should replace the current index_dir value ("/home/search/indexdata") with the path to the index files, in my case this is "/home/warp/indexdata".
+
It's possible to update search indexes using replication packets, the same way your slave MusicBrainz database is updated.
  
If you now query the search server, you should get some results. For example, try this: [http://localhost:8080/ws/2/artist/?query=%22alice%22 http://localhost:8080/ws/2/artist?query=%22alice%22].
+
You need to edit the updateindex.sh and adapt the SETTINGS section to fit your setup:
 +
vi /home/search/searchserver/updater/updateindex.cfg
 +
 
 +
Once you're done, you can launch the indexes updating:
 +
/home/search/searchserver/updater/updateindex.sh
 +
 
 +
You can run this script hourly using cron.
 +
 
 +
Advanced options:
 +
 
 +
* You can get more verbose log by using the --verbose parameter:
 +
/home/search/searchserver/updater/updateindex.sh --verbose
 +
 
 +
* The default settings allow you update most of the indexes excepted recording ones.
 +
If you want to choose specifically the indexes to be updated, either update the INDEXES variable in updateindex.cfg,
 +
or comment the INDEXES variable in updateindex.cfg and run the script using the --indexes args:
 +
/home/search/searchserver/updater/updateindex.sh --indexes artist,label
 +
 
 +
* A lock file is created to ensure you're not running concurrently the script.
 +
You can provide the lock file by setting the LOCK_FILE env variable. This can be useful if you can to update concurrently different indexes:
 +
LOCK_FILE=/tmp/lock_updating_release /home/search/searchserver/updater/updateindex.sh --indexes release
 +
LOCK_FILE=/tmp/lock_updating_label /home/search/searchserver/updater/updateindex.sh --indexes label
  
 
==Tuning Tomcat==
 
==Tuning Tomcat==
  
If you followed the instructions so far, you should have a running search server. The README included with the search server includes some hints about tuning tomcat, you should follow those.
+
Ubuntu enables the Java security manager by default, this will prevent the search server working.
 +
For Ubuntu, set TOMCAT6_SECURITY in /etc/default/tomcat7 to no:
 +
 
 +
    # Use the Java security manager? (yes/no)
 +
    TOMCAT6_SECURITY=no
 +
 
 +
Next, configure Tomcat with the max heap memory you want to use for Search Server. This is
 +
very important because by default it will only use a maximum of 32MB, adding
 +
the following to your profile sets up Tomcat with 512MB. This is the optimum amount to use if you can afford it, do not
 +
allocate more than this because search can use the unallocated memory to cache the indexes.
 +
 
 +
Also configure Tomcat to run with file encoding UTF-8, otherwise it will use the default which
 +
will vary from platform to platform. To accomplish both, set the JAVA_OPTS like this:
 +
 
 +
    export JAVA_OPTS="-Xms512M -Xmx512M -Dfile.encoding=UTF-8"
 +
 
 +
In Ubuntu, you can change JAVA_OPTS in /etc/default/tomcat7 -- you do not need to set an environment var.
 +
 
 +
Next, specify that Tomcat expects URIEncodings in UTF-8 format so they are decoded correctly.
 +
In server.xml (in ubuntu thats in /etc/tomcat7/server.xml) add the URIEncoding parameter to this
 +
line:
 +
 
 +
    <Connector port="8080" protocol="HTTP/1.1"connectionTimeout="20000" redirectPort="8443">
 +
 
 +
So it nows looks like:
 +
 
 +
    <Connector port="8080" protocol="HTTP/1.1"connectionTimeout="20000" redirectPort="8443" URIEncoding="UTF-8">
 +
 
 +
By default Tomcat runs on port 8080. To switch it to port 80, edit the Connector line in server.xml again:
 +
 
 +
    <Connector port="80" protocol="HTTP/1.1"connectionTimeout="20000" redirectPort="8443" URIEncoding="UTF-8">
 +
 
 +
Finally, to enable a threadpool so that Tomcat can use multiple processors/cores, uncomment/add this line
 +
in server.xml
 +
 
 +
    <Executor name="tomcatThreadPool" namePrefix="catalina-exec-"
 +
              maxThreads="150" minSpareThreads="4" minThreads="8"/>
 +
 
 +
and add the executor attribute to the Connector:
 +
 
 +
    <Connector port="80" protocol="HTTP/1.1"connectionTimeout="20000" redirectPort="8443"
 +
              URIEncoding="UTF-8" executor="tomcatThreadPool">
 +
 
 +
We opted to create one thread per available core our setup, which in this case is 8.
 +
 
 +
Now start (or restart) Tomcat to have the latest settings take effect.
 +
 
 +
 
 +
==Testing the Search Server==
 +
 
 +
You can now lookup search for resources with a url like:
 +
 
 +
    http://localhost/ws/2/artist/?query=fred
 +
 
 +
For compatibility with Webservice version 1 use:
 +
 
 +
    http://localhost/ws/1/artist/?query=fred
 +
 
 +
You can also get the results in JSON format using a url like:
 +
 
 +
    http://localhost/ws/2/artist/?query=fred&fmt=json
 +
 
 +
 
 +
==Server administration==
 +
 
 +
 
 +
If you have built new indexes you can inform the search server of the new indexes without restarting it using the init
 +
command. Setting init to mmap will memory map the indexes (this now the default),
 +
 
 +
    http://localhost:8080/?init=mmap
 +
 
 +
Or you can revert to the older filesystem based format using
 +
 
 +
    http://localhost:8080/?init=nfio
 +
 
 +
You can enable the rate limiter with
 +
 
 +
    http://localhost:8080/?rate=true
 +
 
 +
or disable it with
 +
 
 +
    http://localhost:8080/?rate=false
 +
 
 +
The reload command is intended for use when an existing index has been updated rather than replaced, this is not currently used
 +
    http://localhost:8080/?reload=true
 +
 
 +
All the above commands can only be performed on the local search machine otherwise a 403 error will be returned.
 +
 
 +
The number of queries done against any index since the servlet was started can be obtained using the count parameter
 +
and index name
 +
 
 +
    http://localhost:8080/?count=artist
 +
 
 +
 
 +
==Troubleshooting==
 +
 
 +
The search url is a mapping you can also use the underlying url directly as follows:
  
==Encoding issues==
+
    http://localhost:8080/?type=artist&query=fred
  
Make sure the follow the instructions in the README related to UTF-8.  If you don't set "URIEncoding" on the connectors in server.xml non-ascii lookups will probably fail.
 
  
 
[[Category:Development]]
 
[[Category:Development]]

Latest revision as of 15:16, 10 September 2020

Status: This Page is Glorious History!

This how-to guide was for the previous search server system. See the new server's readme instead.


The Search Server provides the indexed search functions for MusicBrainz.

Its source code lives here: https://github.com/metabrainz/search-server

Requirements


This server can be run on linux/osx/windows, but these instructions assume that you will be running linux and will be using the tomcat7 server to host the servlet.

It also assumes you have created a user called search with a home folder of /home/search

To run this search server you will also need to have a MusicBrainz database with the core data set loaded. Please see

   https://github.com/metabrainz/musicbrainz-server/blob/master/INSTALL.md

for details on how to setup at least a "database only install". This document assumes that you have completed the setup of this server.

You will also need these tools:

   - Java complete with JDK 1.6, not just the JRE
   - Apache Tomcat 7
   - Maven 2

In a recent Ubuntu, you can install these with this command:

   apt-get install openjdk-6-jdk maven2 tomcat7

Alternatively if you're not on Ubuntu, install the required tools from the following links

   - Java complete with JDK 1.6, not just the JRE (http://www.oracle.com/technetwork/java/javase/downloads/index.html)
   - Apache Tomcat 6    ( http://tomcat.apache.org )
   - Maven version 2    ( http://maven.apache.org/download.html )

setup Java Home directory in your profile (not needed on ubuntu):

   export JAVA_HOME="/usr/bin/java"


Check out and build server code

Check out the mmd-schema and search-server repositories using Git as follows:

   git clone https://github.com/metabrainz/mmd-schema.git
   git clone https://bitbucket.org/metabrainz/search-server.git

Build and install the model:

   cd mmd-schema/brainz-mmd2-jaxb
   mvn install

By default the search server home will be at: /home/search and the indexes will live in /home/search/indexdata. But the index location can be overridden by editing

   ... /webapps/ROOT/WEB-INF/web.xml

so that the index dir is correct:

   <param-value>/home/search/indexdata</param-value>

Then build the indexer and the search application as follows:

   cd search-server
   mvn package

This step will download any required java components and then compile and test the whole server.

Development

For development environments there is a much simpler deployment possible

   mvn install  (because jetty will uses the installed index.jar, not work directly from the code like the servlet code)
   cd search-server/servlet
   mvn jetty:run

This will start the Jetty servlet container (instead of Tomcat), then just use the underlying url on port 8080

    http://localhost:8080/?type=artist&query=fred


Deploy the Search Server Code

Unjar the search server webapp into the ROOT directory under webapps for your tomcat installation. If you installed Tomcat using apt this will be

   /var/lib/tomcat7/webapps

If you installed tomcat manually the webapps directory is directly within the folder tomcat has been installed to.

Automatic deployment of search apps didn't work so well in practice, so it is recommended that you stop tomcat before upgrading the search application.

On Ubuntu this will work:

   sudo /etc/init.d/tomcat7 stop
   cd /var/lib/tomcat6/webapps
   rm -rf ROOT/*
   cd ROOT
   jar -xf <your lucene java src dir>/servlet/target/searchserver.war
   sudo /etc/init.d/tomcat7 start


Build Indexes

Copy the Index building code

   cp /home/search/searchserver/index/target/index-2.0-SNAPSHOT-jar-with-dependencies.jar /home/search

Download the latest freedb dump (in tar.bz2 format) from:

   http://www.freedb.org/en/download__database.10.html

The file you download should be a complete dump and should look like this:

   freedb-complete-20090901.tar.bz2

Place the downloaded file into /home/search.

Now build indexes with these commands:

   cd /home/search
   java -Xmx512M -jar index-2.0-SNAPSHOT-jar-with-dependencies.jar --indexes-dir /home/search/indexdata
        --freedb-dump /home/search/<freedb tar.bz2 file>

This will build all of the indexes using upto 512mb of memory using all of the defaults for connecting to the database servers. If your database isn't on the same server and named according to the defaults you will need to give the command line more options. To see the options execute this:

   java -Xmx512M -jar index-2.0-SNAPSHOT-jar-with-dependencies.jar --help

Usually you will want to build the freedb index at a different time to the other indexes so you can also build it separately. If you want to build just the freedb_index, you can specify

   --indexes freedb

Building the search indexes will take some time -- even on a fast machine it will still take an hour. Once indexes are built, ensure that your tomcat instance has the permissions to access your data. In Ubuntu:

   chown -R tomcat7:tomcat7 /home/search

Update Indexes using the Live Data Feed

It's possible to update search indexes using replication packets, the same way your slave MusicBrainz database is updated.

You need to edit the updateindex.sh and adapt the SETTINGS section to fit your setup: vi /home/search/searchserver/updater/updateindex.cfg

Once you're done, you can launch the indexes updating: /home/search/searchserver/updater/updateindex.sh

You can run this script hourly using cron.

Advanced options:

  • You can get more verbose log by using the --verbose parameter:

/home/search/searchserver/updater/updateindex.sh --verbose

  • The default settings allow you update most of the indexes excepted recording ones.

If you want to choose specifically the indexes to be updated, either update the INDEXES variable in updateindex.cfg, or comment the INDEXES variable in updateindex.cfg and run the script using the --indexes args: /home/search/searchserver/updater/updateindex.sh --indexes artist,label

  • A lock file is created to ensure you're not running concurrently the script.

You can provide the lock file by setting the LOCK_FILE env variable. This can be useful if you can to update concurrently different indexes: LOCK_FILE=/tmp/lock_updating_release /home/search/searchserver/updater/updateindex.sh --indexes release LOCK_FILE=/tmp/lock_updating_label /home/search/searchserver/updater/updateindex.sh --indexes label

Tuning Tomcat

Ubuntu enables the Java security manager by default, this will prevent the search server working. For Ubuntu, set TOMCAT6_SECURITY in /etc/default/tomcat7 to no:

   # Use the Java security manager? (yes/no)
   TOMCAT6_SECURITY=no

Next, configure Tomcat with the max heap memory you want to use for Search Server. This is very important because by default it will only use a maximum of 32MB, adding the following to your profile sets up Tomcat with 512MB. This is the optimum amount to use if you can afford it, do not allocate more than this because search can use the unallocated memory to cache the indexes.

Also configure Tomcat to run with file encoding UTF-8, otherwise it will use the default which will vary from platform to platform. To accomplish both, set the JAVA_OPTS like this:

   export JAVA_OPTS="-Xms512M -Xmx512M -Dfile.encoding=UTF-8"

In Ubuntu, you can change JAVA_OPTS in /etc/default/tomcat7 -- you do not need to set an environment var.

Next, specify that Tomcat expects URIEncodings in UTF-8 format so they are decoded correctly. In server.xml (in ubuntu thats in /etc/tomcat7/server.xml) add the URIEncoding parameter to this line:

   <Connector port="8080" protocol="HTTP/1.1"connectionTimeout="20000" redirectPort="8443">

So it nows looks like:

   <Connector port="8080" protocol="HTTP/1.1"connectionTimeout="20000" redirectPort="8443" URIEncoding="UTF-8">

By default Tomcat runs on port 8080. To switch it to port 80, edit the Connector line in server.xml again:

   <Connector port="80" protocol="HTTP/1.1"connectionTimeout="20000" redirectPort="8443" URIEncoding="UTF-8">

Finally, to enable a threadpool so that Tomcat can use multiple processors/cores, uncomment/add this line in server.xml

   <Executor name="tomcatThreadPool" namePrefix="catalina-exec-" 
             maxThreads="150" minSpareThreads="4" minThreads="8"/>

and add the executor attribute to the Connector:

   <Connector port="80" protocol="HTTP/1.1"connectionTimeout="20000" redirectPort="8443" 
              URIEncoding="UTF-8" executor="tomcatThreadPool">

We opted to create one thread per available core our setup, which in this case is 8.

Now start (or restart) Tomcat to have the latest settings take effect.


Testing the Search Server

You can now lookup search for resources with a url like:

   http://localhost/ws/2/artist/?query=fred

For compatibility with Webservice version 1 use:

   http://localhost/ws/1/artist/?query=fred

You can also get the results in JSON format using a url like:

   http://localhost/ws/2/artist/?query=fred&fmt=json


Server administration

If you have built new indexes you can inform the search server of the new indexes without restarting it using the init command. Setting init to mmap will memory map the indexes (this now the default),

   http://localhost:8080/?init=mmap

Or you can revert to the older filesystem based format using

   http://localhost:8080/?init=nfio

You can enable the rate limiter with

   http://localhost:8080/?rate=true

or disable it with

   http://localhost:8080/?rate=false

The reload command is intended for use when an existing index has been updated rather than replaced, this is not currently used

   http://localhost:8080/?reload=true

All the above commands can only be performed on the local search machine otherwise a 403 error will be returned.

The number of queries done against any index since the servlet was started can be obtained using the count parameter and index name

   http://localhost:8080/?count=artist


Troubleshooting

The search url is a mapping you can also use the underlying url directly as follows:

    http://localhost:8080/?type=artist&query=fred