W logu takie oto informacje:
2010-06-27 06:45:38 CEST DZIENNIK: could not rename temporary statistics file "global/pgstat.tmp" to "global/pgstat.stat": Nieaktualny uchwyt pliku NFS
A po wylistowaniu głównego klastra czyli:
/var/lib/postgresql/8.3/mainglobal
total 0
-????????? ? ? ? ? ? pgstat.stat
Nie zanotowałem niepożądanego zachowania bazy w tym czasie, nawet pg_controldata zwracał wszystko normalnie, ale w każdym razie nieładne.
Przyczyną był prawdopodobnie nieczyste odmontowanie dysku - pewnie podczas dłuższej awarii zasilania.
Rozwiązanie:
/etc/init.d/postgresql-8.3 stop
umount /var/lib/postgresql
fsck.ext2 /dev/mapper/lvol-1 (partycja z postgresem)
mount /var/lib/postgresql
/etc/init.d/postgresql-8.3 start
If you have ever tried to use phplot library to make dynamically generated graphs i.e. from database, for sure you had find that the alghoritm of making Y tick inrement is not to clever.
This code helps You make it more like Excel/OOSpreadsheet does.
// $max = is the maximum value from data range
$mn = array(2,5,10);
$dm = pow(10, floor(log10(abs($max))-1));
$range = 0;
foreach ($mn AS $v) {
$range = $v * $dm;
if ($range == 0) continue;
$r = $max / $range;
if ($r >= 5 AND $r <= 10) {
$interval = $range;
}
}
if (empty($interval)) {
$interval = $mn[0] * $dm;
}
$plot->SetPlotAreaWorld(NULL,0);
$plot->SetYTickIncrement($interval);
Let’s go
$xml = new DOMDocument('1.0', 'UTF-8');
$xml->preserveWhiteSpace = FALSE;
$xml->formatOutput = TRUE;
$xml->appendChild(new DOMElement('items'));
// access to root element without checking if exists !
$root = $xml->documentElement;
// create new node called item and put it to root (items)
$item = $root->appendChild($xml->createElement('item'));
// create custom node in item child called key with value called Test
$item->appendChild($xml->createElement('key'))->
appendChild($xml->createTextNode('Test'));
$xml->save('test.xml');
If you want to have a lot of great tools from KDE (Umbrello etc) try this
Installer
Home page
Home Page
Teoretycznie można to wykonać w 4 liniach:
Wyedytuj plik /etc/apt/sources.list i zamień “etch” na “lenny“.
#vim /etc/apt/sources.list
#aptitude update
#aptitude install apt dpkg aptitude
#aptitude full-upgrade
Aby rozszerzyć logiczny volumin LVM należy po pierwsze zapewnić miejsce w grupie:
vgdisplay - powinno pokazać dla grupy w pozycji Free PE / Size wolne gigabajty
Następnie odmontowujemy partycję,
umount /mnt/lvol2
rozszerzamy volumin logiczny o 35 GB
lvextend -L +35GB /dev/vg1/lvol2
oraz zwiększamy system plików komendami (dla ext3)
e2fsck /dev/vg1/lvol2
resize2fs /dev/vg1/lvol2
mount /mnt/lvol2
Gotowe, partycja ma już o 35GB więcej.
Jeżeli nie ma miejsca już w grupie, wówczas należy dodać wolumin fizyczny do grupy. Ale o tym napiszę jak się skończy miejsce - czyli pewnie za kilka miesięcy
Przy wykonywaniu skryptu PHP z lini poleceń Windows 7 zgłasza nieoczekiwany błąd aplikacji. O dziwo wygląda na to że polecenia są wykonywane, tylko wywala się moduł na zakończeniu.
Podobny problem jets opisany tutaj:
cli has stopped working on vista
W moim przypadku przyczyną nie był mysqli.dll tylko php_pop3.dll
When trying to connect with SQL Server 2005 with PHP there might be a hard to find problem. PHP just return message: Couldn’t connect to sQL Server on … but there is no specific reason for this.
The first thing where I was looking for a reason was a connection string, precisely the server varaible value ($myServer) e.g.:
ini_set('display_errors', 1);
$myServer = "R400-JAC\CDN_OPTIMA";
$myUser = "sa";
$myPass = "password";
$myDB = "CDN_Demo";
//connection to the database
$dbhandle = mssql_connect($myServer, $myUser, $myPass)
or die("Couldn't connect to SQL Server on $myServer");
//select a database to work with
$selected = mssql_select_db($myDB, $dbhandle)
or die("Couldn't open database $myDB");
//declare the SQL statement that will query the database
$query = "SELECT Knt_Nazwa1, Knt_Grupa
FROM [CDN].[Kontrahenci]";
//execute the SQL query and return records
$result = mssql_query($query);
var_dump($result);
$numRows = mssql_num_rows($result);
echo "
” . $numRows . ” Row” . ($numRows == 1 ? “” : “s”) . ” Returned
“;
//display the results
while($row = mssql_fetch_array($result))
{
echo “
” . $row["Knt_Nazwa1"] . $row["Knt_Grupa"] .”
“;
}
//close the connection
mssql_close($dbhandle);
?>
So then I was trying to find if it is all about SQL Server, so was trying to change port for TCP/IP settings in SQL Surface Area configuration Manager. But all was right (settings was TCP/IP ADN Named Pipes).
Then I launch SQL Server Browser Service which is by default not active. Still wrong. So then I set static port for TCP/IP settings in Server Configuration Manager which is explained here , and trying to change serverName variable for:
- localhost:1443
- localhost,50076 (which I found in registry)
- 192.168.1.3:1433
- R400-JAC\CDN_OPTIMA:1433
- R400-JAC\CDN_OPTIMA:1503 (after change static port in SQL Service Manager)
still nothing…
Then at last I found that the reason was somewhere else. It was about ntwdblib.DLL which was in version 2000.2.8.0. This was not working. I download version 2000.80.194.0 and restart apache - so the script began to work.
At last I return to previous settings in SQL Manager Utilites. Script still working so that was the reason.
This script simply parse given database (demo) and schema (reports) and make and execute desired queries.
Output is saved id current dir.
#!/bin/bash
SCHEMA=reports
DBNAME=demo
psql -U postgres demo -t -c "\dt $SCHEMA. " > tables.dat
psql -U postgres demo -t -c "\dv $SCHEMA. "> views.dat
psql -U postgres demo -t -c "\ds $SCHEMA. " > sequence.dat
echo "SET search_path TO $SCHEMA;" > sametables.sql
echo "SET search_path TO $SCHEMA;" > sameviews.sql
echo "SET search_path TO $SCHEMA;" > sameseq.sql
cat tables.dat | awk -F'\|' '{print $2}' >> sametables.sql
cat views.dat | awk -F'\|' '{print $2}' >> sameviews.sql
cat sequence.dat | awk -F'\|' '{print $2}' >> sameseq.sql
vim -c '%s/^\([ a-z0-9\-_]*\)$/GRANT select,insert,update,delete ON \1 TO http;/’ -c ‘wq’ sametables.sql
vim -c ‘%s/^\([ a-z0-9\-_]*\)$/GRANT select ON \1 TO http;/’ -c ‘wq’ sameviews.sql
vim -c ‘%s/^\([ a-z0-9\-_]*\)$/GRANT usage ON \1 TO http;/’ -c ‘wq’ sameseq.sql
psql -U postgres $DBNAME -f sametables.sql
psql -U postgres $DBNAME -f sameviews.sql
psql -U postgres $DBNAME -f sameseq.sql
psql -U postgres $DBNAME -c “grant ALL ON schema $SCHEMA TO http;”