correlation https://teguhth.blogspot.com/2025/01/test-insert-select-data-using-maxscale.html
1. info server testing
2. diagram
3. create datasource
4. run url
http://10.10.10.90:8888/test_maxscale_route.cfm
5. create lucee script to test
[root@teguhth-all ROOT]# pwd
/opt/lucee/tomcat/webapps/ROOT
[root@teguhth-all ROOT]#
[root@teguhth-all ROOT]# cat test_maxscale_route.cfm
<cfsetting showdebugoutput="false">
<!DOCTYPE html>
<html>
<head>
<title>MariaDB MaxScale Routing Test</title>
<style>
body{
font-family: Arial, Helvetica, sans-serif;
margin:20px;
}
table{
border-collapse:collapse;
width:100%;
margin-bottom:20px;
}
th,td{
border:1px solid #ccc;
padding:8px;
text-align:left;
}
th{
background:#f2f2f2;
}
.ok{
color:green;
font-weight:bold;
}
.err{
color:red;
font-weight:bold;
}
</style>
</head>
<body>
<h2>MariaDB MaxScale Routing Hint Test</h2>
<!-- ========================================================== -->
<!-- Test 1 : -- maxscale route to master -->
<!-- ========================================================== -->
<cftry>
<cfquery name="qMasterLine" datasource="dbmax">
SELECT
@@hostname AS hostname,
@@version AS version
-- maxscale route to master
</cfquery>
<cfcatch>
<cfset qMasterLine="">
</cfcatch>
</cftry>
<!-- ========================================================== -->
<!-- Test 2 : -- maxscale route to slave -->
<!-- ========================================================== -->
<cftry>
<cfquery name="qSlaveLine" datasource="dbmax">
SELECT
@@hostname AS hostname,
@@version AS version
-- maxscale route to slave
</cfquery>
<cfcatch>
<cfset qSlaveLine="">
</cfcatch>
</cftry>
<!-- ========================================================== -->
<!-- Test 3 : /* maxscale route to master */ -->
<!-- ========================================================== -->
<cftry>
<cfquery name="qMasterBlock" datasource="dbmax">
SELECT
@@hostname AS hostname,
@@version AS version
/* maxscale route to master */
</cfquery>
<cfcatch>
<cfset qMasterBlock="">
</cfcatch>
</cftry>
<!-- ========================================================== -->
<!-- Test 4 : /* maxscale route to slave */ -->
<!-- ========================================================== -->
<cftry>
<cfquery name="qSlaveBlock" datasource="dbmax">
SELECT
@@hostname AS hostname,
@@version AS version
/* maxscale route to slave */
</cfquery>
<cfcatch>
<cfset qSlaveBlock="">
</cfcatch>
</cftry>
[root@teguhth-all ROOT]# pwd
/opt/lucee/tomcat/webapps/ROOT
[root@teguhth-all ROOT]#
[root@teguhth-all ROOT]# cat test_maxscale_route.cfm
<cfsetting showdebugoutput="false">
<!DOCTYPE html>
<html>
<head>
<title>MariaDB MaxScale Routing Test</title>
<style>
body{
font-family: Arial, Helvetica, sans-serif;
margin:20px;
}
table{
border-collapse:collapse;
width:100%;
margin-bottom:20px;
}
th,td{
border:1px solid #ccc;
padding:8px;
text-align:left;
}
th{
background:#f2f2f2;
}
.ok{
color:green;
font-weight:bold;
}
.err{
color:red;
font-weight:bold;
}
</style>
</head>
<body>
<h2>MariaDB MaxScale Routing Hint Test</h2>
<!-- ========================================================== -->
<!-- Test 1 : -- maxscale route to master -->
<!-- ========================================================== -->
<cftry>
<cfquery name="qMasterLine" datasource="dbmax">
SELECT
@@hostname AS hostname,
@@version AS version
-- maxscale route to master
</cfquery>
<cfcatch>
<cfset qMasterLine="">
</cfcatch>
</cftry>
<!-- ========================================================== -->
<!-- Test 2 : -- maxscale route to slave -->
<!-- ========================================================== -->
<cftry>
<cfquery name="qSlaveLine" datasource="dbmax">
SELECT
@@hostname AS hostname,
@@version AS version
-- maxscale route to slave
</cfquery>
<cfcatch>
<cfset qSlaveLine="">
</cfcatch>
</cftry>
<!-- ========================================================== -->
<!-- Test 3 : /* maxscale route to master */ -->
<!-- ========================================================== -->
<cftry>
<cfquery name="qMasterBlock" datasource="dbmax">
SELECT
@@hostname AS hostname,
@@version AS version
/* maxscale route to master */
</cfquery>
<cfcatch>
<cfset qMasterBlock="">
</cfcatch>
</cftry>
<!-- ========================================================== -->
<!-- Test 4 : /* maxscale route to slave */ -->
<!-- ========================================================== -->
<cftry>
<cfquery name="qSlaveBlock" datasource="dbmax">
SELECT
@@hostname AS hostname,
@@version AS version
/* maxscale route to slave */
</cfquery>
<cfcatch>
<cfset qSlaveBlock="">
</cfcatch>
</cftry>
<!-- ========================================================== -->
<!-- Test 5 : /* maxscale route to slave */ -->
<!-- ========================================================== -->
<cftry>
<cfquery name="qnormal" datasource="dbmax">
SELECT
@@hostname AS hostname,
@@version AS version
</cfquery>
<cfcatch>
<cfset qnormal="">
</cfcatch>
</cftry>
<table>
<tr>
<th>No</th>
<th>Routing Hint</th>
<th>Hostname</th>
<th>Version</th>
</tr>
<cfoutput>
<tr>
<td>1</td>
<td>select @@hostname,@@version -- maxscale route to master</td>
<cfif IsQuery(qMasterLine)>
<td>#qMasterLine.hostname#</td>
<td>#qMasterLine.version#</td>
<cfelse>
<td colspan="2" class="err">FAILED</td>
</cfif>
</tr>
<tr>
<td>2</td>
<td>select @@hostname,@@version -- maxscale route to slave</td>
<cfif IsQuery(qSlaveLine)>
<td>#qSlaveLine.hostname#</td>
<td>#qSlaveLine.version#</td>
<cfelse>
<td colspan="2" class="err">FAILED</td>
</cfif>
</tr>
<tr>
<td>3</td>
<td>select @@hostname,@@version /* maxscale route to master */</td>
<cfif IsQuery(qMasterBlock)>
<td>#qMasterBlock.hostname#</td>
<td>#qMasterBlock.version#</td>
<cfelse>
<td colspan="2" class="err">FAILED</td>
</cfif>
</tr>
<tr>
<td>4</td>
<td>select @@hostname,@@version /* maxscale route to slave */</td>
<cfif IsQuery(qSlaveBlock)>
<td>#qSlaveBlock.hostname#</td>
<td>#qSlaveBlock.version#</td>
<cfelse>
<td colspan="2" class="err">FAILED</td>
</cfif>
</tr>
<tr>
<!-- Test 5 : /* maxscale route to slave */ -->
<!-- ========================================================== -->
<cftry>
<cfquery name="qnormal" datasource="dbmax">
SELECT
@@hostname AS hostname,
@@version AS version
</cfquery>
<cfcatch>
<cfset qnormal="">
</cfcatch>
</cftry>
<table>
<tr>
<th>No</th>
<th>Routing Hint</th>
<th>Hostname</th>
<th>Version</th>
</tr>
<cfoutput>
<tr>
<td>1</td>
<td>select @@hostname,@@version -- maxscale route to master</td>
<cfif IsQuery(qMasterLine)>
<td>#qMasterLine.hostname#</td>
<td>#qMasterLine.version#</td>
<cfelse>
<td colspan="2" class="err">FAILED</td>
</cfif>
</tr>
<tr>
<td>2</td>
<td>select @@hostname,@@version -- maxscale route to slave</td>
<cfif IsQuery(qSlaveLine)>
<td>#qSlaveLine.hostname#</td>
<td>#qSlaveLine.version#</td>
<cfelse>
<td colspan="2" class="err">FAILED</td>
</cfif>
</tr>
<tr>
<td>3</td>
<td>select @@hostname,@@version /* maxscale route to master */</td>
<cfif IsQuery(qMasterBlock)>
<td>#qMasterBlock.hostname#</td>
<td>#qMasterBlock.version#</td>
<cfelse>
<td colspan="2" class="err">FAILED</td>
</cfif>
</tr>
<tr>
<td>4</td>
<td>select @@hostname,@@version /* maxscale route to slave */</td>
<cfif IsQuery(qSlaveBlock)>
<td>#qSlaveBlock.hostname#</td>
<td>#qSlaveBlock.version#</td>
<cfelse>
<td colspan="2" class="err">FAILED</td>
</cfif>
</tr>
<tr>
<td>5</td>
<td>select @@hostname,@@version </td>
<cfif IsQuery(qnormal)>
<td>#qnormal.hostname#</td>
<td>#qnormal.version#</td>
<cfelse>
<td colspan="2" class="err">FAILED</td>
</cfif>
<td>select @@hostname,@@version </td>
<cfif IsQuery(qnormal)>
<td>#qnormal.hostname#</td>
<td>#qnormal.version#</td>
<cfelse>
<td colspan="2" class="err">FAILED</td>
</cfif>
</tr>
</cfoutput>
</table>
<div style="font-family:Courier New, monospace;font-size:14px;">
Copyright by : Teguh Triharto<br>
Website :
<a href="https://www.linkedin.com/in/teguhth" target="_blank">
https://www.linkedin.com/in/teguhth
</a>
</div>
</body>
</html>
[root@teguhth-all ROOT]#






No comments:
Post a Comment