当前位置: 首页 > wzjs >正文

银川免费网站建设公司做网站需要什么资质

银川免费网站建设,公司做网站需要什么资质,重庆市建设工程节能中心网站,用自己电脑做网站 dns文章目录 一、源码编译及安装1. 指定安装路径2. 编译安装3. 安装后 PostgreSQL 的目录结构4. 设置环境变量 二、PG数据库初始化1. 初始化数据库目录2. 启动数据库3. 连接数据库4. 数据库启动失败,端口被占用 三、GIST索引使用1. 下载数据文件2. 将数据集加载到 Post…

文章目录

  • 一、源码编译及安装
    • 1. 指定安装路径
    • 2. 编译安装
    • 3. 安装后 PostgreSQL 的目录结构
    • 4. 设置环境变量
  • 二、PG数据库初始化
    • 1. 初始化数据库目录
    • 2. 启动数据库
    • 3. 连接数据库
    • 4. 数据库启动失败,端口被占用
  • 三、GIST索引使用
    • 1. 下载数据文件
    • 2. 将数据集加载到 Postgres 中
      • 2.1 连接数据库
      • 2.2 定义一个枚举类型
      • 2.3 创建一张数据表
      • 2.4 加载到数据表
      • 源码编译安装PROJ库
      • 2.5 为数据设置经纬度坐标
        • 2.5.1 安装PROJ库
        • 2.5.2 安装GDAL
        • 2.5.3 安装postgis扩展
    • 3. 创建gist空间索引
    • 4. 创建Btree-gist索引


一、源码编译及安装

git clone https://github.com/postgres/postgres.git

1. 指定安装路径

--prefix=/opt/pgsql/postgresql指定安装路径,最终make install的时候,程序会被安装到这个目录下,而不是默认的/usr/lcoal

./configure --prefix=/opt/pgsql/postgresql

2. 编译安装

make
make install

3. 安装后 PostgreSQL 的目录结构

/opt/pgsql/postgresql/bin/        # 可执行文件
/opt/pgsql/postgresql/lib/        # 库文件
/opt/pgsql/postgresql/share/      # 共享资源,如配置模板、文档

4. 设置环境变量

vi ~/.bashrc
export PATH=/opt/pgsql/postgresql/bin:$PATH
source ~/.bashrc

二、PG数据库初始化

1. 初始化数据库目录

该操作只有在部署完后的首次需要执行,指定数据库文件存放地址-D $HOME/pgdata,指定超级用户名-U postgres

/opt/pgsql/postgresql/bin/initdb -D /opt/postgres-custom/mydb -U postgres -E UTF8 --locale=en_US.UTF-8

2. 启动数据库

/opt/pgsql/postgresql/bin/pg_ctl -D /opt/postgres-custom/mydb -l logfile start

其中:-D 指定数据库目录,-l logfile 指定日志文件

3. 连接数据库

/usr/local/pgsql/postgresql/bin/psql -U postgres

输出

(base) hhhh@ubuntu-Super-Server:~$ psql -U postgres
psql (13.18)
Type "help" for help.postgres=# 

4. 数据库启动失败,端口被占用

检查端口是否被占用,执行sudo ss -tuln | grep 5432 检查是否被占用

(base) hhhhh@ubuntu-Super-Server:~$ sudo ss -tuln | grep 5432
tcp   LISTEN 0      200                                      127.0.0.1:5432       0.0.0.0:*   

或者通过ps aux | grep postgres检查

(base) hhhh@ubuntu-Super-Server:~$ ps aux | grep postgres
hhhhh 1273591  0.0  0.0 214064 22400 ?        Ss   2月12   5:40 /opt/pgsql/postgresql/bin/postgres -D /opt/postgres-custom/mydb
hhhhh 1273592  0.0  0.0 214440 24972 ?        Ss   2月12   0:20 postgres: checkpointer 

上述内容表明:数据目录是 /opt/postgres-custom/mydb,而且正是它占用了 5432 端口,通过下面的命令关闭当前进程

/opt/pgsql/postgresql/bin/pg_ctl -D /opt/postgres-custom/mydb stop

三、GIST索引使用

GIST作为一个通用索引,支持实现各种树索引如Btree、Rtree等,在这里我们以GIST中的btree实现作为例子

1. 下载数据文件

cd $HOME/gist/test_dataset
wget https://data.police.uk/data/archive/2017-04.zip

查看一共多少条数据xsv cat rows **/*-street.csv | xsv count,并查看都有哪些列

(base) hhhhh@ubuntu-Super-Server:~/gist/test_dataset$ xsv cat rows **/*-street.csv | xsv count
38595130
(base) hhhhh@ubuntu-Super-Server:~/gist/test_dataset$ xsv headers 2010-12/2010-12-avon-and-somerset-street.csv
1   Crime ID
2   Month
3   Reported by
4   Falls within
5   Longitude
6   Latitude
7   Location
8   LSOA code
9   LSOA name
10  Crime type
11  Last outcome category
12  Context
(base) hanbaofu@ubuntu-Super-Server:~/gist/test_dataset$ 

统计多个 *-street.csv 文件中,不同类型犯罪(Crime type)出现的频率,并以表格形式展示。

(base) hanbaofu@ubuntu-Super-Server:~/gist/test_dataset$ xsv cat rows **/*-street.csv \
> | pv -l -s 38595130 \
> | xsv frequency --select 'Crime type' --limit 0 \
> | xsv table38.6M 0:00:38 [1.01M/s] [===============================================================================================>] 100%            
field       value                         count
Crime type  Anti-social behaviour         13869607
Crime type  Violence and sexual offences  4047849
Crime type  Other theft                   3258648
Crime type  Criminal damage and arson     3129836
Crime type  Burglary                      2866490
Crime type  Vehicle crime                 2477833
Crime type  Other crime                   2147319
Crime type  Shoplifting                   1890071
Crime type  Violent crime                 1673219
Crime type  Drugs                         987402
Crime type  Public order                  792808
Crime type  Robbery                       391709
Crime type  Bicycle theft                 369895
Crime type  Theft from the person         346421
Crime type  Public disorder and weapons   242145
Crime type  Possession of weapons         103878
(base) hanbaofu@ubuntu-Super-Server:~/gist/test_dataset$ 

2. 将数据集加载到 Postgres 中

2.1 连接数据库

(base) hanbaofu@ubuntu-Super-Server:~/gist$ /usr/local/pgsql/postgresql/bin/psql -U postgres
psql (18devel)
Type "help" for help.postgres=# 

执行create database crimes_db;生成数据库,并切换到当前数据库\c crimes_db

postgres=# create database crimes_db;
CREATE DATABASE
postgres=# \c crimes_db
You are now connected to database "crimes_db" as user "postgres".
crimes_db=# 

2.2 定义一个枚举类型

CREATE TYPE crime_type AS ENUM ('Anti-social behaviour','Violence and sexual offences','Other theft','Criminal damage and arson','Burglary','Vehicle crime','Other crime','Shoplifting','Violent crime','Drugs','Public order','Robbery','Bicycle theft','Theft from the person','Public disorder and weapons','Possession of weapons'
);

2.3 创建一张数据表

CREATE TABLE crimes (month DATE,longitude REAL,latitude REAL,crime crime_type
);

2.4 加载到数据表

执行下面的命令,把多个 CSV 文件中的数据导入到 PostgreSQL 中的 crimes 表里

(base) hhhhh@ubuntu-Super-Server:~/gist/test_dataset$ xsv cat rows **/*-street.csv \
> | pv -l -s 38595130 \
> | xsv select Month,Longitude,Latitude,'Crime type' \
> | sed -E 's/^([0-9]+-[0-9]+)/\1-01/g' \
> | psql -U postgres -d crimes_db -c 'copy crimes from stdin csv header'38.6M 0:01:25 [ 452k/s] [===============================================================================================>] 100%            
COPY 38595130
(base) hhhhh@ubuntu-Super-Server:~/gist/test_dataset$ 

通过快速 交叉表快速检查数据是否已加载完毕,在此之前,先安装如下扩展

crimes_db=# create extension tablefunc;
ERROR:  extension "tablefunc" is not available
DETAIL:  Could not open extension control file "/usr/local/pgsql/postgresql/share/extension/tablefunc.control": No such file or directory.
HINT:  The extension must first be installed on the system where PostgreSQL is running.

我们发现安装扩展失败,这是因为在从进行源码编译 PostgreSQL时,默认只编译了核心部分,而 PostgreSQL 自带的很多扩展(比如 tablefunc、uuid-ossp 等)其实都在一postgresql/contrib

执行下面的命令安装 contrib 扩展,这会把所有 .control、.sql 文件安装到 PostgreSQL 的安装目录下

cd ~/gist/postgres/contrib
make
sudo make install

接下来重新回到 psql,执行刚才的创建扩展命令即可。

crimes_db=# CREATE EXTENSION tablefunc;
CREATE EXTENSION
crimes_db=# 

通过快速交叉表看看多年来数据的分布情况:

select * from crosstab($$ select crime, to_char(month, 'YYYY') as year, count(*) from crimes group by crime, year order by crime asc, year asc $$,$$ select gs from generate_series(2010, 2017) gs $$
) as ("Crime" text, "2010" int, "2011" int, "2012" int, "2013" int, "2014" int, "2015" int, "2016" int, "2017" int);

得到如下输出:注意在psql中,只要你不输入分号,就会默认这个命令没结束

crimes_db=# select * from crosstab(
crimes_db(# $$ select crime, to_char(month, 'YYYY') as year, count(*) from crimes group by crime, year order by crime asc, year asc $$,
crimes_db(# $$ select gs from generate_series(2010, 2017) gs $$
crimes_db(# ) as ("Crime" text, "2010" int, "2011" int, "2012" int, "2013" int, "2014" int, "2015" int, "2016" int, "2017" int);Crime             |  2010  |  2011   |  2012   |  2013   |  2014   |  2015   |  2016   |  2017  
------------------------------+--------+---------+---------+---------+---------+---------+---------+--------Anti-social behaviour        | 201016 | 2792756 | 2369431 | 2191485 | 2035155 | 1875251 | 1850397 | 554116Violence and sexual offences |        |         |         |  477713 |  839521 | 1049988 | 1232210 | 448417Other theft                  |        |  251482 |  737010 |  582768 |  515839 |  505800 |  496783 | 168966Criminal damage and arson    |        |  207293 |  563360 |  526600 |  516930 |  549252 |  570616 | 195785Burglary                     |  37893 |  505841 |  476006 |  455384 |  427448 |  410673 |  409102 | 144143Vehicle crime                |  29416 |  411012 |  392300 |  378911 |  356789 |  368599 |  394087 | 146719Other crime                  | 142705 | 1530533 |  182205 |   71454 |   53501 |   63296 |   74160 |  29465Shoplifting                  |        |  104179 |  303366 |  321207 |  331093 |  339237 |  361982 | 129007Violent crime                |  57580 |  729387 |  676732 |  209520 |         |         |         |       Drugs                        |        |   71007 |  208111 |  198252 |  177470 |  151401 |  137739 |  43422Public order                 |        |         |         |   91823 |  152113 |  194164 |  254129 | 100579Robbery                      |   5731 |   75068 |   68042 |   60648 |   52416 |   51651 |   56042 |  22111Bicycle theft                |        |         |         |   73342 |   95021 |   88193 |   86670 |  26669Theft from the person        |        |         |         |   68442 |   81964 |   83056 |   83483 |  29476Public disorder and weapons  |        |   51555 |  147405 |   43185 |         |         |         |       Possession of weapons        |        |         |         |   14133 |   21415 |   25168 |   31218 |  11944
(16 rows)crimes_db=# 

源码编译安装PROJ库

# 安装编译所需依赖
sudo apt-get install build-essential cmake sqlite3 libsqlite3-dev
# 下载和编译PROJ
cd ~
wget https://download.osgeo.org/proj/proj-9.3.0.tar.gz
tar -xvzf proj-9.3.0.tar.gz
cd proj-9.3.0
mkdir build && cd build
cmake ..
make -j$(nproc)
sudo make install
sudo ldconfig

在执行cmake …的时候出现如下错误,这是因为在编译PROJ库时缺少TIFF库

-- Found Sqlite3: /usr/lib/x86_64-linux-gnu/libsqlite3.so
-- Sqlite3 version: 3.45.1
CMake Error at /usr/share/cmake-3.28/Modules/FindPackageHandleStandardArgs.cmake:230 (message):Could NOT find TIFF (missing: TIFF_LIBRARY TIFF_INCLUDE_DIR)
Call Stack (most recent call first):/usr/share/cmake-3.28/Modules/FindPackageHandleStandardArgs.cmake:600 (_FPHSA_FAILURE_MESSAGE)/usr/share/cmake-3.28/Modules/FindTIFF.cmake:272 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)CMakeLists.txt:198 (find_package)

安装TIFF库的开发包:

sudo apt-get install libtiff-dev

如果遇到如下错误,则通过conda install -c conda-forge libtiff安装即可

-- Configuring incomplete, errors occurred!
(base) hanbaofu@ubuntu-Super-Server:~/proj-9.3.0/build$ sudo apt-get install libtiff-dev
正在读取软件包列表... 完成
正在分析软件包的依赖关系树... 完成
正在读取状态信息... 完成                 
有一些软件包无法被安装。如果您用的是 unstable 发行版,这也许是
因为系统无法达到您要求的状态造成的。该版本中可能会有一些您需要的软件
包尚未被创建或是它们已被从新到(Incoming)目录移出。
下列信息可能会对解决问题有所帮助:下列软件包有未满足的依赖关系:libdeflate-dev : 依赖: libdeflate0 (= 1.19-1build1) 但是 1.19-1build1.1 正要被安装libzstd-dev : 依赖: libzstd1 (= 1.5.5+dfsg2-2build1) 但是 1.5.5+dfsg2-2build1.1 正要被安装
E: 无法修正错误,因为您要求某些软件包保持现状,就是它们破坏了软件包间的依赖关系。
(base) hanbaofu@ubuntu-Super-Server:~/proj-9.3.0/build$ conda install -c conda-forge libtiff
Retrieving notices: done

2.5 为数据设置经纬度坐标

在正式开始之前,需要先安装相应的依赖

2.5.1 安装PROJ库
cd ~/proj-9.3.0
rm -rf build
mkdir build && cd build
cmake .. -DCMAKE_PREFIX_PATH=$CONDA_PREFIX
make -j$(nproc)
sudo make install
sudo ldconfig
2.5.2 安装GDAL

下载源码

wget https://github.com/OSGeo/gdal/releases/download/v3.7.3/gdal-3.7.3.tar.gz
tar -xzf gdal-3.7.3.tar.gz
cd gdal-3.7.3
mkdir build && cd build
cmake ..
make -j$(nproc)
sudo make install
sudo ldconfig

安装完之后检查是否正确安装

# 检查gdal-config是否存在
which gdal-config# 验证GDAL库文件是否存在
ls -la /usr/local/lib/libgdal*# 检查GDAL版本
gdal-config --version

设置环境变量

export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
export CPLUS_INCLUDE_PATH=/usr/local/include:$CPLUS_INCLUDE_PATH
export C_INCLUDE_PATH=/usr/local/include:$C_INCLUDE_PATH
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH
2.5.3 安装postgis扩展

在配置PostGIS时,确保 PostGIS 与相应的PG13 环境绑定,如果是其他的PG版本,则修改下面的内容即可

cd ~/gist/postgis-3.4.0
./configure --with-pgconfig=/opt/pgsql/postgresql/bin/pg_config

显式指定GDAL的所有相关路径:

./configure \--with-gdal=/usr/local/bin/gdal-config \--with-gdalconfig=/usr/local/bin/gdal-config \LDFLAGS="-L/usr/local/lib" \CPPFLAGS="-I/usr/local/include"make sudo make install

输出

configure: WARNING: unrecognized options: --with-gdalPostGIS is now configured for x86_64-pc-linux-gnu-------------- Compiler Info ------------- C compiler:           gcc -std=gnu99 -g -O2 -fno-math-errno -fno-signed-zeros -WallC++ compiler (Wagyu): gcc -std=c++11 -x c++ C++ compiler (FlatGeobuf): gcc -std=c++11 -x c++ CPPFLAGS:              -I$HOME/miniconda3/include   -I$HOME/miniconda3/include/libxml2 -I/home/hanbaofu/miniconda3/include    -DNDEBUG -I/usr/local/includeLDFLAGS:              -L/usr/local/lib -lmSQL preprocessor:     /usr/bin/cpp -traditional-cpp -w -P -Upixel -UboolArchiver:             gcc-ar rs-------------- Additional Info ------------- Interrupt Tests:   ENABLED-------------- Dependencies -------------- GEOS config:          $HOME/miniconda3/bin/geos-configGEOS version:         3.13.1GDAL config:          /usr/local/bin/gdal-configGDAL version:         3.7.3PostgreSQL config:    /usr/local/pgsql/postgresql/bin/pg_configPostgreSQL version:   PostgreSQL 18develPROJ4 version:        93Libxml2 config:       $HOME/miniconda3/bin/xml2-configLibxml2 version:      2.13.7JSON-C support:       noprotobuf support:     yesprotobuf-c version:   1004001PCRE support:         not foundPerl:                 /usr/bin/perl--------------- Extensions --------------- PostgreSQL EXTENSION support:       enabledPostGIS Raster:                     enabledPostGIS Topology:                   enabledSFCGAL support:                     disabledAddress Standardizer support:       disabled-------- Documentation Generation -------- xsltproc:             xsl style sheets:     dblatex:              convert:              mathml2.dtd:          http://www.w3.org/Math/DTD/mathml2/mathml2.dtd

然后在psql中执行下面的命令

create extension postgis;

3. 创建gist空间索引

4. 创建Btree-gist索引


文章转载自:

http://LXnsamvf.ysjjr.cn
http://vZyUs9lE.ysjjr.cn
http://YmLLcKH6.ysjjr.cn
http://E7UEWNEM.ysjjr.cn
http://e4APbRol.ysjjr.cn
http://L6hxNhBK.ysjjr.cn
http://R76GxXxx.ysjjr.cn
http://fSafl5S7.ysjjr.cn
http://XJZhN7Bx.ysjjr.cn
http://RwXuF93W.ysjjr.cn
http://K9HY8KZi.ysjjr.cn
http://NgKFYxrX.ysjjr.cn
http://z8UvaNMH.ysjjr.cn
http://x2uJK0IW.ysjjr.cn
http://fjBbda59.ysjjr.cn
http://HBa1T7m9.ysjjr.cn
http://AQ6DAdXW.ysjjr.cn
http://86xRu74i.ysjjr.cn
http://NgjDSrMn.ysjjr.cn
http://5arIeibD.ysjjr.cn
http://zz3l99uR.ysjjr.cn
http://LTkggwhp.ysjjr.cn
http://nLsRkPS6.ysjjr.cn
http://7nwiS3LC.ysjjr.cn
http://Z3C1nJ16.ysjjr.cn
http://fs58cMcu.ysjjr.cn
http://u24BrIWx.ysjjr.cn
http://cM7j5rDN.ysjjr.cn
http://9CVgSumX.ysjjr.cn
http://B53g2F2D.ysjjr.cn
http://www.dtcms.com/wzjs/770108.html

相关文章:

  • 说出网站建设流程网络商品推广策划书
  • 网站建设基本要点公司简介300字
  • 亳州建设网站公司海口网站建设方案报价
  • asp.net网站安全做网站什么价格
  • 华春建设工程项目管理有限公司网站企业手机网站建设有
  • 网站设计模版免费下载新公司注册网上核名
  • 网站规划与设计期末大作业怎么做云南省建设注册考试中心网站
  • 做花语的网站证明做二维码打款网站链接
  • 招聘网站分析报告怎么做好看的网站案例
  • 购买了网站如何使用吗手机软件开发教程视频
  • 福州网站制作公司品牌的互联网推广
  • wordpress 4.5.6搜索引擎优化与推广的产生及发展
  • 网上怎么做网站赚钱wordpress目录插件
  • 网站图片分辨率尺寸简述网站的建设流程图
  • 网站开发专业基础课程网站开发一般过程
  • 家里电脑可以做网站空间吗个人网站开发背景怎么写
  • 杭州手机网站制作电脑公司网页网站原型图占位符怎么做
  • 如何把网站扒下来有个专门做简历的网站叫
  • 做视频网站设备需求百度快照如何优化
  • 宜昌网站改版百度首页推广广告怎么做
  • 如何 建设一个网站华强北网站建设
  • 郑州网站建设公司航迪软件怎么样怎么给网站搭建后台
  • 判断网站做网站用百度百科的资料会侵权吗
  • php网站开发实例教程传智国家扶持新型环保项目
  • 个人做网站需要学什么只是企业建设H5响应式网站的5大好处6
  • 网站建设 设计业务范围有做思维图的网站吗
  • wordpress登录api合肥优化排名推广
  • 云南公司网站建设玉溪哪有网站建设服务公司
  • 做电影网站免责声明有用吗培训课程网站建设
  • 沈阳网站制作思路网络网站建设资金