forked from docs/doc-exports
Reviewed-by: Wagner, Fabian <fabian.wagner@t-systems.com> Co-authored-by: Hasko, Vladimir <vladimir.hasko@t-systems.com> Co-committed-by: Hasko, Vladimir <vladimir.hasko@t-systems.com>
125 lines
18 KiB
HTML
125 lines
18 KiB
HTML
<a name="ddm_02_0005"></a><a name="ddm_02_0005"></a>
|
|
|
|
<h1 class="topictitle1">Step 4: Log In to the DDM Schema</h1>
|
|
<div id="body1590996012361"><p id="ddm_02_0005__p182349915464">After you create a DDM instance, you can log in to it using a client such as Navicat, or connect to the required schema in the instance using the CLI or JDBC driver.</p>
|
|
<p id="ddm_02_0005__p93511517460">This section describes how to log in to a DDM instance or a schema.</p>
|
|
<div class="section" id="ddm_02_0005__section1043172824710"><h4 class="sectiontitle">Preparations</h4><p id="ddm_02_0005__p77785810474">Before you log in to your DDM instance or schema, you have to obtain its connection address.</p>
|
|
</div>
|
|
<div class="section" id="ddm_02_0005__section1567342520566"><h4 class="sectiontitle">Obtaining the Schema Connection Address</h4><ol id="ddm_02_0005__ol166134317567"><li id="ddm_02_0005__li126013551311"><span>Log in to the DDM console.</span></li><li id="ddm_02_0005__li2601655514"><span>Hover on the left menu to display <strong id="ddm_02_0005__b236017596552">Service List</strong> and choose <strong id="ddm_02_0005__b18361759105512">Databases</strong> > <strong id="ddm_02_0005__b8361659195515">Distributed Database Middleware</strong>.</span></li><li id="ddm_02_0005__li96013551117"><span>In the navigation pane, choose <strong id="ddm_02_0005__b150175813195">Instances</strong>. In the instance list, locate the required DDM instance and click its name.</span></li><li id="ddm_02_0005__li8462174295115"><span>In the navigation pane, choose <strong id="ddm_02_0005__b1466812391434">Schemas</strong>.</span></li><li id="ddm_02_0005__li10166133185219"><span>In the schema list, locate the required schema and click its name.</span></li><li id="ddm_02_0005__li209951839111018"><span>In the <strong id="ddm_02_0005__b1393212316458">Connection Address</strong> area, view CLI and JDBC connection addresses.</span><p><div class="note" id="ddm_02_0005__note796895017333"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><ul id="ddm_02_0005__ul1475622413263"><li id="ddm_02_0005__li2075682420267">If load balancing is enabled, one floating IP address will be assigned to a DDM instance even if it has multiple nodes. You can use this address to connect to the DDM instance for load balancing.</li><li id="ddm_02_0005__li136317145573">There are some historical instances that do not support load balancing, so they have multiple IP addresses. For load balancing, you can use JDBC connection strings to connect to them.</li><li id="ddm_02_0005__li534382475710">If read-only groups are created, each group will be assigned a load balancing address for service isolation.</li></ul>
|
|
</div></div>
|
|
</p></li></ol>
|
|
</div>
|
|
<div class="section" id="ddm_02_0005__section1398853714615"><h4 class="sectiontitle">Connection Methods</h4><p id="ddm_02_0005__p14989123717613">For details about method 1, see <a href="#ddm_02_0005__section19691512121812">Using Navicat to Log In to a DDM Instance</a>.</p>
|
|
<p id="ddm_02_0005__p69891372612">For details about method 2, see <a href="#ddm_02_0005__section1621624581510">Using the MySQL CLI to Log In to a Schema</a>.</p>
|
|
<p id="ddm_02_0005__p139896371268">For details about method 3, see <a href="#ddm_02_0005__section1690417388176">Using a JDBC Driver to Log In to a Schema</a>.</p>
|
|
</div>
|
|
<div class="note" id="ddm_02_0005__note19959638358"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><ol id="ddm_02_0005__ol1938754815238"><li id="ddm_02_0005__li11387848122310">For security purposes, select an ECS in the same VPC as your DDM instance.</li><li id="ddm_02_0005__li15387134832315">Ensure that a MySQL client has been installed on the required ECS or the MySQL connection driver has been configured.</li><li id="ddm_02_0005__li203871748182312">Before you log in to a DDM instance, configure its information on the client or connection driver.</li></ol>
|
|
</div></div>
|
|
<div class="section" id="ddm_02_0005__section19691512121812"><a name="ddm_02_0005__section19691512121812"></a><a name="section19691512121812"></a><h4 class="sectiontitle">Using Navicat to Log In to a DDM Instance</h4><ol id="ddm_02_0005__ol183557581224"><li id="ddm_02_0005__li113557586229"><span>Log in to the DDM console, locate the required DDM instance, and click its name.</span></li><li id="ddm_02_0005__li36914481235"><span>Ask technical support to add an EIP to the feature whitelist. In the <strong id="ddm_02_0005__b178001514079">Instance Information</strong> area, click <strong id="ddm_02_0005__b148011714975">Bind</strong>. In the displayed dialog box, select the EIP and click <strong id="ddm_02_0005__b75374103813">OK</strong>. Bind the EIP with your DDM instance.</span></li><li id="ddm_02_0005__li173060103165"><span>In the navigation pane on the left, click the VPC icon and choose <strong id="ddm_02_0005__b1814064702720">Access Control</strong> > <strong id="ddm_02_0005__b1755991611218">Security Groups</strong>.</span></li><li id="ddm_02_0005__li1628823132520"><span>On the <strong id="ddm_02_0005__b9668131717123">Security Groups</strong> page, locate the required security group and click <strong id="ddm_02_0005__b10669717171210">Manage Rule</strong> in the <strong id="ddm_02_0005__b1366991713126">Operation</strong> column. On the displayed page, click <strong id="ddm_02_0005__b6667181915126">Add Rule</strong>. Configure the security group rule as needed and click <strong id="ddm_02_0005__b837215215129">OK</strong>.</span><p><div class="note" id="ddm_02_0005__note102888318253"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="ddm_02_0005__p2038832623610">After binding an EIP to your DDM instance, set strict inbound and outbound rules for the security group to enhance database security.</p>
|
|
</div></div>
|
|
</p></li><li id="ddm_02_0005__li6562165513294"><span>Open Navicat and click <strong id="ddm_02_0005__b17161152681210">Connection</strong>. In the displayed dialog box, enter the host IP address (EIP), username, and password (DDM account).</span><p><div class="note" id="ddm_02_0005__note1512135613393"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="ddm_02_0005__p3121175643915">Navicat12 is recommended for Navicat clients.</p>
|
|
</div></div>
|
|
</p></li><li id="ddm_02_0005__li1751902852620"><span>Click <strong id="ddm_02_0005__b141791845135417">Test Connection</strong>. If a message is returned indicating that the connection is successful, click <strong id="ddm_02_0005__b851210719553">OK</strong>. The connection will succeed 1 to 2 minutes later. If the connection fails, the failure cause is displayed. Modify the required information and try again.</span></li></ol>
|
|
<div class="note" id="ddm_02_0005__note14739638113218"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="ddm_02_0005__p1899110469321">Using Navicat to access a DDM instance is similar to using other visualized MySQL tools such as MySQL Workbench. Therefore, the procedure of using other visualized MySQL tools to connect to a DDM instance has been omitted.</p>
|
|
</div></div>
|
|
</div>
|
|
<div class="section" id="ddm_02_0005__section1621624581510"><a name="ddm_02_0005__section1621624581510"></a><a name="section1621624581510"></a><h4 class="sectiontitle">Using the MySQL CLI to Log In to a Schema</h4><ol id="ddm_02_0005__ol1053254716256"><li id="ddm_02_0005__li35321947202517"><span>Log in to the required ECS, open the CLI, and run the following command:</span><p><pre class="screen" id="ddm_02_0005__screen1094816405448">mysql -h ${<em id="ddm_02_0005__i14013200175">DDM_SERVER_ADDRESS</em>} -P ${<em id="ddm_02_0005__i5062017175">DDM_SERVER_PORT</em>} -u ${<em id="ddm_02_0005__i12042051712">DDM_USER</em>} -p [-D ${<em id="ddm_02_0005__i2092061712">DDM_DBNAME</em>}] [--default -character -set=utf8][--default_auth=mysql_native_password]</pre>
|
|
|
|
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="ddm_02_0005__table98862342274" frame="border" border="1" rules="all"><caption><b>Table 1 </b>Parameter description</caption><thead align="left"><tr id="ddm_02_0005__row388523412276"><th align="left" class="cellrowborder" valign="top" width="32%" id="mcps1.3.8.2.1.2.2.2.4.1.1"><p id="ddm_02_0005__p088519348279"><strong id="ddm_02_0005__b19810625114019">Parameter</strong></p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="52%" id="mcps1.3.8.2.1.2.2.2.4.1.2"><p id="ddm_02_0005__p108859345276"><strong id="ddm_02_0005__b1752192815404">Description</strong></p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="16%" id="mcps1.3.8.2.1.2.2.2.4.1.3"><p id="ddm_02_0005__p186181313143220"><strong id="ddm_02_0005__b1736520326409">Example Value</strong></p>
|
|
</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody><tr id="ddm_02_0005__row7885534172720"><td class="cellrowborder" valign="top" width="32%" headers="mcps1.3.8.2.1.2.2.2.4.1.1 "><p id="ddm_02_0005__p1088513413272">DDM_SERVER_ADDRESS</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.3.8.2.1.2.2.2.4.1.2 "><p id="ddm_02_0005__p38859341276">IP address of the DDM instance</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="16%" headers="mcps1.3.8.2.1.2.2.2.4.1.3 "><p id="ddm_02_0005__p1390504115324">192.168.0.200</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="ddm_02_0005__row1886193415276"><td class="cellrowborder" valign="top" width="32%" headers="mcps1.3.8.2.1.2.2.2.4.1.1 "><p id="ddm_02_0005__p118853348275">DDM_SERVER_PORT</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.3.8.2.1.2.2.2.4.1.2 "><p id="ddm_02_0005__p1788553422712">Connection port of the DDM instance</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="16%" headers="mcps1.3.8.2.1.2.2.2.4.1.3 "><p id="ddm_02_0005__p136191613183210">5066</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="ddm_02_0005__row2886193414276"><td class="cellrowborder" valign="top" width="32%" headers="mcps1.3.8.2.1.2.2.2.4.1.1 "><p id="ddm_02_0005__p198869342276">DDM_USER</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.3.8.2.1.2.2.2.4.1.2 "><p id="ddm_02_0005__p19886123412713">Account of the DDM instance</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="16%" headers="mcps1.3.8.2.1.2.2.2.4.1.3 "><p id="ddm_02_0005__p4136613336">dbuser01</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="ddm_02_0005__row488613432717"><td class="cellrowborder" valign="top" width="32%" headers="mcps1.3.8.2.1.2.2.2.4.1.1 "><p id="ddm_02_0005__p588653432710">DDM_DBNAME</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.3.8.2.1.2.2.2.4.1.2 "><p id="ddm_02_0005__p198861334122718">(Optional) Name of the target schema in the DDM instance</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="16%" headers="mcps1.3.8.2.1.2.2.2.4.1.3 "><p id="ddm_02_0005__p15619171343210">-</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="ddm_02_0005__row1488693414277"><td class="cellrowborder" valign="top" width="32%" headers="mcps1.3.8.2.1.2.2.2.4.1.1 "><p id="ddm_02_0005__p1188653416276">default-character-set=utf8</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.3.8.2.1.2.2.2.4.1.2 "><p id="ddm_02_0005__p16886193432712">(Optional) Select character set UTF-8 for encoding.</p>
|
|
<p id="ddm_02_0005__p288615340270">Configure this parameter if garbled characters are displayed during parsing due to inconsistency between MySQL connection code and actually used code.</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="16%" headers="mcps1.3.8.2.1.2.2.2.4.1.3 "><p id="ddm_02_0005__p14619101317328">-</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="ddm_02_0005__row169963912128"><td class="cellrowborder" valign="top" width="32%" headers="mcps1.3.8.2.1.2.2.2.4.1.1 "><p id="ddm_02_0005__p109971192129">default_auth=mysql_native_password</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.3.8.2.1.2.2.2.4.1.2 "><p id="ddm_02_0005__p19998209171211">(Optional) The password authentication plug-in is used by default.</p>
|
|
<p id="ddm_02_0005__p18299841134610">If you use the MySQL 8.0 client, this parameter is required.</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="16%" headers="mcps1.3.8.2.1.2.2.2.4.1.3 "><p id="ddm_02_0005__p69981097121">-</p>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</p></li><li id="ddm_02_0005__li12173181813011"><span>View the command output. The following is an example output of running a MySQL command in the Windows CLI.</span><p><pre class="screen" id="ddm_02_0005__screen763154814420">C:\Users\testDDM>mysql -h 192.168.0.200 -P 5066 -D db_5133 -u dbuser01 -p
|
|
Enter password:
|
|
Reading table information for completion of table and column names
|
|
You can turn off this feature to get a quicker startup with -A
|
|
|
|
Welcome to the MySQL monitor. Commands end with ;or \g.
|
|
Your MySQL connection id is 5
|
|
Server version: 5.6.29
|
|
|
|
Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
|
|
|
|
Oracle is a registered trademark of Oracle Corporation and/or its
|
|
affiliates. Other names may be trademarks of their respective
|
|
owners.
|
|
|
|
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
|
|
|
|
mysql></pre>
|
|
</p></li></ol>
|
|
</div>
|
|
<div class="section" id="ddm_02_0005__section1690417388176"><a name="ddm_02_0005__section1690417388176"></a><a name="section1690417388176"></a><h4 class="sectiontitle">Using a JDBC Driver to Log In to a Schema</h4><ol id="ddm_02_0005__ol187418223920"><li id="ddm_02_0005__li1612519402101"><span>Load the required JDBC driver.</span><p><pre class="screen" id="ddm_02_0005__screen1426392813512">Class.forname(com.mysql.jdbc.Driver);</pre>
|
|
<div class="note" id="ddm_02_0005__note91401524201115"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="ddm_02_0005__p9140824121111">JDBC drivers 5.1.49 or later are recommended.</p>
|
|
</div></div>
|
|
</p></li><li id="ddm_02_0005__li16913162392"><span>Create a database connection.</span><p><pre class="screen" id="ddm_02_0005__screen1312371515017">String username = "dbuser01" ;
|
|
String password = "xxxxxx" ;
|
|
String url = "jdbc:mysql://192.168.0.200:5066/db_5133";
|
|
Connection con = DriverManager.getConnection(url , username , password);</pre>
|
|
</p></li><li id="ddm_02_0005__li5620164510391"><span>Create a Statement object.</span><p><pre class="screen" id="ddm_02_0005__screen1144085505211">Statement stmt = con.createStatement();</pre>
|
|
</p></li><li id="ddm_02_0005__li1841819444011"><span>Execute the required SQL statement.</span><p><pre class="screen" id="ddm_02_0005__screen01151822195615">ResultSet rs = stmt.executeQuery("select now() as Systemtime");
|
|
con.close();</pre>
|
|
</p></li><li id="ddm_02_0005__li139111931387"><a name="ddm_02_0005__li139111931387"></a><a name="li139111931387"></a><span>(Optional) Optimize code as needed.</span><p><pre class="screen" id="ddm_02_0005__screen69311015919">loadBalanceAutoCommitStatementThreshold=5&loadBalanceHostRemovalGracePeriod=15000&loadBalanceBlacklistTimeout=60000&loadBalancePingTimeout=5000&retriesAllDown=10&connectTimeout=10000</pre>
|
|
<div class="note" id="ddm_02_0005__note19978141913917"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><ul id="ddm_02_0005__ul066216919107"><li id="ddm_02_0005__li85394701412">Parameters <strong id="ddm_02_0005__b179951315155414">loadBalanceAutoCommitStatementThreshold</strong> and <strong id="ddm_02_0005__b316162548">retriesAllDown</strong> must be configured based on the example in <a href="#ddm_02_0005__li139111931387">5</a>. Otherwise, an infinite loop may occur during the connection switchover, resulting in stack overflow.</li><li id="ddm_02_0005__li61276200129"><strong id="ddm_02_0005__b454065617124">loadBalanceAutoCommitStatementThreshold</strong>: defines the number of matching statements which will trigger the driver to potentially swap physical server connections. </li><li id="ddm_02_0005__li18127720101218"><strong id="ddm_02_0005__b112491434112216">loadBalanceHostRemovalGracePeriod</strong>: indicates the grace period to wait for a host being removed from a load-balanced connection, to be released when it is the active host.</li><li id="ddm_02_0005__li512712071217"><strong id="ddm_02_0005__b1579516475259">loadBalanceBlacklistTimeout</strong>: indicates the time in milliseconds between checks of servers which are unavailable, by controlling how long a server lives in the global blacklist.</li><li id="ddm_02_0005__li9127182010127"><strong id="ddm_02_0005__b2670149113616">loadBalancePingTimeout</strong>: indicates the time in milliseconds that the connection will wait for a response to a ping operation when you set <strong id="ddm_02_0005__b79673516447">loadBalanceValidateConnectionOnSwapServer</strong> to <strong id="ddm_02_0005__b39810533442">true</strong>.</li><li id="ddm_02_0005__li2127122012121"><strong id="ddm_02_0005__b192903512133">retriesAllDown</strong>: indicates the maximum number of connection attempts before an exception is thrown when a valid host is searched. SQLException will be returned if the threshold of retries is reached with no valid connections obtained.</li><li id="ddm_02_0005__li512715206124"><strong id="ddm_02_0005__b4918143918474">connectTimeout</strong>: indicates the maximum amount of time in milliseconds that the JDBC driver is willing to wait to set up a socket connection. <strong id="ddm_02_0005__b17990131613523">0</strong> indicates that the connection does not time out. This parameter is available to JDK-1.4 or later versions. The default value is <strong id="ddm_02_0005__b941111461320">0</strong>.</li></ul>
|
|
</div></div>
|
|
</p></li></ol>
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<div class="familylinks">
|
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="ddm_02_0001.html">Getting Started</a></div>
|
|
</div>
|
|
</div>
|
|
|