@@ -188,170 +188,15 @@ Recommended Steps to Run OpenGauss with Python GaussDB Driver Testing (Assuming
188188
189189Steps to Run OpenGauss(SSL) with Python GaussDB Driver Testing (Assuming Docker is Installed)::
190190
191- # Create certificate directory
192- mkdir -p /opengauss8889/certs
193- cd /opengauss8889/certs
194-
195- # Generate CA certificate
196- openssl genrsa -out ca.key 4096
197- openssl req -x509 -new -nodes -key ca.key -sha256 -days 3650 \
198- -subj "/C=CN/ST=OpenGauss/L=OpenGauss/O=MyOrg/OU=DB/CN=OpenGaussCA" \
199- -out ca.crt
200-
201- # Generate server certificate
202- openssl genrsa -out server.key 2048
203- openssl req -new -key server.key \
204- -subj "/C=CN/ST=OpenGauss/L=OpenGauss/O=MyOrg/OU=DB/CN=opengauss.local" \
205- -out server.csr
206-
207- # SAN config (replace IP/DNS with the address you will use to connect,
208- # for example 127.0.0.1 or the host IP)
209- cat > san.cnf <<EOF
210- [ req ]
211- default_bits = 2048
212- distinguished_name = req_distinguished_name
213- req_extensions = req_ext
214- [ req_distinguished_name ]
215- [ req_ext ]
216- subjectAltName = @alt_names
217- [ alt_names ]
218- DNS.1 = opengauss.local
219- IP.1 = 127.0.0.1
220- EOF
221-
222- # Sign the server certificate with the CA, including SAN
223- openssl x509 -req -in server.csr -CA ca.crt -CAkey ca.key -CAcreateserial \
224- -out server.crt -days 730 -sha256 -extfile san.cnf -extensions req_ext
225-
226- # Optional: client certificate (for mutual TLS)
227- openssl genrsa -out client.key 2048
228- openssl req -new -key client.key -subj "/CN=root" -out client.csr
229- openssl x509 -req -in client.csr -CA ca.crt -CAkey ca.key -CAcreateserial \
230- -out client.crt -days 730 -sha256
231-
232- # Create configuration directory
233- mkdir -p /opengauss8889/conf
234- cat > /opengauss8889/conf/postgresql.conf <<EOF
235- max_connections = 200 # (change requires restart)
236- session_timeout = 10min # allowed duration of any unused session, 0s-86400s(1 day), 0 is disabled
237- bulk_write_ring_size = 2GB # for bulkload, max shared_buffers
238- max_prepared_transactions = 200 # zero disables the feature
239- cstore_buffers = 512MB #min 16MB
240- enable_incremental_checkpoint = on # enable incremental checkpoint
241- incremental_checkpoint_timeout = 60s # range 1s-1h
242- enable_double_write = on # enable double write
243- wal_keep_segments = 16 # in logfile segments, 16MB each normal, 1GB each in share storage mode; 0 disables
244- enable_slot_log = off
245- synchronous_standby_names = '*' # standby servers that provide sync rep
246- walsender_max_send_size = 8MB # Size of walsender max send size
247- hot_standby = on # "on" allows queries during recovery
248- enable_kill_query = off # optional: [on, off], default: off
249- logging_collector = on # Enable capturing of stderr and csvlog
250- log_filename = 'postgresql-%Y-%m-%d_%H%M%S.log' # log file name pattern,
251- log_file_mode = 0600 # creation mode for log files,
252- log_rotation_size = 20MB # Automatic rotation of logfiles will
253- log_min_duration_statement = 1800000 # -1 is disabled, 0 logs all statements
254- log_connections = off # log connection requirement from client
255- log_disconnections = off # log disconnection from client
256- log_duration = off # log the execution time of each query
257- log_hostname = off # log hostname
258- log_line_prefix = '%m %u %d %h %p %S ' # special values:
259- log_timezone = 'UCT'
260- enable_alarm = on
261- connection_alarm_rate = 0.9
262- alarm_report_interval = 10
263- alarm_component = '/opt/snas/bin/snas_cm_cmd'
264- use_workload_manager = on # Enables workload manager in the system.
265- datestyle = 'iso, mdy'
266- timezone = 'UCT'
267- lc_messages = 'en_US.utf8' # locale for system error message
268- lc_monetary = 'en_US.utf8' # locale for monetary formatting
269- lc_numeric = 'en_US.utf8' # locale for number formatting
270- lc_time = 'en_US.utf8' # locale for time formatting
271- default_text_search_config = 'pg_catalog.english'
272- lockwait_timeout = 1200s # Max of lockwait_timeout and deadlock_timeout +1s
273- pgxc_node_name = 'gaussdb' # Coordinator or Datanode name
274- audit_enabled = on
275- job_queue_processes = 10 # Number of concurrent jobs, optional: [0..1000], default: 10.
276- dolphin.nulls_minimal_policy = on # the inverse of the default configuration value ! do not change !
277- password_encryption_type = 0
278- wal_level = logical
279- application_name = ''
280- listen_addresses = '*'
281- max_replication_slots = 10
282- max_wal_senders = 10
283- shared_buffers = 512MB
284- ssl = on
285- ssl_cert_file = '/var/lib/opengauss/certs/server.crt'
286- ssl_key_file = '/var/lib/opengauss/certs/server.key'
287- ssl_ca_file = '/var/lib/opengauss/certs/ca.crt'
288- EOF
289-
290- cat > /opengauss8889/conf/postgresql.conf <<EOF
291- local all all trust
292- host all all 127.0.0.1/32 trust
293- host all all ::1/128 trust
294- host all all 0.0.0.0/0 md5
295- hostssl all all 0.0.0.0/0 cert
296- host replication gaussdb 0.0.0.0/0 md5
297- EOF
298-
299-
300- # Pull the latest OpenGauss server image from Docker Hub
301- docker pull opengauss/opengauss-server:latest
302-
303- # Run a new OpenGauss container in the background with:
304- # - custom container name "opengauss-custom"
305- # - privileged mode enabled
306- # - root user credentials set via environment variables
307- # - port 5432 exposed
308- docker run --name opengauss-cp --privileged=true -d \
309- -e GS_USERNAME=root \
310- -e GS_USER_PASSWORD=Password@123 \
311- -e GS_PASSWORD=Password@123 \
312- -p 8889:5432 \
313- -v /opengauss8889:/var/lib/opengauss \
314- -v /opengauss8889/certs:/var/lib/opengauss/certs \
315- -v /opengauss8889/conf/postgresql.conf:/var/lib/opengauss/data/postgresql.conf \
316- -v /opengauss8889/conf/pg_hba.conf:/var/lib/opengauss/data/pg_hba.conf \
317- opengauss/opengauss-server:latest
318-
191+ # Create OpenGauss(SSL) container by running the following command:
192+ sh example/ssl_opengauss_docker.sh
193+
194+ # Default user: root
195+ # Default password: Password@123
196+ # Default port: 8889
197+ # Default IP: 127.0.0.1
198+ # Default database: test
319199
320- # Enter the container shell
321- docker exec -it opengauss-cp bash
322-
323- # Confirm the data directory (in some images it may be /var/lib/opengauss/data)
324- # Assume the data directory is /var/lib/opengauss/data
325- DATA_DIR=/var/lib/opengauss/data
326- # Find the owner (username) of the data directory
327- OWNER=$(stat -c '%U' "$DATA_DIR" 2>/dev/null || echo omm)
328-
329- # Set proper permissions for the key files and change ownership to the data directory owner
330- chown "$OWNER":"$OWNER" /var/lib/opengauss/certs/*
331- chmod 600 /var/lib/opengauss/certs/*
332-
333- # Verify the files
334- ls -l /var/lib/opengauss/certs
335-
336- # Exit the container
337- exit
338-
339- # Restart the container to apply changes
340- docker restart opengauss-cp
341-
342- # ReEnter the container
343- docker exec -it opengauss-cp bash
344-
345- # Switch to the default OpenGauss database user "omm"
346- su - omm
347-
348- # Connect to the OpenGauss database using the gsql client
349- gsql -d postgres -p 5432 -U omm
350-
351- -- Create a new database named "test" with Default compatibility with Oracle enabled
352- CREATE DATABASE test;
353-
354-
355200 # Set the Python import path to include your local GaussDB Python project
356201 # Replace your_path with actual values
357202 export PYTHONPATH=/your_path/gaussdb-python
@@ -363,9 +208,15 @@ Steps to Run OpenGauss(SSL) with Python GaussDB Driver Testing (Assuming Docker
363208 export GAUSSDB_TEST_DSN="dbname=test user=root password=Password@123 host=127.0.0.1 port=8889 sslmode=require"
364209 export GAUSSDB_TEST_DSN="dbname=test user=root password=Password@123 host=127.0.0.1 port=8889 sslmode=verify-ca sslrootcert=/opengauss8889/certs/ca.crt sslcert=/opengauss8889/certs/client.crt sslkey=/opengauss8889/certs/client.key"
365210
211+ # Run demonstration code
212+ export SSL_ROOT_CERT="/opengauss8889/certs/ca.crt"
213+ python example/ssl_demo.py
214+
366215 # Run all tests using pytest, showing verbose output and test durations
367216 pytest --durations=0 -s -v
368217
218+ For more usage examples, please refer to the README.md in the /example directory.
219+
369220The library includes some pre-commit hooks to check that the code is valid
370221according to the project coding convention. Please make sure to install them
371222by running::
0 commit comments