enmotech / enmotech-docker-opengauss

Ennotech openGauss Docker Image
GNU General Public License v3.0
46 stars 26 forks source link

Cannot connect outside of docker #24

Closed zouyonghao closed 2 years ago

zouyonghao commented 2 years ago

I try to connect outside of docker, but it report:

error: server closed the connection unexpectedly
        This probably means the server terminated abnormally
        before or while processing the request.
kamusis commented 2 years ago

Please mention all the operations you have done, like the docker run command, and docker ps, etc

zouyonghao commented 2 years ago

I just use the command from the tutorials

docker run --name opengauss --privileged=true -d -e GS_PASSWORD=Secretpassword@123 -p 15432:5432 enmotech/opengauss:latest
[root@localhost ~]# docker ps
CONTAINER ID        IMAGE                       COMMAND                  CREATED             STATUS              PORTS                     NAMES
0bd736cb2040        enmotech/opengauss:latest   "entrypoint.sh gauss…"   17 minutes ago      Up 17 minutes       0.0.0.0:15432->5432/tcp   opengauss

[omm@localhost ~]$ gsql -d postgres -U gaussdb -W'Secretpassword@123' -h 127.0.0.1 -p15432
failed to connect 127.0.0.1:15432.
zouyonghao commented 2 years ago

Logs from docker

[root@localhost ~]# docker logs -f opengauss

                        Message: The supplied GS_PASSWORD is meet requirements.

The files belonging to this database system will be owned by user "omm".
This user must also own the server process.

The database cluster will be initialized with locale "en_US.UTF-8".
The default text search configuration will be set to "english".

fixing permissions on existing directory /var/lib/opengauss/data ... ok
creating subdirectories ... ok
selecting default max_connections ... 100
selecting default shared_buffers ... 32MB
creating configuration files ... ok
Begin init undo subsystem meta.
[INIT UNDO] Init undo subsystem meta successfully.
creating template1 database in /var/lib/opengauss/data/base/1 ... The core dump path is an invalid directory
2022-08-23 16:03:50.076 [unknown] [unknown] localhost 140430116162624 0[0:0#0]  [BACKEND] WARNING:  macAddr is 578/2886795266, sysidentifier is 37923857/166413, randomNum is 2265025037
ok
initializing pg_authid ... ok
setting password ... ok
initializing dependencies ... ok
loading PL/pgSQL server-side language ... ok
creating system views ... ok
creating performance views ... ok
loading system objects' descriptions ... ok
creating collations ... ok
creating conversions ... ok
creating dictionaries ... ok
setting privileges on built-in objects ... ok
initialize global configure for bucketmap length ... ok
creating information schema ... ok
loading foreign-data wrapper for distfs access ... ok
loading foreign-data wrapper for hdfs access ... ok
loading foreign-data wrapper for log access ... ok
loading hstore extension ... ok
loading foreign-data wrapper for MOT access ... ok
loading security plugin ... ok
update system tables ... ok
creating snapshots catalog ... ok
vacuuming database template1 ... ok
copying template1 to template0 ... ok
copying template1 to postgres ... ok
freezing database template0 ... ok
freezing database template1 ... ok
freezing database postgres ... ok

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

Success. You can now start the database server of single node using:

    gaussdb -D /var/lib/opengauss/data --single_node
or
    gs_ctl start -D /var/lib/opengauss/data -Z single_node -l logfile

[2022-08-23 16:04:10.181][183][][gs_ctl]: gs_ctl started,datadir is /var/lib/opengauss/data
[2022-08-23 16:04:10.397][183][][gs_ctl]: waiting for server to start...
.0 LOG:  [Alarm Module]can not read GAUSS_WARNING_TYPE env.

0 LOG:  [Alarm Module]Host Name: 0bd736cb2040

0 LOG:  [Alarm Module]Host IP: 172.17.0.2

0 LOG:  [Alarm Module]Get ENV GS_CLUSTER_NAME failed!

0 LOG:  [Alarm Module]Invalid data in AlarmItem file! Read alarm English name failed! line: 57

0 WARNING:  failed to open feature control file, please check whether it exists: FileName=gaussdb.version, Errno=2, Errmessage=No such file or directory.
0 WARNING:  failed to parse feature control file: gaussdb.version.
0 WARNING:  Failed to load the product control file, so gaussdb cannot distinguish product version.
The core dump path is an invalid directory
2022-08-23 16:04:10.681 [unknown] [unknown] localhost 140330134125632 0[0:0#0]  0 [BACKEND] LOG:  when starting as multi_standby mode, we couldn't support data replicaton.
gaussdb.state does not exist, and skipt setting since it is optional.2022-08-23 16:04:10.706 [unknown] [unknown] localhost 140330134125632 0[0:0#0]  0 [BACKEND] LOG:  [Alarm Module]can not read GAUSS_WARNING_TYPE env.

2022-08-23 16:04:10.706 [unknown] [unknown] localhost 140330134125632 0[0:0#0]  0 [BACKEND] LOG:  [Alarm Module]Host Name: 0bd736cb2040

2022-08-23 16:04:10.706 [unknown] [unknown] localhost 140330134125632 0[0:0#0]  0 [BACKEND] LOG:  [Alarm Module]Host IP: 172.17.0.2

2022-08-23 16:04:10.706 [unknown] [unknown] localhost 140330134125632 0[0:0#0]  0 [BACKEND] LOG:  [Alarm Module]Get ENV GS_CLUSTER_NAME failed!

2022-08-23 16:04:10.706 [unknown] [unknown] localhost 140330134125632 0[0:0#0]  0 [BACKEND] LOG:  [Alarm Module]Invalid data in AlarmItem file! Read alarm English name failed! line: 57

2022-08-23 16:04:10.724 [unknown] [unknown] localhost 140330134125632 0[0:0#0]  0 [BACKEND] LOG:  loaded library "security_plugin"
2022-08-23 16:04:10.724 [unknown] [unknown] localhost 140330134125632 0[0:0#0]  0 [BACKEND] WARNING:  could not create any HA TCP/IP sockets
2022-08-23 16:04:10.724 [unknown] [unknown] localhost 140330134125632 0[0:0#0]  0 [BACKEND] WARNING:  could not create any HA TCP/IP sockets
2022-08-23 16:04:10.745 [unknown] [unknown] localhost 140330134125632 0[0:0#0]  0 [BACKEND] WARNING:  No explicit IP is configured for listen_addresses GUC.
2022-08-23 16:04:10.746 [unknown] [unknown] localhost 140330134125632 0[0:0#0]  0 [BACKEND] LOG:  InitNuma numaNodeNum: 1 numa_distribute_mode: none inheritThreadPool: 0.
2022-08-23 16:04:10.746 [unknown] [unknown] localhost 140330134125632 0[0:0#0]  0 [BACKEND] LOG:  reserved memory for backend threads is: 220 MB
2022-08-23 16:04:10.746 [unknown] [unknown] localhost 140330134125632 0[0:0#0]  0 [BACKEND] LOG:  reserved memory for WAL buffers is: 128 MB
2022-08-23 16:04:10.746 [unknown] [unknown] localhost 140330134125632 0[0:0#0]  0 [BACKEND] LOG:  Set max backend reserve memory is: 348 MB, max dynamic memory is: 11065 MB
2022-08-23 16:04:10.746 [unknown] [unknown] localhost 140330134125632 0[0:0#0]  0 [BACKEND] LOG:  shared memory 362 Mbytes, memory context 11413 Mbytes, max process memory 12288 Mbytes
2022-08-23 16:04:10.798 [unknown] [unknown] localhost 140330134125632 0[0:0#0]  0 [CACHE] LOG:  set data cache  size(402653184)
2022-08-23 16:04:10.816 [unknown] [unknown] localhost 140330134125632 0[0:0#0]  0 [CACHE] LOG:  set metadata cache  size(134217728)
2022-08-23 16:04:10.880 [unknown] [unknown] localhost 140330134125632 0[0:0#0]  0 [SEGMENT_PAGE] LOG:  Segment-page constants: DF_MAP_SIZE: 8156, DF_MAP_BIT_CNT: 65248, DF_MAP_GROUP_EXTENTS: 4175872, IPBLOCK_SIZE: 8168, EXTENTS_PER_IPBLOCK: 1021, IPBLOCK_GROUP_SIZE: 4090, BMT_HEADER_LEVEL0_TOTAL_PAGES: 8323072, BktMapEntryNumberPerBlock: 2038, BktMapBlockNumber: 25, BktBitMaxMapCnt: 512
2022-08-23 16:04:10.918 [unknown] [unknown] localhost 140330134125632 0[0:0#0]  0 [BACKEND] LOG:  gaussdb: fsync file "/var/lib/opengauss/data/gaussdb.state.temp" success
2022-08-23 16:04:10.918 [unknown] [unknown] localhost 140330134125632 0[0:0#0]  0 [BACKEND] LOG:  create gaussdb state file success: db state(STARTING_STATE), server mode(Normal), connection index(1)
2022-08-23 16:04:10.969 [unknown] [unknown] localhost 140330134125632 0[0:0#0]  0 [BACKEND] LOG:  max_safe_fds = 983, usable_fds = 1000, already_open = 7
The core dump path is an invalid directory
2022-08-23 16:04:10.973 [unknown] [unknown] localhost 140330134125632 0[0:0#0]  0 [BACKEND] LOG:  user configure file is not found, it will be created.
2022-08-23 16:04:10.981 [unknown] [unknown] localhost 140330134125632 0[0:0#0]  0 [BACKEND] LOG:  the configure file /usr/local/opengauss/etc/gscgroup_omm.cfg doesn't exist or the size of configure file has changed. Please create it by root user!
2022-08-23 16:04:10.981 [unknown] [unknown] localhost 140330134125632 0[0:0#0]  0 [BACKEND] LOG:  Failed to parse cgroup config file.
2022-08-23 16:04:11.050 [unknown] [unknown] localhost 140330134125632 0[0:0#0]  0 [EXECUTOR] WARNING:  Failed to obtain environment value $GAUSSLOG!
2022-08-23 16:04:11.050 [unknown] [unknown] localhost 140330134125632 0[0:0#0]  0 [EXECUTOR] DETAIL:  N/A
2022-08-23 16:04:11.050 [unknown] [unknown] localhost 140330134125632 0[0:0#0]  0 [EXECUTOR] CAUSE:  Incorrect environment value.
2022-08-23 16:04:11.050 [unknown] [unknown] localhost 140330134125632 0[0:0#0]  0 [EXECUTOR] ACTION:  Please refer to backend log for more details.
2022-08-23 16:04:11.052 [unknown] [unknown] localhost 140330134125632 0[0:0#0]  0 [EXECUTOR] WARNING:  Failed to obtain environment value $GAUSSLOG!
2022-08-23 16:04:11.052 [unknown] [unknown] localhost 140330134125632 0[0:0#0]  0 [EXECUTOR] DETAIL:  N/A
2022-08-23 16:04:11.052 [unknown] [unknown] localhost 140330134125632 0[0:0#0]  0 [EXECUTOR] CAUSE:  Incorrect environment value.
2022-08-23 16:04:11.052 [unknown] [unknown] localhost 140330134125632 0[0:0#0]  0 [EXECUTOR] ACTION:  Please refer to backend log for more details.
.
[2022-08-23 16:04:12.422][183][][gs_ctl]:  done
[2022-08-23 16:04:12.422][183][][gs_ctl]: server started (/var/lib/opengauss/data)
GS_DB = omm
Execute SQL: gsql -v ON_ERROR_STOP=1 --username omm --password Secretpassword@123 --dbname postgres --set db=omm --set passwd=Secretpassword@123
CREATE DATABASE
CREATE ROLE
ALTER ROLE

 default user is gaussdb
 default no repuser created

/usr/local/bin/entrypoint.sh: ignoring /docker-entrypoint-initdb.d/*

[2022-08-23 16:04:18.110][253][][gs_ctl]: gs_ctl stopped ,datadir is /var/lib/opengauss/data
waiting for server to shut down............. done
server stopped

openGauss  init process complete; ready for start up.

0 LOG:  [Alarm Module]can not read GAUSS_WARNING_TYPE env.

0 LOG:  [Alarm Module]Host Name: 0bd736cb2040

0 LOG:  [Alarm Module]Host IP: 172.17.0.2

0 LOG:  [Alarm Module]Get ENV GS_CLUSTER_NAME failed!

0 LOG:  [Alarm Module]Invalid data in AlarmItem file! Read alarm English name failed! line: 57

0 WARNING:  failed to open feature control file, please check whether it exists: FileName=gaussdb.version, Errno=2, Errmessage=No such file or directory.
0 WARNING:  failed to parse feature control file: gaussdb.version.
0 WARNING:  Failed to load the product control file, so gaussdb cannot distinguish product version.
The core dump path is an invalid directory
2022-08-23 16:04:28.988 [unknown] [unknown] localhost 140251376278592 0[0:0#0]  0 [BACKEND] LOG:  when starting as multi_standby mode, we couldn't support data replicaton.
2022-08-23 16:04:29.009 [unknown] [unknown] localhost 140251376278592 0[0:0#0]  0 [BACKEND] LOG:  [Alarm Module]can not read GAUSS_WARNING_TYPE env.

2022-08-23 16:04:29.009 [unknown] [unknown] localhost 140251376278592 0[0:0#0]  0 [BACKEND] LOG:  [Alarm Module]Host Name: 0bd736cb2040

2022-08-23 16:04:29.010 [unknown] [unknown] localhost 140251376278592 0[0:0#0]  0 [BACKEND] LOG:  [Alarm Module]Host IP: 172.17.0.2

2022-08-23 16:04:29.010 [unknown] [unknown] localhost 140251376278592 0[0:0#0]  0 [BACKEND] LOG:  [Alarm Module]Get ENV GS_CLUSTER_NAME failed!

2022-08-23 16:04:29.010 [unknown] [unknown] localhost 140251376278592 0[0:0#0]  0 [BACKEND] LOG:  [Alarm Module]Invalid data in AlarmItem file! Read alarm English name failed! line: 57

2022-08-23 16:04:29.022 [unknown] [unknown] localhost 140251376278592 0[0:0#0]  0 [BACKEND] LOG:  loaded library "security_plugin"
2022-08-23 16:04:29.022 [unknown] [unknown] localhost 140251376278592 0[0:0#0]  0 [BACKEND] WARNING:  could not create any HA TCP/IP sockets
2022-08-23 16:04:29.022 [unknown] [unknown] localhost 140251376278592 0[0:0#0]  0 [BACKEND] WARNING:  could not create any HA TCP/IP sockets
2022-08-23 16:04:29.047 [unknown] [unknown] localhost 140251376278592 0[0:0#0]  0 [BACKEND] WARNING:  No explicit IP is configured for listen_addresses GUC.
2022-08-23 16:04:29.047 [unknown] [unknown] localhost 140251376278592 0[0:0#0]  0 [BACKEND] LOG:  InitNuma numaNodeNum: 1 numa_distribute_mode: none inheritThreadPool: 0.
2022-08-23 16:04:29.047 [unknown] [unknown] localhost 140251376278592 0[0:0#0]  0 [BACKEND] LOG:  reserved memory for backend threads is: 220 MB
2022-08-23 16:04:29.047 [unknown] [unknown] localhost 140251376278592 0[0:0#0]  0 [BACKEND] LOG:  reserved memory for WAL buffers is: 128 MB
2022-08-23 16:04:29.047 [unknown] [unknown] localhost 140251376278592 0[0:0#0]  0 [BACKEND] LOG:  Set max backend reserve memory is: 348 MB, max dynamic memory is: 11065 MB
2022-08-23 16:04:29.047 [unknown] [unknown] localhost 140251376278592 0[0:0#0]  0 [BACKEND] LOG:  shared memory 362 Mbytes, memory context 11413 Mbytes, max process memory 12288 Mbytes
2022-08-23 16:04:29.082 [unknown] [unknown] localhost 140251376278592 0[0:0#0]  0 [CACHE] LOG:  set data cache  size(402653184)
2022-08-23 16:04:29.092 [unknown] [unknown] localhost 140251376278592 0[0:0#0]  0 [CACHE] LOG:  set metadata cache  size(134217728)
2022-08-23 16:04:29.140 [unknown] [unknown] localhost 140251376278592 0[0:0#0]  0 [SEGMENT_PAGE] LOG:  Segment-page constants: DF_MAP_SIZE: 8156, DF_MAP_BIT_CNT: 65248, DF_MAP_GROUP_EXTENTS: 4175872, IPBLOCK_SIZE: 8168, EXTENTS_PER_IPBLOCK: 1021, IPBLOCK_GROUP_SIZE: 4090, BMT_HEADER_LEVEL0_TOTAL_PAGES: 8323072, BktMapEntryNumberPerBlock: 2038, BktMapBlockNumber: 25, BktBitMaxMapCnt: 512
2022-08-23 16:04:29.165 [unknown] [unknown] localhost 140251376278592 0[0:0#0]  0 [BACKEND] LOG:  gaussdb: fsync file "/var/lib/opengauss/data/gaussdb.state.temp" success
2022-08-23 16:04:29.166 [unknown] [unknown] localhost 140251376278592 0[0:0#0]  0 [BACKEND] LOG:  create gaussdb state file success: db state(STARTING_STATE), server mode(Normal), connection index(1)
2022-08-23 16:04:29.177 [unknown] [unknown] localhost 140251376278592 0[0:0#0]  0 [BACKEND] LOG:  max_safe_fds = 982, usable_fds = 1000, already_open = 8
The core dump path is an invalid directory
2022-08-23 16:04:29.181 [unknown] [unknown] localhost 140251376278592 0[0:0#0]  0 [BACKEND] LOG:  the configure file /usr/local/opengauss/etc/gscgroup_omm.cfg doesn't exist or the size of configure file has changed. Please create it by root user!
2022-08-23 16:04:29.181 [unknown] [unknown] localhost 140251376278592 0[0:0#0]  0 [BACKEND] LOG:  Failed to parse cgroup config file.
2022-08-23 16:04:29.200 [unknown] [unknown] localhost 140251376278592 0[0:0#0]  0 [EXECUTOR] WARNING:  Failed to obtain environment value $GAUSSLOG!
2022-08-23 16:04:29.200 [unknown] [unknown] localhost 140251376278592 0[0:0#0]  0 [EXECUTOR] DETAIL:  N/A
2022-08-23 16:04:29.200 [unknown] [unknown] localhost 140251376278592 0[0:0#0]  0 [EXECUTOR] CAUSE:  Incorrect environment value.
2022-08-23 16:04:29.200 [unknown] [unknown] localhost 140251376278592 0[0:0#0]  0 [EXECUTOR] ACTION:  Please refer to backend log for more details.
2022-08-23 16:04:29.201 [unknown] [unknown] localhost 140251376278592 0[0:0#0]  0 [EXECUTOR] WARNING:  Failed to obtain environment value $GAUSSLOG!
2022-08-23 16:04:29.201 [unknown] [unknown] localhost 140251376278592 0[0:0#0]  0 [EXECUTOR] DETAIL:  N/A
2022-08-23 16:04:29.201 [unknown] [unknown] localhost 140251376278592 0[0:0#0]  0 [EXECUTOR] CAUSE:  Incorrect environment value.
2022-08-23 16:04:29.201 [unknown] [unknown] localhost 140251376278592 0[0:0#0]  0 [EXECUTOR] ACTION:  Please refer to backend log for more details.
travelliu commented 2 years ago

In the container, please use the port 5432 in the container, and use the mapped port 15432 in the host @zouyonghao

travelliu commented 2 years ago

@zouyonghao echo "listen_addresses = '*'" >> /var/lib/opengauss/data/postgresql.conf

and reboot container

zouyonghao commented 2 years ago

I can connect to it after changing some settings according to this post.

kamusis commented 2 years ago

@zouyonghao actually, there is a little issue in the latest version openGauss docker images building process, we have re-build the images, if you like you can re-pull the image, now should has no problem to connect container database instance from hosting machine (outside of docker).

#  docker run --name opengauss --privileged=true -d -e GS_PASSWORD=Secretpassword@123 -p 25432:5432 enmotech/opengauss:latest
Unable to find image 'enmotech/opengauss:latest' locally
latest: Pulling from enmotech/opengauss
22c5ef60a68e: Pull complete
28692a7bf40a: Pull complete
53d8b65999fe: Pull complete
2feb7fb751a7: Pull complete
21970696c490: Pull complete
Digest: sha256:b8a21dfa15d57476528051f1b8b138dac45cfbad3ef97cba2b340433476147f8
Status: Downloaded newer image for enmotech/opengauss:latest
74b80b59d1e9fac54f1a3eb1b347f387f5718c7051c8d0258fd947ee7d326610

-- here you should wait for a little while (serveral seconds), letting the initdb process finished, when initdb is doing his work, can't connect to the instance.
$ gsql -d postgres -U gaussdb -W'Secretpassword@123' -h 127.0.0.1 -p 25432
failed to connect 127.0.0.1:25432.

-- after several seconds, can connect to docker database without any manually modification.
$ gsql -d postgres -U gaussdb -W'Secretpassword@123' -h 127.0.0.1 -p 25432
gsql ((MogDB 3.0.0 build 8ca3fdcc) compiled at 2022-06-21 23:50:02 commit 0 last mr  )
Non-SSL connection (SSL connection is recommended when requiring high-security)
Type "help" for help.

MogDB=> select version();
                                                                       version
------------------------------------------------------------------------------------------------------------------------------------------------------
 (openGauss 3.0.0 build 02c14696) compiled at 2022-04-01 18:12:34 commit 0 last mr   on x86_64-unknown-linux-gnu, compiled by g++ (GCC) 7.3.0, 64-bit
(1 row)

Thanks for your comments and have a good day.

zouyonghao commented 2 years ago

Thanks @kamusis

kongdingchao commented 4 months ago

Using the latest version but still reporting errors docker run --name opengauss --privileged=true -d -e GS_PASSWORD=Secretpassword@123 -p 25432:5432 enmotech/opengauss:latest image

kamusis commented 4 months ago

@kongdingchao openGauss version 5.0 and later has issues running containers on macOS or Windows. We have provided some clarifications on the README page on Docker Hub. If you are attempting to run a container of openGauss version 5.0 or later on macOS or Windows, you should use the enmotech/opengauss-lite⁠ version. This is because since version 5.0, the openGauss EE container cannot start up properly on macOS or Windows. However, there are no issues when running it on Linux.