配置环境,将以下行加入 /home/halo/.bashrc 的末尾:
cat >> /home/halo/.bashrc << EOF
export HALO_HOME=/opt/halo/product/dbms/14/
export LD_LIBRARY_PATH=\$HALO_HOME/lib
export PGDATA=/data/halo
export PATH=\$HALO_HOME/bin:\$PATH
EOF
初始化数据目录:
pg_ctl init
输出:
The files belonging to this database system will be owned by user "halo".
This user must also own the server process.
The database cluster will be initialized with locale "en_US.UTF-8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".
Data page checksums are disabled.
fixing permissions on existing directory /data/halo ... ok
creating subdirectories ... ok
selecting dynamic shared memory implementation ... posix
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting default time zone ... Asia/Tokyo
creating configuration files ... ok
running bootstrap script ... ok
performing post-bootstrap initialization ... ok
syncing data to disk ... ok
initdb: warning: enabling "trust" authentication for local connections
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:
/opt/halo/product/dbms/14/bin/pg_ctl -D /data/halo -l logfile start
启动halo数据库:
/opt/halo/product/dbms/14/bin/pg_ctl -D /data/halo -l logfile start
查看版本信息:
$ hsql
psql (1.0.14.10 (231130))
Type "help" for help.
halo0root=# select version();
version
-----------------------------------------------------------------------------------------------------------------------
羲和(Halo) 1.0.14.10 (231130) on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44), 64-bit
(1 row)
创建超级用户:
halo0root=# CREATE USER shawnyan SUPERUSER PASSWORD '1';
CREATE ROLE
使用新用户连接数据库:
$ hsql -Ushawnyan
psql (1.0.14.10 (231130))
Type "help" for help.
halo0root=# \conninfo
You are connected to database "halo0root" as user "shawnyan" via socket in "/tmp" at port "1921".
halo0root=# \l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-----------+-------+----------+-------------+-------------+-------------------
halo0root | halo | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
template0 | halo | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/halo +
| | | | | halo=CTc/halo
template1 | halo | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/halo +
| | | | | halo=CTc/halo
(3 rows)
halo0root=# \du halo
List of roles
Role name | Attributes | Member of
-----------+------------------------------------------------------------+-----------
halo | Superuser, Create role, Create DB, Replication, Bypass RLS | {}