当前位置: 首页 > news >正文

容器运行常见数据库

一.涉及镜像压缩包

  • 均为amd架构
  • 版本:mysql:5.7.42、postgres:13.16、dm8:20250206_rev257733_x86_rh6_64、oceanbase-ce:v4.0、opengauss:5.0.2

通过网盘分享的文件:db.tgz
链接: https://pan.baidu.com/s/1EBbFPZj1FxCA4_GxjVunWg?pwd=563s 提取码: 563s

二.mysql-5.7.42

  • 容器执行命令
docker run --name mysql -p 20307:3306 --restart=always --privileged=true \
-e MYSQL_ROOT_PASSWORD="SLBmysql2025" \
-v /data/mysql/my.cnf:/etc/my.cnf \
-v /data/mysql/data:/var/lib/mysql \
-d xxx/mysql:5.7.42
  • my.cnf文件(/data/mysql/my.cnf)
[mysqld]
port=3306
skip-host-cache
skip-name-resolve
datadir=/var/lib/mysql
socket=/run/mysqld/mysqld.sock
secure-file-priv=/var/lib/mysql-files
user=mysql
symbolic-links=0
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
slow_query_log_file = /var/lib/mysql/mysql-slow.log
log_bin = mysql-bin
slow_query_log_file = /var/lib/mysql/mysql-slow.log
server-id = 1
bind-address = 0.0.0.0
default_time_zone = '+08:00'
log_timestamps = SYSTEM
init-connect = 'SET NAMES utf8mb4'
character-set-server = utf8mb4
back_log = 300
max_connections = 5000
max_connect_errors = 1000
open_files_limit = 65535
table_open_cache = 128
max_allowed_packet = 4M
binlog_cache_size = 1M
max_heap_table_size = 8M
tmp_table_size = 16M
read_buffer_size = 2M
read_rnd_buffer_size = 8M
sort_buffer_size = 8M
join_buffer_size = 8M
key_buffer_size = 4M
thread_cache_size = 8
query_cache_type = 1
query_cache_size = 8M
query_cache_limit = 2M
ft_min_word_len = 4
binlog_format = mixed
expire_logs_days = 30
max_binlog_size =1G
slow_query_log = 1
long_query_time = 1
performance_schema = 0
explicit_defaults_for_timestamp
lower_case_table_names = 1
skip-external-locking
default_storage_engine = InnoDB
innodb_file_per_table = 1
innodb_open_files = 500
innodb_buffer_pool_size = 64M
innodb_write_io_threads = 4
innodb_read_io_threads = 4
innodb_thread_concurrency = 0
innodb_purge_threads = 1
innodb_flush_log_at_trx_commit = 2
innodb_log_buffer_size = 2M
innodb_log_file_size = 32M
innodb_log_files_in_group = 3
innodb_max_dirty_pages_pct = 90
innodb_lock_wait_timeout = 120
bulk_insert_buffer_size = 8M
interactive_timeout = 28800
wait_timeout = 28800

[mysqldump]
quick
max_allowed_packet = 100M

[client]
port = 3306
socket=/run/mysqld/mysqld.sock

!includedir /etc/mysql/conf.d/
!includedir /etc/mysql/mysql.conf.d/

三.postgresql:13.16

  • 容器执行命令
docker run --name postgres13-16 --restart=always --privileged=true \
-e POSTGRES_USER=postgres \
-e POSTGRES_PASSWORD="SLBpg2025" \
-p 25432:5432 \
-v /data/pg/data:/var/lib/postgresql/data \
-d xxx/postgres:13.16
  • 运行后修改/data/pg/data/postgresql.conf
listen_addresses = '*'
port = 5432
max_connections = 2000
superuser_reserved_connections = 10
password_encryption = scram-sha-256
shared_buffers = 128MB
dynamic_shared_memory_type = posix
wal_level = replica
max_wal_size = 4096MB    
min_wal_size = 80MB   
max_wal_senders = 10
wal_keep_size= 4096MB   
synchronous_standby_names = '*'
hot_standby = on
log_destination = 'stderr'
logging_collector = on
log_directory = 'log'
log_filename = 'postgresql-%a.log'
log_truncate_on_rotation = on
log_rotation_age = 1d
log_rotation_size = 0
log_line_prefix = '%m [%p] '
log_timezone = 'PRC'
log_statement = 'all'  
log_duration = on  
log_min_duration_sample = 30000ms
log_statement_sample_rate = 0.2
datestyle = 'iso, mdy'
timezone = 'PRC'
lc_messages = 'en_US.UTF-8'
lc_monetary = 'en_US.UTF-8'
lc_numeric = 'en_US.UTF-8'
lc_time = 'en_US.UTF-8'
default_text_search_config = 'pg_catalog.english'
archive_mode = on   
archive_command = 'gzip < %p > /var/lib/postgresql/data/pg_wal/%f.gz'         
shared_preload_libraries = 'pg_stat_statements'
pg_stat_statements.max = 10000
pg_stat_statements.track = all
  • 创建扩展
--连接到数据库后创建扩展
CREATE EXTENSION IF NOT EXISTS pg_stat_statements;
SELECT * FROM pg_extension WHERE extname = 'pg_stat_statements';

四.dm V8

  • 容器执行命令
docker run -p 30236:5236 --restart=always --name=dm8 --privileged=true \
-e SYSDBA_PWD="SLBsysdba2025" \
-e LD_LIBRARY_PATH=/opt/dmdbms/bin \
-e PAGE_SIZE=16 -e EXTENT_SIZE=32 -e CASE_SENSITIVE=1 \
-e LOG_SIZE=1024 -e UNICODE_FLAG=1  \
-e INSTANCE_NAME=dm8 \
-v /data/dm/data:/opt/dmdbms/data \
-d xxx/dm8:20250206_rev257733_x86_rh6_64

五.oceanbase V4.0

  • 容器执行命令
docker run -p 22881:2881 -m 8G --name=obce-4.0 --restart=always --privileged=true \
-e MODE=NORMAL -e OB_DATA_DIR=/data \
-itd xxx/oceanbase-ce:v4.0
  • 进入容器启动server
docker exec -it obce-4.0 bash

[admin@0fd82061e752 ~]$ obd cluster list
+------------------------------------------------------------+
|                        Cluster List                        |
+--------+---------------------------------+-----------------+
| Name   | Configuration Path              | Status (Cached) |
+--------+---------------------------------+-----------------+
| obdemo | /home/admin/.obd/cluster/obdemo | deployed        |
+--------+---------------------------------+-----------------+
[admin@0fd82061e752 ~]$ obd cluster start obdemo 
Get local repositories ok
Search plugins ok
Open ssh connection ok
Load cluster param plugin ok
Check before start observer ok
[WARN] (127.0.0.1) clog and data use the same disk (/)

Check before start obproxy ok
Start observer ok
observer program health check ok
Connect to observer ok
Initialize cluster ok
Start obproxy ok
obproxy program health check ok
Connect to obproxy ok
Initialize cluster ok
Wait for observer init ok
+---------------------------------------------+
|                   observer                  |
+-----------+---------+------+-------+--------+
| ip        | version | port | zone  | status |
+-----------+---------+------+-------+--------+
| 127.0.0.1 | 4.0.0.0 | 2881 | zone1 | ACTIVE |
+-----------+---------+------+-------+--------+
obclient -h127.0.0.1 -P2881 -uroot -prootPWD123 -Doceanbase

+---------------------------------------------+
|                   obproxy                   |
+-----------+------+-----------------+--------+
| ip        | port | prometheus_port | status |
+-----------+------+-----------------+--------+
| 127.0.0.1 | 2883 | 2884            | active |
+-----------+------+-----------------+--------+
obclient -h127.0.0.1 -P2883 -uroot -prootPWD123 -Doceanbase
obdemo running
  • 根据输出信息验证联通性
obclient -h127.0.0.1 -P2881 -uroot -prootPWD123 -Doceanbase
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the OceanBase.  Commands end with ; or \g.
Your OceanBase connection id is 3221487617
Server version: OceanBase_CE 4.0.0.0 (r100000272022110114-6af7f9ae79cd0ecbafd4b1b88e2886ccdba0c3be) (Built Nov  1 2022 14:56:31)

Copyright (c) 2000, 2018, OB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
obclient [oceanbase]>
obclient [oceanbase]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| LBACSYS            |
| mysql              |
| oceanbase          |
| ORAAUDITOR         |
| SYS                |
| test               |
+--------------------+
7 rows in set (0.008 sec)

六.opengauss 5.0.2

  • 容器运行命令
docker run --name=opengauss-5.0.2 --privileged=true --restart=always \
-e GS_PASSWORD=SLBopengauss@2025 \
-e LD_LIBRARY_PATH="/usr/local/opengauss/lib:$LD_LIBRARY_PATH" \
-v /data/opengauss/data:/var/lib/opengauss  \
-u root -p 15432:5432 \
-d xxx/opengauss:5.0.2
  • 进入容器创建软链接,验证连通性
[root@master01 opengauss]# docker exec -it opengauss-5.0.2 bash
root@bb7dece59a51:/# ln -s /usr/local/opengauss/bin/gsql /usr/local/bin/gsql
root@bb7dece59a51:/# gsql -dpostgres -Ugaussdb -W'SLBopengauss@2025' -h127.0.0.1 -p5432
gsql ((openGauss 5.0.2 build 48a25b11) compiled at 2024-05-14 10:26:01 commit 0 last mr  )
Non-SSL connection (SSL connection is recommended when requiring high-security)
Type "help" for help.

openGauss=> \l
                         List of databases
   Name    | Owner | Encoding | Collate | Ctype | Access privileges 
-----------+-------+----------+---------+-------+-------------------
 omm       | omm   | UTF8     | C       | C     | 
 postgres  | omm   | UTF8     | C       | C     | 
 template0 | omm   | UTF8     | C       | C     | =c/omm           +
           |       |          |         |       | omm=CTc/omm
 template1 | omm   | UTF8     | C       | C     | =c/omm           +
           |       |          |         |       | omm=CTc/omm
(4 rows)
  • 在/data/opengauss/data/data/postgresql.conf中修改配置文件所需参数即可

相关文章:

  • 吉安购物网站制作如何建立网站服务器
  • 网站的国际化 怎么做百度答主招募入口官网
  • 成都网页设计价格seo搜索推广费用多少
  • 公司网站做的很烂seo网站收录工具
  • 有源代码怎么做网站接广告的网站
  • 网站功能板块怎么做好网站搜索引擎优化
  • 使用 IntersectionObserver 实现懒加载和无限滚动
  • 静态页面在安卓端可以正常显示,但是在ios打开这个页面就需要刷新才能显示全图片
  • Dify+Ollama+DeepSeek部署本地大模型+知识库搭建
  • CSS flex布局 列表单个元素点击 本行下插入详情独占一行
  • BMS项目-面试及答疑整理
  • 【HarmonyOS之旅】基于ArkTS开发(二) -> UI开发三
  • Linux:线程的互斥与同步
  • Vmware ubuntu22.04 虚拟机 连接windows主机虚拟串口
  • 5G时代的运维变革与美信监控易的深度剖析
  • 【漫话机器学习系列】093.代价函数和损失函数(Cost and Loss Functions)
  • 网络安全扫IP工具
  • QT基础二、信号和槽
  • Python常见面试题的详解8
  • Javascript网页设计案例:通过PDF.js实现一款PDF阅读器,包括预览、页面旋转、页面切换、放大缩小、黑夜模式等功能
  • 【油猴脚本/Tampermonkey】DeepSeek 服务器繁忙无限重试(20250217优化)
  • 鸿蒙NEXT开发-界面渲染(条件和循环)
  • DeepSeek-R1论文阅读及蒸馏模型部署
  • 华三交换机-链路聚合配置案例
  • Vue2 中使用 UniApp 时,生命周期钩子函数总结
  • 【SpringBoot整合系列】SpringBoot3.x整合Swagger