目前共有3篇帖子。 字體大小:較小 - 100% (默認)▼  內容轉換:马新简体▼
 
點擊 回復
30 2
在幸狐RV1106开发板上用gcc14.2本地编译安装postgresql 17.5数据库
一派掌門 二十級
1樓 發表于:2025-6-30 20:10

在幸狐RV1106开发板上用gcc14.2本地编译安装postgresql 17.5数据库


编译环境:

RV1106G3

Linux luckfox-rv1106 5.10.160 #3 Fri Jun 27 14:16:20 AWST 2025 armv7l GNU/Linux

BusyBox v1.36.1

gcc version 14.2.0 (GCC)

GNU ld (GNU Binutils) 2.44

GNU Make 4.4

ncurses 6.5.20240427(libncursesw.so.6.5)

OpenSSL 1.1.1w  11 Sep 2023


瑞芯微RV1106从SD卡启动自己的busybox1.36.1根文件系统:https://zh.purasbar.com/post.php?t=32786

在fedora42上用arm-gnu-toolchain-14.2交叉编译器编译gcc14.2、gdb14.2和make4.4:https://zh.purasbar.com/post.php?t=32816

在瑞芯微RV1106板子上用gcc14.2本地编译安装apache2.4.63,开启http2和tls1.3,并且https支持XP系统的IE6-8浏览器:https://zh.purasbar.com/post.php?t=32825


工作目录:

mkdir ~/software/postgresql

cd ~/software/postgresql


【编译安装icu4c-77_1】

[方法1: 在板子上本地编译]

wget https://github.com/unicode-org/icu/releases/download/release-77-1/icu4c-77_1-src.tgz --no-check-certificate

tar xf icu4c-77_1-src.tgz

cd icu/source

./configure --with-data-packaging=files

make


批量创建文件夹:

mkdir -p $(find data/out/build -type d | sed "s/data\/out\/build/\/usr\/local\/share\/icu\/77.1/")

注意文件夹名字中的版本号。如果不知道的话,可以先执行make install看看报错信息。


make install

cd ../..


[方法2: 在电脑上交叉编译]

export PATH=$PATH:/home/oct1158/Downloads/arm-gnu-toolchain-14.2.rel1-x86_64-arm-none-linux-gnueabihf/bin

wget https://github.com/unicode-org/icu/releases/download/release-77-1/icu4c-77_1-src.tgz

tar xf icu4c-77_1-src.tgz

cd icu

mkdir _build

cd _build

../source/configure

make


mkdir ../_build2

cd ../_build2

../source/configure --host=arm-none-linux-gnueabihf --with-cross-build=$(pwd)/../_build --with-data-packaging=files

make


修改data/Makefile文件:第172-181行,把每一行的$(ICUPKGDATA_DIR)都改成$(DESTDIR)$(ICUPKGDATA_DIR)。

批量创建文件夹:

mkdir -p $(find data/out/build -type d | sed "s/data\/out\/build/_install\/usr\/local\/share\/icu\/77.1/")

注意文件夹名字中的版本号。如果不知道的话,可以先执行make install DESTDIR=$(pwd)/_install看看报错信息。


make install DESTDIR=$(pwd)/_install

cd _install

sudo chown -R root:root usr

tar czf icu4c-77_1-binary.tar.gz usr

mv icu4c-77_1-binary.tar.gz /var/www/html/oct1158


[测试icu库是否能正常工作(非常重要)]

先运行一下ldconfig。


执行:/usr/local/bin/icuinfo

提示:ICU Initialization returned: U_FILE_ACCESS_ERROR


执行:ICU_DATA=/usr/local/share/icu/77.1 /usr/local/bin/icuinfo

提示:ICU Initialization returned: U_ZERO_ERROR

看到U_ZERO_ERROR就说明正常了。


修改/etc/profile文件:添加export ICU_DATA=/usr/local/share/icu/77.1。

改完后用exit命令退出命令行,再按回车键重新进入命令行。


【编译安装bison-3.8.2】

wget https://ftp.gnu.org/gnu/bison/bison-3.8.2.tar.gz --no-check-certificate

tar xf bison-3.8.2.tar.gz

cd bison-3.8.2

./configure

make

make install

cd ..


【编译安装flex-2.6.4】

wget https://github.com/westes/flex/releases/download/v2.6.4/flex-2.6.4.tar.gz --no-check-certificate

tar xf flex-2.6.4.tar.gz

cd flex-2.6.4

./configure

make

make install

cd ..


【编译安装readline-8.2.13】

wget https://ftp.gnu.org/gnu/readline/readline-8.2.13.tar.gz --no-check-certificate

tar xf readline-8.2.13.tar.gz

cd readline-8.2.13

./configure

make

make install

ldconfig

cd ..


【编译安装postgresql-17.5】

wget https://ftp.postgresql.org/pub/source/v17.5/postgresql-17.5.tar.gz --no-check-certificate

tar xf postgresql-17.5.tar.gz

cd postgresql-17.5

./configure LDFLAGS="-lncursesw"

(如果报Could not execute a simple test program.的错误,说明之前忘记了执行ldconfig。请检查gcc helloworld.c -o helloworld -lreadline -lncursesw编译出来的程序是否能成功执行,helloworld.c里面是空白main函数。)

make

make install

ldconfig

cd ..


【使用postgresql-17.5数据库】

给/dev/urandom添加权限:chmod o+rw /dev/urandom(不添加权限的话会报running bootstrap script ... 2025-06-30 08:31:57.060 UTC [415] PANIC:  could not generate secret authorization token的错误)

给/dev/null添加权限:chmod o+rw /dev/null

添加postgres用户和组:adduser postgres

登录postgres用户:su postgres

初始化数据库:/usr/local/pgsql/bin/initdb -D /home/postgres/data


[root@luckfox-rv1106 /]# ls /home/postgres/

[root@luckfox-rv1106 /]# su postgres

[postgres@luckfox-rv1106 /]$ /usr/local/pgsql/bin/initdb -D /home/postgres/data

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".

The default database encoding has accordingly been set to "SQL_ASCII".

The default text search configuration will be set to "english".


Data page checksums are disabled.


creating directory /home/postgres/data ... ok

creating subdirectories ... ok

selecting dynamic shared memory implementation ... sysv

selecting default "max_connections" ... 100

selecting default "shared_buffers" ... 128MB

selecting default time zone ... UTC

creating configuration files ... ok

running bootstrap script ... ok

performing post-bootstrap initialization ... 2025-06-30 11:32:18.303 UTC [368] WARNING:  no usable system locales were found

ok

syncing data to disk ... ok


initdb: warning: enabling "trust" authentication for local connections

initdb: hint: You 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:


    /usr/local/pgsql/bin/pg_ctl -D /home/postgres/data -l logfile start


[postgres@luckfox-rv1106 /]$ ls ~

data

[postgres@luckfox-rv1106 /]$


如果报下面的错误:

performing post-bootstrap initialization ... 2025-06-30 11:28:10.430 UTC [341] FATAL:  could not open collator for locale "und": U_FILE_ACCESS_ERROR

2025-06-30 11:28:10.430 UTC [341] STATEMENT:  UPDATE pg_collation SET collversion = pg_collation_actual_version(oid) WHERE collname = 'unicode';

要么是编译icu库的时候没带--with-data-packaging=files选项,要么是没有在/etc/profile文件中添加export ICU_DATA=/usr/local/share/icu/77.1环境变量,要么是改了/etc/profile文件但没用exit命令退出命令行再按回车键重新进入命令行。


(postgres用户)启动数据库服务器:/usr/local/pgsql/bin/pg_ctl -D ~/data -l ~/logfile start

(postgres用户)创建mydb数据库:/usr/local/pgsql/bin/createdb mydb

(postgres用户)进入数据库:/usr/local/pgsql/bin/psql

查看数据库列表:\l

选择数据库:\c mydb

创建表:create table test (id serial, title character varying(500), time timestamp default now(), primary key(id));

查看表结构:\d test

插入记录:

insert into test (title) values ('安装黑翼猫扩展内核能使win2000 sp4的ie6浏览器支持sha256签名的https证书'),

('安装微软官方的KB968730补丁能使64位winxp sp2的ie6-8浏览器支持sha256签名的https证书'),

('32位winxp sp3的ie6-8浏览器原生支持sha256签名的https证书'),

('只要采用sha1签名的https证书,2025年的apache2.4.63的https不仅支持xp系统的ie6-8浏览器,还支持原版win2000 sp4系统的ie5-6浏览器'),

('xp系统安装one core api 4.0.1补丁后,可以安装和运行vscode1.70.2,VSCodeUserSetup安装包文件的属性里面的兼容性下拉框要记得选择win7sp1');

查看表数据:select * from test;

退出数据库:\q

(postgres用户)关闭数据库服务器:/usr/local/pgsql/bin/pg_ctl -D ~/data stop


执行/usr/local/pgsql/bin/psql时如果报错:

psql: error: connection to server on socket "/tmp/.s.PGSQL.5432" failed: server closed the connection unexpectedly

        This probably means the server terminated abnormally

        before or while processing the request.

解决办法:在root用户下chmod o+rw /dev/urandom。

建议将chmod o+rw /dev/urandom和chmod o+rw /dev/null添加到开机脚本/etc/init.d/rcS里面。

一派掌門 二十級
2樓 發表于:2025-6-30 20:13
 
一派掌門 二十級
3樓 發表于:2025-7-1 08:14
ICU_DATA=/usr/local/share/icu/77.1 /usr/local/bin/icuinfo 注意这是一行命令,不是两行。
zero error零错误,就是没有错误的意思,在icu库里面用于UErrorCode类型变量的初始值。
 

回復帖子

內容:
用戶名: 您目前是匿名發表
驗證碼:
(快捷鍵:Ctrl+Enter)
 

本帖信息

點擊數:30 回複數:2
評論數: ?
作者:巨大八爪鱼
最後回復:巨大八爪鱼
最後回復時間:2025-7-1 08:14
 
©2010-2025 Purasbar Ver2.0
除非另有聲明,本站採用創用CC姓名標示-相同方式分享 3.0 Unported許可協議進行許可。