Friday, January 02, 2009
Wednesday, September 10, 2008
To make port install org.macports.mysql5.plist in your /Library/LaunchDaemons
To make port install org.macports.mysql5.plist in your /Library/LaunchDaemons
sudo port install mysql5 +server
Instead of
sudo port install mysql5
Wednesday, August 13, 2008
Install PostgreSQL 8.3.3 on Joyent OpenSolaris
[gmg6p9aa:~/postgresql-8.3.3] root# ./configure --with-libraries=/opt/csw/lib:/opt/csw/libexec --with-includes=/opt/csw/include
checking build system type... i386-pc-solaris2.11
......
checking for syslog.h... yes
checking for optreset... no
checking for strtoll... yes
checking for strtoull... yes
checking for atexit... yes
checking for LARGEFILESOURCE value needed for large files... no
checking for fseeko... (cached) yes
checking test program... failed
configure: error:
Could not execute a simple test program. This may be a problem
related to locating shared libraries. Check the file 'config.log'
for the exact reason.
http://www.pgcluster.org/svn/pgcluster-1.5/doc/FAQ_Solaris
[gmg6p9aa:~/postgresql-8.3.3] root# export LDFLAGS="-R/opt/csw/lib/:/usr/lib/"
[gmg6p9aa:~/postgresql-8.3.3] root#./configure --with-libraries=/opt/csw/lib/:/usr/lib/ --with-includes=/opt/csw/include/:/usr/include/
checking build system type... i386-pc-solaris2.11
......
checking for onsgmls... no
checking for nsgmls... no
checking for openjade... no
checking for jade... no
checking for DocBook V4.2... no
checking for DocBook stylesheets... no
checking for collateindex.pl... no
checking for sgmlspl... no
configure: creating ./config.status
config.status: creating GNUmakefile
config.status: creating src/Makefile.global
config.status: creating src/include/pg_config.h
config.status: creating src/interfaces/ecpg/include/ecpg_config.h
config.status: src/interfaces/ecpg/include/ecpg_config.h is unchanged
config.status: linking ./src/backend/port/tas/dummy.s to src/backend/port/tas.s
config.status: linking ./src/backend/port/dynloader/solaris.c to src/backend/port/dynloader.c
config.status: linking ./src/backend/port/sysv_sema.c to src/backend/port/pg_sema.c
config.status: linking ./src/backend/port/sysv_shmem.c to src/backend/port/pg_shmem.c
config.status: linking ./src/backend/port/dynloader/solaris.h to src/include/dynloader.h
config.status: linking ./src/include/port/solaris.h to src/include/pg_config_os.h
config.status: linking ./src/makefiles/Makefile.solaris to src/Makefile.port
make
make install
[gmg6p9aa:~/postgresql-8.3.3] root# mkdir /usr/local/pgsql/data (as root)
[gmg6p9aa:~/postgresql-8.3.3] root# sudo chown postgres:postgres /usr/local/pgsql/data/
[gmg6p9aa:~/postgresql-8.3.3] root# sudo su postgres -c "/usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data"
[gmg6p9aa:~/postgresql-8.3.3] root# sudo su postgres -c "/usr/local/pgsql/bin/postgres -p 9999 -D /usr/local/pgsql/data"
Thursday, July 17, 2008
git-svn: Can't locate SVN/Core.pm
To import subversion repository to git, I get the following problem
git-svn clone http://dev.com/code/example/trunk example
Can't locate SVN/Core.pm in @INC (@INC contains: /usr/local/lib/perl5/site_perl /opt/local/lib/perl5/5.8.8/darwin-2level /opt/local/lib/perl5/5.8.8 /opt/local/lib/perl5/site_perl/5.8.8/darwin-2level /opt/local/lib/perl5/site_perl/5.8.8 /opt/local/lib/perl5/site_perl /opt/local/lib/perl5/vendor_perl/5.8.8/darwin-2level /opt/local/lib/perl5/vendor_perl/5.8.8 /opt/local/lib/perl5/vendor_perl .) at /usr/local/bin/git-svn line 29.
Installing of the perl subversion binding solved this problem.
Felix:~/Developments sunfmin$ sudo port install p5-svn-simple
---> Fetching subversion-perlbindings
---> Attempting to fetch subversion-1.4.6.tar.bz2 from http://subversion.tigris.org//downloads/
---> Verifying checksum(s) for subversion-perlbindings
---> Extracting subversion-perlbindings
---> Configuring subversion-perlbindings
---> Building subversion-perlbindings with target swig-pl
---> Staging subversion-perlbindings into destroot
---> Installing subversion-perlbindings 1.4.6_0
---> Activating subversion-perlbindings 1.4.6_0
---> Cleaning subversion-perlbindings
---> Fetching p5-svn-simple
---> Attempting to fetch SVN-Simple-0.27.tar.gz from http://cpan.perl.org/authors/id/C/CL/CLKAO/
---> Verifying checksum(s) for p5-svn-simple
---> Extracting p5-svn-simple
---> Configuring p5-svn-simple
---> Building p5-svn-simple with target all
---> Staging p5-svn-simple into destroot
---> Installing p5-svn-simple 0.27_0
---> Activating p5-svn-simple 0.27_0
---> Cleaning p5-svn-simple
Felix:~/Developments sunfmin$
Friday, July 04, 2008
Install ruby-pg (PostgreSQL ruby driver) On Leopard
It is not so easy to install ruby-pg in Leopard
Felix:~ sunfmin$ sudo gem install ruby-pg
Building native extensions. This could take a while...
ERROR: Error installing pg:
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb install pg
=========== WARNING ===========
You are building this extension on OS X without setting the
ARCHFLAGS environment variable, and PostgreSQL does not appear
to have been built as a universal binary. If you are seeing this
message, that means that the build will probably fail.
Try setting the environment variable ARCHFLAGS
to '-arch i386' before building.
For example:
(in bash) $ export ARCHFLAGS='-arch i386'
(in tcsh) % setenv ARCHFLAGS '-arch i386'
Then try building again.
===================================
checking for main() in -lpq... yes
checking for libpq-fe.h... yes
checking for libpq/libpq-fs.h... yes
checking for PQconnectionUsedPassword()... no
checking for PQisthreadsafe()... no
checking for PQprepare()... no
checking for PQexecParams()... no
checking for PQescapeString()... no
checking for PQescapeStringConn()... no
checking for lo_create()... no
checking for pg_encoding_to_char()... no
checking for PQsetClientEncoding()... no
creating Makefile
make
gcc -I. -I. -I/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/universal-darwin9.0 -I. -DHAVE_LIBPQ_FE_H -DHAVE_LIBPQ_LIBPQ_FS_H -I/opt/local/include/postgresql82 -fno-common -arch ppc -arch i386 -Os -pipe -fno-common -c compat.c
In file included from compat.c:16:
compat.h:38:2: error: #error PostgreSQL client version too old, requires 7.3 or later.
In file included from compat.c:16:
compat.h:121: error: redefinition of typedef 'PQnoticeReceiver'
/opt/local/include/postgresql82/libpq-fe.h:136: error: previous declaration of 'PQnoticeReceiver' was here
compat.h:125: error: redeclaration of enumerator 'PQERRORS_TERSE'
/opt/local/include/postgresql82/libpq-fe.h:97: error: previous definition of 'PQERRORS_TERSE' was here
compat.h:126: error: redeclaration of enumerator 'PQERRORS_DEFAULT'
/opt/local/include/postgresql82/libpq-fe.h:98: error: previous definition of 'PQERRORS_DEFAULT' was here
compat.h:128: error: redeclaration of enumerator 'PQERRORS_VERBOSE'
/opt/local/include/postgresql82/libpq-fe.h:100: error: previous definition of 'PQERRORS_VERBOSE' was here
compat.h:128: error: conflicting types for 'PGVerbosity'
/opt/local/include/postgresql82/libpq-fe.h:100: error: previous declaration of 'PGVerbosity' was here
compat.h:132: error: redeclaration of enumerator 'PQTRANS_IDLE'
/opt/local/include/postgresql82/libpq-fe.h:88: error: previous definition of 'PQTRANS_IDLE' was here
compat.h:133: error: redeclaration of enumerator 'PQTRANS_ACTIVE'
/opt/local/include/postgresql82/libpq-fe.h:89: error: previous definition of 'PQTRANS_ACTIVE' was here
compat.h:134: error: redeclaration of enumerator 'PQTRANS_INTRANS'
/opt/local/include/postgresql82/libpq-fe.h:90: error: previous definition of 'PQTRANS_INTRANS' was here
compat.h:135: error: redeclaration of enumerator 'PQTRANS_INERROR'
/opt/local/include/postgresql82/libpq-fe.h:91: error: previous definition of 'PQTRANS_INERROR' was here
compat.h:137: error: redeclaration of enumerator 'PQTRANS_UNKNOWN'
/opt/local/include/postgresql82/libpq-fe.h:93: error: previous definition of 'PQTRANS_UNKNOWN' was here
compat.h:137: error: conflicting types for 'PGTransactionStatusType'
/opt/local/include/postgresql82/libpq-fe.h:93: error: previous declaration of 'PGTransactionStatusType' was here
compat.h:142: error: conflicting types for 'PQtransactionStatus'
/opt/local/include/postgresql82/libpq-fe.h:258: error: previous declaration of 'PQtransactionStatus' was here
compat.h:143: error: conflicting types for 'PQparameterStatus'
/opt/local/include/postgresql82/libpq-fe.h:260: error: previous declaration of 'PQparameterStatus' was here
compat.h:157: error: conflicting types for 'PQsetErrorVerbosity'
/opt/local/include/postgresql82/libpq-fe.h:277: error: previous declaration of 'PQsetErrorVerbosity' was here
compat.h:169:2: error: #error unsupported postgresql version, requires 7.3 or later.
compat.c: In function 'PQsetClientEncoding':
compat.c:21: error: syntax error before '{' token
compat.c:282: error: storage class specified for parameter 'query'
compat.c:282: error: parameter 'query' is initialized
compat.c:286: error: syntax error before 'if'
compat.c:341: error: parameter 'target' is initialized
compat.c:341: error: 'to' undeclared (first use in this function)
compat.c:341: error: (Each undeclared identifier is reported only once
compat.c:341: error: for each function it appears in.)
compat.c:342: error: parameter 'remaining' is initialized
compat.c:342: error: 'length' undeclared (first use in this function)
compat.c:344: error: syntax error before 'while'
compat.c:396: error: syntax error before 'len'
compat.c:470: error: redefinition of parameter 'i'
compat.c:390: error: previous definition of 'i' was here
compat.c:473: error: syntax error before 'if'
In file included from compat.c:16:
compat.h:38:2: error: #error PostgreSQL client version too old, requires 7.3 or later.
In file included from compat.c:16:
compat.h:121: error: redefinition of typedef 'PQnoticeReceiver'
/opt/local/include/postgresql82/libpq-fe.h:136: error: previous declaration of 'PQnoticeReceiver' was here
compat.h:125: error: redeclaration of enumerator 'PQERRORS_TERSE'
/opt/local/include/postgresql82/libpq-fe.h:97: error: previous definition of 'PQERRORS_TERSE' was here
compat.h:126: error: redeclaration of enumerator 'PQERRORS_DEFAULT'
/opt/local/include/postgresql82/libpq-fe.h:98: error: previous definition of 'PQERRORS_DEFAULT' was here
compat.h:128: error: redeclaration of enumerator 'PQERRORS_VERBOSE'
/opt/local/include/postgresql82/libpq-fe.h:100: error: previous definition of 'PQERRORS_VERBOSE' was here
compat.h:128: error: conflicting types for 'PGVerbosity'
/opt/local/include/postgresql82/libpq-fe.h:100: error: previous declaration of 'PGVerbosity' was here
compat.h:132: error: redeclaration of enumerator 'PQTRANS_IDLE'
/opt/local/include/postgresql82/libpq-fe.h:88: error: previous definition of 'PQTRANS_IDLE' was here
compat.h:133: error: redeclaration of enumerator 'PQTRANS_ACTIVE'
/opt/local/include/postgresql82/libpq-fe.h:89: error: previous definition of 'PQTRANS_ACTIVE' was here
compat.h:134: error: redeclaration of enumerator 'PQTRANS_INTRANS'
/opt/local/include/postgresql82/libpq-fe.h:90: error: previous definition of 'PQTRANS_INTRANS' was here
compat.h:135: error: redeclaration of enumerator 'PQTRANS_INERROR'
/opt/local/include/postgresql82/libpq-fe.h:91: error: previous definition of 'PQTRANS_INERROR' was here
compat.h:137: error: redeclaration of enumerator 'PQTRANS_UNKNOWN'
/opt/local/include/postgresql82/libpq-fe.h:93: error: previous definition of 'PQTRANS_UNKNOWN' was here
compat.h:137: error: conflicting types for 'PGTransactionStatusType'
/opt/local/include/postgresql82/libpq-fe.h:93: error: previous declaration of 'PGTransactionStatusType' was here
compat.h:142: error: conflicting types for 'PQtransactionStatus'
/opt/local/include/postgresql82/libpq-fe.h:258: error: previous declaration of 'PQtransactionStatus' was here
compat.h:143: error: conflicting types for 'PQparameterStatus'
/opt/local/include/postgresql82/libpq-fe.h:260: error: previous declaration of 'PQparameterStatus' was here
compat.h:157: error: conflicting types for 'PQsetErrorVerbosity'
/opt/local/include/postgresql82/libpq-fe.h:277: error: previous declaration of 'PQsetErrorVerbosity' was here
compat.h:169:2: error: #error unsupported postgresql version, requires 7.3 or later.
compat.c: In function 'PQsetClientEncoding':
compat.c:21: error: syntax error before '{' token
compat.c:282: error: storage class specified for parameter 'query'
compat.c:282: error: parameter 'query' is initialized
compat.c:286: error: syntax error before 'if'
compat.c:341: error: parameter 'target' is initialized
compat.c:341: error: 'to' undeclared (first use in this function)
compat.c:341: error: (Each undeclared identifier is reported only once
compat.c:341: error: for each function it appears in.)
compat.c:342: error: parameter 'remaining' is initialized
compat.c:342: error: 'length' undeclared (first use in this function)
compat.c:344: error: syntax error before 'while'
compat.c:396: error: syntax error before 'len'
compat.c:470: error: redefinition of parameter 'i'
compat.c:390: error: previous definition of 'i' was here
compat.c:473: error: syntax error before 'if'
lipo: can't open input file: /var/tmp//ccxi5qM7.out (No such file or directory)
make: *** [compat.o] Error 1
Gem files will remain installed in /Library/Ruby/Gems/1.8/gems/pg-0.7.9.2008.03.18 for inspection.
Results logged to /Library/Ruby/Gems/1.8/gems/pg-0.7.9.2008.03.18/ext/gem_make.out
Felix:~ sunfmin$
Felix:~ sunfmin$ sudo env ARCHFLAGS="-arch i386" gem install --remote ruby-pg
Building native extensions. This could take a while...
Successfully installed ruby-pg-0.7.9.2008.01.28
1 gem installed
Installing ri documentation for ruby-pg-0.7.9.2008.01.28...
Installing RDoc documentation for ruby-pg-0.7.9.2008.01.28...
Felix:~ sunfmin$
Friday, June 20, 2008
Tell postfix not to send email to local
We want to config the server can only send emails, can NOT receive emails from local or remote. Because our domain is pointed to this server, But our email server is on Google Enterprise. So before If we want to send email from the server, It first looks up locally, and send to local directly, So emails never get reach to Google.
I tried: http://www.postfix.org/faq.html#null_client But I seems not work.
After check out the postfix log:
Jun 20 08:45:15 example.com postfix/pickup[21505]: [ID 197553 mail.info] 9EE3D43D17: uid=0 from=<root>
Jun 20 08:45:15 example.com postfix/cleanup[21511]: [ID 197553 mail.info] 9EE3D43D17: message-id=<20080620084515.9EE3D43D17@example.com>
Jun 20 08:45:15 example.com postfix/qmgr[21506]: [ID 197553 mail.info] 9EE3D43D17: from=<root@example.com>, size=294, nrcpt=1 (queue active)
Jun 20 08:45:15 example.com postfix/error[21509]: [ID 197553 mail.info] 9EE3D43D17: to=<theplant@example.com>, relay=none, delay=0, status=bounced (User unknown in virtual alias table)
Jun 20 08:45:15 example.com postfix/cleanup[21511]: [ID 197553 mail.info] 9FC7E43D19: message-id=<20080620084515.9FC7E43D19@example.com>
Jun 20 08:45:15 example.com postfix/qmgr[21506]: [ID 197553 mail.info] 9FC7E43D19: from=<>, size=1973, nrcpt=1 (queue active)
Jun 20 08:45:15 example.com postfix/error[21509]: [ID 197553 mail.info] 9FC7E43D19: to=<root@example.com>, relay=none, delay=0, status=bounced (User unknown in virtual alias table)
Jun 20 08:45:15 example.com postfix/qmgr[21506]: [ID 197553 mail.info] 9FC7E43D19: removed
Jun 20 08:45:15 example.com postfix/qmgr[21506]: [ID 197553 mail.info] 9EE3D43D17: removed
Even you set
local_transport = error:local delivery is disabled
But when you have aliasmaps, aliasdatabase, virtualaliasmaps. Postfix will still try to find the alias name in local. So it fails when it can not find it.
main.cf
myorigin = example.com
#relayhost = example.com
inet_interfaces = 127.0.0.1
#local_transport = error:local delivery is disabled
## -- Maps
#alias_maps = dbm:/opt/csw/etc/postfix/aliases
#alias_database = dbm:/opt/csw/etc/postfix/aliases
canonical_maps = dbm:/opt/csw/etc/postfix/canonical
recipient_canonical_maps = dbm:/opt/csw/etc/postfix/recipient_canonical
sender_canonical_maps = dbm:/opt/csw/etc/postfix/sender_canonical
#virtual_alias_maps = dbm:/opt/csw/etc/postfix/virtual
master.cf
discard unix - - n - - discard
#local unix - n n - - local
virtual unix - n n - - virtual
And Another thing, make sure your hostname is NOT your domain.
because It will check hostname first and mx record? I guess.
Monday, March 03, 2008
Install SSL for apache
Setup Certificate
# from: http://www.vanemery.com/Linux/Apache/apache-SSL.html
[root]# openssl genrsa -des3 -out my-ca.key 2048
[root]# openssl req -new -x509 -days 3650 -key my-ca.key -out my-ca.crt
# deleted -des3 to not using pass phrase
[root]# openssl genrsa -out mars-server.key 1024
[root]# openssl req -new -key mars-server.key -out mars-server.csr
[root]# openssl x509 -req -in mars-server.csr -out mars-server.crt -sha1 -CA my-ca.crt -CAkey my-ca.key -CAcreateserial -days 3650
Setup Apache
# For no ssl
-bash-3.00$ more /opt/csw/apache2/etc/virtualhosts/yourserver.conf
<VirtualHost 8.17.170.154:80>
ServerName youserver.com
ServerAlias *.youserver.com
DocumentRoot /home/youserver.com/app/current/public
<Directory "/home/youserver.com/app/current/public/">
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
<Proxy balancer://yourserver-mongrels>
BalancerMember http://127.0.0.1:8000
BalancerMember http://127.0.0.1:8001
BalancerMember http://127.0.0.1:8002
BalancerMember http://127.0.0.1:8003
</Proxy>
ProxyPass /images !
ProxyPass /javascripts !
ProxyPass /stylesheets !
ProxyPass / balancer://yourserver-mongrels/
ProxyPassReverse / balancer://yourserver-mongrels/
ProxyPreserveHost On
</VirtualHost>
# For ssl
-bash-3.00$ more /opt/csw/apache2/etc/virtualhosts/yourserver-ssl.conf
<VirtualHost 8.17.170.154:443>
ServerName youserver.com
ServerAlias *.youserver.com
DocumentRoot /home/youserver.com/app/current/public
<Directory "/home/youserver.com/app/current/public/">
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
<Proxy balancer://yourserver-mongrels>
BalancerMember http://127.0.0.1:8000
BalancerMember http://127.0.0.1:8001
BalancerMember http://127.0.0.1:8002
BalancerMember http://127.0.0.1:8003
</Proxy>
ProxyPass /images !
ProxyPass /javascripts !
ProxyPass /stylesheets !
ProxyPass / balancer://yourserver-mongrels/
ProxyPassReverse / balancer://yourserver-mongrels/
ProxyPreserveHost On
SSLEngine On
SSLCertificateFile /home/youserver.com/ssl/mars-server.crt
SSLCertificateKeyFile /home/youserver.com/ssl/mars-server.key
</VirtualHost>
Saturday, March 01, 2008
Merb Console
Tried Merb Console
felix@Felix:~/Developments/kakei$ merb -i
~ loading gem 'activerecord' from config/init.rb:27 ...
~ loading gem 'merb_activerecord' from config/init.rb:27 ...
~ loading gem 'merb_rspec' from config/init.rb:36 ...
~ loading gem 'merb_helpers' from config/init.rb:39 ...
~ Loaded DEVELOPMENT Environment...
~ Connecting to database...
~ Compiling routes...
~ Using 'share-nothing' cookie sessions (4kb limit per client)
irb(main):035:0*
irb(main):036:0* merb
=> #<Merb::Rack::Console:0xb76f6604>
irb(main):037:0>
irb(main):038:0*
irb(main):039:0* merb.url(:payments)
=> "/payments"
irb(main):040:0> merb.url(:new_payment)
=> "/payments/new"
irb(main):041:0> merb.url(:delete_payment)
=> "/payments//delete"
irb(main):042:0> merb.url(:delete_payment, )
SyntaxError: compile error
(irb):42: syntax error, unexpected ')'
from (irb):42
from :0
irb(main):043:0> payment = Payment.find(1)
=> #<Payment id: 1, amount: 23423, paid_for: "34234", created_at: "2008-03-01 17:26:41">
irb(main):044:0> merb.url(:delete_payment, payment)
=> "/payments/1/delete"
irb(main):045:0> merb.url(:edit_payment, payment)
=> "/payments/1/edit"
irb(main):046:0> merb.url(:as_payment, payment)
RuntimeError: Named route not found: as_payment
from /usr/lib/ruby/gems/1.8/gems/merb-core-0.9.1/lib/merb-core/dispatch/router.rb:90:in `generate'
from /usr/lib/ruby/gems/1.8/gems/merb-core-0.9.1/lib/merb-core/rack/adapter/irb.rb:14:in `url'
from (irb):46
from :0
irb(main):047:0> merb.url(:payment, payment)
=> "/payments/1"
irb(main):003:0* merb.show_routes
Named Routes
new_payment: /payments/new
edit_payment: /payments/:id/edit
payment: /payments/:id
delete_payment: /payments/:id/delete
payments: /payments
custom_payment: /payments/:action/:id
Anonymous Routes
/payments/?(\.:format)?
/payments/index(\.:format)?
/payments/new
/payments/?(\.:format)?
/payments/:id(\.:format)?
/payments/:id[;/]edit
/payments/:id[;/]delete
/payments/:id(\.:format)?
/payments/:id(\.:format)?
/:controller(/:action(/:id)?)?(\.:format)?
=> nil
Saturday, February 02, 2008
Keep all my bash history commands
I like the bash history. because many command is difficult to remember when I want to use it next time.
felix@Felix:~$ cd
felix@Felix:~$ echo "export HISTSIZE=999999999" >> .profile
and then you can find you command by
felix@Felix:~$ history|grep git
Sunday, January 06, 2008
Use Ruby language power in command line
Task: Delete file that didn't added to subversion
svn st|grep ?
Then you can get all the files that not added to subversion but the list is with a ?, so It's not easy to delete it with rm
felix@Felix:~/Developments/joblet$ svn st|grep ?
? aaa
? bbb
? ccc
Then I want to trim the ?, awk may simple do the task, but for those who don't know awk. and instead we use Ruby for day to day work.
Ruby gives you the way to do task on command line.
felix@Felix:~/Developments/joblet$ svn st|grep ?|ruby -pe '$_ = $_[1..-1].strip + "\n"'
aaa
bbb
ccc
felix@Felix:~/Developments/joblet$ rm `svn st|grep ?|ruby -pe '$_ = $_[1..-1].strip + "\n"'`
Thursday, December 13, 2007
Give a ticket number to your subversion commit message when you are using trac
If you give a number when you commit your changes to subversion
svn commit -m "Fixed Ticket #456"
then Trac will connect the changeset to the Ticket, Wonderful feature, isn't it.
Friday, December 07, 2007
Migrate PostgreSQL 8.1 Data to PostgreSQL 8.2
Install PSQL 8.2
Felix:~ sunfmin$ sudo port install postgresql82
Dump all the PSQL 8.1 Databases to a file
Using The new installed PSQL 8.2 's pg_dumpall to dump all the PSQL 8.1 databases
Felix:~ sunfmin$ /opt/local/lib/postgresql82/bin/pg_dumpall > ~/pg81_all_dump
Initialize PSQL 8.2 Database instance
Felix:~/Developments sunfmin$ sudo su postgres -c '/opt/local/lib/postgresql82/bin/initdb -D /opt/local/var/db/postgresql82/defaultdb'
Password:
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.
The database cluster will be initialized with locale C.
creating directory /opt/local/var/db/postgresql82/defaultdb ... ok
creating subdirectories ... ok
selecting default max_connections ... 100
selecting default shared_buffers/max_fsm_pages ... 32MB/204800
creating configuration files ... ok
creating template1 database in /opt/local/var/db/postgresql82/defaultdb/base/1 ... ok
initializing pg_authid ... ok
initializing dependencies ... ok
creating system views ... ok
loading system objects' descriptions ... ok
creating conversions ... ok
setting privileges on built-in objects ... ok
creating information schema ... ok
vacuuming database template1 ... ok
copying template1 to template0 ... ok
copying template1 to postgres ... ok
WARNING: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the -A option the
next time you run initdb.
Success. You can now start the database server using:
/opt/local/lib/postgresql82/bin/postgres -D /opt/local/var/db/postgresql82/defaultdb
or
/opt/local/lib/postgresql82/bin/pg_ctl -D /opt/local/var/db/postgresql82/defaultdb -l logfile start
Start your database
Felix:~/Developments sunfmin$ sudo su postgres -c "/opt/local/lib/postgresql82/bin/pg_ctl -D /opt/local/var/db/postgresql82/defaultdb -l /opt/local/var/log/postgresql82/postgres.log start"
server starting
You may encounter some problem like this following
Felix:~/Developments sunfmin$ sudo su postgres /opt/local/lib/postgresql82/bin/postgres -D /opt/local/var/db/postgresql82/defaultdb
Password:
/opt/local/lib/postgresql82/bin/postgres: /opt/local/lib/postgresql82/bin/postgres: cannot execute binary file
Felix:~/Developments sunfmin$ sudo /opt/local/lib/postgresql82/bin/postgres -D /opt/local/var/db/postgresql82/defaultdb
"root" execution of the PostgreSQL server is not permitted.
The server must be started under an unprivileged user ID to prevent
possible system security compromise. See the documentation for
more information on how to properly start the server.
Felix:~/Developments sunfmin$ psql
psql: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
Restore all the data
Felix:~ sunfmin$ /opt/local/lib/postgresql82/bin/psql -f pg81_all_dump template1 -U postgres
You are now connected to database "postgres".
SET
SET
SET
CREATE ROLE
ALTER ROLE
CREATE ROLE
ALTER ROLE
CREATE ROLE
ALTER ROLE
CREATE ROLE
ALTER ROLE
CREATE ROLE
ALTER ROLE
CREATE DATABASE
Failed system call was shmget
When I try to setup PostgreSQL 8.2 on Mac OS X 10.4 , I get the following error.
Felix:~ sunfmin$ sudo su postgres -c '/opt/local/lib/postgresql82/bin/initdb -D /opt/local/var/db/postgresql82/defaultdb'
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.
The database cluster will be initialized with locale C.
creating directory /opt/local/var/db/postgresql82/defaultdb ... ok
creating subdirectories ... ok
selecting default max_connections ... 10
selecting default shared_buffers/max_fsm_pages ... 400kB/20000
creating configuration files ... ok
creating template1 database in /opt/local/var/db/postgresql82/defaultdb/base/1 ... FATAL: could not create shared memory segment: Cannot allocate memory
DETAIL: Failed system call was shmget(key=1, size=1646592, 03600).
HINT: This error usually means that PostgreSQL's request for a shared memory segment exceeded available memory or swap space. To reduce the request size (currently 1646592 bytes), reduce PostgreSQL's shared_buffers parameter (currently 50) and/or its max_connections parameter (currently 10).
The PostgreSQL documentation contains more information about shared memory configuration.
child process exited with exit code 1
initdb: removing data directory "/opt/local/var/db/postgresql82/defaultdb"
Following http://brilliantcorners.org/node/tag/osx
I changed: /etc/rc
sysctl -w kern.sysv.shmmax=4194304 kern.sysv.shmmin=1 kern.sysv.shmmni=32 kern.sysv.shmseg=8 kern.sysv.shmall=1024
to
sysctl -w kern.sysv.shmmax=167772160 kern.sysv.shmmin=1 kern.sysv.shmmni=32 kern.sysv.shmseg=8 kern.sysv.shmall=65536
And Then the problem solved.
Felix:~/Developments sunfmin$ sudo su postgres -c '/opt/local/lib/postgresql82/bin/initdb -D /opt/local/var/db/postgresql82/defaultdb'
Password:
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.
The database cluster will be initialized with locale C.
creating directory /opt/local/var/db/postgresql82/defaultdb ... ok
creating subdirectories ... ok
selecting default max_connections ... 100
selecting default shared_buffers/max_fsm_pages ... 32MB/204800
creating configuration files ... ok
creating template1 database in /opt/local/var/db/postgresql82/defaultdb/base/1 ... ok
initializing pg_authid ... ok
initializing dependencies ... ok
creating system views ... ok
loading system objects' descriptions ... ok
creating conversions ... ok
setting privileges on built-in objects ... ok
creating information schema ... ok
vacuuming database template1 ... ok
copying template1 to template0 ... ok
copying template1 to postgres ... ok
WARNING: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the -A option the
next time you run initdb.
Success. You can now start the database server using:
/opt/local/lib/postgresql82/bin/postgres -D /opt/local/var/db/postgresql82/defaultdb
or
/opt/local/lib/postgresql82/bin/pg_ctl -D /opt/local/var/db/postgresql82/defaultdb -l logfile start
Monday, December 03, 2007
Update itself with single command
It is cool that like gem and MacPorts could update itself with just a single command.
sudo gem update --system
sudo port selfupdate
and also when you can not find software you want in port, don't forget to do a
sudo port -d sync
Saturday, December 01, 2007
Write your blog in Markdown with Emacs and post it directly to Google Blogger
For those who using Emacs, Markdown and Blogger
You write your blog entry in Emacs and with Markdown format
Then you issue a M-x blogger-post command in emacs, It convert
the markdown to html and post it to your Blogger blog.
How to Install
- See An Emacs Client For Blogger to install g-client (You'd better check it out from repository)
- See Emacs markdown-mode to install Emacs markdown-mode
- Put the following script to your emacs load path
The code
(require 'gblogger)
(defvar markdown-blogger-new-entry-template
"<entry xmlns='http://www.w3.org/2005/Atom'>
<generator url=\"%s\">%s</generator>
<author> <name>%s </name> </author>
<title mode=\"escaped\" type=\"text/html\">%s </title>
<content type='xhtml'>
<div xmlns=\"http://www.w3.org/1999/xhtml\">
%s
</div>
</content>
</entry>"
"Template for new Blogger entries.")
(defun blogger-post()
(interactive)
(markdown)
(set-buffer (get-buffer "*markdown-output*"))
(setq post-url "http://www\.blogger\.com/feeds/7841127/posts/default")
(setq markdown-buffer (current-buffer))
(setq markdown-content (buffer-string))
(setq title (read-string "Title: "))
(setq buffer (get-buffer-create "*markdown-blogger-post*"))
(declare (special gblogger-auth-handle markdown-blogger-new-entry-template
gblogger-generator-name ))
(g-auth-ensure-token gblogger-auth-handle)
(set-buffer buffer)
(erase-buffer)
(insert (format markdown-blogger-new-entry-template
gblogger-generator-name gblogger-generator-name
"Felix Sun" title markdown-content))
(switch-to-buffer buffer)
(g-app-mode)
(setq g-app-this-url post-url
g-app-auth-handle gblogger-auth-handle
g-app-publish-action 'g-app-post-entry)
(g-app-publish)
)
Posted from emacs
You can do that also
http://emacspeak.blogspot.com/2007/03/emacs-client-for-google-services.htmlFriday, November 30, 2007
Add code formatter to your blog
see: http://code.google.com/p/syntaxhighlighter/
You could format ruby like this.
describe RSpec do
before(:each) do
@rspec = RSpec.new
end
describe "at release 1.0.8" do
before(:each) do
@rspec.version = "1.0.8"
end
it "should not support nested example groups" do
@rspec.should_not support_nested_example_groups
end
end
describe "at release 1.1.0" do
before(:each) do
@rspec.version = "1.1.0"
end
it "should support nested example groups" do
@rspec.should support_nested_example_groups
end
end
end
Thursday, November 29, 2007
Integrate your website with joblet seamlessly
For most of website that integrated joblet like asoboo. right now just link to http://asoboo.joblet.jp
But you may not want your user go out of your own domain. If you want to do so, You need to create a subdomain for you website, because things like http://asoboo.com/jobs simple not very easy to work. (all inside url of joblet is begain with / )
So For Apache, create a virtual host
ServerName jobs.asoboo.com
<Directory proxy:http://asoboo.joblet.jp>
Order Allow,Deny
Allow from all
</Directory>
ProxyPass / http://asoboo.joblet.jp/
ProxyPassReverse / http://asoboo.joblet.jp/
And Then you can point your browser to http://jobs.asoboo.com, :)
Saturday, October 27, 2007
Different ps command in Solaris
why /usr/ucb/ps command is having out put differnet than
/usr/bin/ps
I CAN'T run /usr/bin/ps axuwwww
but I can under /usr/ucb/ps
Or /usr/ucb/ps -ef does not work, but
/usr/bin/ps -ef does work.
Wednesday, October 24, 2007
Put 503 page for your rails application
ErrorDocument 503 /503.html
in apache configuration for you rails application, because when you
deploy , mongrels may take some time to restart.


