[Add active_master to replicatedDatabases in global.inc Adrian Georgescu **20080224113759 Added web link between sip target and sip_accounts Rewrite of mysql monitoring functions ] hunk ./mysql_replication_lib.phtml 6 -/* - -To use this library create a web page like this: - -$replicated_databases=array( - "cluster1" => array("db1"=>array('ip' => '10.0.0.131', - 'slave_of' => 'db2', - 'user' => 'root', - 'password' => 'pass' - ), - "db2"=>array('ip' => '10.0.0.132', - 'slave_of' => 'db1' - 'user' => 'root', - 'password' => 'pass' - ) - ) - ); - - -require("mysql_replication_lib.phtml"); - -$ReplicationOverview = new ReplicationOverview($clusters); -$ReplicationOverview->showOverview(); - -*/ - - hunk ./mysql_replication_lib.phtml 63 - $this->server = $_REQUEST['server']; + $this->repair['server_to_repair'] = $_REQUEST['server']; hunk ./mysql_replication_lib.phtml 74 - if ($this->server && $key==$this->server) { - $this->master_hostname=$this->clusters[$this->cluster][$key]['slave_of']; - $this->master_ip=$this->clusters[$this->cluster][$this->master_hostname]['ip']; - $this->master=$this->clusters[$this->cluster][$key]['slave_of']; - break; + foreach (array_keys($this->clusters[$this->cluster]) as $key2) { + if ($key == $key2) continue; + if ($this->clusters[$this->cluster][$key2]['slave_of'] == $key) { + $this->is_master[$key]++; + } hunk ./mysql_replication_lib.phtml 82 - foreach (array_keys($this->clusters[$this->cluster]) as $key) { - if ($this->server && $this->clusters[$this->cluster][$key]['slave_of'] == $this->master && $key != $this->server) { - $this->slave_ip=$this->clusters[$this->cluster][$key]['ip']; - $this->slave_hostname =$key; - break; + if ($this->repair['server_to_repair']) { + + $this->repair['master_server']=$this->clusters[$this->cluster][$this->repair['server_to_repair']]['slave_of']; + + foreach (array_keys($this->clusters[$this->cluster]) as $key) { + if ($this->repair['server_to_repair'] == $this->clusters[$this->cluster][$key]['slave_of']) { + $this->repair['has_slave']= $key; + break; + } + } + + foreach (array_keys($this->clusters[$this->cluster]) as $key) { + if ($this->clusters[$this->cluster][$key]['slave_of'] == $this->repair['master_server'] && $key != $this->repair['server_to_repair']) { + $this->repair['snapshot_server'] = $key; + break; + } + } + + if (!$this->repair['snapshot_server']) { + $this->repair['snapshot_server']=$this->repair['master_server']; + } + + if ($this->repair['snapshot_server'] != $this->repair['master_server']) { + if ($this->clusters[$this->cluster][$this->repair['snapshot_server']]['active_master']) { + $this->repair['snapshot_server'] = $this->repair['master_server']; + } hunk ./mysql_replication_lib.phtml 109 + hunk ./mysql_replication_lib.phtml 111 + hunk ./mysql_replication_lib.phtml 139 - if ($this->server != $key) { - printf ("
Click to learn how to repair me",$_SERVER['PHP_SELF'],urlencode($key),urlencode($this->cluster)); + if ($this->repair['server_to_repair'] != $key) { + printf ("
How to repair me",$_SERVER['PHP_SELF'],urlencode($key),urlencode($this->cluster)); + } else { + printf ("
Repair instructions",$_SERVER['PHP_SELF'],urlencode($key),urlencode($this->cluster)); hunk ./mysql_replication_lib.phtml 169 - printf ("Master status"); - - printf ("Log file%s",$this->status[$key]->color,$this->status[$key]->master_log_file); - printf ("Position%s",$this->status[$key]->master_position); + if ($this->is_master[$key]) { + printf ("Master status"); + printf ("Log file%s",$this->status[$key]->color,$this->status[$key]->master_log_file); + printf ("Position%s",$this->status[$key]->master_position); + } else { + printf ("Master status"); + printf ("Log file%s",$this->status[$key]->master_log_file); + printf ("Position%s",$this->status[$key]->master_position); + } hunk ./mysql_replication_lib.phtml 179 - printf ("Slave status"); + printf ("Slave of %s status",$this->status[$key]->slave_of); hunk ./mysql_replication_lib.phtml 213 - if ($downtime && $key==$this->master_hostname) { + if ($downtime && $key==$this->repair['master_server']) { hunk ./mysql_replication_lib.phtml 221 - if ($downtime && $key==$this->master_hostname) { + if ($downtime && $key==$this->repair['master_server']) { hunk ./mysql_replication_lib.phtml 232 - function printInstructions() { - - if (!$this->server) return; hunk ./mysql_replication_lib.phtml 233 + function printInstructions() { hunk ./mysql_replication_lib.phtml 235 -$text="The ssh public keys for user root must be shared
between machines. Test scp as root between machines."; + if (!$this->repair['server_to_repair']) return; hunk ./mysql_replication_lib.phtml 237 -$this->printStep($this->master_hostname,$text); +$text="The ssh public keys for user root must be shared
between machines. Test scp as root between machines. "; +$text.=sprintf("
Using %s to take snapshot.",$this->repair['snapshot_server']); hunk ./mysql_replication_lib.phtml 240 -if ($this->slave_hostname) { +$this->printStep($this->repair['master_server'],$text); hunk ./mysql_replication_lib.phtml 242 + if ($this->repair['snapshot_server'] != $this->repair['master_server']) { + // lock master and wait for snapshot server to catch up with the master server hunk ./mysql_replication_lib.phtml 251 -# write down file a& possition %s.file %s.pos +# note file & possition %s.file %s.pos hunk ./mysql_replication_lib.phtml 254 -",$this->master_hostname,$this->master_hostname); +",$this->repair['master_server'],$this->repair['master_server']); hunk ./mysql_replication_lib.phtml 256 -$this->printStep($this->master_hostname,$text); +$this->printStep($this->repair['master_server'],$text); hunk ./mysql_replication_lib.phtml 263 -# wait until same file/pos as %s is displayed +# wait until same possition as %s hunk ./mysql_replication_lib.phtml 266 -",$this->master_hostname); +",$this->repair['master_server']); hunk ./mysql_replication_lib.phtml 268 -$this->printStep($this->slave_hostname,$text,true); +$this->printStep($this->repair['snapshot_server'],$text,true); hunk ./mysql_replication_lib.phtml 272 -$this->printStep($this->master_hostname,$text); - - -$text=" - -/etc/init.d/monit stop - -/etc/init.d/mysql stop - -"; - -$this->printStep($this->slave_hostname,$text); - -$text=" - -/etc/init.d/monit stop - -/etc/init.d/mysql stop - -"; - -$this->printStep($this->server,$text); - -$text=sprintf(" -rsync -avzP --delete /var/lib/mysql %s:/var/lib/ - -/etc/init.d/mysql start - -/etc/init.d/monit start -",$this->server); - -$this->printStep($this->slave_hostname,$text); +$this->printStep($this->repair['master_server'],$text); hunk ./mysql_replication_lib.phtml 275 + } else { hunk ./mysql_replication_lib.phtml 277 -(cd /var/lib/mysql/; rm *.info *relay-bin*) - -/etc/init.d/mysql start - -/etc/init.d/monit start hunk ./mysql_replication_lib.phtml 280 -show master status; -# write down the file and possition %s.file %s.pos - -CHANGE MASTER TO MASTER_HOST='%s', -MASTER_USER='%s', -MASTER_PASSWORD='%s', -MASTER_LOG_FILE='%s.file', -MASTER_LOG_POS=%s.pos; - -slave start; +slave stop; hunk ./mysql_replication_lib.phtml 282 -",$this->server, -$this->server, -$this->master_ip, -$this->clusters[$this->cluster][$this->master_hostname]['replication_user'], -$this->clusters[$this->cluster][$this->master_hostname]['replication_password'], -$this->master_hostname, -$this->master_hostname +show master status; +# note file & possition %s.file %s.pos +",$this->repair['snapshot_server'], +$this->repair['snapshot_server'] hunk ./mysql_replication_lib.phtml 287 -$this->printStep($this->server,$text); hunk ./mysql_replication_lib.phtml 288 -$text=sprintf(" +$this->printStep($this->repair['snapshot_server'],$text); hunk ./mysql_replication_lib.phtml 290 -mysql -u root -p + } hunk ./mysql_replication_lib.phtml 292 -stop slave; hunk ./mysql_replication_lib.phtml 293 -CHANGE MASTER TO MASTER_HOST='%s', -MASTER_USER='%s', -MASTER_PASSWORD='%s', -MASTER_LOG_FILE='%s.file', -MASTER_LOG_POS=%s.pos; +$text=" hunk ./mysql_replication_lib.phtml 295 -slave start; -", -$this->clusters[$this->cluster][$this->server]['ip'], -$this->clusters[$this->cluster][$this->server]['replication_user'], -$this->clusters[$this->cluster][$this->server]['replication_password'], -$this->server, -$this->server -); +/etc/init.d/monit stop hunk ./mysql_replication_lib.phtml 297 -$this->printStep($this->master_hostname,$text); +/etc/init.d/mysql stop hunk ./mysql_replication_lib.phtml 299 - } else { +"; hunk ./mysql_replication_lib.phtml 301 +$this->printStep($this->repair['snapshot_server'],$text); hunk ./mysql_replication_lib.phtml 311 -$this->printStep($this->server,$text); - +$this->printStep($this->repair['server_to_repair'],$text); hunk ./mysql_replication_lib.phtml 314 +rsync -avzP --delete /var/lib/mysql %s:/var/lib/ hunk ./mysql_replication_lib.phtml 316 -mysql -u root -p - -flush tables with read lock; - -show master status; -# write down the file and possition %s.file %s.pos - -unlock tables; +",$this->repair['server_to_repair']); hunk ./mysql_replication_lib.phtml 318 -/etc/init.d/monit stop +$this->printStep($this->repair['snapshot_server'],$text); hunk ./mysql_replication_lib.phtml 320 -/etc/init.d/mysql stop - -rsync -avzP --delete /var/lib/mysql %s:/var/lib/ +$text=sprintf(" hunk ./mysql_replication_lib.phtml 325 +",$this->repair['server_to_repair']); hunk ./mysql_replication_lib.phtml 327 -", -$this->master_hostname, -$this->master_hostname, -$this->server -); - -$this->printStep($this->master_hostname,$text,true); +$this->printStep($this->repair['snapshot_server'],$text); hunk ./mysql_replication_lib.phtml 339 -# write down the file and possition %s.file %s.pos +# note %s.file %s.pos hunk ./mysql_replication_lib.phtml 349 -",$this->server, -$this->server, -$this->master_ip, -$this->clusters[$this->cluster][$this->master_hostname]['replication_user'], -$this->clusters[$this->cluster][$this->master_hostname]['replication_password'], -$this->master_hostname, -$this->master_hostname +",$this->repair['server_to_repair'], +$this->repair['server_to_repair'], +$this->clusters[$this->cluster][$this->repair['master_server']]['ip'], +$this->clusters[$this->cluster][$this->repair['master_server']]['replication_user'], +$this->clusters[$this->cluster][$this->repair['master_server']]['replication_password'], +$this->repair['master_server'], +$this->repair['master_server'] hunk ./mysql_replication_lib.phtml 357 -$this->printStep($this->server,$text); +$this->printStep($this->repair['server_to_repair'],$text); hunk ./mysql_replication_lib.phtml 373 -$this->clusters[$this->cluster][$this->server]['ip'], -$this->clusters[$this->cluster][$this->server]['replication_user'], -$this->clusters[$this->cluster][$this->server]['replication_password'], -$this->server, -$this->server +$this->clusters[$this->cluster][$this->repair['server_to_repair']]['ip'], +$this->clusters[$this->cluster][$this->repair['server_to_repair']]['replication_user'], +$this->clusters[$this->cluster][$this->repair['server_to_repair']]['replication_password'], +$this->repair['server_to_repair'], +$this->repair['server_to_repair'] hunk ./mysql_replication_lib.phtml 380 -$this->printStep($this->master_hostname,$text); +if ($this->clusters[$this->cluster][$this->repair['master_server']]['slave_of'] == $this->repair['server_to_repair']) { + $this->printStep($this->repair['master_server'],$text); +} hunk ./mysql_replication_lib.phtml 384 - } hunk ./mysql_replication_lib.phtml 385 + hunk ./provisioning/ngnpro_client_lib.phtml 3032 + + $_sip_accounts_url = $this->url.sprintf("&service=sip_accounts@%s&username_filter=%s&domain_filter=%s", + urlencode($this->SoapEngine->soapEngine), + urlencode($alias->target->username), + urlencode($alias->target->domain) + ); hunk ./provisioning/ngnpro_client_lib.phtml 3056 - %s@%s + %s@%s hunk ./provisioning/ngnpro_client_lib.phtml 3069 + $_sip_accounts_url, hunk ./rating_lib.phtml 142 - syslog(LOG_NOTICE, "Duration less than minimum $this->minimumDuration"); + //syslog(LOG_NOTICE, "Duration less than minimum $this->minimumDuration"); hunk ./rating_lib.phtml 1231 - "name"=>"Active", + "name"=>"Lock", hunk ./rating_lib.phtml 4131 - "ShowAccounts\n". hunk ./rating_lib.phtml 4133 - "ReloadRatingTables\n". - "ShowProfiles\n". - "ShowENUMtlds\n". - "ShowMemory\n". - "ReloadSipAccountsWithQuota\n". - "ReloadDomains\n". hunk ./rating_lib.phtml 4138 - "DebitBalance From=sip:123@example.com To=sip:0031650222333 Duration=59\n". + "DebitBalance From=sip:123@example.com To=sip:0031650222333@example.com Duration=59\n". + "ShowPrepaidAccounts Filter=123@example.com\n". hunk ./rating_lib.phtml 4141 - "ShowPrepaidAccounts Filter=123@example.com\n" + "ReloadRatingTables\n". + "ReloadSipAccountsWithQuota\n". + "ReloadDomains\n". + "ShowAccounts\n". + "ShowProfiles\n". + "ShowENUMtlds\n". + "ShowMemory\n" hunk ./setup/global.inc.in 182 - 'replication_password'=>'password' + 'replication_password'=>'password', + 'active_master' => true hunk ./setup/global.inc.new.installation 109 - 'replication_password'=>'password' + 'replication_password'=>'password', + 'active_master' => true