博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
PostgreSQL installed in FreeBSD
阅读量:5907 次
发布时间:2019-06-19

本文共 30757 字,大约阅读时间需要 102 分钟。

上一篇BLOG介绍了freebsd的安装, 
本文将介绍一下freebsd下编译安装postgresql.
首先要下载postgresql代码, 解压, 安装.
root@digoal:~ # fetch http://ftp.postgresql.org/pub/source/v9.3.4/postgresql-9.3.4.tar.bz2root@digoal:~ # tar -jxvf postgresql-9.3.4.tar.bz2root@digoal:~ # cd postgresql-9.3.4root@digoal:~/postgresql-9.3.4 # ./configure --prefix=/opt/pgsql9.3.4 --with-pgport=1921 --with-perl --with-tcl --with-python --with-openssl --with-pam --with-ldap --with-libxml --with-libxslt --enable-thread-safety
使用这个configure选项的话, 会缺少很多包, 所以要根据configure的返回安装对应的包.
首先会缺少bison, 但是PG不会因为缺少bison不允许安装, 所以只是WARNING, 缺少一些功能, 需要的话可以安装bison
root@my-domain:~ # pkg search bisonbison-2.7.1,1bisoncpp-4.09.01py27-bison-0.1.8_3ruby19-rbison-0.0.7_3root@my-domain:~ # pkg install bison
接下来, 
checking for perl... noconfigure: WARNING:*** Without Perl you will not be able to build PostgreSQL from Git.*** You can obtain Perl from any CPAN mirror site.*** (If you are using the official distribution of PostgreSQL then you do not*** need to worry about this, because the Perl output is pre-generated.)configure: error: Perl not found
说明缺少perl的包, 可以使用pkg search查找一下包名. 然后安装
root@digoal:~ # pkg search perl
如果search没有结果, 可能是pkg的repository没有配置好, 可以update一下.
root@digoal:~ # pkg updateUpdating repository cataloguedigests.txz                                                                             100% 1085KB  67.8KB/s 185.3KB/s   00:16    packagesite.txz                                                                         100% 5007KB 250.3KB/s 376.6KB/s   00:20    Incremental update completed, 23207 packages processed:0 packages updated, 0 removed and 23207 added.
再次搜索就有了.
root@digoal:~ # pkg search perlHyperlatex-2.9.a_4amanda-perl-wrapper-1.01ap22-mod_perl2-2.0.8,3claws-mail-perl-3.10.0clipperlib-6.0.0dnsmax-perl-1.0.1libmp3-archive-perl-0.9libproxy-perl-0.4.6libtext-charwidth-perl-0.04libtext-wrapi18n-perl-0.06mldonkey-perlreactor-0.2nzbperl-0.6.8_1p5-DBIx-Log4perl-0.26p5-Dancer-Logger-Log4perl-0.8.1p5-Log-Any-Adapter-Log4perl-0.06p5-Log-Log4perl-1.42p5-Log-Log4perl-Appender-RabbitMQ-0.102220p5-MooseX-Log-Log4perl-0.46p5-Script-isAperlScript-1.0.0p5-Test-Log4perl-0.1001p5-bioperl-1.6.923p5-eperl-2.2.14p5-jmx4perl-1.07_1p5-perl-ldap-0.5800p5-perlbrew-0.59p5-perlkde-4.12.5p5-perlqt-4.12.5p5-rpm-build-perl-0.82p5-uni-perl-0.91pecl-perl-1.0.1perl2html-0.9.2_1perl5-5.16.3_10perl5.14-5.14.4_7perl5.18-5.18.2_3perl5.20-5.20.0_2perlconsole-0.4_1postfix-policyd-spf-perl-2.010postgresql84-plperl-8.4.21_1postgresql9-plperl-9.4.b1postgresql90-plperl-9.0.17postgresql91-plperl-9.1.13_1postgresql92-plperl-9.2.8_1postgresql93-plperl-9.3.4sooperlooper-1.7.0_1superlu-3.0.20060201_6superlu_mt-2.0.20080115_5urxvt-perls-2.0_1不建议安装最新的root@digoal:~ # pkg install perl5.20-5.20.0_2Updating repository catalogueThe following 1 packages will be installed:        Installing perl5.20: 5.20.0_2The installation will require 48 MB more space13 MB to be downloadedProceed with installing packages [y/N]: y
重新执行configure, 看看还缺少什么包, 继续安装.
root@digoal:~/postgresql-9.3.4 # ./configure --prefix=/opt/pgsql9.3.4 --with-pgport=1921 --with-perl --with-tcl --with-python --with-openssl --with-pam --with-ldap --with-libxml --with-libxslt --enable-thread-safetychecking for python... noconfigure: error: Python not found
这次少了python.
root@digoal:~/postgresql-9.3.4 # pkg search pythonpython-2.7_1,2root@digoal:~/postgresql-9.3.4 # pkg install python-2.7_1,2Updating repository catalogueThe following 4 packages will be installed:        Installing gettext: 0.18.3.1_1        Installing python27: 2.7.6_4        Installing python2: 2_2        Installing python: 2.7_1,2The installation will require 78 MB more space12 MB to be downloadedProceed with installing packages [y/N]: ygettext-0.18.3.1_1.txz                                                                  100% 2078KB  79.9KB/s 268.0KB/s   00:26    python27-2.7.6_4.txz                                                                    100% 9997KB 217.3KB/s 177.0KB/s   00:46    python2-2_2.txz                                                                         100% 2336     2.3KB/s   2.3KB/s   00:00    python-2.7_1,2.txz                                                                      100% 2288     2.2KB/s   2.2KB/s   00:00    Checking integrity... done[1/4] Installing gettext-0.18.3.1_1... done[2/4] Installing python27-2.7.6_4... done[3/4] Installing python2-2_2... done[4/4] Installing python-2.7_1,2... done====Note that some of the standard modules are provided as separateports since they require extra dependencies:bsddb           databases/py-bsddbgdbm            databases/py-gdbmsqlite3         databases/py-sqlite3tkinter         x11-toolkits/py-tkinterInstall them as needed.====
重新执行configure, 看看还缺少什么包, 继续安装.
root@digoal:~/postgresql-9.3.4 # ./configure --prefix=/opt/pgsql9.3.4 --with-pgport=1921 --with-perl --with-tcl --with-python --with-openssl --with-pam --with-ldap --with-libxml --with-libxslt --enable-thread-safetychecking for xmlSaveToBuffer in -lxml2... noconfigure: error: library 'xml2' (version >= 2.6.23) is required for XML support
这次缺少的 xml2
root@digoal:~/postgresql-9.3.4 # pkg search xml2xml2-0.5_1root@digoal:~/postgresql-9.3.4 # pkg install xml2-0.5_1Updating repository catalogueThe following 2 packages will be installed:        Installing libxml2: 2.9.1_1        Installing xml2: 0.5_1The installation will require 4 MB more space772 KB to be downloadedProceed with installing packages [y/N]: ylibxml2-2.9.1_1.txz                                                                     100%  753KB 150.6KB/s  92.7KB/s   00:05    xml2-0.5_1.txz                                                                          100%   19KB  19.2KB/s  19.2KB/s   00:01    Checking integrity... done[1/2] Installing libxml2-2.9.1_1... done[2/2] Installing xml2-0.5_1... done

接下来缺少xslt
root@digoal:~/postgresql-9.3.4 # ./configure --prefix=/opt/pgsql9.3.4 --with-pgport=1921 --with-perl --with-tcl --with-python --with-openssl --with-pam --with-ldap --with-libxml --with-libxslt --enable-thread-safetychecking for xsltCleanupGlobals in -lxslt... noconfigure: error: library 'xslt' is required for XSLT supportroot@digoal:~/postgresql-9.3.4 # pkg search xsltlibxslt-1.1.28_3root@digoal:~/postgresql-9.3.4 # pkg install libxslt-1.1.28_3Updating repository catalogueThe following 3 packages will be installed:        Installing libgpg-error: 1.13_1        Installing libgcrypt: 1.5.3_2        Installing libxslt: 1.1.28_3The installation will require 2 MB more space621 KB to be downloadedProceed with installing packages [y/N]: ylibgpg-error-1.13_1.txz                                                                 100%   73KB  73.0KB/s  23.0KB/s   00:01    libgcrypt-1.5.3_2.txz                                                                   100%  335KB 111.6KB/s 224.8KB/s   00:03    libxslt-1.1.28_3.txz                                                                    100%  213KB  70.9KB/s  52.8KB/s   00:03    Checking integrity... done[1/3] Installing libgpg-error-1.13_1... done[2/3] Installing libgcrypt-1.5.3_2... done[3/3] Installing libxslt-1.1.28_3... done
注意libxslt安装完后, 报缺少libxslt/xslt.h头文件
root@digoal:~/postgresql-9.3.4 # ./configure --prefix=/opt/pgsql9.3.4 --with-pgport=1921 --with-perl --with-tcl --with-python --with-openssl --with-pam --with-ldap --with-libxml --with-libxslt --enable-thread-safetychecking for libxslt/xslt.h... noconfigure: error: header file 
is required for XSLT support
但是这个头文件实际上已经存在了
root@digoal:~/postgresql-9.3.4 # find / -name xslt.h/usr/local/include/libxslt/xslt.h
使用CPPFLAGS设置include文件夹
./configure --helpSome influential environment variables:  CC          C compiler command  CFLAGS      C compiler flags  LDFLAGS     linker flags, e.g. -L
if you have libraries in a nonstandard directory
LIBS libraries to pass to the linker, e.g. -l
CPPFLAGS C/C++/Objective C preprocessor flags, e.g. -I
if you have headers in a nonstandard directory
CPP C preprocessor LDFLAGS_EX extra linker flags for linking executables only LDFLAGS_SL extra linker flags for linking shared libraries only DOCBOOKSTYLE location of DocBook stylesheets
重新执行configure, 并设置CPPFLAGS. 检查通过.
root@digoal:~/postgresql-9.3.4 # ./configure CPPFLAGS='-I/usr/local/include' --prefix=/opt/pgsql9.3.4 --with-pgport=1921 --with-perl --with-tcl --with-python --with-openssl --with-pam --with-ldap --with-libxml --with-libxslt --enable-thread-safetychecking libxslt/xslt.h usability... yeschecking libxslt/xslt.h presence... yes
报缺少ldap.h
checking for ldap.h... noconfigure: error: header file 
is required for LDAP
安装openldap
root@digoal:~/postgresql-9.3.4 # pkg search ldap  openldap-server-2.4.39_1root@digoal:~/postgresql-9.3.4 # pkg install openldap-server-2.4.39_1Updating repository catalogueThe following 4 packages will be installed:        Installing openldap-client: 2.4.39        Installing libltdl: 2.4.2_3        Installing db46: 4.6.21.4        Installing openldap-server: 2.4.39_1The installation will require 39 MB more space7 MB to be downloadedProceed with installing packages [y/N]: yopenldap-client-2.4.39.txz                                                              100%  995KB  58.5KB/s 184.6KB/s   00:17    libltdl-2.4.2_3.txz                                                                     100%   37KB  36.8KB/s  36.8KB/s   00:00    db46-4.6.21.4.txz                                                                       100% 5218KB 173.9KB/s 437.9KB/s   00:30    openldap-server-2.4.39_1.txz                                                            100%  884KB 126.4KB/s 224.4KB/s   00:07    Checking integrity... done[1/4] Installing openldap-client-2.4.39... done[2/4] Installing libltdl-2.4.2_3... done[3/4] Installing db46-4.6.21.4... done[4/4] Installing openldap-server-2.4.39_1...===> Creating users and/or groups.Creating group 'ldap' with gid '389'.Creating user 'ldap' with uid '389'. done************************************************************The OpenLDAP client package has been successfully installed.Edit  /usr/local/etc/openldap/ldap.confto change the system-wide client defaults.Try `man ldap.conf' and visit the OpenLDAP FAQ-O-Matic at  http://www.OpenLDAP.org/faq/index.cgi?file=3for more information.************************************************************************************************************************The OpenLDAP server package has been successfully installed.In order to run the LDAP server, you need to edit  /usr/local/etc/openldap/slapd.confto suit your needs and add the following lines to /etc/rc.conf:  slapd_enable="YES"  slapd_flags='-h "ldapi://%252fvar%252frun%252fopenldap%252fldapi/ ldap://0.0.0.0/"'  slapd_sockets="/var/run/openldap/ldapi"Then start the server with  /usr/local/etc/rc.d/slapd startor reboot.Try `man slapd' and the online manual at  http://www.OpenLDAP.org/doc/for more information.  slapd runs under a non-privileged user id (by default `ldap'),see /usr/local/etc/rc.d/slapd for more information.************************************************************
接下来是未找到tcl和tclsh, 注意版本.
checking for tclsh... nochecking for tcl... nochecking for tclsh8.5... nochecking for tclsh85... nochecking for tclsh8.4... nochecking for tclsh84... nochecking for tclsh8.3... nochecking for tclsh83... noconfigure: error: Tcl shell not foundroot@digoal:~/postgresql-9.3.4 # pkg search tcltcl84-8.4.20_2,1tcl85-8.5.15_2tcl86-8.6.1root@digoal:~/postgresql-9.3.4 # pkg install tcl85-8.5.15_2Updating repository catalogueThe following 1 packages will be installed:        Installing tcl85: 8.5.15_2The installation will require 6 MB more space920 KB to be downloadedProceed with installing packages [y/N]: y
好了, 终于完全通过检测了
root@digoal:~/postgresql-9.3.4 # ./configure CPPFLAGS='-I/usr/local/include' --prefix=/opt/pgsql9.3.4 --with-pgport=1921 --with-perl --with-tcl --with-python --with-openssl --with-pam --with-ldap --with-libxml --with-libxslt --enable-thread-safety.......configure: using compiler=FreeBSD clang version 3.3 (tags/RELEASE_33/final 183502) 20130610configure: using CFLAGS=-O2 -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapvconfigure: using CPPFLAGS=-I/usr/local/include -I/usr/local/include/libxml2 -I/usr/include configure: using LDFLAGS= -L/usr/local/lib -L/usr/lib  -Wl,--as-neededconfigure: creating ./config.statusconfig.status: creating GNUmakefileconfig.status: creating src/Makefile.globalconfig.status: creating src/include/pg_config.hconfig.status: creating src/include/pg_config_ext.hconfig.status: creating src/interfaces/ecpg/include/ecpg_config.hconfig.status: linking src/backend/port/tas/dummy.s to src/backend/port/tas.sconfig.status: linking src/backend/port/dynloader/freebsd.c to src/backend/port/dynloader.cconfig.status: linking src/backend/port/sysv_sema.c to src/backend/port/pg_sema.cconfig.status: linking src/backend/port/sysv_shmem.c to src/backend/port/pg_shmem.cconfig.status: linking src/backend/port/unix_latch.c to src/backend/port/pg_latch.cconfig.status: linking src/backend/port/dynloader/freebsd.h to src/include/dynloader.hconfig.status: linking src/include/port/freebsd.h to src/include/pg_config_os.hconfig.status: linking src/makefiles/Makefile.freebsd to src/Makefile.port
使用gmake, 如果缺少的话, 使用pkg安装.
root@digoal:~/postgresql-9.3.4 # gmake world                                                                                        gmake: Command not found.root@digoal:~/postgresql-9.3.4 # pkg search gmakegmake-3.82_1root@digoal:~/postgresql-9.3.4 # pkg install gmake-3.82_1root@digoal:~/postgresql-9.3.4 # gmake world...............root@digoal:~/postgresql-9.3.4 # gmake install-world
创建pgsql的软链接
root@digoal:~/postgresql-9.3.4 # ln -s /opt/pgsql9.3.4 /opt/pgsql
配置资源限制, 参考
man login.conf
vi /etc/login.confdefault:\         :passwd_format=sha512:\        :copyright=/etc/COPYRIGHT:\        :welcome=/etc/motd:\        :setenv=MAIL=/var/mail/$,BLOCKSIZE=K:\        :path=/sbin /bin /usr/sbin /usr/bin /usr/games /usr/local/sbin /usr/local/bin ~/bin:\        :nologin=/var/run/nologin:\        :cputime=unlimited:\        :datasize=unlimited:\        :stacksize=unlimited:\        :memorylocked=64K:\        :memoryuse=unlimited:\        :filesize=unlimited:\        :coredumpsize=unlimited:\        :openfiles=unlimited:\        :maxproc=unlimited:\        :sbsize=unlimited:\        :vmemoryuse=unlimited:\        :swapuse=unlimited:\        :pseudoterminals=unlimited:\        :priority=0:\        :ignoretime@:\        :umask=022:postgres:\        :openfiles=unlimited:\        :maxproc=unlimited:
更新库
cap_mkdb /etc/login.conf
查看当前的ulimit
root@digoal:~ # su - postgrespostgres@digoal:~ % ulimit -acpu time               (seconds, -t)  unlimitedfile size           (512-blocks, -f)  unlimiteddata seg size           (kbytes, -d)  33554432stack size              (kbytes, -s)  524288core file size      (512-blocks, -c)  unlimitedmax memory size         (kbytes, -m)  unlimitedlocked memory           (kbytes, -l)  64max user processes              (-u)  6670open files                      (-n)  58266virtual mem size        (kbytes, -v)  unlimitedswap limit              (kbytes, -w)  unlimitedsbsize                   (bytes, -b)  unlimitedpseudo-terminals                (-p)  unlimited
配置内核参数, 
参考
root@digoal:~/postgresql-9.3.4 # vi /etc/sysctl.confkern.ipc.shmall=131072kern.ipc.shmmax=536870912kern.ipc.shm_use_phys=1   锁定shared memory到内存
生效
root@digoal:~/postgresql-9.3.4 # sysctl -w -f /etc/sysctl.confkern.ipc.shmall: 131072 -> 131072kern.ipc.shmmax: 536870912 -> 536870912kern.ipc.shm_use_phys: 1 -> 1
修改几个启动时加载的内核参数, 这几个参数不能在sysctl.conf中动态配置.
root@digoal:~/postgresql-9.3.4 # vi /boot/loader.conf zfs_load="YES"kern.ipc.semmni=256kern.ipc.semmns=512kern.ipc.semmnu=256
重启freebsd
确认这几个配置已经生效.
root@digoal:~ # sysctl -a|grep semmnikern.ipc.semmni: 256<118>sysctl: oid 'kern.ipc.semmni' is a read only tunable at line 12<118>sysctl: oid 'kern.ipc.semmni' is a read only tunable at line 12
配置防火墙, 
参见

添加普通用户, 用于运行postgresql
root@digoal:~/postgresql-9.3.4 # adduser Username: postgresFull name: postgresqlUid (Leave empty for default): Login group [postgres]: Login group is postgres. Invite postgres into other groups? []: Login class [default]: Shell (sh csh tcsh nologin) [sh]: csh  选择cshHome directory [/home/postgres]: Home directory permissions (Leave empty for default): Use password-based authentication? [yes]: Use an empty password? (yes/no) [no]: Use a random password? (yes/no) [no]: Enter password: Enter password again: Lock out the account after creation? [no]: Username   : postgresPassword   : *****Full Name  : postgresqlUid        : 1001Class      : Groups     : postgres Home       : /home/postgresHome Mode  : Shell      : /bin/cshLocked     : noOK? (yes/no): yesadduser: INFO: Successfully added (postgres) to the user database.Add another user? (yes/no): noGoodbye!
配置环境变量.
root@digoal:~/postgresql-9.3.4 # su - postgrespostgres@digoal:~ % vi .cshrc # $FreeBSD: release/10.0.0/share/skel/dot.cshrc 243893 2012-12-05 13:56:39Z eadler $## .cshrc - csh resource script, read at beginning of execution by each shell## see also csh(1), environ(7).# more examples available at /usr/share/examples/csh/#alias h         history 25alias j         jobs -lalias la        ls -aFalias lf        ls -FAalias ll        ls -lAF# A righteous umaskumask 22set path = (/opt/pgsql/bin /sbin /bin /usr/sbin /usr/bin /usr/games /usr/local/sbin /usr/local/bin $HOME/bin)setenv PGHOME /opt/pgsql setenv LD_LIBRARY_PATH /opt/pgsql/libsetenv PGDATA /home/postgres/pg_rootsetenv PGHOST $PGDATAsetenv PGPORT 1921setenv PGUSER postgressetenv PGDATABASE postgressetenv MANPATH $PGHOME/share/mansetenv  EDITOR  visetenv  PAGER   moresetenv  BLOCKSIZE       Kif ($?prompt) then        # An interactive shell -- set some stuff up        set prompt = "%N@%m:%~ %# "        set promptchars = "%#"        set filec        set history = 1000        set savehist = (1000 merge)        set autolist = ambiguous        # Use history to aid expansion        set autoexpand        set autorehash        set mail = (/var/mail/$USER)        if ( $?tcsh ) then                bindkey "^W" backward-delete-word                bindkey -k up history-search-backward                bindkey -k down history-search-forward        endifendif
重新登录csh, 确认环境变量已经生效.
postgres@digoal:~ % exitlogoutroot@digoal:~/postgresql-9.3.4 # su - postgrespostgres@digoal:~ % psql -Vpsql (PostgreSQL) 9.3.4postgres@digoal:~ % which psql/opt/pgsql/bin/psql
初始化数据库集群
postgres@digoal:~ % initdb -D $PGDATA -U postgres -E UTF8 --locale=C -WThe 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".The default text search configuration will be set to "english".Data page checksums are disabled.creating directory /home/postgres/pg_root ... okcreating subdirectories ... okselecting default max_connections ... 100selecting default shared_buffers ... 128MBcreating configuration files ... okcreating template1 database in /home/postgres/pg_root/base/1 ... okinitializing pg_authid ... okEnter new superuser password: Enter it again: setting password ... okinitializing dependencies ... okcreating system views ... okloading system objects' descriptions ... okcreating collations ... okcreating conversions ... okcreating dictionaries ... oksetting privileges on built-in objects ... okcreating information schema ... okloading PL/pgSQL server-side language ... okvacuuming database template1 ... okcopying template1 to template0 ... okcopying template1 to postgres ... oksyncing data to disk ... okWARNING: enabling "trust" authentication for local connectionsYou can change this by editing pg_hba.conf or using the option -A, or--auth-local and --auth-host, the next time you run initdb.Success. You can now start the database server using:    postgres -D /home/postgres/pg_rootor    pg_ctl -D /home/postgres/pg_root -l logfile start
配置数据库参考
cd $PGDATAvi postgresql.conflisten_addresses = '0.0.0.0'            # what IP address(es) to listen on;port = 1921                             # (change requires restart)max_connections = 100                   # (change requires restart)superuser_reserved_connections = 13     # (change requires restart)unix_socket_directories = '.'   # comma-separated list of directoriesunix_socket_permissions = 0700          # begin with 0 to use octal notationtcp_keepalives_idle = 60                # TCP_KEEPIDLE, in seconds;tcp_keepalives_interval = 10            # TCP_KEEPINTVL, in seconds;tcp_keepalives_count = 10               # TCP_KEEPCNT;shared_buffers = 128MB                  # min 128kBmaintenance_work_mem = 128MB            # min 1MBshared_preload_libraries = 'pg_stat_statements'         # (change requires restart)vacuum_cost_delay = 10                  # 0-100 millisecondsvacuum_cost_limit = 10000               # 1-10000 creditsbgwriter_delay = 10ms                   # 10-10000ms between roundswal_level = hot_standby                 # minimal, archive, or hot_standbysynchronous_commit = off                # synchronization level;wal_buffers = 16384kB                   # min 32kB, -1 sets based on shared_bufferswal_writer_delay = 10ms         # 1-10000 millisecondscheckpoint_segments = 8         # in logfile segments, min 1, 16MB eacharchive_mode = on               # allows archiving to be donearchive_command = '/bin/date'           # command to use to archive a logfile segmentmax_wal_senders = 8             # max number of walsender processeswal_keep_segments = 32          # in logfile segments, 16MB each; 0 disableshot_standby = on                        # "on" allows queries during recoverymax_standby_archive_delay = 300s        # max delay before canceling queriesmax_standby_streaming_delay = 300s      # max delay before canceling querieswal_receiver_status_interval = 1s       # send replies at least this oftenhot_standby_feedback = on               # send info from standby to preventeffective_cache_size = 2048MBlog_destination = 'csvlog'              # Valid values are combinations oflogging_collector = on          # Enable capturing of stderr and csvloglog_directory = 'pg_log'                # directory where log files are written,log_filename = 'postgresql-%Y-%m-%d_%H%M%S.log' # log file name pattern,log_file_mode = 0600                    # creation mode for log files,log_truncate_on_rotation = on           # If on, an existing log file with thelog_rotation_age = 1d                   # Automatic rotation of logfiles willlog_rotation_size = 10MB                # Automatic rotation of logfiles willlog_checkpoints = onlog_connections = onlog_disconnections = onlog_error_verbosity = verbose           # terse, default, or verbose messageslog_lock_waits = on                     # log lock waits >= deadlock_timeoutlog_statement = 'ddl'                   # none, ddl, mod, alllog_timezone = 'PRC'autovacuum = on                 # Enable autovacuum subprocess?  'on'log_autovacuum_min_duration = 0 # -1 disables, 0 logs all actions anddatestyle = 'iso, mdy'timezone = 'PRC'lc_messages = 'C'                       # locale for system error messagelc_monetary = 'C'                       # locale for monetary formattinglc_numeric = 'C'                        # locale for number formattinglc_time = 'C'                           # locale for time formattingdefault_text_search_config = 'pg_catalog.english'pg_stat_statements.max=1000pg_stat_statements.track=allvi pg_hba.confhost all all 0.0.0.0/0 md5
启动数据库
pg_ctl start
测试
postgres@digoal:~/pg_root % psqlpsql (9.3.4)Type "help" for help.No relations found.postgres=# create extension pg_stat_statements;CREATE EXTENSION
安装pgfincore, 报错, 暂未解决.
可能freebsd 10的libc版本太老.
http://git.postgresql.org/gitweb/?p=pgfincore.git;a=snapshot;h=0c891865d0e3777faafadb2fe3d84748b3a77d87;sf=tgzroot@digoal:~ # pkg install lrzsz-0.12.20_4root@digoal:~ # lrz# tar -zxvf pgfincore-0c89186.tar.gz# mv pgfincore-0c89186 postgresql-9.3.4/contrib/root@digoal:~ # mv pgfincore-0c89186 postgresql-9.3.4/contrib/root@digoal:~ # cd postgresql-9.3.4/contrib/pgfincore-0c89186/root@digoal:~/postgresql-9.3.4/contrib/pgfincore-0c89186 # set path = (/opt/pgsql/bin /sbin /bin /usr/sbin /usr/bin /usr/games /usr/local/sbin /usr/local/bin $HOME/bin)root@digoal:~/postgresql-9.3.4/contrib/pgfincore-0c89186 # which pg_config/opt/pgsql/bin/pg_configgmake uninstallgmakeIn file included from pgfincore.c:18:./fincore.h:10:30: error: unknown type name 'loff_t'; did you mean 'off_t'?int fincore(unsigned int fd, loff_t start, loff_t len, unsigned char * vec);                             ^~~~~~                             off_t/usr/include/sys/stat.h:86:18: note: 'off_t' declared heretypedef __off_t         off_t;                        ^In file included from pgfincore.c:18:./fincore.h:10:44: error: unknown type name 'loff_t'; did you mean 'off_t'?int fincore(unsigned int fd, loff_t start, loff_t len, unsigned char * vec);                                           ^~~~~~                                           off_t/usr/include/sys/stat.h:86:18: note: 'off_t' declared heretypedef __off_t         off_t;                        ^In file included from pgfincore.c:18:./fincore.h:12:30: error: unknown type name 'loff_t'; did you mean 'off_t'?int fincore(unsigned int fd, loff_t start, loff_t len, unsigned char * vec)                             ^~~~~~                             off_t/usr/include/sys/stat.h:86:18: note: 'off_t' declared heretypedef __off_t         off_t;                        ^In file included from pgfincore.c:18:./fincore.h:12:44: error: unknown type name 'loff_t'; did you mean 'off_t'?int fincore(unsigned int fd, loff_t start, loff_t len, unsigned char * vec)                                           ^~~~~~                                           off_t/usr/include/sys/stat.h:86:18: note: 'off_t' declared heretypedef __off_t         off_t;                        ^In file included from pgfincore.c:18:./fincore.h:14:10: warning: implicit declaration of function 'syscall' is invalid in C99 [-Wimplicit-function-declaration]  return syscall(__NR_fincore, fd, start, len, vec);         ^pgfincore.c:245:36: error: use of undeclared identifier '_SC_AVPHYS_PAGES'        values[1] = Int64GetDatum(sysconf(_SC_AVPHYS_PAGES));                                          ^/opt/pgsql9.3.4/include/server/postgres.h:555:47: note: expanded from macro 'Int64GetDatum'#define Int64GetDatum(X) ((Datum) SET_8_BYTES(X))                                              ^/opt/pgsql9.3.4/include/server/postgres.h:318:38: note: expanded from macro 'SET_8_BYTES'#define SET_8_BYTES(value)      ((Datum) (value))                                          ^pgfincore.c:353:29: error: use of undeclared identifier '_SC_AVPHYS_PAGES'        pgfdv->pagesFree = sysconf(_SC_AVPHYS_PAGES);                                   ^pgfincore.c:634:33: error: use of undeclared identifier '_SC_AVPHYS_PAGES'        pgfloader->pagesFree = sysconf(_SC_AVPHYS_PAGES);                                       ^pgfincore.c:951:30: error: use of undeclared identifier '_SC_AVPHYS_PAGES'        pgfncr->pagesFree = sysconf(_SC_AVPHYS_PAGES);                                    ^1 warning and 8 errors generated.gmake: *** [pgfincore.o] Error 1
查过man  sysconf后, 发现这里的identifier确实没有_SC_AVPHYS_PAGES.
_SC_AVPHYS_PAGES只有     _SC_PAGESIZE             The size of a system page in bytes.     _SC_PAGE_SIZE             Equivalent to _SC_PAGESIZE.     _SC_PHYS_PAGES             The number of pages of physical memory.  Note that it is possible             that the product of this value and the value of _SC_PAGESIZE will             overflow a long in some configurations on a 32bit machine.在CentOS 6.x中当然有这个定义man sysconf        - _SC_AVPHYS_PAGES              The number of currently available pages of physical memory.在opensolaris中也有这个定义man sysconf
或者玩一下opensolaris (or illumos now), 不过oracle关闭了opensolaris, 现已由illumos社区继承.
This is the home of the illumos project, the open source fork of Sun's OpenSolaris. Launched in 2010, the project enjoys financial and technical support from several key companies which rely on the illumos kernel as the technological foundation for their own products, as well as the backing of a growing developer community.

[参考]
1. 
2. 
3. 
4. 
5. 
6. man login.conf
7. 
man  sysconf
8. freebsd的一些基本操作, 收集自互联网.
Step 1 FreeBSD下安装软件包·pkg_add方式安装软件包。·Ports方式安装软件包。·源代码方式安装软件包。跟随下面步骤进行远程软件包的安装.FreeBSD下可以使用多种方法安装软件包,即可以使用pkg_add方式安装,也可以使用Ports方式安装,还可以下程序源码进行编译安装。不同的安装方式有不向的特点,有的省时间、快速;有点定制性高可以根据自己需要进行选择。pkg_add方式安装pkg_add方式安装方法1、用户预先下载编译好的需要进行安装的软件包,一般是*.tbz 和*.tgz格式的软件包。直接使用pkg_add+软件包名称,安装即可。可以使用-v参数显示安装过程。源程序可以从各大FTP站点(比如ftp://ftp.FreeBSD.org/pub/FreeBSD/ports/packages/)或各发行光盘中找到。pkg_add+软件包名称安装。此处以安装lsof-4.79D.tbz为例下载并显示lsof-4.79D.tbz软件包进行安装pkg_add -v lsof-4.79D.tbz (参数-v显示安装过程信息),安装完成可以输入rehash刷新。pkg_add方式安装方法2、用户不需要下载软件包,直接在安装时输入pkg_add -r和软件包的名称,系统将自动查找并下载、安装软件包(参数-r的作用是,使系统自动决定软件包的版本,格式并进行下载软件安装)。用户设定PACKAGESITE这个环境变量,选择距离最近的FTP服务器,可以加速下载安装过程。在上一篇的用户shell中PACKAGESITE这个环境变量,此处不再设定。pkg_add是在freebsd里面用来通过package安装软件一个命令,而-r 则是说本地没有package包,安装时自动从网上下载。默认的站点一般如:ftp://ftp.freebsd.org/pub/FreeBSD/ports/i386/packages-6.1-release/All/这样的格式,访问国外的服务器一般比国内的要慢很多,特别是现在正值海底光纤就震断之际,国外网站更是难以访问。所以非常有必要修改这个默认ftp站点,所以就要设置PACKAGESITE这个环境变量在csh shell里这样改:#setenv PACKAGESITE ftp://ftp.freebsd.org.cn/pub/FreeBSD/ports/i386/packages-6.1-release/All/注意在不同的shell里设置环境变量的方法是不同的,在不同的shell运行这个,不会提示错误,但设置后也没有效果的。在sh shell里这样改:# export PACKAGESITE=ftp://ftp.freebsd.org.cn /pub/FreeBSD/ports/i386/packages-6.1-release/All/好了现在通过pkg_add -r 来安装软件下载快得多了!pkg_add -r+软件包名称安装(系统自动解决依赖关系)。此处以安装wget为例不需要指定版本及格式,直接输入安装命令pkg_add -r wget即可。系统会自动连接服务器进行下载,并且自动解决依赖关系。使用Ports方式安装软件包Ports中进入软件包名称安装目录,执行make install clean进行安装(系统自动解决依赖关系) Ports安装命令总结make install :安裝所选定的 Portmake deinstall :移除已安裝的 Portmake reinstall :移除之后再安裝一次make clean :安裝完毕后移除 make 資料夾下的档案make distclean :移除安裝后的原始档案,以节省磁碟空间make rmconfig :移除之前安裝过程中选项的設定使用源代码进行安装程序以Apache22为例(假设安装路径为/usr/local/apache22) 下载Apache22的talball可以使用wget在FreeBSD下载,也可以在Win下载完成再传到FreeBSD机器上。解包并指定安装路径,进行配置,安装--prefix : 設定 Apache httpd 安裝路径--enable-so : 告訴 Apache 启动 so 模組, 让 Apache 能够载入 shared modules(例如 PHP) 启动Apache22进行测试浏览器打开http://youipaddress好了,Apache22安装成功了。Step 2 FreeBSD下的下载程序.FreeBSD中安装下载程序axel和wget:安装axel程序可以使用任意方法安装,如pkg_add或者Ports方式安装。这里使用pkg_add -r axel命令安装axel程序的使用,axel+要下载的文件的url安装wget程序使用Ports方式安装,查找到wget所在目录,进入目录,执行make install clean使用方式和axel基本一样。wget+下载的程序名称的url

转载地址:http://oejpx.baihongyu.com/

你可能感兴趣的文章
css文字环绕图片效果
查看>>
nutch插件扩展点
查看>>
UIWebView和WKWebView的使用及js交互
查看>>
设计模式--BRIDGE
查看>>
java同屏软件(优化手段:线程池 + 压缩)
查看>>
Lighttpd轻量级web服务器安装手册
查看>>
2、HDFS的HA原理及配置
查看>>
顺序数据---马尔科夫模型
查看>>
com.atlassian.util.concurrent.LazyReference$InitializationException: java.lang.NullPointerException
查看>>
ECSHOP_修改后台登陆路径
查看>>
Eclipse 3.7如何安装egit
查看>>
Android之最简单的ImageView加边框方法
查看>>
Redis 基础入门
查看>>
GTK中设置滚动条到某一特定位置
查看>>
算法(第四版)课后练习 1.3.29
查看>>
android Draw Rect 坐标图示
查看>>
What is Serverless?
查看>>
CYQ.Data 轻量数据层之路 应用示例三 Aop切入留言系统--操作日志(二十七)
查看>>
Homebrew 的安装方法(官方的方法老是安装失败) 第三方
查看>>
java 服务程序cpu资源占用高的问题
查看>>