|||
通过网盘分享的文件:sharkdb17.tar.gz链接: https://pan.baidu.com/s/16YYgQBon_isfwomplA3lLA?pwd=pp1w 提取码: pp1w
yum install -y libicu-develyum install -y cmake gcc gcc-c++ perl readlineyum install -y readline-devel openssl openssl-devel zlib zlib-develyum install -y systemtap systemtap-sdt-devel ncurses-devel
make 版本 3.80以上gcc 版本4.5以上tar gzip bzip 是否安装
进入解压目录:
cd /home/shark/source/sharkdb-17.1编辑SHELL 编译配置选项文件
#make clean #清除编译./configure --prefix=/Program/sharkdb17/db_soft --enable-dtrace --with-openssl CFLAGS="-g3 -std=c11 -Wno-declaration-after-statement" --enable-cassert#make -j4 #4个并发编译#make install #安装
解释:
#make clean #清除编译./configure --prefix=/Program/sharkdb17/db_soft \ #安装目录--enable-dtrace \ #启用动态跟踪--with-openssl \ #SSL支持--enable-debug CFLAGS="-g3 -std=c11" \ #启用DEBUG 并DEBUG 3级 C11标准--enable-cassert #启用断言-Wno-declaration-after-statement #忽悠定义在后#make -j4 #4个并发编译#make install #安装
编译:
make编译运行过程中的最终命令
gcc -Wall -Wmissing-prototypes -Wpointer-arith-Wdeclaration-after-statement -Werror=vla -Wendif-labels-Wmissing-format-attribute -Wformat-security-fno-strict-aliasing -fwrapv -fexcess-precision=standard-g3 -std=c11 isolation_main.o pg_regress.o-L../../../src/interfaces/libpq-lpq -L../../../src/port -L../../../src/common-Wl,--as-needed -Wl,-rpath,'/Program/sharkdb17/db_soft/lib',--enable-new-dtags-lpgcommon -lpgport -lssl -lcrypto -lz-lreadline -lpthread -lrt -ldl -lm-o pg_isolation_regress
创建目录
mkdir /Program/sharkdb17/db_softmkdir /Program/sharkdb17/db_data
用户环境:
export PGHOME=/Program/sharkdb17export PGBIN=$PGHOME/db_softexport PGDATA=$PGHOME/db_dataexport PATH=$PGBIN/bin:$PATHexport MANPATH=$PGBIN/share/man:$MANPATHexport LANG="zh_CN.utf8"export DATE='date +"%Y%m%d%H%M"'export LD_LIBRARY_PATH=$PGBIN/lib:$LD_LIBRARY_PATHexport LC_ALL=zh_CN.utf8alias stop_pg='pg_ctl -D $PGDATA -m fast stop'alias start_pg='pg_ctl -D $PGDATA -s -l $PGDATA/pg_logfile start'alias reload_pg='pg_ctl reload -D $PGDATA'
安装
make install
initdb -D $PGDATA --encoding=UTF8 --locale=zh_CN.UTF-8 --lc-collate=zh_CN.utf8 --lc-ctype=zh_CN.utf8The files belonging to this database system will be owned by user "shark".This user must also own the server process.The database cluster will be initialized with this locale configuration:locale provider: libcLC_COLLATE: zh_CN.utf8LC_CTYPE: zh_CN.utf8LC_MESSAGES: zh_CN.UTF-8LC_MONETARY: zh_CN.UTF-8LC_NUMERIC: zh_CN.UTF-8LC_TIME: zh_CN.UTF-8initdb: could not find suitable text search configuration for locale "zh_CN.utf8"The default text search configuration will be set to "simple".Data page checksums are disabled.fixing permissions on existing directory /Program/sharkdb17/db_data ... okcreating subdirectories ... okselecting dynamic shared memory implementation ... posixselecting default "max_connections" ... 100selecting default "shared_buffers" ... 128MBselecting default time zone ... PRCcreating configuration files ... okrunning bootstrap script ... okperforming post-bootstrap initialization ... oksyncing data to disk ... okinitdb: warning: enabling "trust" authentication for local connectionsinitdb: 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:pg_ctl -D /Program/sharkdb17/db_data -l logfile start
[shark@sharkdb=>~]$start_pg[shark@sharkdb=>~]$ps -ef |grep SharkDBshark 3310 1 0 22:45 ? 00:00:00 /Program/sharkdb17/db_soft/bin/SharkDB -D /Program/pg17/pg_datashark 3311 3310 0 22:45 ? 00:00:00 SharkDB:checkpointershark 3312 3310 0 22:45 ? 00:00:00 SharkDB:background writershark 3314 3310 0 22:45 ? 00:00:00 SharkDB:walwritershark 3315 3310 0 22:45 ? 00:00:00 SharkDB:autovacuum launchershark 3316 3310 0 22:45 ? 00:00:00 SharkDB:logical replication launchershark 3336 3254 0 22:47 pts/0 00:00:00 grep --color SharkDB
[shark@sharkdb=>~]$pgsql -d template1pgsql (17.1)Type "help" for help.SHARKSQL>
注意是PGSQL这个客户端命令,不是PG原来的PSQL
SHARKSQL> show databasesList of databases+-----------+-------+----------+-----------------+------------+------------+--------+-----------+-------------------+| Name | Owner | Encoding | Locale Provider | Collate | Ctype | Locale | ICU Rules | Access privileges |+-----------+-------+----------+-----------------+------------+------------+--------+-----------+-------------------+| postgres | shark | UTF8 | libc | zh_CN.utf8 | zh_CN.utf8 | | | || template0 | shark | UTF8 | libc | zh_CN.utf8 | zh_CN.utf8 | | | =c/shark +|| | | | | | | | | shark=CTc/shark || template1 | shark | UTF8 | libc | zh_CN.utf8 | zh_CN.utf8 | | | =c/shark +|| | | | | | | | | shark=CTc/shark |+-----------+-------+----------+-----------------+------------+------------+--------+-----------+-------------------+(3 rows)
创建和授权
SHARKSQL> create database testdb;CREATE DATABASETime: 445.214 ms
SHARKSQL> grant all on testdb to shark;ERROR: relation "testdb" does not existTime: 0.918 ms
SHARKSQL> use testdbcommand:testdbYou are now connected to database "testdb" as user "shark".SHARKSQL> create table mytable (id serial primary key, name varchar(50) not null);CREATE TABLETime: 68.394 ms
SHARKSQL> desc mytableTable "public.mytable"+--------+-----------------------+-----------+----------+-------------------------------------+| Column | Type | Collation | Nullable | Default |+--------+-----------------------+-----------+----------+-------------------------------------+| id | integer | | not null | nextval('mytable_id_seq'::regclass) || name | character varying(50) | | not null | |+--------+-----------------------+-----------+----------+-------------------------------------+Indexes:"mytable_pkey" PRIMARY KEY, btree (id)
SHARKSQL> CREATE INDEX idx_name ON mytable (NAME);CREATE INDEXTime: 8.142 ms
SHARKSQL> insert into mytable(name) values('张蛋蛋');INSERT 0 1Time: 18.856 ms
SHARKSQL> select * from mytable;+----+--------+| id | name |+----+--------+| 1 | 张蛋蛋 |+----+--------+(1 row)Time: 2.072 ms
SHARKSQL> select version();+-----------------------------------------------------------------------------+| version |+-----------------------------------------------------------------------------+| SharkDB 17.1 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 5.5.0, 64-bit |+-----------------------------------------------------------------------------+(1 row)Time: 4.217 ms
[shark@sharkdb=>~]$cd $PGDATA[shark@sharkdb=>pg_data]$ll总用量 68Kdrwx------ 2 1000 1000 6 2024-12-08 01:25:47 shark_twophasedrwx------ 2 1000 1000 6 2024-12-08 01:25:47 shark_tblspcdrwx------ 2 1000 1000 6 2024-12-08 01:25:47 shark_stat_tmpdrwx------ 2 1000 1000 6 2024-12-08 01:25:47 shark_snapshotsdrwx------ 2 1000 1000 6 2024-12-08 01:25:47 shark_serialdrwx------ 2 1000 1000 6 2024-12-08 01:25:47 shark_replslotdrwx------ 2 1000 1000 6 2024-12-08 01:25:47 shark_notifydrwx------ 4 1000 1000 34 2024-12-08 01:25:47 shark_multixactdrwx------ 2 1000 1000 6 2024-12-08 01:25:47 shark_dynshmem-rw------- 1 1000 1000 3 2024-12-08 01:25:47 SHARKDB_VERSIONdrwx------ 2 1000 1000 6 2024-12-08 01:25:47 shark_commit_ts-rw------- 1 1000 1000 88 2024-12-08 01:25:48 SharkDB.auto.conf-rw------- 1 1000 1000 30K 2024-12-08 01:25:48 postgresql.conf-rw------- 1 1000 1000 5.6K 2024-12-08 01:25:48 pg_hba.conf-rw------- 1 1000 1000 2.6K 2024-12-08 01:25:48 pg_ident.confdrwx------ 2 1000 1000 17 2024-12-08 01:25:48 shark_xactdrwx------ 2 1000 1000 17 2024-12-08 01:25:48 shark_subtransdrwx------ 4 1000 1000 74 2024-12-08 01:25:48 shark_redo-rw------- 1 1000 1000 63 2024-12-09 22:45:30 postmaster.optsdrwx------ 2 1000 1000 6 2024-12-09 22:45:30 shark_stat-rw------- 1 1000 1000 87 2024-12-09 22:45:30 postmaster.piddrwx------ 6 1000 1000 42 2024-12-09 22:52:50 basedrwx------ 2 1000 1000 4.0K 2024-12-09 22:55:16 globaldrwx------ 4 1000 1000 65 2024-12-09 23:05:30 shark_logical-rw------- 1 1000 1000 4.0K 2024-12-09 23:05:31 pg_logfile
[shark@sharkdb=>pg_data]$vim pg_hba.conf添加一条规则:192.168.2.0/24 trust
# TYPE DATABASE USER ADDRESS METHOD# "local" is for Unix domain socket connections onlylocal all all trust# IPv4 local connections:host all all 127.0.0.1/32 trusthost all all 192.168.2.0/24 trust
#------------------------------------------------------------------------------# CONNECTIONS AND AUTHENTICATION#------------------------------------------------------------------------------# - Connection Settings -listen_addresses = '*' # what IP address(es) to listen on;# comma-separated list of addresses;# defaults to 'localhost'; use '*' for all# (change requires restart)port = 5432 # (change requires restart)max_connections = 1000 # (change requires restart)
监听改成星号,端口5432,最大链接改成1000
[shark@sharkdb=>pg_data]$stop_pgwaiting for server to shut down.... doneserver stopped[shark@sharkdb=>pg_data]$start_pg[shark@sharkdb=>pg_data]$pgsql -h 192.168.2.178 -p 5432 -U shark -d testdbpgsql (17.1)Type "help" for help.SHARKSQL>
由于PG各个版本的每个进程,也就是每个功能模块都是独立的,里面每次都要用字符串检查目录是否存在. 所以本架构师统一了下 shark_dir.h
目前只测试了主程序,初始化程序,启动控制程序.其它功能没有测试.如果遇到了对应的关于目录和主进程名报错,欢迎留言告之
分享源码: 主要考虑白嫖了人家美国PG组织开源代码,不好意思!
也算是本人对PG代码的贡献.至于美国PG组织收不收,那不是本人的事!
合作电话:010-64087828
社区邮箱:greatsql@greatdb.com


