</tr> <?php } ?> </table> </fieldset> <?php if (count($running)) { ?> <fieldset class='sdm_nodes' id='sdm_nodes'> <legend>Nodes</legend> <?php foreach ($running as $node) { $node_prof = slony::get_node_profile($node['node']); ?> <fieldset class='sdm_node' id='sdm_node_<?php echo $node['node']; ?> '> <legend class='sdm_node_title' id='sdm_node_title_<?php echo $node['node']; ?> '> Node # <?php echo $node['node']; ?> - <?php echo $node_prof['host']; ?>
<?php echo '<br />'; $tablename = $_POST['table']; // apply the changes to the database(s) if ($slony_cluster_name) { // if database is being replicated slony::$silent = true; $dump = slony::propagate_schema_change($_POST['sql']); echo $_POST['sql']; echo "\n<br />\n<br />"; //var_dump($dump); //comment foreach ($dump['output'] as $line) { if (preg_match('#error#i', $line)) { echo '<div style="color:red;">' . $line . '</div>'; $do_not_log = true; } else { echo $line; } echo "\n<br />"; } echo "\n<br />"; if ($do_not_log) { echo "<div style='color:red;'>There was an error propagating the schema change on one or more node, you will need to apply the change manually</div>"; } else { } } else { // no replication is going on.. just execute on the database echo 'no replication on this database.<br />'; // make schema change $SQL = $_POST['sql'];
foreach ($bad_ssh as $bad) { echo "Unable to SSH to {$bad}. <br />"; } // $disable_slony = true; } //var_dump(slony::check_dbconnection()); if ($bad_db = slony::check_dbconnection()) { foreach ($bad_db as $bad) { echo "User '{$bad['user']}' can not connect to database {$bad['conninfo']} with the error \"{$bad['error']}\" <br />"; } } //var_dump(slony::check_slony_is_installed()); if (!slony::cluster_defined()) { //we do not need to perform this check all the time //it is reasonably likely that no one is going to uninstall slony from a node foreach ($bad_slony = slony::check_slony_is_installed() as $key => $bad) { if (!$bad['success']) { $disable_slony = true; if ($bad['success'] === false) { echo "Unable to determine Slony-I installation status on {$bad['host']} for reason \"{$bad['error']}\" <br />"; } else { echo "Slony-I is not installed on {$bad['host']}. <br />"; } } } } ?> </div><?php if (!in_array('ssh2', get_loaded_extensions())) { echo "You are using phpseclib to make your ssh connections. It is recommended you install the libssh2 php extension, which is 10 times faster.<br />"; }
<?php $tablename = $_POST['sky_qs'][0]; $action = $_POST['sky_qs'][1]; if ($tablename == '-multiple-') { $tablename = $_POST['tables']; } slony::$silent = NULL; $tables = explode(',', $tablename); switch ($action) { case 'enable': slony::add_table($tables); break; case 'disable': foreach ($tables as $table) { slony::drop_table($table); } break; default: } /*$i = 0; $SQL = "alter table $tablename $action replication on slave $i"; $dbw->Execute($SQL) or die("$SQL<br>".$dbw->ErrorMsg()); $SQL = "alter table $tablename $action replication"; $dbw->Execute($SQL) or die("$SQL<br>".$dbw->ErrorMsg()); if ($action=='enable') echo 'on'; else echo 'off'; */
} else { //show new cluster page $show_new_cluster = true; //redirect('/dev/slony/add-new'); } template::inc('intranet', 'top'); ?> <div style="margin: 10px 0;"> <?php if ($show_new_cluster) { ?> Before you begin setting up your Slony Cluster, you should thoroughly read the documentation <a href='http://skyphp.org/doc/slony'>here</a>. Make sure you have all the below prerequisites met, you will not be able to continue until you do.<br><br> <?php $prerequisites = slony::check_environment(); $prereqs = array('slony_tables' => 'slony_* Tables Installed', 'slony' => 'Slony-I Installed', 'skyphp_storage_path_writable' => '$skypph_storage_path is Writable', 'libssh2' => 'libssh2 Installed', 'cpan' => 'Perl CPAN Moduels Installed'); ?> <?php $prereqs_met = 0; $errors = array(); foreach ($prereqs as $key => $prereq) { if ($prerequisites[$key] === true) { $prereqs_met++; } else { $errors[] = $prerequisites[$key]; } } if ($prereqs_met == count($prereqs)) { ?>
HAVE CONFLICTING DEFINITIONS! REPLICATION NOT PERMITTED!</strong><?php } else { echo $rep_on ? 'ON' : 'OFF'; } if (!$r->Fields('sequence')) { ?> <br/> <strong class='sequence_warning'>THIS TABLE HAS NO ID SEQUENCE!</strong><?php } if ($r->Fields('haspkey') == 'f') { ?> <br /> <strong class='sequence_warning'>THIS TABLE HAS NO PRIMARY KEY!</strong><?php } ?> </td> <td <?php echo slony::cluster_defined() ? '' : 'class="hide"'; ?> > <script type='text/javascript'>var rep_checkbox_orig_state_<?php echo $r->Fields('tablename'); ?> = <?php echo $rep_on ? 'true' : 'false'; ?> ;</script> <?php if (!$conflict) { ?> <input id='rep_checkbox_<?php echo $r->Fields('tablename');
slony::add_node($id); case 'promote': slony::promote($id); break; case 'uninstall': slony::uninstall(); break; case 'status': $not_running = slony::get_number_of_nodes() - count(slony::get_running_slons()); if ($not_running) { echo "<strong class='status status_bad'>{$not_running} node" . ($not_running > 1 ? 's are' : ' is') . " not replicating!</strong>"; } else { echo "<strong class='status status_good'>All nodes are replicating.</strong>"; } break; case 'kill': //killing pids given to us via javascript has the potential //to wreak havoc if somebody is trying to send non-slony pids... //for instance, someone could feasibly kill our database, or apache... //so we check the given values first to see if they match our slony pids $pid = $_POST['b']; if (!array_key_exists($pid, slony::ps($id))) { echo "No slony related processes are running with pid {$pid}, are you being shady?"; } else { slony::kill($id, $pid); echo "kill ran for {$pid}"; } break; default: die("Wrong parameters."); }
template::inc('intranet', 'top'); ?> <fieldset><legend>Node Profile</legend> <?php aql::form('slony_node'); ?> <input type="button" value="Save" onclick="save_form('<?php echo $model; ?> '<?php echo slony::cluster_defined() ? ",null,null" : ""; ?> );" /> <?php if (!slony::cluster_defined()) { ?> <input type="button" value="Save and Define Another Node" onclick="save_form('<?php echo $model; ?> ',null,null,function(){location.href='/dev/slony/node/add-new';});" /> <input type="button" value="Save and Continue to Next Step" onclick="save_form('<?php echo $model; ?> ',null,null,function(){location.href='/dev/slony/add-new';});" /> <input type="button" value="Discard and Continue to Next Step" onclick="location.href='/dev/slony/add-new';" /> <?php } ?> </fieldset> <?php