<?php include_once __DIR__ . '/../include.php'; include_once __DIR__ . '/lib_example.php'; // load production config $config = (include_once __DIR__ . '/../../_clickhouse_config_product.php'); $cl = new ClickHouseDB\Cluster($config); $cl->setScanTimeOut(2.5); // 2500 ms if (!$cl->isReplicasIsOk()) { throw new Exception('Replica state is bad , error=' . $cl->getError()); } // $cluster_name = 'sharovara'; // echo "> {$cluster_name} , count shard = " . $cl->getClusterCountShard($cluster_name) . " ; count replica = " . $cl->getClusterCountReplica($cluster_name) . "\n"; echo "\n----\nEND\n"; // ----------------------------------------------------------------------
<?php include_once __DIR__ . '/../include.php'; include_once __DIR__ . '/lib_example.php'; $config = (include_once __DIR__ . '/../../_clickhouse_config_product.php'); // load production config $cl = new ClickHouseDB\Cluster($config); if (!$cl->isReplicasIsOk()) { throw new Exception('Replica state is bad , error=' . $cl->getError()); } $cluster_name = 'sharovara'; echo "> {$cluster_name} , count shard = " . $cl->getClusterCountShard($cluster_name) . " ; count replica = " . $cl->getClusterCountReplica($cluster_name) . "\n"; // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ $nodes = $cl->getNodesByTable('shara.adpreview_body_views_sharded'); foreach ($nodes as $node) { echo "{$node} > \n"; print_r($cl->client($node)->tableSize('adpreview_body_views_sharded')); print_r($cl->client($node)->showCreateTable('shara.adpreview_body_views')); } // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------
<?php include_once __DIR__ . '/../include.php'; include_once __DIR__ . '/lib_example.php'; // load production config $config = (include_once __DIR__ . '/../../_clickhouse_config_product.php'); $cl = new ClickHouseDB\Cluster($config); $cl->setScanTimeOut(2.5); // 2500 ms $cl->setSoftCheck(true); if (!$cl->isReplicasIsOk()) { throw new Exception('Replica state is bad , error=' . $cl->getError()); } // $cluster_name = 'sharovara'; // echo "> {$cluster_name} , count shard = " . $cl->getClusterCountShard($cluster_name) . " ; count replica = " . $cl->getClusterCountReplica($cluster_name) . "\n"; // Выбрать IP содержащий строку ".248" типа 123.123.123.248, разделитель ; - если не найдена первая берется $cli = $cl->clientLike($cluster_name, '.298;.964'); $cli->ping(); echo "\n----\nEND\n"; // ----------------------------------------------------------------------
<?php include_once __DIR__ . '/../include.php'; include_once __DIR__ . '/lib_example.php'; //$config = [ // 'host' => 'cluster.clickhouse.dns.com', // 'port' => '8123', // 'username' => 'default', // 'password' => '' //]; // // load production config $config = (include_once __DIR__ . '/../../_clickhouse_config_product.php'); // ---------------------------------------------------------------------- $cl = new ClickHouseDB\Cluster($config); $cl->setScanTimeOut(2.5); // 2500 ms if (!$cl->isReplicasIsOk()) { throw new Exception('Replica state is bad , error=' . $cl->getError()); } echo "Ips:\n"; print_r($cl->getNodes()); echo "getClusterList:\n"; print_r($cl->getClusterList()); // foreach (['pulse', 'repikator', 'sharovara', 'repikator3x', 'sharovara3x'] as $name) { echo "-------------------- {$name} ---------------------------\n"; print_r($cl->getClusterNodes($name)); echo "> Count Shard = " . $cl->getClusterCountShard($name) . "\n"; echo "> Count Replica = " . $cl->getClusterCountReplica($name) . "\n"; }
<?php include_once __DIR__ . '/../include.php'; include_once __DIR__ . '/lib_example.php'; // load production config $config = (include_once __DIR__ . '/../../_clickhouse_config_product.php'); $cl = new ClickHouseDB\Cluster($config); $cl->setScanTimeOut(2.5); // 2500 ms $cl->setSoftCheck(true); if (!$cl->isReplicasIsOk()) { throw new Exception('Replica state is bad , error=' . $cl->getError()); } $tables = $cl->getTables(); foreach ($tables as $dbtable => $tmp) { echo ">>> {$dbtable} :"; $size = $cl->getSizeTable($dbtable); echo "\t" . humanFileSize($size) . "\n"; } $table_for_truncate = 'target.events_sharded'; $result = $cl->truncateTable($table_for_truncate); echo "Result:truncate table\n"; print_r($result); echo "\n----\nEND\n"; // ----------------------------------------------------------------------