5

We have started a new project that uses marklogic to store documents. To get the app running, we need to create a database, a forest, new users and setup an XDBC server. It is quite easy to do it from the web admin tool provided by Marklogic, but to run it from a continuous integration server we need to automate it. Is there any way to do it from the command line (like the sqlcmd.exe for sqlserver or sql plus in oracle) ??

uttamkini
  • 508
  • 5
  • 12

2 Answers2

5

As long as you are using MarkLogic 5.x, the easiest thing to do would be to use the Configuration Manager. This web based tool allows you to export the entire DB and app server configuration to a single xml file which can be version controlled. It can also then be imported to completely setup or reconfigure your MarkLogic instance.

In order to use this as part of continuous integration, you would have to script the import of the configuration. You could create an http server that has one endpoint which invokes the configuration API to do the loading, as documente here: http://community.marklogic.com/pubs/5.0/apidocs/package-api.html. This https based service could easily be invoked via ANT or any other CI tool.

Alternatively, especially if you are not yet running on 5.x, you could script the entire process instead of using a configuration package. All of the admin tasks are documented here: http://community.marklogic.com/pubs/5.0/books/adminAPI.pdf. You would then have to write all of the code necessary to configure your database, app servers, etc. and then expose it via an http server as described above.

Clark Richey
  • 382
  • 1
  • 10
  • Thanks for the link. we are using 5.x. For a start I tried importing the app server into an xml and I got an a package xml. The next step was to actually install the package. I used package:install(fn:doc("/xdbcserver.xml"))..... The problem is that the file with the uri /xdbcserver.xml is expected to be present in the database. This means that somebody has to manually put it in there. It is kind of contradictory to the purpose of automating the configuration. I would like a function which loads the package from the client filesystem rather than an existing doc in the DB.Any hints?Thanks again – uttamkini Apr 09 '12 at 19:07
1

Thanks to Clark Richey's help, I might have found out a way of automating the configuration of the MarkLogic server 5.x (though by no means straightforward).

For example if you want to automate the creation of an xdbc server, Go the query console of an instance where a manually configured xdbc server exists.Use the following xquery to generate a package file for the xdbc server(in my case called sample-server).

import module namespace package = "http://marklogic.com/package/package" at "/MarkLogic/package/package.xqy";

let $my-package := package:create()

return package:add-appserver($my-package, "Default", "sample-server")

You would now see a package xml which contains all the information needed to create and configure the xdbc server. Save this in a file or on your clipboard. Now go to the query console of the marklogic instance that you want to configure. Use the following xquery to actually install it on the instance.

import module namespace package = "http://marklogic.com/package/package" at "/MarkLogic/package/package.xqy";

let $package := {paste the package xml you saved in file/clipboard step1}

return package:install($package)

You will now a get an xml result which says that the package has been written.

Now for the all important step of automating this in my CI environment. I would write a an custom ant/nant task (or in my specific case a powershell cmdlet) which reads the configuration file from a file system, connects to ML using XCC (and admin credentials, because stuff like creating databases and app servers need it) and then executes the very same xquery defined above. I can then version control the configuration file in my source control and that way I can automate the creation/configuration of databases on a fresh install of ML without any manual intervention. Any other better ways of doing it ??

Community
  • 1
  • 1
uttamkini
  • 508
  • 5
  • 12
  • So that you know, there are a set of ant taks for MarkLogic on github http://developer.marklogic.com/code/ant-tasks – derickson Apr 11 '12 at 01:27
  • 3
    The configuration management application also provide a packaging REST interface. There is a url for POST-ing a package for installation. More details here: http://community.marklogic.com/pubs/5.0/apidocs/packageREST.html – grtjn Apr 12 '12 at 05:51