= How to ... setup a Hive server = This page gives you instructions about how to setup and run a Hive server. == Certificate and Authentication == * Follow the documentation on [[Documentation/DevelopmentCenter/Develop Services|service development]] * Notes on using SQL Server 2008 R2: * In the connection string the `.\SQLEXPRESS` should be changed to `.` . For example in the command to create the ASP.NET authentication database: `aspnet_regsql.exe -C "data source=.;Integrated Security=SSPI" -A all -d HeuristicLab.Authentication`. * If the above mentioned command fails with a timeout, the error could be a compatibility problem between the 2005 and 2008R2 SQL Server versions. SQL Server Management Studio offers the option in the database properties to set the compatibility level to SQL Server 2005 and this should fix the problem. * Goto Windows Services > start `Distributed Transaction Coordinator` service (needed to use transactions over multiple databases) == Setup IIS == * In the Server Manager (or on Windows 8 and beyond in ''Programs and Features'' and then ''Turn Windows features on or off'') add `Non-HTTP Activation` in the Add Features Wizard under `.NET Framework 3.5.1 Features` * Go to Windows Services and start `NetTcpActivator` and `NetTcpPortSharing` services * Open IIS Manager * Create an application pool (Hive-3.3, .net 4.x, integrated) * Open advanced settings of the application pool and select `NetworkService` as identity (if you don't have your own identities for IIS `AppPools`) * Set `Disable Overlapping Recycle` to true. This avoids that multiple `AppDomains` are created which causes problems in Hive-3.3. * Create a new website (or use an existing one) * Go to bindings of the website. * Add a http-binding with port 80. * Add a net.tcp-binding with port 808 (Binding information: `808:*`) * Create a new application within the website and call it Hive-3.3 and use the already created appPool Hive-3.3 * Open advanced settings of the application and enter `http, net.tcp` as enabled protocols * Grant the usergroup `IIS_IUSRS` read-permissions on the application directory * Grant the `NETWORK SERVICE` group read access to the certificate you created in UsersHowtosDevelopServices * For the charting to work in the Status.aspx page, a folder for caching the images has to be created. The default, as configured in the `Web.config`, is `C:\TempImageFiles\`. Note that `Network Service` must have read and write permissions to this folder. * Allow port 808 in Firewall * For Windows Firewall enable `Windows Communication Foundation Net.TCP Listener Adapter (TCP-In)` Rule in `Inbound Rules` == Add groups and users to the authentication db == * Open the Hive Visual Studio solution * Click on the Hive-3.3 Web project. In the solution explorer the ASP.NET Configuration button shows up. As mentioned in UsersHowtosDevelopServices this allows to configure users and groups. On the configuration website, first add the groups: * Hive Administrator * Hive Slave * Hive User * Hive `IsAllowedPrivileged` * Users can now be added to the appropriate groups. * A special user for hive slaves must be added. This user has to be in the `Hive Slave` group. The default configuration is * User: `hiveslave` * Password: `hiveslave` == Webservice client setup == * All clients (slave, administration, experiment manager) have an `app.config` file which contains a `certificate` tag under ``. To get this value for the local server execute `svcutil.exe http://localhost/Hive-3.3/HiveService.svc?wsdl`. This generates the client stub for the hive webservice. In the `output.config` file you will find the `certificate` tag with the right value. Replace all keys in the hive clients with this key of your machine. == Setup Hive database == * Open the SQL Server Configuration Manager. * If the Configuration Manager displays `Remote Procedure call failed`, install SQL Service Pack 1 (http://www.microsoft.com/en-us/download/details.aspx?id=26727). * Right click the `SQL Server (MSSQLSERVER)` and select properties. * In the Filestream Tab enable `Filestream for Transact-SQL access` and `Filestream for file I/O streaming access`. * Restart the service. * Open the SQL Server Management Studio and create a new database called `HeuristicLab.Hive-3.3` * Open a new Query and enter the commands: {{{ EXEC sp_configure filestream_access_level, 2 GO RECONFIGURE GO }}} * Go to the Properties of the new Database. * Select the `Filegroup` page and add a new Filestream called `FileStream` and use it as `default`. * Go to the `Files` page and add a new file `HeuristicLab.Hive-3.3_FileStream` with type `Filestream` and the Filegroup `FileStream` you created in the previous step. Set the Path where `HeuristicLab.Hive-3.3` database is located. * In the `Options` page set `Recovery model`(at the top) to `Simple` and `Auto Shrink` to `True`. * Use the SQL Server Management Studio to open and execute the following two scripts in this order: * `Initialize Hive Database.sql` * `Prepare Hive Database.sql` * If you have already installed an older Hive-Server version (< 3.3.x) and want to keep your data while updating to a newer version, execute `Migrate to Filestream.sql` instead. You have to execute the previous steps to enable the Filestream before executing the migration script. * All scripts can be found in `HeuristicLab.Services.Hive.DataAccess\3.3\SQL Scripts\` * Use the SQL Server Management Studio to create a new login for the `NETWORK SERVICE` group (or the identity you defined when creating the application pool): In Object Explorer: Security -> Logins -> right click (New Login...). Next you have to add the login to the two created `HeuristicLab` databases (`HeuristicLab.Hive-3.3`, `HeuristicLab.Authentication`) in the `Users` section (in Object Explorer: Databases -> !HeuristicLab.* -> Security -> Users -> right click (New User...)). == Setup Access Service database == Hive uses HeuristicLab's Access Service. This service is a wrapper around ASP.NET's authentication service and provides besides user management also client management functionality. Hive directly uses the Access Service's assemblies, so you don't have to set up the Access service, but you need to create the database: * Use the SQL Server Management Studio to open and execute the following three scripts in this order (located in HeuristicLab.Services.Access.DataAccess\3.3\SQL Scripts\): * `Create AccessServiceDB.sql` * `Initialize AccessServiceDB.sql` * `Create Initial Values.sql` * Add the user `NETWORK SERVICE` (or the identity you defined when creating the application pool) to the database: in the `Users` section (in Object Explorer: Databases -> HeuristicLab.AccessService -> Security -> Users -> right click (New User...) give the new user at least read and write access. == Install the Janitor Service == There are some tasks on the server that have to be executed periodically. Previously this logic was executed with the heartbeats that the slaves sent. Because this lead to performance problems there is now an own windows service with an installer. The installer is created with the NSIS (Nullsoft Scriptable Install System). Download and install NSIS from http://nsis.sourceforge.net/. The installer scripts are located in the `Installers` directory in the source tree. Right-click on the file `HiveJanitorServiceInstaller.nsi` and select ''Compile NSIS Script''. If everything works, you get, in the same directory, a file called ''HeuristicLab Hive Janitor Service Installer.exe''. You can now copy and install this file on your server. Please note that you have to compile the HeuristicLab Services solution before as the installer just takes the binaries and creates the installer out of them. You can open *.nsi files with a text editor to see what's actually happening. You can also find there, at the beginning of the file, that BUILDCONFIGURATION is set to Debug. If you want to package Release binaries change this in the nsi file and rebuild the Services solution using Release mode. == Problems and solutions == * Exception `Could Not Load Type System.ServiceModel.Activation.HttpModule` * run `aspnet_regiis.exe -iru` * "HTTP-Fehler 500.19 - Internal Server Error: Dieser Konfigurationsabschnitt kann in diesem Pfad nicht verwendet werden. Dies ist der Fall, wenn der Abschnitt auf übergeordneter Ebene gesperrt ist. Die Sperrung erfolgt standardmäßig (overrideModeDefault="Deny") oder wird explizit mit einem location-Tag mit overrideMode="Deny" oder der Legacyeinstellung allowOverride="false" festgelegt." {{{ Konfigurationsquelle 139: 140: 141: }}} * Open Visual Studio command prompt as administrator and go to `%windir%\system32\inetsrv\config` * Enter "`notepad applicationHost.config`" * Search for the line {{{
}}} * Change `overrideModeDefault` to `Allow`. == How to update Hive server == Updating the server is as simple as copying the new binaries into the ''"/bin"'' folder of the website. Of course changes to the database need to be done accordingly. It is no problem if there are slaves calculating during the update if it takes only a few seconds. If the update lasts longer than one minute (''"!SlaveHeartbeatTimeout"'') the slaves will be identified to be timed out as the server goes online again and their jobs will be lost. == Changing the URL of the Hive server == The default URL for Hive is http://services.heuristiclab.com/Hive-3.3/HiveService.svc. If you are building your own Hive server, you need to change this URL as well as the certificate string in all configuration files. This has to be done for * the server in the Web.config * for the !HeuristicLab.Clients.Hive-3.3 project in the app.config (client endpoint) * and the !HeuristicLab.Clients.Hive.Slave-3.3 project in the app.config (client endpoint) After this change you have to recompile everything. The slave as well as the Job Manager and Administrator should now connect to your Hive server. == Hive Web Site == You can setup a web site (WebApp) that can show you more information about Hive's state (which jobs are currently calculting, how many jobs are in the queue,...). For more information have a look at [[Documentation/Howto/SetupHiveStatistics| Hive Statistics Setup]].