標籤:evel div eve where su - prefix env tor std
1. 建立postgres使用者和組
# groupadd -g 101 dba# useradd -u 501 -g dba -G root -d /usr/local/pgsql postgres
2. 添加postgres使用者環境變數
$ cat ~/.bash_profile# .bash_profile# Get the aliases and functionsif [ -f ~/.bashrc ]; then . ~/.bashrcfi# User specific environment and startup programsexport PGHOME=/usr/local/pgsqlexport PGDATA=/usr/local/pgsql/dataexport PATH=$PGHOME/bin:$PATH:$HOME/bin
export LD_LIBRARY_PATH=$PGHOME/lib:/lib64:/usr/lib64:/usr/local/lib64:/lib:/usr/lib:/usr/local/lib:$LD_LIBRARY_PATH
3. 調整系統參數
# tail -n 12 /etc/sysctl.confvm.overcommit_memory=1vm.overcommit_ratio=90fs.aio-max-nr=1048576fs.file-max= 7672460net.ipv4.ip_local_port_range=9000 65500net.core.rmem_default=262144net.core.rmem_max=4194304net.core.wmem_default=262144net.core.wmem_max=1048586kernel.sem= 50100 64128000 50100 1280kernel.shmall=5242880kernel.shmmax=12884901888# tail -n 4 /etc/security/limits.confpostgres soft nproc 8192postgres hard nproc 16384postgres soft nofile 4096postgres hard nofile 65536
4. 安裝Python
# wget https://www.python.org/ftp/python/2.7.13/Python-2.7.13.tgz# tar -zxf Python-2.7.13.tgz# cd Python-2.7.13# ./configure --enable-shared --with-distutils# make# make install# /usr/local/bin/python --versionPython 2.7.13
5. 安裝依賴包
# yum install -y perl-ExtUtils-Embed python-devel gcc-c++ openssl-devel readline readline-devel zlib zlib-devel openssl openssl-devel pam pam-devel libxml2 libxml2-devel libxslt libxslt-devel openldap openldap-devel libgeos-dev libproj-dev libgdal-dev xsltproc docbook-xsl docbook-xml imagemagick libmagickcore-dev dblatex tcl tcl-devel
6. 安裝PostgreSQL
$ wget https://ftp.postgresql.org/pub/source/v9.5.7/postgresql-9.5.7.tar.bz2$ tar -jxf postgresql-9.5.7.tar.bz2$ cd postgresql-9.5.7$ ./configure -prefix=/usr/local/pgsql --with-perl --with-tcl --with-openssl --with-pam --with-libxml --with-libxslt --with-wal-segsize=32$ make$ make install$ cd contrib/$ make && make install$ mkdir /usr/local/pgsql/{data,arch}$ sudo echo "su - postgres -c ‘pg_ctl start -D /usr/local/pgsql/data‘" >> /etc/rc.local$ /usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data/$ cat /usr/local/pgsql/data/postgresql.conf | grep -v "^$" | grep -v "^#"listen_addresses = ‘*‘ # what IP address(es) to listen on;port = 5432 # (change requires restart)max_connections = 300 # (change requires restart)shared_buffers = 2048MB # min 128kBlogging_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,$ cat /usr/local/pgsql/data/pg_hba.conf | grep -v "^$" | grep -v "^#"local all all trusthost all all 127.0.0.1/32 trusthost all all 0.0.0.0/0 md5host all all ::1/128 trust$ pg_ctl start -W$ psql psql (9.5.7)Type "help" for help.postgres=# select version(); version ---------------------------------------------------------------------------------------------------------- PostgreSQL 9.5.7 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-18), 64-bit(1 row)
PostgreSQL&PostGIS完整安裝