podman启动mysql容器,使用podman卷时会出现权限问题

vdzxcuhz  于 5个月前  发布在  Mysql
关注(0)|答案(1)|浏览(107)

podman版本及操作系统

podman版本:podman版本4.7.2操作系统:macOS Monterey podman-compose版本:1.0.6

问题描述

写入yaml文件,使用podman compose启动容器。yaml文件中没有使用卷挂载目录的权限。以下是yaml文件的内容:

version: '3.5'
services:
  mysql:
    image: mysql:8.0.35
    container_name: mysql8
    restart: unless-stopped
    environment:
      MYSQL_ROOT_PASSWORD: 12345678
    ports:
      - 13306:3306
    user: mysql
    volumes:
      - ./mysql_volumes/data:/var/lib/mysql
      - ./mysql_volumes/config:/etc/mysql/conf.d
      - ./mysql_volumes/logs:/var/log/mysql
      - ./mysql_volumes/init:/docker-entrypoint-initdb.d

# container network
networks:
  default:
    name: mysql-net
    driver: bridge

字符串
podman logs -f container_id输出以下日志信息:

2023-11-24 11:42:25+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.35-1.el8 started.
2023-11-24 11:42:25+00:00 [Note] [Entrypoint]: Initializing database files
mysqld: [Warning] World-writable config file '/etc/mysql/conf.d/my.cnf' is ignored.
2023-11-24T11:42:25.829548Z 0 [Warning] [MY-011068] [Server] The syntax '--skip-host-cache' is deprecated and will be removed in a future release. Please use SET GLOBAL host_cache_size=0 instead.
2023-11-24T11:42:25.829942Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.0.35) initializing of server in progress as process 36
2023-11-24T11:42:25.835507Z 0 [Warning] [MY-010159] [Server] Setting lower_case_table_names=2 because file system for /var/lib/mysql/ is case insensitive
2023-11-24T11:42:25.840692Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2023-11-24T11:42:26.015975Z 1 [ERROR] [MY-012592] [InnoDB] Operating system error number 13 in a file operation.
2023-11-24T11:42:26.016240Z 1 [ERROR] [MY-012595] [InnoDB] The error means mysqld does not have the access rights to the directory.
2023-11-24T11:42:26.016302Z 1 [ERROR] [MY-013183] [InnoDB] Assertion failure: log0files_governor.cc:1547:err == DB_SUCCESS thread 281473385119616
InnoDB: We intentionally generate a memory trap.
InnoDB: Submit a detailed bug report to http://bugs.mysql.com.
InnoDB: If you get repeated assertion failures or crashes, even
InnoDB: immediately after the mysqld startup, there may be
InnoDB: corruption in the InnoDB tablespace. Please refer to
InnoDB: http://dev.mysql.com/doc/refman/8.0/en/forcing-innodb-recovery.html
InnoDB: about forcing recovery.
2023-11-24T11:42:26Z UTC - mysqld got signal 6 ;
Most likely, you have hit a bug, but this error can also be caused by malfunctioning hardware.
BuildID[sha1]=666ff782b6ef10983c1529c4607aae3ecbc7150e
Thread pointer: 0x441dab30
Attempting backtrace. You can use the following information to find out
where mysqld died. If you see no messages after this, something went
terribly wrong...
stack_bottom = ffffa1223640 thread_stack 0x100000
/usr/sbin/mysqld(my_print_stacktrace(unsigned char const*, unsigned long)+0x44) [0x1dfd9e4]
/usr/sbin/mysqld(print_fatal_signal(int)+0x2a0) [0xf17b10]
/usr/sbin/mysqld(my_server_abort()+0xa4) [0xf17d54]
/usr/sbin/mysqld(my_abort()+0x14) [0x1df7624]
/usr/sbin/mysqld(ut_dbg_assertion_failed(char const*, char const*, unsigned long)+0x270) [0x20050e0]
/usr/sbin/mysqld(log_files_create(log_t&, unsigned long)+0x378) [0x1edd478]
/usr/sbin/mysqld(log_sys_init(bool, unsigned long, unsigned long&)+0x704) [0x1eed874]
/usr/sbin/mysqld(srv_start(bool)+0xb88) [0x1fbf268]
/usr/sbin/mysqld() [0x1e415bc]
/usr/sbin/mysqld(dd::bootstrap::DDSE_dict_init(THD*, dict_init_mode_t, unsigned int)+0x70) [0x1bddfa0]
/usr/sbin/mysqld(dd::bootstrap::initialize(THD*)+0x84) [0x1be1ac4]
/usr/sbin/mysqld() [0xfc4660]
/usr/sbin/mysqld() [0x245eab8]
/lib64/libpthread.so.0(+0x7950) [0xffffa2892950]
/lib64/libc.so.6(+0x23e1c) [0xffffa2021e1c]

Trying to get some variables.
Some pointers may be invalid and cause the dump to abort.
Query (0): Connection ID (thread ID): 1
Status: NOT_KILLED

The manual page at http://dev.mysql.com/doc/mysql/en/crashing.html contains
information that should help you find out what is causing the crash.
2023-11-24 11:42:26+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.35-1.el8 started.
2023-11-24 11:42:26+00:00 [Note] [Entrypoint]: Initializing database files
mysqld: [Warning] World-writable config file '/etc/mysql/conf.d/my.cnf' is ignored.
2023-11-24T11:42:26.277274Z 0 [Warning] [MY-011068] [Server] The syntax '--skip-host-cache' is deprecated and will be removed in a future release. Please use SET GLOBAL host_cache_size=0 instead.
2023-11-24T11:42:26.277445Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.0.35) initializing of server in progress as process 36
2023-11-24T11:42:26.279170Z 0 [ERROR] [MY-010457] [Server] --initialize specified but the data directory has files in it. Aborting.
2023-11-24T11:42:26.279174Z 0 [ERROR] [MY-013236] [Server] The designated data directory /var/lib/mysql/ is unusable. You can remove all files that the server added to it.
2023-11-24T11:42:26.279440Z 0 [ERROR] [MY-010119] [Server] Aborting
2023-11-24T11:42:26.279505Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.35)  MySQL Community Server - GPL.
2023-11-24 11:42:26+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.35-1.el8 started.
2023-11-24 11:42:26+00:00 [Note] [Entrypoint]: Initializing database files
mysqld: [Warning] World-writable config file '/etc/mysql/conf.d/my.cnf' is ignored.
2023-11-24T11:42:26.504825Z 0 [Warning] [MY-011068] [Server] The syntax '--skip-host-cache' is deprecated and will be removed in a future release. Please use SET GLOBAL host_cache_size=0 instead.


从yaml文件中删除user,启动容器的日志信息为:

2023-11-24 11:48:14+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.35-1.el8 started.
chown: changing ownership of '/var/lib/mysql/': Operation not permitted
chown: changing ownership of '/var/lib/mysql/ibdata1': Operation not permitted
chown: changing ownership of '/var/lib/mysql/.DS_Store': Operation not permitted
chown: changing ownership of '/var/lib/mysql/#innodb_redo': Operation not permitted
chown: changing ownership of '/var/lib/mysql/#ib_16384_1.dblwr': Operation not permitted
chown: changing ownership of '/var/lib/mysql/#ib_16384_0.dblwr': Operation not permitted
chown: changing ownership of '/var/lib/mysql/auto.cnf': Operation not permitted
chown: changing ownership of '/var/lib/mysql': Operation not permitted
chown: changing ownership of '/var/lib/mysql/ibdata1': Operation not permitted
chown: changing ownership of '/var/lib/mysql/.DS_Store': Operation not permitted
chown: changing ownership of '/var/lib/mysql/#innodb_redo': Operation not permitted
chown: changing ownership of '/var/lib/mysql/#ib_16384_1.dblwr': Operation not permitted
chown: changing ownership of '/var/lib/mysql/#ib_16384_0.dblwr': Operation not permitted
chown: changing ownership of '/var/lib/mysql/auto.cnf': Operation not permitted


我修改了四个目录的权限:config、data、init和logs。

chmod 777 config
chmod 777 data
chmod 777 init
chmod 777 logs


启动mysql容器时仍然存在问题,podman logs -f container_id输出的日志信息为:

2023-11-24 11:42:25+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.35-1.el8 started.
2023-11-24 11:42:25+00:00 [Note] [Entrypoint]: Initializing database files
mysqld: [Warning] World-writable config file '/etc/mysql/conf.d/my.cnf' is ignored.
2023-11-24T11:42:25.829548Z 0 [Warning] [MY-011068] [Server] The syntax '--skip-host-cache' is deprecated and will be removed in a future release. Please use SET GLOBAL host_cache_size=0 instead.
2023-11-24T11:42:25.829942Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.0.35) initializing of server in progress as process 36
2023-11-24T11:42:25.835507Z 0 [Warning] [MY-010159] [Server] Setting lower_case_table_names=2 because file system for /var/lib/mysql/ is case insensitive
2023-11-24T11:42:25.840692Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2023-11-24T11:42:26.015975Z 1 [ERROR] [MY-012592] [InnoDB] Operating system error number 13 in a file operation.
2023-11-24T11:42:26.016240Z 1 [ERROR] [MY-012595] [InnoDB] The error means mysqld does not have the access rights to the directory.
2023-11-24T11:42:26.016302Z 1 [ERROR] [MY-013183] [InnoDB] Assertion failure: log0files_governor.cc:1547:err == DB_SUCCESS thread 281473385119616
InnoDB: We intentionally generate a memory trap.
InnoDB: Submit a detailed bug report to http://bugs.mysql.com.
InnoDB: If you get repeated assertion failures or crashes, even
InnoDB: immediately after the mysqld startup, there may be
InnoDB: corruption in the InnoDB tablespace. Please refer to
InnoDB: http://dev.mysql.com/doc/refman/8.0/en/forcing-innodb-recovery.html
InnoDB: about forcing recovery.
2023-11-24T11:42:26Z UTC - mysqld got signal 6 ;
Most likely, you have hit a bug, but this error can also be caused by malfunctioning hardware.
BuildID[sha1]=666ff782b6ef10983c1529c4607aae3ecbc7150e
Thread pointer: 0x441dab30
Attempting backtrace. You can use the following information to find out
where mysqld died. If you see no messages after this, something went
terribly wrong...
stack_bottom = ffffa1223640 thread_stack 0x100000
/usr/sbin/mysqld(my_print_stacktrace(unsigned char const*, unsigned long)+0x44) [0x1dfd9e4]
/usr/sbin/mysqld(print_fatal_signal(int)+0x2a0) [0xf17b10]
/usr/sbin/mysqld(my_server_abort()+0xa4) [0xf17d54]
/usr/sbin/mysqld(my_abort()+0x14) [0x1df7624]
/usr/sbin/mysqld(ut_dbg_assertion_failed(char const*, char const*, unsigned long)+0x270) [0x20050e0]
/usr/sbin/mysqld(log_files_create(log_t&, unsigned long)+0x378) [0x1edd478]
/usr/sbin/mysqld(log_sys_init(bool, unsigned long, unsigned long&)+0x704) [0x1eed874]
/usr/sbin/mysqld(srv_start(bool)+0xb88) [0x1fbf268]
/usr/sbin/mysqld() [0x1e415bc]
/usr/sbin/mysqld(dd::bootstrap::DDSE_dict_init(THD*, dict_init_mode_t, unsigned int)+0x70) [0x1bddfa0]
/usr/sbin/mysqld(dd::bootstrap::initialize(THD*)+0x84) [0x1be1ac4]
/usr/sbin/mysqld() [0xfc4660]
/usr/sbin/mysqld() [0x245eab8]
/lib64/libpthread.so.0(+0x7950) [0xffffa2892950]
/lib64/libc.so.6(+0x23e1c) [0xffffa2021e1c]

Trying to get some variables.
Some pointers may be invalid and cause the dump to abort.
Query (0): Connection ID (thread ID): 1
Status: NOT_KILLED

The manual page at http://dev.mysql.com/doc/mysql/en/crashing.html contains
information that should help you find out what is causing the crash.
2023-11-24 11:42:26+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.35-1.el8 started.
2023-11-24 11:42:26+00:00 [Note] [Entrypoint]: Initializing database files
mysqld: [Warning] World-writable config file '/etc/mysql/conf.d/my.cnf' is ignored.
2023-11-24T11:42:26.277274Z 0 [Warning] [MY-011068] [Server] The syntax '--skip-host-cache' is deprecated and will be removed in a future release. Please use SET GLOBAL host_cache_size=0 instead.
2023-11-24T11:42:26.277445Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.0.35) initializing of server in progress as process 36
2023-11-24T11:42:26.279170Z 0 [ERROR] [MY-010457] [Server] --initialize specified but the data directory has files in it. Aborting.
2023-11-24T11:42:26.279174Z 0 [ERROR] [MY-013236] [Server] The designated data directory /var/lib/mysql/ is unusable. You can remove all files that the server added to it.
2023-11-24T11:42:26.279440Z 0 [ERROR] [MY-010119] [Server] Aborting
2023-11-24T11:42:26.279505Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.35)  MySQL Community Server - GPL.
2023-11-24 11:42:26+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.35-1.el8 started.
2023-11-24 11:42:26+00:00 [Note] [Entrypoint]: Initializing database files
mysqld: [Warning] World-writable config file '/etc/mysql/conf.d/my.cnf' is ignored.
2023-11-24T11:42:26.504825Z 0 [Warning] [MY-011068] [Server] The syntax '--skip-host-cache' is deprecated and will be removed in a future release. Please use SET GLOBAL host_cache_size=0 instead.

zed5wv10

zed5wv101#

你需要添加一个命令就在你的形象,使其不区分大小写

version: '3.5'
services:
  mysql:
    image: mysql:8.0.35
    command: --default-authentication-plugin=mysql_native_password --lower_case_table_names=1
    container_name: mysql8
    restart: unless-stopped
    environment:
      MYSQL_ROOT_PASSWORD: 12345678
    ports:
      - 13306:3306
    user: mysql
    volumes:
      - ./mysql_volumes/data:/var/lib/mysql
      - ./mysql_volumes/config:/etc/mysql/conf.d
      - ./mysql_volumes/logs:/var/log/mysql
      - ./mysql_volumes/init:/docker-entrypoint-initdb.d

字符串

相关问题