JBOSS 7.4 domain mode cluster on lxd container on Ubuntu 20.4

Posted by datahawklab on August 4, 2021

create base adopt openjdk image ubuntu 20.04 lxd

1
lxc launch ubuntu-minimal:focal openjdk

add required packages

1
2
3
4
5
lxc exec openjdk bash

apt-get update -y &&\
apt-get install wget unzip -y &&\
apt autoremove -y

add non root user to base container

1
2
3
4
lxc exec openjdk bash

useradd -d /home/servid -m -s /bin/bash -c "service id" servid &&\
echo -e "tublu1224\ntublu1224" | passwd servid

install adopt open JDK .bashrc on container

1
2
3
4
5
6
lxc shell openjdk

cd ~ &&\
rm -rf .bashrc &&\
wget http://192.168.1.176:8000/github/sample-code/eap-jdg-reference/jboss-eap-7.3/.bashrc . ;\
source .bashrc

install adopt open JDK on container

1
2
3
4
5
6
7
8
9
10
lxc shell openjdk


cd ~ &&\
rm -rf jdk8u292-b10-jre &&\
wget $wget http://192.168.1.176:8000/jdk-binaries/OpenJDK8U-jre_x64_linux_hotspot_8u292b10.tar.gz . ;\
tar xvf OpenJDK8U-jre_x64_linux_hotspot_8u292b10.tar.gz && \
rm -rf OpenJDK8U-jre_x64_linux_hotspot_8u292b10.tar.gz && \
java -version &&\
exit

publish base odopt open jdk base image

1
2
3
lxc stop openjdk &&\
lxc publish openjdk --alias baseopenjdk &&\
lxc delete openjdk

export JBOSS_HOME=/home/servidc/Downloads/jboss/jboss-eap-7.4.0/jboss-eap-7.4 &&
cd $JBOSS_HOME/bin &&
./add-user.sh

cd /home/servidc/Downloads/jboss/jboss-eap-7.4.0 &&
rm -rf jboss-eap-7.4.zip &&
zip -r jboss-eap-7.4.zip jboss-eap-7.4

prepare jboss 7.4 xml configuration files for domain mode

update the host.xml files

1
2
export JBOSS_HOME=/home/servidc/Downloads/jboss/jboss-eap-7.3.0/jboss-eap-7.3 &&\
cp $JBOSS_HOME/domain/configuration/host.xml $JBOSS_HOME/domain/configuration/host-slave-1.xml

update host-slave-1.xml

change name, domain-controller and secret in host-slave-1.xml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<host xmlns="urn:jboss:domain:16.0" name="slave1">
.....
....
    <domain-controller>
        <remote security-realm="ManagementRealm" username="jadmin">
            <discovery-options>
                <static-discovery name="primary" protocol="${jboss.domain.master.protocol:remote+http}" host="${jboss.domain.master.address}" port="${jboss.domain.master.port:9990}"/>
            </discovery-options>
        </remote>
    </domain-controller>
........
            <security-realm name="ManagementRealm">
                <server-identities>
                   <secret value="UGFzc3dvcmQx" />
                </server-identities>
                <authentication>
1
2
3
4
5
6
7
8
9
cp $JBOSS_HOME/domain/configuration/host-slave-1.xml $JBOSS_HOME/domain/configuration/host-slave-2.xml
cp $JBOSS_HOME/domain/configuration/host-slave-1.xml $JBOSS_HOME/domain/configuration/host-slave-3.xml

export JBOSS_HOME=/home/servidc/Downloads/jboss/jboss-eap-7.3 &&\
cd $JBOSS_HOME/bin &&\
./add-user.sh

# id: jadmin
# password: Password1

apply jboss patches

1
2
3
4
5
6
export JBOSS_HOME=/home/servidc/Downloads/jboss/jboss-eap-7.3 &&\
$JBOSS_HOME/bin/jboss-cli.sh --command="patch apply /home/servidc/Downloads/jboss/jboss-eap-7.3.8-patch.zip"

rm -rf $JBOSS_HOME/domain/configuration/domain_xml_history
rm -rf $JBOSS_HOME/domain/configuration/host_xml_history

refresh jboss zip file

1
2
3
cd /home/servidc/Downloads/jboss &&\
rm -rf jboss-eap-7.3.zip &&\
zip -r jboss-eap-7.3.zip jboss-eap-7.3

create base jboss 7.3 image from adopt open jdk image

launch base jboss container

1
2
3
lxc delete jboss73 --force ;\
lxc launch baseopenjdk jboss73 && \
lxc shell jboss73

install jboss binaries

1
2
3
4
5
6
cd ~ && \
rm -rf jboss-eap-7.3 &&\
wget http://192.168.1.176:8000/jboss/jboss-eap-7.3.zip . ;\
unzip -qq jboss-eap-7.3.zip && \
rm -rf jboss-eap-7.3.zip &&\
exit

install adopt open JDK .bashrc on container

1
2
3
4
5
6
lxc shell jboss73

cd ~ &&\
rm -rf .bashrc &&\
wget http://192.168.1.176:8000/github/sample-code/eap-jdg-reference/jboss-eap-7.3/.bashrc . ;\
source .bashrc

publish base jboss 7.3 image from adopt open jdk image

1
2
3
lxc stop jboss73 && \
lxc publish jboss73 --alias basejboss73 &&\
lxc delete jboss73

launch jboss cluster servers

lxc launch basejboss73 jboss73-master &&
lxc launch basejboss73 jboss73-slave1 &&
lxc launch basejboss73 jboss73-slave2 &&
lxc launch basejboss73 jboss73-slave3

get ip address of any running container

1
lxc list | grep jboss73 | awk -F"|" '{print $2 $4}' | awk -F"(" '{print $1 $2}' | awk '{print $1,$2}'
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
lxc shell jboss73-master

cd $JBOSS_HOME/bin && nohup ./domain.sh -Djboss.bind.address.management=10.115.6.78 -Djboss.bind.address=10.115.6.78 >/dev/null 2>&1 &

lxc shell jboss73-slave1
cd $JBOSS_HOME/bin && nohup ./domain.sh --host-config=host-slave-1.xml -Djboss.domain.master.address=10.115.6.78 -Djboss.bind.address.management=10.115.6.172 -Djboss.bind.address=10.115.6.172 >/dev/null 2>&1 &

lxc shell jboss73-slave2

lxc

lxc shell jboss73-slave3

cd $JBOSS_HOME/bin && nohup ./domain.sh --host-config=host-slave-3.xml -Djboss.domain.master.address=10.115.6.78 -Djboss.bind.address.management=10.115.6.203 -Djboss.bind.address=10.115.6.203 >/dev/null 2>&1 &

http://10.115.6.78:9990

delete jboss cluster servers

lxc shell jboss73-slave1

1
2
3
4
lxc delete jboss73-master --force &&\
lxc delete jboss73-slave1 --force &&\
lxc delete jboss73-slave2 --force &&\
lxc delete jboss73-slave3 --force

http://10.115.6.214:9990/management

http://10.115.6.78:8080/helloworld-rs-7.3.8.GA/text/xml