Creating a virtual XWiki environment

Basic information

Virtual XWiki Environment

  • A Virtual XWiki environment allows you to run two or more XWiki instances on the same server. Each XWiki Virtual Server has its own database, so (for example) you can have sensitive sales data on one Virtual Server, and public information on another.

Performance

  • A Virtual Server configuration performs a lot better than having multiple XWiki Servers running on the same hardware. This is fairly obvious when you consider that each instance of a full wiki installation would make use of it's own resources (a significant portion of which is the actual XWiki application itself).
  • As an example, the xwiki.com server farm - which uses only two clustered Java instances - currently runs over 8000 individual XWiki's (as of the last count). This number is growing on a daily basis! Granted, you will need decent servers for that kind of volume.. but that's just an example of available performance under the virtual setup.
PLEASE NOTE: color scheme used in this document:

  • Words used to identify something specific which will be referred to later
  • Suggestions - advice from the School of Hard Knocks
  • Examples.

Requirements

The following is a basic outline of what you will need to have (or be able to have done on your behalf) in order to configure the Virtual environment. They are not exhaustive, but if you're answering no to these, you may not be able to complete your configurations.

Network permissions and databases may be restricted on corporate networks: in this case, you need to ascertain who is in charge and get approval for them to make the required changes (if required) before continuing.

Warning: Virtual wikis don't currently work when using PostgreSQL as the JDBC driver doesn't support setCatalog() for changing databases as PostgreSQL connections are pointed to a specific database at connection time.

  • You will need a little bit of IT knowledge, or at least have access to someone who can help with the main technical aspects of this installation.
  • Choose one instance of XWiki that has been installed on your network. We'll refer to this server as the controller for the Virtual XWiki's. The database name for your proposed main installation should be "xwiki".
    • If you've still got to install the XWiki instance, please refer to the installation guide and complete this step first.
    • You will need administrator access to this wiki.
  • Able to add network forwarding to your network address. So you should be able to point, say abc.def.com to the same IP address as xyz.def.com; this is an important requirement.
  • Root priveledges to your database, or ability to create new databases and assign permissions to the new databases.
  • Able to restart the java container (eg tomcat or jetty), or can have this restarted on demand.
    • A file will also have to be modified, so you will need to have write access to the files on the server as well.

Setting up the Virtual Servers

Getting ready.

  • Write down the IP address of your xwiki controller.
  • Write down the database username that is used by the xwiki controller.
  • Find out what domain name you can use for the servers to be subdomained from. Typical examples are us.bigcompany.com, smallercompany.co.uk, etc. You will need to obtain the full name of the server you are using, or the proposed name for the server (eg ourxwikiserver.us.bigcompany.com or ourxwiki.smallercompany.co.uk). I'll call this ourxwiki.yourdomain.com for the time being.
    • I would recommend asking for a unique name (not using the actual server name), as this will be easier to work with if you ever cluster the server, or if the server is replaced by another one. Remember, it's easy to update a network record; but not so easy to update everyone's links for a new server name. This is only a recommendation and is NOT REQUIRED to setup a virtual xwiki.
  • Decide on the names of your Virtual XWiki server(s), and the controller. While XWiki will assume www.yourdomain.com points to your main xwiki, it is better in the long run to specify this too.
    • Example:
      • internal = internal.ourxwiki.yourdomain.com
      • public = public.ourwiki.yourdomain.com
      • sales = sales.ourwiki.yourdomain.com
  • Warn your users (if the server is active) and schedule few hours downtime for the XWiki server. It won't take near that time, but this will allow you to test and make sure all showstopper issues are covered.

The installation.

  • Backup all affected XWiki databases now.
    • If your backup is not working, delay these steps until you can get it working. This prepares you for a possible revert of the system if anything goes wrong.
  • Create (or have created) network pointers for your virtual server domains. ALL YOUR VIRTUAL XWIKI DOMAINS MUST POINT TO YOUR XWIKI CONTROLLER IP ADDRESS. XWiki will figure out what to do with the request based on this data.
    • Example:
      • internal.ourxwiki.yourdomain.com
      • public.ourwiki.yourdomain.com
      • sales.ourwiki.yourdomain.com
      • Also make sure you are pointing ourwiki.yourdomain.com to the same server!! This will point to your main server; and is an important step
After all this preparation you will create proper sub wikis, for that you have, from XWiki1.1, two solutions :

Wiki Manager

From XWiki1.1 you can use the Wiki Manager that will take care of what you find in By hand chapter.

Simply install Wiki Manager Plugin and Wiki Manager Application and follow instructions.

By hand

  • Edit your database and add a new database for all virtual servers. Note that XWiki version 0.9.840 and below require a datbase to be setup. You can also use existing databases if you are simply combining pre-existing XWiki servers. The xwiki controller database username must be granted all permissions to the virtual databases if not already granted.
    • Example:
      • "xwikiinternal" for internal.ourxwiki.yourdomain.com
      • "xwikipublic" for public.ourwiki.yourdomain.com
      • "xwikisales" for sales.ourwiki.yourdomain.com
  • In your Class Editor, create a new class called "XWikiServerClass".
    • Click "Edit this Class"
      • Add a string property called "server"
      • Add another string property called "owner".
      • This part depends on your own preferences. If there are enough people wanting more details I'll add to this document, but it's not necessary: To make this easier to maintain, you can create the template and class sheet details as per the examples at the FAQ tutorial.
    • Create a new page for each of your Virtual Wiki's (as well as your main controller, don't forget!!) based on the following format:
      • XWiki.XWikiServerThisdatabasename, where Thisdatabasename is the name of the Virtual Server database.
        • THIS IS IMPORTANT: the text for This databasename MUST have it's first letter CAPITALIZED. This is regardless of your database setup!!!!!!!
      • In each document, (assuming you did not create a special class sheet and template), you must attach the XWikiServerClass object.
        • Fill in the "server" field listing the server name for each of your servers
          • Example:
            • internal.ourwiki.yourdomain.com
            • public.ourwiki.yourdomain.com
            • sales.ourwiki.yourdomain.com
        • Fill in the "owner" field with the owner user of the Virtual XWiki; for example XWiki.Admin.
    • Stop your java container (eg tomcat or jetty).
    • Open the xwiki.cfg file on the physical server (located under xwikiWEB-INF) and modify the xwiki.virtual entry to be 1. If you are certain xwiki.virtual does not exist, you can create it.
      • It is useful to setup xwiki.virtual.redirect (in the line below the xwiki.virtual) to point to your main wiki. This avoids potential problems in future should you ever accidentally delete your main xwiki document
    • You can now restart Tomcat and test your new links. The main controller link should work straight away
      • You will notice that your main wiki should work without any additional configuration.
        • If your Virtual Wikis were created from already existing databases, then they should not need any work either.
        • If the Virtual Wikis are new, clean databases you may need to carry out an import of the .xar base setup files (for XWiki10B1 or above).
Your Virtual environment should now be complete.

--Author's notes: This is a first draft attempt, basing some data on the FAQ entry in the old .org site. Please post a comment if there are any issues; or email the xwiki-users email list.

Version 3.4 last modified by Sergiu on 01/02/2008 at 23:28

Comments 11

VincentMassol | 25.01.2007 at 08:22 PM
Hi Brandon,

Here's an idea. It would be cool if you could ensure that the information on http://www.xwiki.org/xwiki/bin/view/FAQ/HowToSetupVirtualWikis is included in this document so that you can then edit http://www.xwiki.org/xwiki/bin/view/FAQ/HowToSetupVirtualWikis and simply put a link to the page here.


brandone | 26.01.2007 at 01:11 PM
The main information is included in this, just expanded on. I can review both monday morning if it'll help.

EricVanderVlist | 12.02.2007 at 08:41 AM
Instead of using different host names, is that possible to use different suffixes (such as http://example.com/xwiki/foo/, http://example.com/xwiki/bar/) and how would you do that?

This would be especially interesting for servers runing with https (in that case, each different host name requires a specific IP address and a different certificate which can be quite expensive).

Thanks,

Eric


brandone | 13.02.2007 at 10:53 AM
Eric: "http://example.com/xwiki/foo/, http://example.com/xwiki/bar/ " I don't think that would work for a virtual configuration. You could setup individual XWiki servers on the same server, but this is not very efficient and can lead to other problems.. Bear in mind that you're not actually hosting multiple web sites, as much as creating multiple cname pointers. Your IP address will still point to only one web server, but you would be using different server names to refer to it - and if memory serves (depending on your certifier), you can use wildcard (eg *.example.com) for your SSL cert, allowing you to create subdomains.

ToddMorgan | 09.04.2007 at 02:45 PM
Is it possible to produce an example of a Virtual Xwiki that can be downloaded? ie a XAR and DB dump (assuming a working DB - eg MySQL)

Or better yet produce an Xwiki (VMware) Appliance (which I was attempting to do) when I ran into a problem with creating a VirtualWiki following these instructions - perhaps some detailed screen shots with a complete worked example would be useful here.

I had intended to create an appliance using the DevWare appliance (http://www.vmware.com/vmtn/appliances/directory/313) but I was unable to get a successful installation of Xwiki on it so I resorted to Windows. I couldn't get my files uploaded to be installed under Tomcat in the correct location as there wasn't a FTP server, SAMBA share and my command line Linux isn't that great. Perhaps someone else, with more Linux proficiency can achieve this.


JanEldenmalm | 29.04.2007 at 01:20 AM
I get the below error and stack trace when following this set-up instruction and try to access a virtual wiki. I also get an error when I try to save the "XWikiServerClass" in my "XWiki.XWikiServerXwiki" page as described, never the less when I look at the "XWiki.XWikiServerXwiki" page it has the server object added and the two strings servet and owner set to server="fqdn of virtual wiki", and owner set to "XWiki.Admin".

javax.servlet.ServletException: Error number 3201 in 3: Exception while saving document XWiki.XWikiPreferences Wrapped Exception: Error number 13012 in 3: Exception while saving links Wrapped Exception: null org.apache.struts.action.RequestProcessor.processException(RequestProcessor.java:535) org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:433) org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236) org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196) org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414) javax.servlet.http.HttpServlet.service(HttpServlet.java:689) javax.servlet.http.HttpServlet.service(HttpServlet.java:802) com.xpn.xwiki.web.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:118)

root cause

com.xpn.xwiki.XWikiException: Error number 3201 in 3: Exception while saving document XWiki.XWikiPreferences Wrapped Exception: Error number 13012 in 3: Exception while saving links Wrapped Exception: null com.xpn.xwiki.store.XWikiHibernateStore.saveXWikiDoc(XWikiHibernateStore.java:314) com.xpn.xwiki.store.XWikiCacheStore.saveXWikiDoc(XWikiCacheStore.java:100) com.xpn.xwiki.store.XWikiCacheStore.saveXWikiDoc(XWikiCacheStore.java:94) com.xpn.xwiki.XWiki.saveDocument(XWiki.java:895) com.xpn.xwiki.XWiki.getPrefsClass(XWiki.java:2301) com.xpn.xwiki.XWiki.updateDatabase(XWiki.java:351) com.xpn.xwiki.XWiki.updateDatabase(XWiki.java:330) com.xpn.xwiki.XWiki.getXWiki(XWiki.java:446) com.xpn.xwiki.web.XWikiAction.execute(XWikiAction.java:96) org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431) org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236) org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196) org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414) javax.servlet.http.HttpServlet.service(HttpServlet.java:689) javax.servlet.http.HttpServlet.service(HttpServlet.java:802) com.xpn.xwiki.web.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:118)


JanEldenmalm | 29.04.2007 at 01:25 AM
Forgot to mention...the error saving the "XWikiServerClass" in my "XWiki.XWikiServerXwiki" page only appeared during the set-up procedure - after the restart I can now save the string without getting the error

ToddMorgan | 05.05.2007 at 11:07 AM
After seeing Jan's comments I tried just continuing on, as I was getting a similar but different error message. It turns out that it was saving the state. I was able to create all my required virtual wiki's and login verify the unique content etc. That was under WinXP SP2, Tomcat 5.5, Java 1.5.0.11 and XWiki Beta 6.

I tried the exact same using RC3 (after deleting the dir under tomcat, and dropping all the DBs from MySQL) and I get an exception as per Jan - but the state information IS stored.

I restart tomcat and try to access any of the Virtual Wiki's and I get this exception javax.servlet.ServletException: Error number 3201 in 3: Exception while saving document XWiki.XWikiPreferences Wrapped Exception: Error number 13012 in 3: Exception while saving links Wrapped Exception: null org.apache.struts.action.RequestProcessor.processException(RequestProcessor.java:535) org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:433) org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236) org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196) org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414) javax.servlet.http.HttpServlet.service(HttpServlet.java:689) javax.servlet.http.HttpServlet.service(HttpServlet.java:802) com.xpn.xwiki.web.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:118)

root cause

com.xpn.xwiki.XWikiException: Error number 3201 in 3: Exception while saving document XWiki.XWikiPreferences Wrapped Exception: Error number 13012 in 3: Exception while saving links Wrapped Exception: null com.xpn.xwiki.store.XWikiHibernateStore.saveXWikiDoc(XWikiHibernateStore.java:314) com.xpn.xwiki.store.XWikiCacheStore.saveXWikiDoc(XWikiCacheStore.java:100) com.xpn.xwiki.store.XWikiCacheStore.saveXWikiDoc(XWikiCacheStore.java:94) com.xpn.xwiki.XWiki.saveDocument(XWiki.java:895) com.xpn.xwiki.XWiki.getPrefsClass(XWiki.java:2301) com.xpn.xwiki.XWiki.updateDatabase(XWiki.java:351) com.xpn.xwiki.XWiki.updateDatabase(XWiki.java:330) com.xpn.xwiki.XWiki.getXWiki(XWiki.java:446) com.xpn.xwiki.web.XWikiAction.execute(XWikiAction.java:96) org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431) org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236) org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196) org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414) javax.servlet.http.HttpServlet.service(HttpServlet.java:689) javax.servlet.http.HttpServlet.service(HttpServlet.java:802) com.xpn.xwiki.web.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:118)

note The full stack trace of the root cause is available in the Apache Tomcat/5.5.20 logs.


ToddMorgan | 05.05.2007 at 11:08 AM
this is the detail at the bottom of the stack trace in the log file

Wrapped Exception:
java.lang.NullPointerException
	at java.util.Hashtable.put(Hashtable.java:396)
	at com.xpn.xwiki.XWikiContext.setDoc(XWikiContext.java:158)
	at com.xpn.xwiki.store.XWikiHibernateStore.saveLinks(XWikiHibernateStore.java:1470)
	at com.xpn.xwiki.store.XWikiHibernateStore.saveXWikiDoc(XWikiHibernateStore.java:305)
	at com.xpn.xwiki.store.XWikiCacheStore.saveXWikiDoc(XWikiCacheStore.java:100)
	at com.xpn.xwiki.store.XWikiCacheStore.saveXWikiDoc(XWikiCacheStore.java:94)
	at com.xpn.xwiki.XWiki.saveDocument(XWiki.java:895)
	at com.xpn.xwiki.XWiki.getPrefsClass(XWiki.java:2301)
	at com.xpn.xwiki.XWiki.updateDatabase(XWiki.java:351)
	at com.xpn.xwiki.XWiki.updateDatabase(XWiki.java:330)
	at com.xpn.xwiki.XWiki.getXWiki(XWiki.java:446)
	at com.xpn.xwiki.web.XWikiAction.execute(XWikiAction.java:96)
	at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)
	at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
	at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
	at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
	at com.xpn.xwiki.web.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:118)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
	at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
	at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
	at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
	at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
	at java.lang.Thread.run(Thread.java:595)

VitantonioMessa | 31.08.2007 at 01:36 PM
Hi, I'm trying to make the virtual servers work with the standalone distribution (the one file with servlet container, database and XWiki). I've already set up the DNS server, the problem I'm facing is the "Edit your database and add a new database for all virtual servers". How should I do that with the HSQL database? I tried to modify the xwiki_db.script under the database folder (adding a command to create a new schema), but it is overwritten every time I start the server with the "standart" SQL code. Thanks for any idea/suggestion

fburke | 14.09.2007 at 11:56 PM
The examples above show adding multipe virtual servers under one domain name (*.yourdomain.com); instead can we utilize virtual domains using different domain names (i.e., www.yourdomain.com and www.mydomain.com)? I assume this is possible since even Apache can support this, if so it would be helpfull to show an example of this configuration.

Attachments 0

No attachments for this document

Creator: brandone on 2007/01/25 11:35
This wiki is licensed under a Creative Commons license
1.3.2.9174