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.

2014年1月21日 星期二

wwDBLookupCombo動態設定打開下拉選單時要顯示的內容

一般來說可以直接在屬性欄位中的selected中就可以設定要顯示的欄位內容
但因為在不同的資料表共用一個元件時,會因為不同的資料表欄位
而造成要動態去設定要顯示的內容,在切換時先clear,把之前的設定清除
然後用append或add去把後面的字串加入
lcn是欄位名稱
10是要顯示的欄位寬

以下的設定中有很多的\t \r \n這些,目前主要是直接看在屬性欄位設定好後所抓出的字串
wwDBLookupCombo->Selected->Clear();
wwDBLookupCombo->Selected->Append("lcn\t10\tlcn\t\t\r\n");
wwDBLookupCombo->Selected->Append("road_name\t40\troad_name\t\t\r\n");


實際測試最少要在欄位名稱和欄位寬的中間加入\t即可
wwDBLookupComboAddEquipmentLcn->Selected->Clear();
wwDBLookupComboAddEquipmentLcn->Selected->Append("lcn\t10\tlcn");
wwDBLookupComboAddEquipmentLcn->Selected->Append("road_name\t40\tnroad_name");




2014年1月16日 星期四

[BCB]找出同一層內的Component

找出同一層內的Component
於function可以再定義要找的Component type

this->test(this->GroupBox1);
======================================================
void TForm1::test(TWinControl* pObj)
{
    for (unsigned short int i=0 ; iControlCount ; i++)
    {
            if (String(pObj->Controls[i]->ClassName())==”TEdit”)
            {
                ((TEdit *)pObj->Controls[i])->Text = “get it”;
            }
            if (String(pObj->Controls[i]->ClassName())==”TLabel”)
            {
                ((TEdit *)pObj->Controls[i])->Text = “get it”;
            }
    }
}

2014年1月14日 星期二

MSSQL 防止儲存需要資料表重建的變更

當修改MSSQL資料表的資料型態或是否null時出現『防止儲存需要資料表重建的變更』
主要是因為某些設定會造成格式不符資料流失所出現的提醒,但在開發建立時會時常修改
可以在
『SQL Server Management Studio(SSMS) ->工具->選項->設計師->資料表和資料庫設計工具』
頁面中的『防止儲存需要資料表重建的變更』取消勾選後點選『確定』即可。




2013年12月25日 星期三

unknown picture file extension (.png)

fcImager1->Picture->LoadFromFile(progPath+"bibibi.png");

當動態找入png圖檔時出現『unknown picture file extension (.png)』

在該cpp檔案前加入
#pragma link "pngimage"

建議先clean project後再重編一次。


若要找入jpg圖檔include jpeg.hpp
#include

2013年12月24日 星期二

ORA-00059: maximum number of DB_FILES exceeded

alter system set db_files=300 scope=spfile;
shutdown immediate
startup


SQL> show parameter db_files

NAME     TYPE VALUE
------------------------------------ ----------- ------------------------------
db_files     integer 200
SQL> alter system set db_files=300 scope=spfile;

System altered.

SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup
ORACLE instance started.

Total System Global Area  570425344 bytes
Fixed Size    2097888 bytes
Variable Size  205524256 bytes
Database Buffers  356515840 bytes
Redo Buffers    6287360 bytes
Database mounted.
Database opened.
SQL> show parameter db_files

NAME     TYPE VALUE
------------------------------------ ----------- ------------------------------
db_files     integer 300

2013年12月20日 星期五

PostgreSQL 安裝 pldebugger USE_PGSX

PostgreSQL 安裝 pldebugger USE_PGSX

使用 USE_PGSX=1 make,在pldebugger編好後就會直接把編好的plugin_debugger.so和pldbgapi--1.0.sql放到/usr/pgsql-9.3相對應的位置。

yum install git readline-devel zlib-devel openssl-devel

cd /opt
tar xvzf postgresql-9.3.2.tar.gz

cd /opt/postgresql-9.3.2
USE_PGXS=1 ./configure
USE_PGXS=1 make

cd /opt/postgresql-9.3.2/contrib/
git clone git://git.postgresql.org/git/pldebugger.git
make 

cd /opt/postgresql-9.3.2/contrib/pldebugger
USE_PGXS=1 make
USE_PGXS=1 make install

[root@localhost pldebugger]# USE_PGXS=1 make install                                                                                                         gcc -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -I/usr/include/et -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fpic -shared -o plugin_debugger.so plpgsql_debugger.o plugin_debugger.o dbgcomm.o pldbgapi.o -L/usr/pgsql-9.3/lib -L/usr/lib64 -Wl,--as-needed
/bin/mkdir -p '/usr/pgsql-9.3/lib'
/bin/mkdir -p '/usr/pgsql-9.3/share/extension'
/bin/mkdir -p '/usr/pgsql-9.3/share/extension'
/bin/mkdir -p '/usr/share/doc/pgsql/extension'
/usr/bin/install -c -m 755  plugin_debugger.so '/usr/pgsql-9.3/lib/plugin_debugger.so'
/usr/bin/install -c -m 644 ./pldbgapi.control '/usr/pgsql-9.3/share/extension/'
/usr/bin/install -c -m 644 ./pldbgapi--1.0.sql ./pldbgapi--unpackaged--1.0.sql  '/usr/pgsql-9.3/share/extension/'
/usr/bin/install -c -m 644 ./README.pldebugger '/usr/share/doc/pgsql/extension/'


vim /var/lib/pgsql/9.3/data/postgresql.conf
加入下面的設定
shared_preload_libraries = '$libdir/plugin_debugger'

重新啟動
service postgresql-9.3 restart

安裝pldbgapi
su - postgres
psql
CREATE EXTENSION pldbgapi;
\dx

-bash-4.1$ psql
psql (9.3.2)
Type "help" for help.

postgres=# CREATE EXTENSION pldbgapi;
CREATE EXTENSION
postgres=# \dx
                              List of installed extensions
   Name    | Version |   Schema   |                     Description
-----------+---------+------------+------------------------------------------------------
adminpack | 1.0     | pg_catalog | administrative functions for PostgreSQL
pldbgapi  | 1.0     | public     | server-side support for debugging PL/pgSQL functions
plpgsql   | 1.0     | pg_catalog | PL/pgSQL procedural language
(3 rows)

================================================================
當pldebugger在USE_PGXS=1 make時出現下面的錯誤要安裝 openssl-devel套件,安裝好後再重新執行USE_PGXS=1 make

[root@localhost pldebugger]# USE_PGXS=1 make
gcc -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -I/usr/include/et -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fpic -I. -I. -I/usr/pgsql-9.3/include/server -I/usr/pgsql-9.3/include/internal -I/usr/include/et -D_GNU_SOURCE -I/usr/include/libxml2  -I/usr/include  -c -o pldbgapi.o pldbgapi.c
In file included from pldbgapi.c:98:
/usr/pgsql-9.3/include/server/libpq/libpq-be.h:25:25: error: openssl/ssl.h: No such file or directory
/usr/pgsql-9.3/include/server/libpq/libpq-be.h:26:25: error: openssl/err.h: No such file or directory
/usr/pgsql-9.3/include/server/libpq/libpq-be.h:36:27: error: gssapi/gssapi.h: No such file or directory
In file included from pldbgapi.c:98:
/usr/pgsql-9.3/include/server/libpq/libpq-be.h:86: error: expected specifier-qualifier-list before ‘gss_buffer_desc’
/usr/pgsql-9.3/include/server/libpq/libpq-be.h:176: error: expected specifier-qualifier-list before ‘SSL’
make: *** [pldbgapi.o] Error 1

PL/SQL 和 PL/pgSQL 旅行時間TRIGGER

以下TRIGGER內容主要是當區段旅行時間比對成功後,在INSERT AVI_SECTION_TRAVEL資料表後會執行下面的TRIGGER,將新的旅行時間更新到XML_AVI_VALUE表中,因為資料的時間需要是每五分鐘的顯示,如5分、10分,N_MIN_FIND就是找出現在旅行時間是在那個五分鐘區間中,如旅行時間是20131221 12:12:30,則 N_MIN_FIND會是20131221 12:15:00

以下是ORACLE和POSTGRESQL的寫法,主要差異在N_MIN_MOD和N_MIN_FIND兩個變數

ORACLE
=====================================================================
DECLARE
C_MIN_LOG_RANGE CONSTANT INTEGER := 5; --統計分鐘數
  N_MIN_MOD INTEGER;       --取餘數
  N_MIN_ADD INTEGER;       --以旅行時間要加的分鐘數 (統計分鐘數 - N_MIN_MOD)
  N_MIN_FIND TIMESTAMP;    --找volume記錄時間  = 旅行時間 + N_MIN_ADD
N_RECORD_COUNT INTEGER;
BEGIN
N_MIN_MOD := MOD(TO_CHAR(:NEW.DATETIME,'MI'),C_MIN_LOG_RANGE);
  N_MIN_ADD := C_MIN_LOG_RANGE-N_MIN_MOD;
  N_MIN_FIND := TO_TIMESTAMP(TO_CHAR(:NEW.DATETIME+(N_MIN_ADD/1440),'YYYY-MM-DD HH24:MI'),'YYYY-MM-DD HH24:MI');

SELECT COUNT(SECTION_ID) INTO N_RECORD_COUNT FROM XML_AVI_VALUE WHERE SECTION_ID=:NEW.SECTION_ID;

IF N_RECORD_COUNT>0 THEN
UPDATE XML_AVI_VALUE SET TRAVELTIME=:NEW.TRAVEL_SMOOTH,DATACOLLECTTIME=N_MIN_FIND  WHERE SECTION_ID=:NEW.SECTION_ID;
END IF;
END;


POSTGRESQL
=====================================================================
DECLARE
C_MIN_LOG_RANGE CONSTANT INTEGER := 5; --統計分鐘數
N_MIN_MOD INTEGER;       --取餘數
N_MIN_ADD INTEGER;       --以旅行時間要加的分鐘數 (統計分鐘數 - N_MIN_MOD)
N_MIN_FIND TIMESTAMP;     --找volume記錄時間  = 旅行時間 + N_MIN_ADD
N_RECORD_COUNT INTEGER; --找出XML_AVI_VALUE資料表中是否有該SECTION_ID的資料
BEGIN--

--insert avi_xml_value
        N_MIN_MOD := MOD(to_number(TO_CHAR(NEW.datetime,'MI'),'99'),C_MIN_LOG_RANGE);
        IF N_MIN_MOD=0 THEN
   N_MIN_ADD := 0;
ELSE
   N_MIN_ADD := C_MIN_LOG_RANGE-N_MIN_MOD;
END IF;

N_MIN_FIND := TO_TIMESTAMP(TO_CHAR(NEW.datetime,'YYYY-MM-DD HH24:MI'),'YYYY-MM-DD HH24:MI')+(TO_TIMESTAMP(TO_CHAR(N_MIN_ADD,'99'),'MI')-TO_TIMESTAMP(TO_CHAR(0,'99'),'MI'));

SELECT COUNT(SECTION_ID) INTO N_RECORD_COUNT FROM XML_AVI_VALUE WHERE SECTION_ID=NEW.SECTION_ID;

IF N_RECORD_COUNT>0 THEN
   UPDATE XML_AVI_VALUE SET TRAVELTIME=NEW.TRAVEL_SMOOTH,DATACOLLECTTIME=N_MIN_FIND  WHERE SECTION_ID=NEW.SECTION_ID;
END IF;
END;

PostgreSQL 安裝 pldebugger

yum install git readline-devel zlib-devel

cd /opt
tar xvzf postgresql-9.3.2.tar.gz
cd /opt/postgresql-9.3.2/contrib/
git clone git://git.postgresql.org/git/pldebugger.git

cd /opt/postgresql-9.3.2
./configure
make

cd /opt/postgresql-9.3.2/contrib/pldebugger
make
make install

/bin/mkdir -p '/usr/local/pgsql/lib'
/bin/mkdir -p '/usr/local/pgsql/share/extension'
/bin/mkdir -p '/usr/local/pgsql/share/extension'
/bin/mkdir -p '/usr/local/pgsql/share/doc//extension'
/usr/bin/install -c -m 755  plugin_debugger.so '/usr/local/pgsql/lib/plugin_debugger.so'
/usr/bin/install -c -m 644 ./pldbgapi.control '/usr/local/pgsql/share/extension/'
/usr/bin/install -c -m 644 ./pldbgapi--1.0.sql ./pldbgapi--unpackaged--1.0.sql  '/usr/local/pgsql/share/extension/'
/usr/bin/install -c -m 644 ./README.pldebugger '/usr/local/pgsql/share/doc//extension/'

cp /usr/local/pgsql/lib/plugin_debugger.so /usr/pgsql-9.3/lib/  
cp /usr/local/pgsql/share/extension/pldbgapi--1.0.sql /usr/pgsql-9.3/share/extension/  
cp /usr/local/pgsql/share/extension/pldbgapi--unpackaged--1.0.sql /usr/pgsql-9.3/share/extension/
cp /usr/local/pgsql/share/extension/pldbgapi.control /usr/pgsql-9.3/share/extension/

vim /var/lib/pgsql/9.3/data/postgresql.conf
加入
shared_preload_libraries = '$libdir/plugin_debugger'

service postgresql-9.3 restart

su - postgres
psql
CREATE EXTENSION pldbgapi;
\dx

-bash-4.1$ psql
psql (9.3.2)
Type "help" for help.

postgres=# CREATE EXTENSION pldbgapi;
CREATE EXTENSION
postgres=# \dx
                              List of installed extensions
   Name    | Version |   Schema   |                     Description
-----------+---------+------------+------------------------------------------------------
adminpack | 1.0     | pg_catalog | administrative functions for PostgreSQL
pldbgapi  | 1.0     | public     | server-side support for debugging PL/pgSQL functions
plpgsql   | 1.0     | pg_catalog | PL/pgSQL procedural language
(3 rows)

postgres=#

2012年9月2日 星期日

CentOS 設定使用者自動登入


 vim /etc/gdm/custom.conf

[daemon]
AutomaticLoginEnable=true
AutomaticLogin=abc


2012年8月15日 星期三

找出重疊的元件


.cpp
//---------------------------------------------------------------------------

#include
#pragma hdrstop

#include "Unit2.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm2 *Form2;
//---------------------------------------------------------------------------
__fastcall TForm2::TForm2(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm2::___TEST(TObject *Sender, TMouseButton Button,
TShiftState Shift, int X, int Y)
{
int I;
TPoint pt;
TStringList *L = new TStringList;
GetCursorPos(&pt);
pt = this->ScreenToClient(pt);
for (I=0; I if (!Controls[I]->ClassNameIs("TPaintBox")){
continue;
}
if (!PtInRect(Controls[I]->BoundsRect , pt)){
continue;
}
L->Add(Controls[I]->Name);
}
ListBox1->Items->Text = L->Text;
delete L;
}
//---------------------------------------------------------------------------
void __fastcall TForm2::PaintBox1Paint(TObject *Sender)
{
TPaintBox  *tPbx =((TPaintBox *)Sender);
tPbx->Canvas->Rectangle(0,0,tPbx->Width,tPbx->Height);
}
//---------------------------------------------------------------------------
void __fastcall TForm2::Button1Click(TObject *Sender)
{
for (int I=0; I if (!Controls[I]->ClassNameIs("TPaintBox")){
continue;
}
((TPaintBox*)Controls[I])->OnMouseDown = ___TEST;
}
}
//---------------------------------------------------------------------------

====================================================
.h
//---------------------------------------------------------------------------

#ifndef Unit2H
#define Unit2H
//---------------------------------------------------------------------------
#include
#include
#include
#include
#include
//---------------------------------------------------------------------------
class TForm2 : public TForm
{
__published: // IDE-managed Components
TPaintBox *PaintBox1;
TPaintBox *PaintBox2;
TPaintBox *PaintBox3;
TListBox *ListBox1;
TButton *Button1;
void __fastcall PaintBox1Paint(TObject *Sender);
void __fastcall Button1Click(TObject *Sender);

private: // User declarations
void __fastcall ___TEST(TObject *Sender, TMouseButton Button,
TShiftState Shift, int X, int Y);
public: // User declarations
__fastcall TForm2(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TForm2 *Form2;
//---------------------------------------------------------------------------
#endif

2012年8月6日 星期一

移動滑鼠執行事件


  SetCursorPos(30,30);
mouse_event(MOUSEEVENTF_LEFTDOWN,30,30,NULL,NULL);
mouse_event(MOUSEEVENTF_LEFTUP,30,30,NULL,NULL);
mouse_event(MOUSEEVENTF_LEFTDOWN,30,30,NULL,NULL);
mouse_event(MOUSEEVENTF_LEFTUP,30,30,NULL,NULL);

2012年7月1日 星期日

shell script 數字補0

數字1、2、3、 補0 => 01、02、03

xx=`echo $num|awk'{printf "%02d", $1}'`
echo $xx;

2012年6月28日 星期四

CentOS6用yum安裝webmin

vim /etc/yum.repos.d/webmin.repo
加入下面的內容

[Webmin]
name=Webmin Distribution Neutral 
baseurl=http://download.webmin.com/download/yum 
enabled=1

rpm --import http://www.webmin.com/jcameron-key.asc
yum install webmin
yum install gcc openssl openssl-devel

http://localhost:10000
帳號密碼為系統管理者root

2012年6月7日 星期四

the log_filename parameter must equal

當執行pgadmin III的工具->伺服器狀態時會出現the log_filename parameter must equal……
主要是設定檔的LOG FILE格式和PGADMIN III的格式不符所造成的

修改postgresql.conf
vim /var/lib/pgsql/9.1/data/postgresql.conf
修改下面log_filename的參數內容
log_filename = 'postgresql-%Y-%m-%d_%H%M%S.log'

安裝adminpack


使用locate adminpack找到檔案路徑
/usr/pgsql-9.1/share/extension/adminpack--1.0.sql


執行
su -l postgres
psql -d n5_data < /usr/pgsql-9.1/share/extension/adminpack--1.0.sql


出現Use "CREATE EXTENSION adminpack" to load this file.
在9.1的安裝方式改了,改用下面的指令,直接到資料庫中執行指令產生


psql -d n5_data 
CREATE EXTENSION adminpack


最後reload設定檔
su -l postgres
 /usr/pgsql-9.1/bin/pg_ctl reload -d /var/lib/pgsql/9.1/data/

重新開始後pgadmin iii就不會出現這個錯誤,也可以用pgadmin直接看到log內容
log檔案位置:/var/lib/pgsql/9.1/data/pg_log

2012年6月4日 星期一

解壓縮資料夾下的檔案

解壓縮Z
ls *.tar.Z | xargs -n 1 gunzip -d


解開檔案
ls *.tar | xargs -n 1 tar -xvf 

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