您好,登錄后才能下訂單哦!
wgethttp://download.osgeo.org/postgis/source/postgis-2.2.2.tar.gz
wgethttps://ftp.postgresql.org/pub/source/v9.4.8/postgresql-9.4.8.tar.gz
wgethttp://download.osgeo.org/gdal/2.0.0/gdal-2.0.0.tar.gz
wgethttp://download.osgeo.org/geos/geos-3.5.0.tar.bz2
#yum install -y gcc gdb strace gcc-c++ autoconf libjpeglibjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-develzlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel
#yum install ncurses ncurses-devel curl curl-devel e2fsprogs patche2fsprogs-devel krb5-devel libidn libidn-devel openldap-devel nss_ldapopenldap-clients openldap-servers libevent-devel libevent uuid-devel uuidmysql-devel
#yum install make cmake lrzsz perl perl-ExtUtils-Embed readlinereadline-devl python-devel proj proj-devel screen gmp gmp-devel mpfr mpfr-develdevtoolset-2-gcc devtoolset-2-binutils devtoolset-2-gcc-c++ boost boost-develcmake3 cmake3-gui cmake3-data
--downloadonly--downloaddir=/mnt/yilaibao -y
postgresql安裝
創(chuàng)建軟件包存放目錄:
#mkdir /data
進(jìn)入目錄按上面的鏈接下載軟件包
#cd /data
解壓安裝包
#tar zxvf postgresql-9.4.8
#cd postgresql-9.4.8
#./configure --prefix=/usr/local/pgsql9_4_8 --with-python --with-perl
#make
#make install
添加數(shù)據(jù)庫(kù)賬戶(hù)
#adduser postgres
添加數(shù)據(jù)存放路徑
#mkdir -p /usr/local/pgsql9_4_8/data
#chown postgres /usr/local/pgsql9_4_8/data(chown postgres /usr/local chmod 777 /usr/local/pgsql9_4_8/
chown postgres /usr/local/pgsql9_4_8/bin )
進(jìn)入普通賬號(hào)
su - postgres
/usr/local/pgsql9_4_8/bin/initdb -D /usr/local/pgsql9_4_8/data
啟動(dòng)
/usr/local/pgsql9_4_8/bin/postgres -D /usr/local/pgsql9_4_8/data>logfile 2>&1 &
停止
cd /usr/local/pgsql9_4_8/bin/
./pg_ctl stop -D /usr/local/pgsql9_4_8/data/ -m {smart| fast}
在postgres賬號(hào)下添加環(huán)境變量
export LD_LIBRARY_PATH=/usr/local/pgsql9_4_8/lib
export PATH=/usr/local/pgsql9_4_8/bin:$PATH
---------------------------------------------------------------------------------------------------------------------
//注意:永久添加方法
進(jìn)入普通賬戶(hù):su - postgres
#vi ~/.bash_profile
export LD_LIBRARY_PATH=/usr/local/pgsql9_4_8/lib
export PATH=/usr/local/pgsql9_4_8/bin:$PATH
查看環(huán)境變量#echo $PATH
保存退出,這樣既可永久添加。
---------------------------------------------------------------------------------------------------------------
注意在root下要再添加一次環(huán)境變量,最好上述的環(huán)境變量在普通賬戶(hù)和root賬戶(hù)下都添加。
退出普通賬號(hào)安裝fuzzystrmatch擴(kuò)展包
cd contrib
make
make install
cd /data
tar zxvf gdal-2.0.0.tar.gz
cd gdal-2.0.0
./configure --prefix=/usr/local/gdal --with-xml2=/usr/bin/xml2-config --with-static-proj4=/usr/bin/proj (編譯安裝proj)
make
make install
cd /data
tar jxvf geos-3.5.0.tar.bz2
cd geos-3.5.0
./configure --prefix=/usr/local/geos3
make
make install
vi /etc/ld.so.conf
/usr/local/pgsql9_4_8/lib(根據(jù)自己安裝的路徑改動(dòng))
/usr/local/gdal/lib (根據(jù)自己安裝的路徑改動(dòng))
/usr/local/geos3/lib (根據(jù)自己安裝的路徑改動(dòng))
/usr/local/lib
等最后安裝好后要以 root 的身份運(yùn)行 #ldconfig
#cd /data
#tar zxvfpostgis-2.2.2.tar.gz
# cdpostgis-2.2.2/
./configure--with-pgconfig=/usr/local/pgsql9_4_8/bin/pg_config--with-gdalconfig=/usr/local/gdal/bin/gdal-config--with-geosconfig=/usr/local/geos3/bin/geos-config
make
cd extensions
cd postgis
make clean
make
make install
cd ..
cdpostgis_topology
make clean
make
make install
cd ..
cd postgis_tiger_geocoder
make clean
make
make install
cd ../..
make install
進(jìn)入控制臺(tái)執(zhí)行以下語(yǔ)句:
CREATE EXTENSIONpostgis;
CREATE EXTENSIONfuzzystrmatch;
CREATE EXTENSIONpostgis_tiger_geocoder;
CREATE EXTENSIONpostgis_topology;
yum -y install bzip2
cd /data
tar xvJf CGAL-4.8.1.tar.xz
cd CGAL-4.8.1
yum install gmp gmp-devel
yum install mpfr mpfr-devel
cmake .
make
make install
wget http://people.centos.org/tru/devtools-2/devtools-2.repo -O/etc/yum.repos.d/devtools-2.repo
yum install devtoolset-2-gcc devtoolset-2-binutilsdevtoolset-2-gcc-c++
PATH=/opt/rh/devtoolset-2/root/usr/bin/:$PATH
cd ..
tar zxvf pgrouting-2.2.0.tar.gz
cd pgrouting-pgrouting-2.2.0/
mkdir build
cd build/
cmake3 ..
make
make install
su - postgres
psql
CREATE EXTENSION pgrouting;
給postgres用戶(hù)設(shè)置密碼:
alter user postgres with password 'postgres';
test!@#
Pg數(shù)據(jù)庫(kù)設(shè)置遠(yuǎn)程連接:
1、#cd /usr/local/pgsql9_4_8/data
#vi pg_hba.conf
2、#vipostgresql.conf
3、設(shè)置防火墻(在root下)
#vi /etc/sysconfig/iptables
-A INPUT -m state --state NEW -m tcp -p tcp --dport 5432 -j ACCEPT
4、停止,再啟動(dòng)(在postgres賬戶(hù))
$pg_ctl stop -D /usr/local/pgsql9_4_8/data/ -m fast
$/usr/local/pgsql9_4_8/bin/postgres -D /usr/local/pgsql9_4_8/data>logfile 2>&1 &
Pg數(shù)據(jù)庫(kù)設(shè)置開(kāi)機(jī)自啟動(dòng):
PostgreSQL的開(kāi)機(jī)自啟動(dòng)腳本位于PostgreSQL源碼目錄的contrib/start-scripts路徑下
linux文件即為linux系統(tǒng)上的啟動(dòng)腳本
1)修改linux文件屬性,添加X屬性
#chmod a+x linux
2) 復(fù)制linux文件到/etc/init.d目錄下,更名為postgresql
#cp linux/etc/init.d/postgresql
3)修改/etc/init.d/postgresql文件的兩個(gè)變量
prefix設(shè)置為postgresql的安裝路徑:/opt/pgsql-9.1.2
PGDATA設(shè)置為postgresql的數(shù)據(jù)目錄路徑:
4) 執(zhí)行service postgresqlstart,就可以啟動(dòng)PostgreSQL服務(wù)
#service postgresqlstart
5)設(shè)置postgresql服務(wù)開(kāi)機(jī)自啟動(dòng)
#chkconfig --addpostgresql
執(zhí)行上面的命令,就可以實(shí)現(xiàn)postgresql服務(wù)的開(kāi)機(jī)自啟動(dòng)。
注意事項(xiàng)
在部署前請(qǐng)檢查系統(tǒng)是否安裝了postgresql、postgis等上述軟件,如果有請(qǐng)先卸載、不同Linux發(fā)行版本在安裝過(guò)程中可能會(huì)遇到其他軟件依賴(lài)關(guān)系需要根據(jù)安裝過(guò)程中提示的問(wèn)題解決。
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。