Yang, Tong 48706b7552 MRS COMP-LTS 320-lts.1 version
Reviewed-by: Kacur, Michal <michal.kacur@t-systems.com>
Co-authored-by: Yang, Tong <yangtong2@huawei.com>
Co-committed-by: Yang, Tong <yangtong2@huawei.com>
2024-04-12 12:51:10 +00:00

33 lines
5.9 KiB
HTML

<a name="mrs_01_24451"></a><a name="mrs_01_24451"></a>
<h1 class="topictitle1">Enabling the Read-Only Mode of the ClickHouse Table</h1>
<div id="body0000001583315473"><div class="note" id="mrs_01_24451__note4763174618336"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="mrs_01_24451__p11763164620332">This section applies only to MRS 3.2.0 or later.</p>
</div></div>
<div class="section" id="mrs_01_24451__section1839151415215"><h4 class="sectiontitle">Scenario</h4><p id="mrs_01_24451__p8060118">During data migration, one-click balancing, decommissioning and capacity reduction, ClickHouse allows you to set the <strong id="mrs_01_24451__b7913131755617">only_allow_select_statement</strong> parameter for MergeTree series tables to enable SELECT operations instead of ALTER, RENAME, DROP, and INSERT operations.</p>
</div>
<div class="section" id="mrs_01_24451__section124331218518"><h4 class="sectiontitle">Procedure for Enabling the Read-Only Mode of the ClickHouse Table</h4><ol id="mrs_01_24451__ol11471534103911"><li id="mrs_01_24451__li10269200102512"><a name="mrs_01_24451__li10269200102512"></a><a name="li10269200102512"></a><span>Run the following commands to log in to the node where the client is installed as user <strong id="mrs_01_24451__b1444341184717">root</strong>:</span><p><p id="mrs_01_24451__p1526916017259"><strong id="mrs_01_24451__b256418435317">cd </strong><em id="mrs_01_24451__i13446104403112">Client installation directory</em></p>
<p id="mrs_01_24451__p172694017259"><strong id="mrs_01_24451__b16269180122520">source bigdata_env</strong></p>
</p></li><li id="mrs_01_24451__li1910333418475"><span>Run the following command to authenticate the user if the cluster is in security mode (with Kerberos authentication enabled). Otherwise, skip this step.</span><p><div class="p" id="mrs_01_24451__p1033411059"><strong id="mrs_01_24451__b78921230326">kinit</strong> <em id="mrs_01_24451__i390318239322">Component service user</em><div class="note" id="mrs_01_24451__note1838225719219"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="mrs_01_24451__p1738210571022">The user must have the ClickHouse administrator permissions.</p>
</div></div>
</div>
</p></li><li id="mrs_01_24451__li4140746493"><a name="mrs_01_24451__li4140746493"></a><a name="li4140746493"></a><span>Run the proper client command to connect to the ClickHouse server.</span><p><ul id="mrs_01_24451__ul14596144004313"><li id="mrs_01_24451__li1059615403432">Normal mode<p id="mrs_01_24451__p201011546184216"><a name="mrs_01_24451__li1059615403432"></a><a name="li1059615403432"></a><strong id="mrs_01_24451__b18361222445">clickhouse client --host </strong><em id="mrs_01_24451__i1383718227449">IP address of the ClickHouse instance</em><strong id="mrs_01_24451__b983752213440">--user </strong><em id="mrs_01_24451__i8838182217443">Username</em><strong id="mrs_01_24451__b48385226447"> --password</strong><strong id="mrs_01_24451__b1083872219446"> --port </strong>9440 <strong id="mrs_01_24451__b983902213444">--secure</strong></p>
<p id="mrs_01_24451__p11244188447"><em id="mrs_01_24451__i196152964415">Enter the user password.</em></p>
</li></ul>
<ul id="mrs_01_24451__ul4226164219439"><li id="mrs_01_24451__li11226942134315">Security mode<p id="mrs_01_24451__p676815581061"><a name="mrs_01_24451__li11226942134315"></a><a name="li11226942134315"></a><strong id="mrs_01_24451__b18768155811613">clickhouse client --host </strong><em id="mrs_01_24451__i1876820581565">IP address of the ClickHouse instance</em><strong id="mrs_01_24451__b15768158168">--port </strong>9440 <strong id="mrs_01_24451__b1676811581064">--secure</strong></p>
</li></ul>
<div class="note" id="mrs_01_24451__note1375961741617"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><ul id="mrs_01_24451__ul343108124512"><li id="mrs_01_24451__li343158174514">The user in normal mode is the default user, or you can create an administrator using the open source capability provided by the ClickHouse community. You cannot use the users created on FusionInsight Manager.</li><li id="mrs_01_24451__li124312815450">To obtain the IP address of the ClickHouseServer instance, log in to FusionInsight Manager, choose <strong id="mrs_01_24451__b6139186144510">Cluster</strong> &gt; <strong id="mrs_01_24451__b1814810610452">Services</strong> &gt; <strong id="mrs_01_24451__b111497617453">ClickHouse</strong>, and click the <strong id="mrs_01_24451__b2014936194510">Instance</strong> tab.</li></ul>
</div></div>
</p></li><li id="mrs_01_24451__li1917181215368"><span>Run the following statement to set the table to read-only:</span><p><p id="mrs_01_24451__p64197817247"><strong id="mrs_01_24451__b17696182316363">ALTER TABLE </strong><em id="mrs_01_24451__i54001824153613">{table_name}</em><strong id="mrs_01_24451__b1697023133615"> MODIFY SETTING only_allow_select_statement = true</strong><strong id="mrs_01_24451__b4948142824314">;</strong></p>
</p></li></ol>
</div>
<div class="section" id="mrs_01_24451__section927043455211"><h4 class="sectiontitle">Disabling the Read-Only Mode of the Table</h4><ol id="mrs_01_24451__ol7451193465311"><li id="mrs_01_24451__li144513348536"><span>Log in to the ClickHouse client by referring to <a href="#mrs_01_24451__li10269200102512">1</a> to <a href="#mrs_01_24451__li4140746493">3</a>.</span></li><li id="mrs_01_24451__li1464519504537"><span>Run the following statement to disable the read-only mode of the table:</span><p><p id="mrs_01_24451__p176451750125316"><strong id="mrs_01_24451__b66451550185312">ALTER TABLE </strong><em id="mrs_01_24451__i764575075311">{table_name}</em><strong id="mrs_01_24451__b9645105015312"> MODIFY SETTING only_allow_select_statement = false settings hw_internal_operation = true;</strong></p>
</p></li></ol>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="mrs_01_2344.html">Using ClickHouse</a></div>
</div>
</div>