Wednesday, May 13, 2009

Unable to find the socket transport “ssl” - maybe you forget to enable it when you configured PHP?

1. yum install openssl

2.php install

'./configure' '--with-openssl' '--with-imap-ssl'

php smarty submenu

require_once("MySmarty.class.php");
$o_smarty = new MySmarty();


$o_smarty->caching = false;
$o_smarty->cache_lifetime = 3600*168;
if (!$o_smarty->is_cached('top.tpl')) {



$menu=array (
0=>array (
0=>"aaaa",
1=>"adsa",
),
1=>array (
0=>"bbbb",
1=>"dasas",
2=>"sadas",
),
2=>array (
0=>"cccc",
1=>"asdasddsa",
)
);
$o_smarty->assign('menu',$menu);


}//if (!$o_smarty->is_cached('top.tpl'))


$o_smarty->display("testmenu.tpl");

?>



{foreach item=bmenu from=$menu name=bmenu}

{foreach item=smenu from=$bmenu name=smenu}
{if $smarty.foreach.smenu.index==0}

{$smenu}



    {else}
  • {$smenu}

  • {/if}
    {/foreach}


{/foreach}

postgresql select distinct with random

select distinct categoryid FROM search_random where categoryid in(select categoryid from search_random order by random() limit 8) limit 4

ERROR: pgsenna2: sen_index_update failed

postgres.conf
・ludia.max_n_sort_result = 100000
・ludia.enable_seqscan = on
・ludia_sen_index_flags = 31
・ludia.max_n_index_cache = 16
・ludia.initial_n_segments = 3000

setting up with big value initial_n_segments it will pass error

postgresql order by count

select count(*), u.user_id
from aaa up
join user u
on u.user_id=up.user_id
where accepted=1
group by user_id
having count(*)>1
order by 1

Tuesday, May 12, 2009

PHP smarty submenu

Here are the code
The PHP code is:
$menu=array();
$query="SELECT * FROM domenii WHERE parentid=0";
$resursa=$obj->query($query);
while($row=$obj->fetcharray($resursa)){
$query1="SELECT * FROM domenii WHERE parentid=".$row['id'];
$resursa1=$obj->query($query1);
if($obj->numrows($resursa1)>0){
$submenu=array();
while($row1=$obj->fetcharray($resursa1)){
$submenu[]=array('type'=>$row1['type'],
'id'=>$row1['id'],
'nume'=>$row1['nume'],
'title'=>str_replace(' ','-', $row1['nume']));
}
}else{$submenu='0';}

$menu[]=array('type'=>$row['type'],
'id'=>$row['id'],
'nume'=>$row['nume'],
'title'=>str_replace(' ','-', $row['nume']),
'submenu'=>$submenu);
}

$obj->assign('menu', $menu);

The HTML (with smarty) code:




Compact it like this:

['main_link1'] => Array (
['key1'] => value
['key2'] => value
['submenus'] => Array (
['sublink1'] => Array ()
['sublink2'] => Array ()
)
['main_link2'] => Array (
['key1'] => value
['key2'] => value
['submenus'] => Array (
['sublink1'] => Array ()
['sublink2'] => Array ()
)

Tuesday, April 28, 2009

pgpool-II install and setting(インストールと設定)

pgpool-II 2.0.1のインストール in PostgreSQL 8.3.5

PostgreSQL

# : rootユーザ

$ : postgresユーザ


■pgpool-IIのDL / 展開、postgresユーザへの権限付与

DL先 : /usr/local/src/

展開先 : /usr/local/src/pgpool-II-2.0.1/

インスト先 : /usr/local/pgpool2/

# mkdir /usr/local/pgpool2

# chown postgres.postgres -R /usr/local/pgpool2/

# cd /usr/local/src/

# wget http://pgfoundry.org/frs/download.php/1521/pgpool-II-2.0.1.tar.gz

# tar -zxvf pgpool-II-2.0.1.tar.gz

# chown postgres.postgres -R /usr/local/src/pgpool-II-2.0.1/


■pgpool-IIのインストール(実行ユーザ:postgres)

# su - postgres

$ cd /usr/local/src/pgpool-II-2.0.1/

$ ./configure --prefix=/usr/local/pgpool2

$ make

$ make install



参考

* FrontPage - pgpool Wiki(pgpool-II/tutorial - pgpool Wiki)

Permalink | コメント(0) | トラックバック(0) | 15:32 このエントリーを含むブックマーク
レプリケーション in pgpool-II 2.0.1 / PostgreSQL 8.2.5 / CentOs5CommentsAdd StarCommentsAdd StarCommentsAdd Star

PostgreSQL

# : rootユーザ

$ : postgresユーザ


■ネットワークの設定

# vi /etc/hosts

-> 192.168.xxx.xx1 ecshopping-guide1.localdomain ecshopping-guide1

-> 192.168.xxx.xx2 ecshopping-guide2.localdomain ecshopping-guide2

※TAB区切り

hostname:ecshopping-guide1の場合

# vi /etc/sysconfig/network

-> #NETWORKING_IPV6=yes

-> HOSTNAME=ecshopping-guide1.localdomain


■PostgreSQLの設定

$ vi /usr/local/pgsql/data/postgresql.conf

-> listen_addresses = '*'

-> port = 5432        # default

$ vi /usr/local/pgsql/data/pg_hba.conf

-> local all all trust

-> host all postgres 192.168.xxx.0/24 trust

※半角スペース区切り

■pgpool-IIの設定

$ cp -p /usr/local/pgpool2/etc/pgpool.conf.sample /usr/local/pgpool2/etc/pgpool.conf

$ vi /usr/local/pgpool2/etc/pgpool.conf

-> listen_addresses = '*'

-> port = 9999       # default

-> replication_mode = true

-> load_balance_mode = true

-> enable_pool_hba = false # default

-> # データベースノードの設定(hostname:ecshopping-guide1)

-> backend_hostname0 = 'ecshopping-guide1'

-> backend_port0 = 5432

-> backend_weight0 = 1

-> # データベースノードの設定(hostname:ecshopping-guide1)

-> backend_hostname1 = 'ecshopping-guide1'

-> backend_port1 = 5432

-> backend_weight1 = 1


■レプリケーションの確認(pgbenchを使用)

$ cd /usr/local/src/postgresql-8.2.5/contrib/pgbench

$ make

$ make install

$ /usr/local/pgpool2/bin/pgpool -n &

$ /usr/local/pgsql/bin/createdb -p 9999 bench_replication

$ /usr/local/pgsql/bin/pgbench -i -p 9999 bench_replication


データベースノードに設定したサーバのPostgreSQLを確認。

List of databases
Name | Owner | Encoding
-------------------+----------+----------
bench_replication | postgres | UTF8       <- が、各PostgreSQLに追加されているはず



多分、いまは構成はこんなかんじ。

 ┌─────┐ ┌─────┐  ┌───────────┐
 │client  ├─┤pgpool-II ├─┬┤PostgreSQL(ecshopping-guide1:5432)│
 └─────┘ └─────┘ │└───────────┘
                 │┌───────────┐
                 └┤PostgreSQL(ecshopping-guide2:5432)│
                  └───────────┘



# 最初、レプリケーションされなかったのはPostgreSQLにユーザ作成していなかったから…。

http://www.ecshopping-guide.com