Recent Comments

This is default featured slide 1 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 2 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 3 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 4 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 5 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

2012年5月18日 星期五

postgresql agent設定

以下執行方式是linux系統的設定方式

安裝pgagent 於centos linux

yum install pgagent_91

在執行psql指令時要用postgres帳號做操作
登入帳號

su -l postgres

為資料庫安裝pgagent,這一步要注意,要確定將pgagent.sql安裝到正確的資料庫,
安裝pgagent到資料庫postgres

psql < /usr/share/pgagent_91-3.0.1/pgagent.sql
安裝pgagent到資料庫n5_data

psql -d n5_data < /usr/share/pgagent_91-3.0.1/pgagent.sql

pgagent.sql執行內容,會在該資料庫中建立所需要的資料表,建好後用PgAdminIII中的catalogs->pgAgent->Tables中看到

-bash-4.1$ psql -d n5_data < /usr/share/pgagent_91-3.0.1/pgagent.sql
Password:
BEGIN
CREATE SCHEMA
COMMENT
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "pga_jobagent_pkey" for table "pga_jobagent"
CREATE TABLE
COMMENT
NOTICE:  CREATE TABLE will create implicit sequence "pga_jobclass_jclid_seq" for serial column "pga_jobclass.jclid"
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "pga_jobclass_pkey" for table "pga_jobclass"
CREATE TABLE
CREATE INDEX
COMMENT
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
NOTICE:  CREATE TABLE will create implicit sequence "pga_job_jobid_seq" for serial column "pga_job.jobid"
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "pga_job_pkey" for table "pga_job"
CREATE TABLE
COMMENT
COMMENT
NOTICE:  CREATE TABLE will create implicit sequence "pga_jobstep_jstid_seq" for serial column "pga_jobstep.jstid"
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "pga_jobstep_pkey" for table "pga_jobstep"
CREATE TABLE
CREATE INDEX
COMMENT
COMMENT
COMMENT
NOTICE:  CREATE TABLE will create implicit sequence "pga_schedule_jscid_seq" for serial column "pga_schedule.jscid"
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "pga_schedule_pkey" for table "pga_schedule"
CREATE TABLE
CREATE INDEX
COMMENT
NOTICE:  CREATE TABLE will create implicit sequence "pga_exception_jexid_seq" for serial column "pga_exception.jexid"
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "pga_exception_pkey" for table "pga_exception"
CREATE TABLE
CREATE INDEX
CREATE INDEX
COMMENT
NOTICE:  CREATE TABLE will create implicit sequence "pga_joblog_jlgid_seq" for serial column "pga_joblog.jlgid"
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "pga_joblog_pkey" for table "pga_joblog"
CREATE TABLE
CREATE INDEX
COMMENT
COMMENT
NOTICE:  CREATE TABLE will create implicit sequence "pga_jobsteplog_jslid_seq" for serial column "pga_jobsteplog.jslid"
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "pga_jobsteplog_pkey" for table "pga_jobsteplog"
CREATE TABLE
CREATE INDEX
COMMENT
COMMENT
COMMENT
CREATE FUNCTION
CREATE FUNCTION
COMMENT
CREATE FUNCTION
COMMENT
CREATE FUNCTION
COMMENT
CREATE TRIGGER
COMMENT
CREATE FUNCTION
COMMENT
CREATE TRIGGER
COMMENT
CREATE FUNCTION
COMMENT
CREATE TRIGGER
COMMENT
COMMIT
-bash-4.1$ exit
logout
以上只是為資料庫建立基本的環境,以上執行完時啟動PgAdminIII後,點選該資料庫會在tree中新增一個jobs的項目
可在該jobs中新增排程。

排程建立好後並不會執行,需要啟動pgagent的服務才會依jobs中的設定執行排程,以下指令要在root下操作
因為每個資料庫都建有自已的pgagent,所以在啟動服務的部分也要依不同的資料庫做啟動,指令如下

資料庫postgres啟動排程

pgagent  hostaddr=localhost dbname=postgres user=postgres password=******

資料庫n5_data啟動排程

pgagent  hostaddr=localhost dbname=n5_data user=postgres password=******

執行指令後若沒有錯誤代表啟動成功
可以用ps aux | grep pgagent做檢查

[root@db ~]# ps aux | grep pgagent
root     20774  0.0  0.0 229664  2688 ?        S    17:27   0:00 pgagent hostaddr=localhost dbname=postgres user=postgres password=******
root     21028  0.0  0.0  78012  2292 ?        S    17:32   0:00 pgagent hostaddr=localhost dbname=n5_data user=postgres password=******
root     22467  0.0  0.0 103232   856 pts/0    S+   18:02   0:00 grep pgagent
[root@db ~]#

參考文件

2012年5月4日 星期五

postgresql install pgagent工作排程

yum install pgagent_91

su -l postgres
psql < /usr/share/pgagent_91-3.0.1/pgagent.sql

在PgAdminIII下就會出現Job的功能!

postgresql 備份和還原

備份
pg_dump dbname | gzip > filename.gz


還原前先建立
tablespace
資料庫使用者
資料庫


還原
gunzip -c filename.gz | psql dbname

vsftpd 防火牆設定

vim /etc/sysconfig/iptables-con

IPTABLES_MODULES=""
改成

IPTABLES_MODULES="ip_nat_ftp ip_conntrack_ftp"

vim /etc/sysconfig/iptables
加入

-A INPUT -m state --state NEW -m tcp -p tcp --dport 21 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 20 -j ACCEPT

重新啟動iptables

service iptables restart

selinux
setsebool -P ftp_home_dir=1


2012年5月3日 星期四

centos 關 ping

vim /etc/sysctl.conf

加入一行
net.ipv4.icmp_echo_ignore_all = 1

1:關
0:開

設定好後
sysctl -p

install phpPgAdmin

yum install httpd php

設定 vim /etc/httpd/conf/httpd.conf
DirectoryIndex後面加入index.php



安裝phpPgAdmin

  • yum安裝
    yum install phpPgAdmin
    會將相關的apache php等套件一同安裝
    使用yum安裝完後在/var/www/html並沒有發現phpPgAdmin的資料夾
    主要分成兩個部分
    主程式:/usr/share/phpPgAdmin
    設定檔:/etc/phpPgAdmin/config.inc.php
    網址:127.0.0.1/phpPgAdmin就可以連到,系統會自動設好
    
  • 手動下載安裝:
    下載網站:http://phppgadmin.sourceforge.net/doku.php?id=download
    下載完後解開到/var/www/html下即可
    設定檔:phpPgAdmin/conf/config.inc.php
    網址:127.0.0.1/phpPgAdmin就可以連到
    

設定config.inc.php

vim /etc/phpPgAdmin/config.inc.php

$conf['servers'][0]['host'] = 'localhost';

// Only show owned databases?
// Note: This will simply hide other databases in the list - this does
// not in any way prevent your users from seeing other database by
// other means. (e.g. Run 'SELECT * FROM pg_database' in the SQL area.)
$conf['owned_only'] = true;

// If extra login security is true, then logins via phpPgAdmin with no
// password or certain usernames (pgsql, postgres, root, administrator)
// will be denied. Only set this false once you have read the FAQ and
// understand how to change PostgreSQL's pg_hba.conf to enable
// passworded local connections.
$conf['extra_login_security'] = false;

設定vim /etc/httpd/conf.d/phpPgAdmin.conf
刪除Allow from 127.0.0.1
增加allow from all
重啟httpd

設定SELinux讓網頁可以連接資料庫

setsebool -P httpd_can_network_connect_db=1


2012年5月2日 星期三

Server instrumentation not install

安裝完postgresql後,用PgAdminIII連線會出現Server instrumentation not install的視窗

解決方法:
yum install postgresql91-contrib
su - postgres
psql < /usr/pgsql-9.1/share/extension/adminpack--1.0.sql
再用PgAdminIII重新連線一次,點選在 Server instrumentation not install的視窗下方的『Fix it!』按鈕