Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Separate out session DB into a different RDS instance #178

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 90 additions & 0 deletions common/deployment/setup/resources/createSessionDB.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
create database SESSION_DB;

use SESSION_DB;

CREATE TABLE IF NOT EXISTS IDN_AUTH_SESSION_STORE (
SESSION_ID VARCHAR (100) NOT NULL,
SESSION_TYPE VARCHAR(100) NOT NULL,
OPERATION VARCHAR(10) NOT NULL,
SESSION_OBJECT BLOB,
TIME_CREATED BIGINT,
TENANT_ID INTEGER DEFAULT -1,
EXPIRY_TIME BIGINT,
PRIMARY KEY (SESSION_ID, SESSION_TYPE, TIME_CREATED, OPERATION)
)DEFAULT CHARACTER SET latin1 ENGINE INNODB;

CREATE TABLE IF NOT EXISTS IDN_AUTH_TEMP_SESSION_STORE (
SESSION_ID VARCHAR (100) NOT NULL,
SESSION_TYPE VARCHAR(100) NOT NULL,
OPERATION VARCHAR(10) NOT NULL,
SESSION_OBJECT BLOB,
TIME_CREATED BIGINT,
TENANT_ID INTEGER DEFAULT -1,
EXPIRY_TIME BIGINT,
PRIMARY KEY (SESSION_ID, SESSION_TYPE, TIME_CREATED, OPERATION)
)DEFAULT CHARACTER SET latin1 ENGINE INNODB;

CREATE TABLE IF NOT EXISTS IDN_AUTH_USER_SESSION_MAPPING (
ID INTEGER NOT NULL AUTO_INCREMENT,
USER_ID VARCHAR(255) NOT NULL,
SESSION_ID VARCHAR(255) NOT NULL,
CONSTRAINT USER_SESSION_STORE_CONSTRAINT UNIQUE (USER_ID, SESSION_ID),
PRIMARY KEY (ID))DEFAULT CHARACTER SET latin1;

CREATE TABLE IF NOT EXISTS IDN_AUTH_SESSION_APP_INFO (
SESSION_ID VARCHAR (100) NOT NULL,
SUBJECT VARCHAR (100) NOT NULL,
APP_ID INTEGER NOT NULL,
INBOUND_AUTH_TYPE VARCHAR (255) NOT NULL,
PRIMARY KEY (SESSION_ID, SUBJECT, APP_ID, INBOUND_AUTH_TYPE)
)DEFAULT CHARACTER SET latin1 ENGINE INNODB;

CREATE TABLE IF NOT EXISTS IDN_AUTH_SESSION_META_DATA (
SESSION_ID VARCHAR (100) NOT NULL,
PROPERTY_TYPE VARCHAR (100) NOT NULL,
VALUE VARCHAR (255) NOT NULL,
PRIMARY KEY (SESSION_ID, PROPERTY_TYPE, VALUE)
)DEFAULT CHARACTER SET latin1 ENGINE INNODB;

CREATE TABLE IF NOT EXISTS IDN_AUTH_USER (
USER_ID VARCHAR(255) NOT NULL,
USER_NAME VARCHAR(255) NOT NULL,
TENANT_ID INTEGER NOT NULL,
DOMAIN_NAME VARCHAR(255) NOT NULL,
IDP_ID INTEGER NOT NULL,
PRIMARY KEY (USER_ID),
CONSTRAINT USER_STORE_CONSTRAINT UNIQUE (USER_NAME, TENANT_ID, DOMAIN_NAME, IDP_ID)
)DEFAULT CHARACTER SET latin1;

CREATE TABLE IF NOT EXISTS IDN_AUTH_WAIT_STATUS (
ID INTEGER AUTO_INCREMENT NOT NULL,
TENANT_ID INTEGER NOT NULL,
LONG_WAIT_KEY VARCHAR(255) NOT NULL,
WAIT_STATUS CHAR(1) NOT NULL DEFAULT '1',
TIME_CREATED TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
EXPIRE_TIME TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (ID),
CONSTRAINT IDN_AUTH_WAIT_STATUS_KEY UNIQUE (LONG_WAIT_KEY)
)DEFAULT CHARACTER SET latin1 ;

-- IDN_AUTH_SESSION_STORE --
CREATE INDEX IDX_IDN_AUTH_SESSION_TIME ON IDN_AUTH_SESSION_STORE (TIME_CREATED);
CREATE INDEX IDX_IDN_AUTH_SSTR_ST_OP_ID_TM ON IDN_AUTH_SESSION_STORE (OPERATION, SESSION_TYPE, SESSION_ID, TIME_CREATED);
CREATE INDEX IDX_IDN_AUTH_SSTR_ET_ID ON IDN_AUTH_SESSION_STORE (EXPIRY_TIME, SESSION_ID);

-- IDN_AUTH_TEMP_SESSION_STORE --
CREATE INDEX IDX_IDN_AUTH_TMP_SESSION_TIME ON IDN_AUTH_TEMP_SESSION_STORE (TIME_CREATED);

-- IDN_AUTH_USER --
CREATE INDEX IDX_AUTH_USER_UN_TID_DN ON IDN_AUTH_USER (USER_NAME, TENANT_ID, DOMAIN_NAME);
CREATE INDEX IDX_AUTH_USER_DN_TOD ON IDN_AUTH_USER (DOMAIN_NAME, TENANT_ID);

-- IDN_AUTH_USER_SESSION_MAPPING --
CREATE INDEX IDX_USER_ID ON IDN_AUTH_USER_SESSION_MAPPING (USER_ID);
CREATE INDEX IDX_SESSION_ID ON IDN_AUTH_USER_SESSION_MAPPING (SESSION_ID);

-- IDN_AUTH_SESSION_APP_INFO --
CREATE INDEX IDX_AUTH_SAI_UN_AID_SID ON IDN_AUTH_SESSION_APP_INFO (APP_ID, SUBJECT, SESSION_ID);

-- add tables that could vary in different IS packs
CREATE TABLE IF NOT EXISTS IDN_AUTH_TEMP_SESSION_STORE(id int);
26 changes: 20 additions & 6 deletions common/deployment/setup/setup-bastion.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ wso2_is_3_ip=""
wso2_is_4_ip=""
lb_host=""
rds_host=""
session_rds_host=""
wso2is_host_alias=wso2is
wso2is_1_host_alias=wso2is1
wso2is_2_host_alias=wso2is2
Expand All @@ -36,19 +37,20 @@ lb_alias=loadbalancer
function usage() {
echo ""
echo "Usage: "
echo "$0 -w <wso2_is_1_ip> -i <wso2_is_2_ip> -l <lb_host> -r <rds_host>"
echo "$0 -w <wso2_is_1_ip> -i <wso2_is_2_ip> -l <lb_host> -r <rds_host> -s <session_rds_host>"
echo ""
echo "-w: The private IP of WSO2 IS node 1."
echo "-i: The private IP of WSO2 IS node 2."
echo "-j: The private IP of WSO2 IS node 3."
echo "-k: The private IP of WSO2 IS node 4."
echo "-l: The private hostname of Load balancer instance."
echo "-r: The private hostname of RDS instance."
echo "-s: The private hostname of the session Database RDS instance."
echo "-h: Display this help and exit."
echo ""
}

while getopts "n:w:i:j:k:l:r:h" opts; do
while getopts "n:w:i:j:k:l:r:s:h" opts; do
case $opts in
n)
no_of_nodes=${OPTARG}
Expand All @@ -71,6 +73,9 @@ while getopts "n:w:i:j:k:l:r:h" opts; do
r)
rds_host=${OPTARG}
;;
s)
session_rds_host=${OPTARG}
;;
h)
usage
exit 0
Expand All @@ -92,6 +97,11 @@ if [[ -z $rds_host ]]; then
exit 1
fi

if [[ -z $session_rds_host ]]; then
echo "Please provide the private hostname of the session Database RDS instance."
exit 1
fi

function get_ssh_hostname() {
sudo -u ubuntu ssh -G "$1" | awk '/^hostname / { print $2 }'
}
Expand Down Expand Up @@ -123,7 +133,8 @@ elif [[ $no_of_nodes -eq 1 ]]; then
-f /home/ubuntu/apache-jmeter-*.tgz \
-a $wso2is_host_alias -n "$wso2_is_1_ip" \
-a loadbalancer -n "$wso2_is_1_ip"\
-a rds -n "$rds_host"
-a rds -n "$rds_host"\
-a sessionrds -n "$session_rds_host"
elif [[ $no_of_nodes -eq 2 ]]; then
workspace/setup/setup-jmeter-client-is.sh -g -k /home/ubuntu/private_key.pem \
-i /home/ubuntu \
Expand All @@ -132,7 +143,8 @@ elif [[ $no_of_nodes -eq 2 ]]; then
-a $wso2is_1_host_alias -n "$wso2_is_1_ip" \
-a $wso2is_2_host_alias -n "$wso2_is_2_ip" \
-a $lb_alias -n "$lb_host"\
-a rds -n "$rds_host"
-a rds -n "$rds_host"\
-a sessionrds -n "$session_rds_host"
elif [[ $no_of_nodes -eq 3 ]]; then
workspace/setup/setup-jmeter-client-is.sh -g -k /home/ubuntu/private_key.pem \
-i /home/ubuntu \
Expand All @@ -142,7 +154,8 @@ elif [[ $no_of_nodes -eq 3 ]]; then
-a $wso2is_2_host_alias -n "$wso2_is_2_ip" \
-a $wso2is_3_host_alias -n "$wso2_is_3_ip" \
-a $lb_alias -n "$lb_host"\
-a rds -n "$rds_host"
-a rds -n "$rds_host"\
-a sessionrds -n "$session_rds_host"
elif [[ $no_of_nodes -eq 4 ]]; then
workspace/setup/setup-jmeter-client-is.sh -g -k /home/ubuntu/private_key.pem \
-i /home/ubuntu \
Expand All @@ -153,7 +166,8 @@ elif [[ $no_of_nodes -eq 4 ]]; then
-a $wso2is_3_host_alias -n "$wso2_is_3_ip" \
-a $wso2is_4_host_alias -n "$wso2_is_4_ip" \
-a $lb_alias -n "$lb_host"\
-a rds -n "$rds_host"
-a rds -n "$rds_host"\
-a sessionrds -n "$session_rds_host"
else
echo "Invalid value for no_of_nodes. Please provide a valid number."
exit 1
Expand Down
17 changes: 13 additions & 4 deletions common/deployment/setup/setup-is.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,12 @@ function usage() {
echo "-j: The IP of wso2is node 3."
echo "-k: The IP of wso2is node 4."
echo "-r: The IP address of RDS."
echo "-s: The IP address of session DB RDS."
echo "-h: Display this help and exit."
echo ""
}

while getopts "a:n:w:i:j:k:r:h" opts; do
while getopts "a:n:w:i:j:k:r:s:h" opts; do
case $opts in
a)
is_host_alias=${OPTARG}
Expand All @@ -57,6 +58,9 @@ while getopts "a:n:w:i:j:k:r:h" opts; do
r)
db_instance_ip=${OPTARG}
;;
s)
session_db_instance_ip=${OPTARG}
;;
h)
usage
exit 0
Expand All @@ -78,6 +82,11 @@ if [[ -z $db_instance_ip ]]; then
exit 1
fi

if [[ -z $session_db_instance_ip ]]; then
echo "Please provide the session db instance IP address."
exit 1
fi

echo ""
echo "Copying Is server setup files..."
echo "-------------------------------------------"
Expand All @@ -100,13 +109,13 @@ if [[ -z $no_of_nodes ]]; then
exit 1
elif [[ $no_of_nodes -eq 2 ]]; then
setup_is_node_command="ssh -i ~/private_key.pem -o "StrictHostKeyChecking=no" -t ubuntu@$wso2_is_1_ip \
./update-is-conf.sh -n $no_of_nodes -r $db_instance_ip -w $wso2_is_1_ip -i $wso2_is_2_ip"
./update-is-conf.sh -n $no_of_nodes -r $db_instance_ip -s $session_db_instance_ip -w $wso2_is_1_ip -i $wso2_is_2_ip"
elif [[ $no_of_nodes -eq 3 ]]; then
setup_is_node_command="ssh -i ~/private_key.pem -o "StrictHostKeyChecking=no" -t ubuntu@$wso2_is_1_ip \
./update-is-conf.sh -n $no_of_nodes -r $db_instance_ip -w $wso2_is_1_ip -i $wso2_is_2_ip -j $wso2_is_3_ip"
./update-is-conf.sh -n $no_of_nodes -r $db_instance_ip -s $session_db_instance_ip -w $wso2_is_1_ip -i $wso2_is_2_ip -j $wso2_is_3_ip"
elif [[ $no_of_nodes -eq 4 ]]; then
setup_is_node_command="ssh -i ~/private_key.pem -o "StrictHostKeyChecking=no" -t ubuntu@$wso2_is_1_ip \
./update-is-conf.sh -n $no_of_nodes -r $db_instance_ip -w $wso2_is_1_ip -i $wso2_is_2_ip -j $wso2_is_3_ip -k $wso2_is_4_ip"
./update-is-conf.sh -n $no_of_nodes -r $db_instance_ip -s $session_db_instance_ip -w $wso2_is_1_ip -i $wso2_is_2_ip -j $wso2_is_3_ip -k $wso2_is_4_ip"
else
echo "Invalid value for no_of_nodes. Please provide a valid number."
exit 1
Expand Down
16 changes: 14 additions & 2 deletions common/deployment/setup/update-is-conf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,13 @@ function usage() {
echo "-j: The IP of wso2is node 3."
echo "-k: The IP of wso2is node 4."
echo "-r: The IP address of RDS."
echo "-s: The IP address of session DB RDS."
echo "-w: The IP of wso2is node 2."
echo "-h: Display this help and exit."
echo ""
}

while getopts "n:w:i:j:k:r:h" opts; do
while getopts "n:w:i:j:k:r:s:h" opts; do
case $opts in
n)
no_of_nodes=${OPTARG}
Expand All @@ -53,6 +54,9 @@ while getopts "n:w:i:j:k:r:h" opts; do
r)
db_instance_ip=${OPTARG}
;;
s)
session_db_instance_ip=${OPTARG}
;;
h)
usage
exit 0
Expand All @@ -69,6 +73,11 @@ if [[ -z $db_instance_ip ]]; then
exit 1
fi

if [[ -z $session_db_instance_ip ]]; then
echo "Please provide the session db instance ip address."
exit 1
fi

echo ""
echo "unzipping is server"
echo "-------------------------------------------"
Expand Down Expand Up @@ -101,10 +110,12 @@ cp resources/deployment.toml "$carbon_home"/repository/conf/deployment.toml
echo ""
echo "Applying basic parameter changes..."
echo "-------------------------------------------"
sed -i 's/JVM_MEM_OPTS="-Xms256m -Xmx1024m"/JVM_MEM_OPTS="-Xms2g -Xmx2g"/g' \
sed -i 's/JVM_MEM_OPTS="-Xms256m -Xmx1024m"/JVM_MEM_OPTS="-Xms4g -Xmx4g"/g' \
"$carbon_home"/bin/wso2server.sh || echo "Editing wso2server.sh file failed!"
sed -i "s|jdbc:mysql://wso2isdbinstance2.cd3cwezibdu8.us-east-1.rds.amazonaws.com|jdbc:mysql://$db_instance_ip|g" \
"$carbon_home"/repository/conf/deployment.toml || echo "Editing deployment.toml file failed!"
sed -i "s|jdbc:mysql://wso2isdbinstance3.cd3cwezibdu8.us-east-1.rds.amazonaws.com|jdbc:mysql://$session_db_instance_ip|g" \
"$carbon_home"/repository/conf/deployment.toml || echo "Editing deployment.toml file failed!"

if [[ -z $no_of_nodes ]]; then
echo "Please provide the number of IS nodes in the deployment."
Expand All @@ -116,6 +127,7 @@ if [[ $no_of_nodes -eq 1 ]]; then
echo "Creating databases in RDS..."
echo "============================================"
mysql -h "$db_instance_ip" -u wso2carbon -pwso2carbon < resources/createDB.sql
mysql -h "$session_db_instance_ip" -u wso2carbon -pwso2carbon < resources/createSessionDB.sql
fi
if [[ $no_of_nodes -gt 1 ]]; then
sed -i "s|member_ip_1|$wso2_is_1_ip|g" "$carbon_home"/repository/conf/deployment.toml || echo "Editing deployment.toml file failed!"
Expand Down
Loading