2

I am deploying symmetricds on google container engine, so i have build symmetricds war file and create docker tomcat image like below :-

FROM tomcat
ENV JAVA_OPTS="-Dcom.sun.management.jmxremote.port=1109 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false"
ENV CATALINA_OPTS="-Dcom.sun.management.jmxremote.port=1109 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false"

ADD ./symmetric-ds.war /usr/local/tomcat/webapps/
ADD ./mysql-connector-java-5.1.30.jar /usr/local/tomcat/lib/
COPY ./context.xml /usr/local/tomcat/conf/context.xml
COPY ./server.xml /usr/local/tomcat/conf/server.xml
COPY ./tomcat-users.xml /usr/local/tomcat/conf/tomcat-users.xml

RUN sh -c 'touch /usr/local/tomcat/webapps/symmetric-ds.war'
VOLUME /usr/local/tomcat/webapps/
EXPOSE 8080 1109

and after that i have push it to repository and i am using kubernetes to deploy it. my kubernetes yml file is below :-

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: symserver
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: symserver
    spec:
      containers:
      - name: symserver
        image: symserver:v1
        ports:
        - containerPort: 8080
        - containerPort: 1109
---
apiVersion: v1
kind: Service
metadata:
  name: symserver
spec:
  selector:
    app: symserver
  type: LoadBalancer
  ports:
  - port: 8080
  - port: 1109

I have two problems for which i am looking for solution :-

  1. As docker images are read only whatever properties i have defined in symmetricds.properties (which will be part of war file and war file be inside tomcat and i named tomcat image as symserver for docker ) file are fixed and read only. like

    sync.url=http://$(hostName):8080/symmtric-ds/sync/$(engineName)

when i deploy it to google cloud i get different ip for pods and service external link. so how to solve this problem ? as i have to set this ip in symmetricds.properties file so my other store node can connect to it. and when i restart the server then it 'symmetricds' will again pickup new ip or same ip again from file.

  1. How to use JMX in case of docker and kubernetes, i have added JMX option in build file but somehow i am not able to connect it using jconsole. I have exposed port 1109 to local machine using port forward command.
Anchit Pancholi
  • 1,174
  • 4
  • 14
  • 40

1 Answers1

2

symmetricds.properties file has either to be packed outside of the war file and then manipulated before starting the server so the placeholders could be replaced with concrete values or use the notation ${env.variable.value} and try seeing if Spring replaces them with environment variables

To externalize the file symmetricds.properties add this section to the file WEB-INF\web.xml

<context-param>
    <param-name>multiServerMode</param-name>
    <param-value>true</param-value>
</context-param>

store the file on the file system in a directory, let's say /opt/symm/ and set the java system property symmetric.engines.dir to the value of the directory path

Boris Pavlović
  • 63,078
  • 28
  • 122
  • 148
  • as i am using google cloud with kubernetes i dont know how can i get ip address before pods or service started ? i dont know if there is a way to get that before service start. how can i point symmetricds.properties out side of war ? how to do this ? can you point me any doc for this. – Anchit Pancholi Oct 11 '16 at 14:20
  • i have tried but its not working. I have build war using `symadmin -p symmtricds.properties create-war symmetric-ds.war` and put this in tomcat and start by setting environment. its giving `AbstractCommandLauncher - Failed to load ./conf/symmetric-server.properties. File does not exist.` and its picking data from file which used to generate war file not the file which is present in environment variable location, Did i missed something. I have enable the setting web.xml as well – Anchit Pancholi Oct 12 '16 at 16:34
  • maybe you should build your own maven war project to build it properly – Boris Pavlović Oct 12 '16 at 17:25