Introduced in Feature Pack 3

Configuring the server deployment process

Introduced in Feature Pack 3 You have created a deployment package in previous lessons that can now be deployed onto a Windows and DB2 runtime environment. In this lesson, you install the package onto your runtime machine, configure the deployment settings, and then run the deployment script.

Procedure

  1. Install the server deployment package.

    Before the deployment process can be run, you must copy the deployment package from the development machine where it was built to the runtime machine where the deployment is run.

    1. Create the following directory on your runtime machine:
      • WCBD_deploy_server_common_dir
    2. Extract the contents of WCDE_installdir/wcbd/dist/server/wcbd-deploy-server-warranty.zip into the WCBD_deploy_server_common_dir directory.
  2. Configure the server deployment settings.

    The next step in deployment is to configure a properties file that contains information such as software installation paths and important information about your WebSphere Commerce server. You also use this file to specify which modules to deploy.

    1. Navigate to the following directory:
      • WCBD_deploy_server_common_dir
    2. Copy the contents from wcbd-deploy.properties.template to deploy-warranty.properties, wcbd-deploy.private.properties.template to deploy-warranty.private.properties, and wcbd-setenv.bat.template to setenv.bat.
    3. Open setenv.bat. Modify the ANT_HOME and WAS_HOME environmental properties to the correct values. For example:
      
      ANT_HOME=C:\apache-ant-1.8.2
      WAS_HOME=C:\WebSphere\AppServer
      
    4. Save your changes and close the file.
    5. Open deploy-warranty.properties. Set the following properties according to the configuration of your target server:
      Note: If necessary, see WC_installdir/instances/instance_name/properties/createInstance.properties and WAS_installdir/profiles/WAS_profile_name/properties/portdef.props to obtain the correct values for your configuration.
      
      existing.web.module.list=LOBTools,Stores
      wc.home=<WC_home> (e.g. C:/WebSphere/CommerceServer70)
      wc.instance.name=<WC_instance_name> (e.g. demo)
      was.home=<WAS_home> (e.g. C:/WebSphere/AppServer)
      was.profile.name=<WAS_profile_name) (e.g. demo)
      was.host.list=<Host name of the machine where deployment is to be performed)
      was.port=<WAS_SOAP_port> (e.g. 9066)
      was.jvm.max.memory=1024M
      db.type=db2
      db.name=<DB_name> (e.g. mall)
      db.schema.name=<DB_schema> (e.g. the database user name)
      jdbc.url=<DB_JDBC_URL> (e.g. jdbc:db2://test.com:50000/mall)
      jdbc.driver=com.ibm.db2.jcc.DB2Driver
      jdbc.driver.path=<DB_JDBC_Driver> (e.g. C:/WebSphere/SQLLIB/java/db2jcc4.jar;C:/WebSphere/SQLLIB/java/db2jcc_license_cu.jar)
      datasource.jndi.name=jdbc/WebSphere Commerce DB2 DataSource ${wc.instance.name}
      static.web.deploy=false
      run.wc.server.sync=false
      
    6. Append the following properties used for deploying WebSphere Commerce search customization. In the section at the bottom of the file specifically for customization, insert the following snippet:
      Note: Verify that these values are correct for your environment.
      
      solr.home=${wc.home}/instances/${wc.instance.name}/search/solr/home
      solr.preprocess.dir=${wc.home}/instances/${wc.instance.name}/search/pre-processConfig
      master.catalog=<catalog_id>
      solr.locale=en_US
      solr.profile=${wc.instance.name}_solr
      solr.instance=solrServer
      solr.server.port=3737
      plugin.home=C:/WebSphere/Plugins
      solr.http.port=9080
      solr.https.port=9443
      db.vendor=DB2
      
    7. Save your changes and close the file.
    8. Open deploy-warranty.private.properties.
    9. Set the correct user names and passwords.
    10. Save your changes and close the file.
  3. Customize the script for workspace and search deployment.
    The WebSphere Commerce Build and Deployment tool does not support workspace deployment or the deployment of customized search files by default. Therefore, anew file is created called warranty-deploy-common.xml that contains Ant targets.The wcbd-deploy.xml file is modified to use the new warranty-deploy-common.xml file.
    1. Create the following Ant build file:
      • WCBD_deploy_server_common_dir/warranty-deploy-common.xml
    2. Insert the following content into the file:
      
      <?xml version="1.0" encoding="UTF-8"?>
      
      <project name="warranty-deploy-common">
      
      	<import file="${basedir}/wcbd-deploy-common.xml" />
      
      	<!-- Determine the command suffix -->
      	<condition property="cmd.suffix" value=".bat">
      		<os family="windows"/>
      	</condition>
      	<condition property="cmd.suffix" value=".sh">
      		<os family="unix" />
      	</condition>
      	
      	<!-- Determine the command prefix -->
      	<condition property="cmd.prefix" value="./">
      		<os name="Linux" />
      	</condition>
      	<condition property="cmd.prefix" value="">
      		<os family="windows" />
      	</condition>
      	<condition property="cmd.prefix" value="">
      		<os family="unix" />
      	</condition>
      
      	<target name="UpdateWorkspaceSchema">
      		 <exec executable="${cmd.prefix}config_ant${cmd.suffix}" dir="${wc.home}/bin">
      			<arg value="-buildfile"/>
      			<arg value="${wc.home}/components/Workspaces/xml/updateWorkspacesSchema.xml"/>
      			<arg value="-DinstanceName=${wc.instance.name}"/>
      			<arg value="-DresourceXMLLocation=${was.home}/profiles/${wc.instance.name}/installedApps/WC_${wc.instance.name}_cell/WC_${wc.instance.name}.ear/xml"/>
      			<arg value="-DdbaPassword=${db.user.password}"/>
      			<arg value="CM_updateWorkspacesSchema"/>
      		 </exec>
      	</target>
      
      	<target name="CopyCatalogWorkspaceConfig">
      	    <echo>For Warranty: Copy  com.ibm.commerce.catalog.resource-managers-ext.xml into Commerce installation dir</echo>
      		<copy file="${full.ear.dir}/xml/content-management/com.ibm.commerce.catalog.resource-managers-ext.xml" todir="${wc.home}/instances/${wc.instance.name}/xml/content-management" overwrite="true"/>
      	</target>
      
      <taskdef name="evalXPath" classname="com.ibm.commerce.wc.update.utils.EvalXPathTask" classpath="lib/XMLUpdate.jar" />
      	<taskdef name="xmlUpdate" classname="com.ibm.commerce.wc.update.utils.XMLUpdateTask" classpath="lib/XMLUpdate.jar" />
      	
      	<target name="Edit-Solr-Schema">
      		<xmlUpdate dir="${solr.home}/MC_${master.catalog}/${solr.locale}/CatalogEntry/conf">
      			<![CDATA[<xml-update>
      			<file input="schema.xml" indent="true">
      				<action type="insertAfter"
              					path="/schema/fields/field[last()]">
      					<field name="warterm" type="wc_text" indexed="true" stored="true" multiValued="false" />
      					<field name="wartype" type="wc_text" indexed="true" stored="true" multiValued="false" />
      					<field name="careinstruction" type="wc_text" indexed="true" stored="true" multiValued="false" />
      				</action>
      			</file>
      		</xml-update>]]>
              </xmlUpdate>
          </target>
      	<target name="Edit-DIH-Config">
      		<evalXPath file="${solr.home}/MC_${master.catalog}/${solr.locale}/CatalogEntry/conf/wc-data-config.xml" xPath="/dataConfig/document[@name='CatalogEntry']/entity[@name='Product']/@query" property="query" />
      		<!-- Learn more about this task in the Ant manual -->
      		<loadresource property="newQuery">
      			<propertyresource name="query" />
      			<filterchain>
      				<replacestring from="SELECT " to="SELECT XWARRANTY.WARTERM,XWARRANTY.WARTYPE,XCAREINSTRUCTION.CAREINSTRUCTION, " />
      				<replacestring from="WHERE " to="LEFT OUTER JOIN XWARRANTY ON (CATENTRY.CATENTRY_ID=XWARRANTY.CATENTRY_ID)
      								  LEFT OUTER JOIN XCAREINSTRUCTION ON (CATENTRY.CATENTRY_ID=XCAREINSTRUCTION.CATENTRY_ID AND XCAREINSTRUCTION.LANGUAGE_ID=-1) WHERE " />
      			</filterchain>
      		</loadresource>
      		<xmlUpdate dir="${solr.home}/MC_${master.catalog}/${solr.locale}/CatalogEntry/conf">
      			<![CDATA[<xml-update>
      			<file input="wc-data-config.xml" indent="true">
      				<action type="setAttribute"
      			        		path="/dataConfig/document[@name='CatalogEntry']/entity[@name='Product']" name="query" value="${newQuery}" />
      				<action type="insertAfter"
              					path="/dataConfig/document[@name='CatalogEntry']/entity[@name='Product']/field[last()]">
      					<field column="WARTERM" name="warterm" />
      					<field column="WARTYPE" name="wartype" />
      					<field column="CAREINSTRUCTION" name="careinstruction" />
      				</action>
      			</file>
      		</xml-update>]]>
              </xmlUpdate>
      	</target>
      
      	<target name="Update_Plugin_Config_For_Solr">
      		<propertyregex property="shortHostname" input="${was.host.list}" 
                  regexp="([^\.]+)\.(.+)" 
                  select="\1"
                  defaultvalue="Error"
                  override="true"/>
                  
      		<!-- Update ${was.home}/profiles/${wc.instance.name}/config/cells/WC_${wc.instance.name}_cell/nodes/WC_${wc.instance.name}_node/servers/webserver1/plugin-cfg.xml -->
      		<xmlUpdate dir="${was.home}/profiles/${wc.instance.name}/config/cells/WC_${wc.instance.name}_cell/nodes/WC_${wc.instance.name}_node/servers/webserver1">
      			<![CDATA[<xml-update>
      				<file input="plugin-cfg.xml"
      						indent="true">
      					<action type="appendChild" path="/Config">
      						<!-- for Search solr server -->
      						<VirtualHostGroup Name="VH_${wc.instance.name}_search">
      							<VirtualHost Name="${was.host.list}:${solr.server.port}"/>
      							<VirtualHost Name="${shortHostname}:${solr.server.port}"/>
      						</VirtualHostGroup>
      						<ServerCluster CloneSeparatorChange="false" GetDWLMTable="false"
      							IgnoreAffinityRequests="true" LoadBalance="Round Robin"
      							Name="${solr.instance}_${wc.instance.name}_search_node_Cluster" PostBufferSize="64"
      							PostSizeLimit="-1" RemoveSpecialHeaders="true" RetryInterval="60">
      							<Server ConnectTimeout="0" ExtendedHandshake="false"
      								MaxConnections="-1" Name="${wc.instance.name}_search_node_${solr.instance}"
      								ServerIOTimeout="0" WaitForContinue="false">
      								<Transport Hostname="${was.host.list}" Port="${solr.http.port}" Protocol="http"/>
      								<Transport Hostname="${was.host.list}" Port="${solr.https.port}" Protocol="https">
      									<Property Name="keyring" Value="${plugin.home}/config/solrWebserver/plugin-key.kdb"/>
      									<Property Name="stashfile" Value="${plugin.home}/config/solrWebserver/plugin-key.sth"/>
      								</Transport>
      							</Server>
      						</ServerCluster>
      						<UriGroup Name="VH_${wc.instance.name}_search_${solr.instance}_${wc.instance.name}_search_node_Cluster_URIs">
      							<Uri AffinityCookie="JSESSIONID"
      								AffinityURLIdentifier="jsessionid" Name="/solr/*"/>
      						</UriGroup>
      						<Route ServerCluster="${solr.instance}_${wc.instance.name}_search_node_Cluster"
      							UriGroup="VH_${wc.instance.name}_search_${solr.instance}_${wc.instance.name}_search_node_Cluster_URIs" VirtualHostGroup="VH_${wc.instance.name}_search"/>
      					</action>
      				</file>
      			</xml-update>]]>
      		</xmlUpdate>	
      	</target>
      	
      	<target name="setup-Search">
      		<exec executable="C:/WebSphere/CommerceServer70/components/foundation/subcomponents/search/bin/setupSearchIndex.bat">
      			<arg value="-masterCatalogId"/>
      			<arg value="${master.catalog}"/>
      			<arg value="-instance"/>
      			<arg value="${wc.instance.name}"/>
      			<arg value="-dbuser"/>
      			<arg value="${db.user.name}"/>
      			<arg value="-dbuserpwd"/>
      			<arg value="${db.user.password}"/>
      		</exec>
      	</target>
      	
      <target name="preprocess">
      		<exec dir="${wc.home}/bin" executable="di-preprocess.bat">
      			<arg value="${solr.preprocess.dir}/MC_${master.catalog}/${db.vendor}/"/>
      			<arg value="-instance"/>
      			<arg value="${wc.instance.name}"/>
      			<arg value="-dbuser"/>
      			<arg value="${db.user.name}"/>
      			<arg value="-dbuserpwd"/>
      			<arg value="${db.user.password}"/>
      		</exec>
      	</target>
      	
      	
      	<target name="build-index">
      		<exec dir="${wc.home}/bin" executable="di-buildindex.bat">
      			<arg value="-instance"/>
      			<arg value="${wc.instance.name}"/>
      			<arg value="-masterCatalogId"/>
      			<arg value="${master.catalog}"/>
      			<arg value="-dbuser"/>
      			<arg value="${db.user.name}"/>
      			<arg value="-dbuserpwd"/>
      			<arg value="${db.user.password}"/>
      		</exec>
      	</target>
      	
      		
      	<target name="startSolrServer">
                      <exec dir="${was.home}/profiles/${solr.profile}/bin"
                              executable="${was.home}/profiles/${solr.profile}/bin/serverStatus.bat"
                              outputproperty="serverStatusOutput">
                          <arg line="${solr.instance}" />
                      </exec>
              <if>
                  <contains string="${serverStatusOutput}" substring="ADMU0509I" />
                  <then>
                      <exec dir="${was.home}/profiles/${solr.profile}/bin"
                              executable="${was.home}/profiles/${solr.profile}/bin/startServer.bat">
                          <arg line="${solr.instance}" />
                      </exec>
                  </then>
              </if>
          </target>
      
      
          <target name="stopSolrServer">
      
                      <exec dir="${was.home}/profiles/${solr.profile}/bin"
                              executable="${was.home}/profiles/${solr.profile}/bin/stopServer.bat">
                          <arg line="${solr.instance}" />
                      </exec>
      
          </target>
      	
      	<target name="restartSolrServer">
              <antcall target="stopSolrServer" />
              <antcall target="startSolrServer" />
          </target>
      	
      	<target name="restartWebServer">
      				<exec executable="cmd">
      					<arg value="/c"/>
      					<arg value="iisreset /noforce ${host.name}"/>
      				</exec>
      	</target>
      	<target name="restartServer">
              <antcall target="stopServer" />
              <antcall target="startServer" />
          </target>
      	
      	<target name="startServer">
              <if>
                  <istrue value="${wasGlobalSecurityEnabled}" />
                  <then>
                      <exec dir="${was.home}/profiles/${was.profile.name}/bin"
                              executable="${was.home}/profiles/${was.profile.name}/bin/serverStatus.bat"
                              outputproperty="serverStatusOutput">
                          <arg line="server1 -username ${was.user} -password ${was.password}" />
                      </exec>
                  </then>
                  <else>
                      <exec dir="${was.home}/profiles/${was.profile.name}/bin"
                              executable="${was.home}/profiles/${was.profile.name}/bin/serverStatus.bat"
                              outputproperty="serverStatusOutput">
                          <arg line="server1" />
                      </exec>
                  </else>
              </if>
              <if>
                  <contains string="${serverStatusOutput}" substring="ADMU0509I" />
                  <then>
                      <exec dir="${was.home}/profiles/${was.profile.name}/bin"
                              executable="${was.home}/profiles/${was.profile.name}/bin/startServer.bat">
                          <arg line="server1" />
                      </exec>
                  </then>
              </if>
          </target>
      
      
          <target name="stopServer">
      
                      <exec dir="${was.home}/profiles/${was.profile.name}/bin"
                              executable="${was.home}/profiles/${was.profile.name}/bin/stopServer.bat">
                          <arg line="server1 -username ${was.user} -password ${was.password}" />
                      </exec>
      
          </target>
      
      
      </project>
      
    3. Save your changes and close the file.
    4. Open wcbd-deploy.xml.
      Change the following line:
      
      import file="${basedir}/wcbd-deploy-common.xml"
      
      To:
      
      import file="${basedir}/warranty-deploy-common.xml"
      
    5. Find the deploy target named and add the following lines after <antcall target="clean.working.dir" />:
      
      <!--CUSTOMIZATION TARGETS-->
      		<antcall target="UpdateWorkspaceSchema" />
      		<antcall target="CopyCatalogWorkspaceConfig" />
      		<antcall target="setup-Search" />
      		<antcall target="Edit-Solr-Schema" /> 
      		<antcall target="Edit-DIH-Config" /> 
      		<antcall target="Update_Plugin_Config_For_Solr" />
      		<antcall target="restartWebServer" />
      		<antcall target="restartSolrServer" /> 
      		<antcall target="restartServer" />
      		<antcall target="preprocess" /> 
      		<antcall target="build-index" /> 
      
    6. Save your changes and close the file.