環境
phpのバージョン
PHP 5.4.16 (cli) (built: Aug 11 2016 21:24:59)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies
MariaDBのバージョン
mysql Ver 15.1 Distrib 10.1.16-MariaDB, for Linux (x86_64) using readline 5.1
したいこと
MariaDBで設定しているレプリケーションを監視するPHPを作成したい。
問題点
mysql_query("show slave status", $connect)の箇所でエラーが出る。
クエリが実行できていないっぽい
php
1<?php 2 print("<body>\n"); 3 4 $url = "192.168.1.2"; 5 $user = "slave"; 6 $pass = "XXXXXXX"; 7 $db = "test"; 8 $sel_result = "failed"; 9 10 $connect = mysql_connect($url,$user,$pass) or die("Connect Failed"); 11 12 $res = mysql_query("show slave status", $connect) or die("error!"); 13 $row = mysql_fetch_assoc($res); 14 15 if($row['Slave_IO_Running'] == 'No'){ 16 print "Replication Error \n"; 17 } 18 elseif($row['Slave_SQL_Running']== 'No'){ 19 print "Replication Error \n"; 20 } 21 else{ 22 print "error :0:"; 23 } 24?>
ご教授お願い致します
回答2件
あなたの回答
tips
プレビュー