root@highgo:~# systemctl stop ufw.service root@highgo:~# systemctl disable ufw.service Synchronizing state of ufw.service with SysV service script with /lib/systemd/systemd-sysv-install. Executing: /lib/systemd/systemd-sysv-install disable ufw 或者 root@highgo:~# ufw disable Firewall stopped and disabled on system startup
# timedatectl status Local time: Thu 2022-04-28 10:36:41 CST Universal time: Thu 2022-04-28 02:36:41 UTC RTC time: Thu 2022-04-28 02:36:41 Time zone: Asia/Shanghai (CST, +0800) Network time on: no NTP synchronized: yes RTC in local TZ: no
[root@xxdb01 etcd]# initdb -e sm4 -c "echo 12345678" -D /data/highgo/data 属于此数据库系统的文件宿主为用户 "root". 此用户也必须为服务器进程的宿主. 数据库簇将使用本地化语言 "zh_CN.UTF-8"进行初始化. 默认的数据库编码已经相应的设置为 "UTF8". initdb: could not find suitable text search configuration for locale "zh_CN.UTF-8" 缺省的文本搜索配置将会被设置到"simple" 禁止为数据页生成校验和. Data encryption using sm4 is enabled. Enter new sysdba password: 再输入一遍:
Enter new syssao password: 再输入一遍:
Enter new syssso password: 再输入一遍:
创建目录 /data/highgo/data... 成功 正在创建子目录 ... 成功 选择动态共享内存实现 ......posix 选择默认最大联接数 (max_connections) ... 100 选择默认共享缓冲区大小 (shared_buffers) ... 128MB selecting default time zone ... Asia/Shanghai 创建配置文件 ... 成功 正在运行自举脚本 ...2023-02-11 22:35:08.384 CST [9888] 日志: Switchover the SSHA Role. Current is NONE 成功 正在执行自举后初始化 ...2023-02-11 22:35:08.592 CST [9891] 日志: data encryption performed by sm4 2023-02-11 22:35:08.594 CST [9891] 日志: Switchover the SSHA Role. Current is NONE 成功 同步数据到磁盘...成功
initdb: 警告: enabling "sm3" authentication for local connections 你可以通过编辑 pg_hba.conf 更改或你下次 执行 initdb 时使用 -A或者--auth-local和--auth-host选项.
Success. You can now start the database server using:
[root@xxdb01 opt]# hg_sslkeygen.sh /data/highgo/data Setting the ssl configuration to /data/highgo/data Generating RSA private key, 2048 bit long modulus .......................................................................+++ ..........+++ e is 65537 (0x10001)
highgo=> select set_secure_param('hg_idcheck.pwdvaliduntil','0'); set_secure_param --------------------------------- set configuration successfully. (1 行记录) highgo=# alter user sysdba password 'Hello****'; ALTER ROLE highgo=# \c - syssao highgo=> alter user syssao password 'Hello****'; ALTER ROLE highgo=# \c - syssso highgo=> alter user syssso password 'Hello****'; ALTER ROLE 【hg_idcheck.pwdvaliduntil参数设置密码有效期;取值范围为0-365,设置为0表示不限制天数。修改此参数后,需重新设置用户密码才能生效。】
配置hba文件
vi $PGDATA/pg_hba.conf 添加以下内容: host all all 0.0.0.0/0 sm3
[root@node1 tmp]# psql -U syssso -d highgo psql (4.5.8) Type "help" for help. highgo=> select set_secure_param('hg_sepofpowers','off'); set_secure_param --------------------------------- set configuration successfully. (1 row)
highgo=> \c highgo syssao You are now connected to database "highgo" as user "syssao". highgo=> select set_audit_param('hg_audit','off'); set_audit_param --------------------------------- set configuration successfully. (1 row)
highgo=> \q [root@node1 tmp]# pg_ctl restart
3.3 创建postgis扩展
[root@node1 tmp]# psql -U sysdba -d highgo psql (4.5.8) Type "help" for help.
highgo=# create extension postgis; CREATE EXTENSION highgo=# \dx List of installed extensions Name | Version | Schema | Description --------------------+----------+--------------------+----------------------------------------------------------------------------------------------- hg_mac | 1.0 | information_schema | hgdb mandatory access control without using selinux hg_permission | 1.0 | information_schema | hg permission mysqlface | 1.0 | public | administrative functions for PostgreSQL orafce | 3.9 | public | Functions and operators that emulate a subset of functions and packages from the Oracle RDBMS passwordcheck | 1.0 | information_schema | passwordcheck pg_buffercache | 1.3 | public | examine the shared buffer cache pg_stat_statements | 1.7 | public | track execution statistics of all SQL statements executed plpgsql | 1.0 | pg_catalog | PL/pgSQL procedural language postgis | 3.1.0dev | public | PostGIS geometry and geography spatial types and functions zhfts | 1.1 | public | RUM index access method (10 rows)
3.4 打开三权和审计
[root@node1 ~]# psql -U syssso -d highgo psql (4.5.8) Type "help" for help.
highgo=> select set_secure_param('hg_sepofpowers','on'); set_secure_param --------------------------------- set configuration successfully. (1 row) highgo=> \c highgo syssao You are now connected to database "highgo" as user "syssao". highgo=> select set_audit_param('hg_audit','on'); set_audit_param --------------------------------- set configuration successfully. (1 row) highgo=> \q [root@node1 ~]# pg_ctl restart
日志: 00000: This is a trial edition, validate until 2023-03-12 16:09:09, database will not be able to start up after that time,please apply an official license by that time.