经过多次尝试,我终于能够通过在 my.ini 中添加 innodb_force_recovery = 6 来重新启动严重损坏的数据库
但是现在,除非该行永久存在于 ini 文件中,否则我根本无法启动服务器。这似乎不对。
以这种方式恢复数据库后,除了备份和还原到全新的数据库外,我还应该做些什么吗?
经过多次尝试,我终于能够通过在 my.ini 中添加 innodb_force_recovery = 6 来重新启动严重损坏的数据库
但是现在,除非该行永久存在于 ini 文件中,否则我根本无法启动服务器。这似乎不对。
以这种方式恢复数据库后,除了备份和还原到全新的数据库外,我还应该做些什么吗?
我在docker容器中运行MySQL:
sudo docker run --rm --name mysql5 --net legacy_net --net-alias mysql5 --ip 172.20.0.2 -e MYSQL_ROOT_PASSWORD=$MROOTPASS -d mysql:5.7
mysql -u root -h 172.20.0.2 -p$MROOTPASS
并使用以下命令创建了一个实验数据库:
CREATE DATABASE testdb;
并提交了容器:
sudo docker commit mysql5 mysql:5.7-test
当我启动已提交的容器时:
sudo docker stop mysql5;
sudo docker run --rm --name mysql5 --net legacy_net --net-alias mysql5 --ip 172.20.0.2 -e MYSQL_ROOT_PASSWORD=$MROOTPASS -d mysql:5.7-test
我的测试数据库消失了。
这是正常行为还是我做错了什么?
我的理解是,Docker 将其数据存储在其内部存储的某个位置,当我执行此操作时,该数据会被复制到新映像中docker commit
。我误解了什么?
编辑1
sudo docker inspect mysql5 | grep -i volume
"VolumeDriver": "",
"VolumesFrom": null,
"Type": "volume",
"Source": "/var/lib/docker/volumes/1f04f07e91a16e6e9aeb393af2954dd7e32e2a2b93615fb4b6924de3568951af/_data",
"Volumes": {
sudo docker inspect mysql:5.7
"Volumes": {
"/var/lib/mysql": {}
},
编辑2
mysql
Docker使用 id=999 的用户创建卷:
sudo docker run --rm --name mysql5 -v /home/dmitriano/work/mysql:/var/lib/mysql --net legacy_net --net-alias mysql5 --ip 172.20.0.2 -e MYSQL_ROOT_PASSWORD=$MROOTPASS -d mysql:5.7
ll
drwxr-xr-x 5 999 root 4096 Jan 20 19:31 mysql/
sudo docker exec -it mysql5 bash -c "id 999"
uid=999(mysql) gid=999(mysql) groups=999(mysql)
我应该在主机上用这个 999 做什么?
我将 11 个数据库中的 3 个从 Ubuntu 16.04 上的 MySQL 5.7.44 迁移到了 Ubuntu 24.04 上的 MySQL 8.0.40。
我的旧机器上使用的空间:
root@localhost:/var/lib/mysql# du -ha --max-depth=1
19M ./bot
4.0K ./private_key.pem
1.1M ./performance_schema
48K ./game
79M ./master
4.0K ./public_key.pem
4.0K ./client-key.pem
4.0K ./auto.cnf
5.0G ./beauty
0 ./debian-5.7.flag
201M ./devnote
11M ./mysql
4.0K ./ca.pem
8.0K ./test
12M ./mike1
12M ./ibtmp1
176K ./phpmyadmin
4.0K ./server-cert.pem
680K ./sys
48M ./ib_logfile0
4.0K ./ca-key.pem
127M ./mike
4.0K ./mysql_upgrade_info
4.0K ./ib_buffer_pool
48M ./ib_logfile1
4.0K ./server-key.pem
186M ./slogpost
76M ./ibdata1
4.0K ./client-cert.pem
41M ./shar
5.9G .
我的新机器上使用的空间(新数据库是、、beauty
):shar
slogpost
root@localhost:/var/lib/mysql# du -ha --max-depth=1
101M ./#innodb_redo
101M ./binlog.000161
101M ./binlog.000069
101M ./binlog.000008
101M ./binlog.000095
101M ./binlog.000082
101M ./binlog.000047
4.0K ./localhost.pid
4.0K ./public_key.pem
101M ./binlog.000075
36K ./mysql
101M ./binlog.000177
101M ./binlog.000101
101M ./binlog.000122
4.0K ./server-key.pem
101M ./binlog.000107
101M ./binlog.000158
101M ./binlog.000079
101M ./binlog.000057
101M ./binlog.000028
101M ./binlog.000173
101M ./binlog.000020
4.0K ./binlog.index
101M ./binlog.000112
101M ./binlog.000121
101M ./binlog.000139
101M ./binlog.000142
101M ./binlog.000152
101M ./binlog.000060
101M ./binlog.000136
101M ./binlog.000010
101M ./binlog.000045
101M ./binlog.000077
101M ./binlog.000125
101M ./binlog.000168
101M ./binlog.000169
101M ./binlog.000119
101M ./binlog.000007
101M ./binlog.000176
101M ./binlog.000127
101M ./binlog.000066
4.0K ./client-key.pem
101M ./binlog.000123
101M ./binlog.000099
101M ./binlog.000143
101M ./binlog.000118
4.0K ./private_key.pem
101M ./binlog.000070
101M ./binlog.000145
101M ./binlog.000030
4.0K ./binlog.000002
19M ./shar
4.0K ./auto.cnf
101M ./binlog.000116
101M ./binlog.000160
101M ./binlog.000156
101M ./binlog.000148
101M ./binlog.000097
101M ./binlog.000043
101M ./binlog.000140
101M ./binlog.000042
101M ./binlog.000063
101M ./binlog.000015
101M ./binlog.000050
0 ./debian-5.7.flag
101M ./binlog.000003
101M ./binlog.000180
8.2M ./#ib_16384_1.dblwr
4.0K ./binlog.000036
101M ./binlog.000026
12M ./ibtmp1
101M ./binlog.000034
1.7M ./performance_schema
16M ./undo_002
101M ./binlog.000023
101M ./binlog.000071
101M ./binlog.000033
32K ./binlog.000038
101M ./binlog.000011
76K ./binlog.000039
101M ./binlog.000110
101M ./binlog.000017
101M ./binlog.000012
101M ./binlog.000032
101M ./binlog.000165
101M ./binlog.000086
101M ./binlog.000157
183M ./slogpost
2.3G ./binlog.000133
101M ./binlog.000056
101M ./binlog.000019
101M ./binlog.000022
2.3G ./binlog.000183
101M ./binlog.000073
101M ./binlog.000138
101M ./binlog.000009
101M ./binlog.000067
101M ./binlog.000181
101M ./binlog.000013
101M ./binlog.000162
101M ./binlog.000088
101M ./binlog.000120
101M ./binlog.000054
101M ./binlog.000064
8.6M ./binlog.000035
101M ./binlog.000085
101M ./binlog.000144
101M ./binlog.000091
101M ./binlog.000061
101M ./binlog.000141
4.0K ./binlog.000135
101M ./binlog.000109
101M ./binlog.000103
101M ./binlog.000132
101M ./binlog.000094
101M ./binlog.000151
101M ./binlog.000076
101M ./binlog.000149
101M ./binlog.000104
101M ./binlog.000163
101M ./binlog.000027
101M ./binlog.000114
116K ./sys
101M ./binlog.000182
8.0K ./ib_buffer_pool
101M ./binlog.000115
101M ./binlog.000164
101M ./binlog.000084
2.4G ./beauty
101M ./binlog.000016
101M ./binlog.000153
101M ./binlog.000172
101M ./binlog.000041
101M ./binlog.000174
101M ./binlog.000100
8.0K ./binlog.000185
101M ./binlog.000113
101M ./binlog.000046
101M ./binlog.000178
101M ./binlog.000124
101M ./binlog.000074
101M ./binlog.000105
101M ./binlog.000179
28M ./mysql.ibd
101M ./binlog.000171
101M ./binlog.000155
101M ./binlog.000062
101M ./binlog.000021
101M ./binlog.000044
101M ./binlog.000049
101M ./binlog.000059
101M ./binlog.000147
60K ./binlog.000134
101M ./binlog.000055
4.0K ./binlog.000040
101M ./binlog.000126
101M ./binlog.000170
101M ./binlog.000089
101M ./binlog.000006
101M ./binlog.000080
101M ./binlog.000081
101M ./binlog.000068
172K ./binlog.000037
12M ./ibdata1
101M ./binlog.000146
101M ./binlog.000031
101M ./binlog.000129
101M ./binlog.000150
4.0K ./binlog.000001
804K ./#innodb_temp
101M ./binlog.000065
75M ./binlog.000004
4.0K ./ca-key.pem
101M ./binlog.000025
101M ./binlog.000108
4.0K ./server-cert.pem
101M ./binlog.000090
101M ./binlog.000051
101M ./binlog.000048
101M ./binlog.000052
101M ./binlog.000024
101M ./binlog.000053
101M ./binlog.000130
101M ./binlog.000014
8.0K ./binlog.000184
101M ./binlog.000117
101M ./binlog.000096
101M ./binlog.000005
101M ./binlog.000175
101M ./binlog.000131
101M ./binlog.000078
101M ./binlog.000167
101M ./binlog.000058
101M ./binlog.000083
101M ./binlog.000087
101M ./binlog.000154
101M ./binlog.000166
101M ./binlog.000102
4.0K ./client-cert.pem
101M ./binlog.000128
4.0K ./ca.pem
101M ./binlog.000137
101M ./binlog.000098
16M ./undo_001
101M ./binlog.000029
101M ./binlog.000018
101M ./binlog.000092
101M ./binlog.000106
101M ./binlog.000072
101M ./binlog.000111
2.3G ./binlog.000159
192K ./#ib_16384_0.dblwr
101M ./binlog.000093
27G .
du -csh binlog* | tail -n 1
24G total
beauty
(旧机器上的数据库占用5.0G,因为它包含一些额外的数据)
新机器上的 11 个数据库占用 5.9G,但旧机器上的 3 个数据库占用 27G。
为什么这么多?
要备份数据库我只需执行以下操作:
mysqldump -u $MUSER -h $MHOST -p$MPASS $MDB --no-tablespaces | sed -e 's/DEFINER=[^*]*\*/\*/' > $DBDUMP
为了恢复我这样做:
tar -Oxzf $ARCHIVE_FILE $DBDUMP | mysql -u $MUSER -h $MHOST -p$MPASS $MDB
我正在尝试在两个 mysql 5.7 服务器之间设置复制。我能够从副本服务器连接到源服务器,但当我尝试启动复制时,副本服务器无法连接到源服务器。这可能导致什么
这将成功打开连接到源的 mysql 客户端:
# On replica
$ mysql -u [my_user] -p -h [source_host] \
--ssl-mode=REQUIRED \
--ssl-ca=/etc/[source_host].cabundle
源状态:
mysql> show master status;
+------------------+----------+--------------+------------------+-------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+------------------+----------+--------------+------------------+-------------------+
| mysql-bin.002513 | 45687316 | | | |
+------------------+----------+--------------+------------------+-------------------+
1 row in set (0.00 sec)
在副本上:
mysql> CHANGE MASTER TO
-> MASTER_HOST='[source_host]',
-> MASTER_USER='[my_user]',
-> MASTER_PASSWORD='[my_password]',
-> MASTER_LOG_FILE='mysql-bin.002495',
-> MASTER_LOG_POS=154,
-> MASTER_SSL=1,
-> MASTER_SSL_VERIFY_SERVER_CERT=0,
-> MASTER_SSL_CA='/etc/ssl/[source_host].cabundle'
-> ;
Query OK, 0 rows affected, 2 warnings (0.03 sec)
mysql> start slave;
Query OK, 0 rows affected (0.00 sec)
副本状态:
mysql> show slave stauts \G
*************************** 1. row ***************************
Slave_IO_State: Connecting to master
Master_Host: [source_host]
Master_User: [my_user]
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.002495
Read_Master_Log_Pos: 154
Relay_Log_File: [hostname]-relay-bin.000001
Relay_Log_Pos: 4
Relay_Master_Log_File: mysql-bin.002495
Slave_IO_Running: Connecting
Slave_SQL_Running: Yes
Replicate_Do_DB:
Replicate_Ignore_DB:
Replicate_Do_Table:
Relay_Log_Space: 154
Until_Condition: None
Until_Log_File:
Until_Log_Pos: 0
Master_SSL_Allowed: Yes
Master_SSL_CA_File: /etc/ssl/[source_host].cabundle
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master: NULL
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 2026
Last_IO_Error: error connecting to master '[my_user]@[source_host]:3306' - retry-time: 60 retries:
4
Last_SQL_Errno: 0
Last_SQL_Error:
Replicate_Ignore_Server_Ids:
Master_Server_Id: 0
Master_UUID:
Master_Info_File: [mysql_dir]/master.info
SQL_Delay: 0
SQL_Remaining_Delay: NULL
Slave_SQL_Running_State: Slave has read all relay log; waiting for more updates
Master_Retry_Count: 86400
Master_Bind:
Last_IO_Error_Timestamp: 250115 03:03:38
Last_SQL_Error_Timestamp:
Master_SSL_Crl:
Master_SSL_Crlpath:
Retrieved_Gtid_Set:
Executed_Gtid_Set:
Auto_Position: 0
Replicate_Rewrite_DB:
Channel_Name:
Master_TLS_Version:
副本上的 mysql error.log:
[Note] 'CHANGE MASTER TO FOR CHANNEL '' executed'. Previous state master_host='[source_host]', master_port= 3306, master_log_file='', master_log_pos= 4, master_bind=''. New state master_host='[source_host]', master_port= 3306, master_log_file='mysql-bin.002495', master_log_pos= 154, master_bind=''.
[Warning] Storing MySQL user name or password information in the master info repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START SLAVE; see the 'START SLAVE Syntax' in the MySQL Manual for more information.
[Warning] Slave SQL for channel '': If a crash happens this configuration does not guarantee that the relay log info will be consistent, Error_code: 0
[Note] Slave SQL thread for channel '' initialized, starting replication in log 'mysql-bin.002495' at position 154, relay log './analysis-relay-bin.000001' position: 4
[ERROR] Slave I/O for channel '': error connecting to master '[my_user]@[source_host]:3306' - retry-time: 60 retries: 1, Error_code: 2026
mysql error.log 来源:
[Note] Bad handshake
我正在使用用户“feedbackdev”连接到 MySQL,但查询是使用“feedback”执行的,它是同一服务器上的另一个用户。
root@board:~# mysql -u feedbackdev -p feedbackdev
Enter password:
mysql> select user();
+-----------------------+
| user() |
+-----------------------+
| feedbackdev@localhost |
+-----------------------+
mysql> select rating, COUNT(*) AS rating_count from order_feedback_view where feedback_created_at >= '2024-10-26 09:01:29' group by rating;
ERROR 1143 (42000): SELECT command denied to user 'feedback'@'localhost' for column 'source_id' in table 'orders'
以下是用户可获得的赠款
mysql> show grants for 'feedbackdev'@'localhost';
+----------------------------------------------------------------------+
| Grants for feedbackdev@localhost |
+----------------------------------------------------------------------+
| GRANT PROCESS, SUPER ON *.* TO `feedbackdev`@`localhost` |
| GRANT SET_USER_ID ON *.* TO `feedbackdev`@`localhost` |
| GRANT ALL PRIVILEGES ON `feedbackdev`.* TO `feedbackdev`@`localhost` |
+----------------------------------------------------------------------+
3 rows in set (0.00 sec)
mysql> show grants for 'feedback'@'localhost';
+---------------------------------------------------------------------------+
| Grants for feedback@localhost |
+---------------------------------------------------------------------------+
| GRANT PROCESS, SUPER, REPLICATION CLIENT ON *.* TO `feedback`@`localhost` |
| GRANT FLUSH_TABLES ON *.* TO `feedback`@`localhost` |
| GRANT ALL PRIVILEGES ON `feedback`.* TO `feedback`@`localhost` |
+---------------------------------------------------------------------------+
3 rows in set (0.00 sec)
MySQL 版本 8.0.40
运行SHOW MASTER STATUS;
命令时,我收到语法错误。这太奇怪了。我检查了权限,它们没问题。server-id
和bin-log
都已设置并正常工作。没有正在进行复制。如果问题出在权限上或某些设置未正确设置,我不会收到 SyntaxError。
这是我运行的完整命令:
mysql> SHOW MASTER STATUS;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'MASTER STATUS' at line 1
我甚至尝试以 root 身份运行它,但仍然出现语法错误。谷歌搜索和文档都没有帮助。MySQL 版本是 8.4.0
有人能告诉我造成这种情况的原因是什么吗?
我有一个 Rook Ceph 集群,其中存储了具有 3x 副本的 MySQL 数据库。我也使用该数据库进行开发,也就是说,删除、更改了大量数据等等。
BinaryLogs 也已启用。
数据库总共占用 27GB,其中 22-24GB 是 BinaryLogs。我可以禁用 BinaryLogs,但 20GB 的作用不大,它们每 3 天清除一次。
如果我从容器/主机(df -h)查看大小,我会看到相同的大小(27GB)。
但是Rook Ceph将此Block Image定义为241GB。
而且我不明白如果块图像应该小 9 倍,为什么这个尺寸会这么大?
有什么想法或提示吗?我可以尝试什么或从哪个方向寻找才能了解原因。
我已按照说明一步步在 Kubernetes 上部署 MySQL Operator。按照官方页面的说明进行操作。一旦部署没有错误,操作员就没有处于就绪状态。我已经通过清单和 Helm 尝试过,但得到了相同的响应。
https://dev.mysql.com/doc/mysql-operator/en/mysql-operator-installation-kubectl.html
部署后,操作员尚未准备好
$ kubectl get all -n mysql-operator
NAME READY STATUS RESTARTS AGE
pod/mysql-operator-84ffdf9dbc-m2n4c 0/1 Running 0 31s
NAME READY UP-TO-DATE AVAILABLE AGE
deployment.apps/mysql-operator 0/1 1 0 31s
NAME DESIRED CURRENT READY AGE
replicaset.apps/mysql-operator-84ffdf9dbc 1 1 0 31s
我在 Kubernetes 1.24 和 1.27 版本上进行了测试,得到了相同的结果。
运营商似乎试图获取 xxx-privsecrets 但找不到它
有人遇到同样的问题并找到解决方案吗?
不客气!
日志
2024-05-29 06:46:52: Info: mysqlsh Ver 8.4.0 for Linux on x86_64 - for MySQL 8.4.0 (MySQL Community Server (GPL)) - build 15032060 - commit_id 4de2d1695fdc7089e81c99dcb042953620e444fb - product_id el8-x86-64bit rpm
2024-05-29 06:46:52: Info: Using credential store helper: /usr/bin/mysql-secret-store-login-path
2024-05-29 06:46:52: Info: Loading startup files...
2024-05-29 06:46:52: Info: Loading plugins...
[2024-05-29 06:46:55,639] root [INFO ] Auto-detected cluster domain: cluster.local
[2024-05-29 06:46:55,644] kopf.activities.star [INFO ] MySQL Operator/operator.py=2.1.3 timestamp=2024-04-29T07:16:37 kopf=1.35.4 uid=2
[2024-05-29 06:46:55,659] kopf.activities.star [INFO ] KUBERNETES_VERSION =1.24
[2024-05-29 06:46:55,659] kopf.activities.star [INFO ] OPERATOR_VERSION =2.1.3
[2024-05-29 06:46:55,659] kopf.activities.star [INFO ] OPERATOR_EDITION =community
[2024-05-29 06:46:55,659] kopf.activities.star [INFO ] OPERATOR_EDITIONS =['community', 'enterprise']
[2024-05-29 06:46:55,660] kopf.activities.star [INFO ] SHELL_VERSION =8.4.0
[2024-05-29 06:46:55,660] kopf.activities.star [INFO ] DEFAULT_VERSION_TAG=8.4.0
[2024-05-29 06:46:55,660] kopf.activities.star [INFO ] SIDECAR_VERSION_TAG=8.4.0-2.1.3
[2024-05-29 06:46:55,660] kopf.activities.star [INFO ] DEFAULT_IMAGE_REPOSITORY =container-registry.oracle.com/mysql
[2024-05-29 06:46:55,660] kopf.activities.star [INFO ] setuptools = 50.3.2
[2024-05-29 06:46:55,660] kopf.activities.star [INFO ] pip = 20.2.4
[2024-05-29 06:46:55,660] kopf.activities.star [INFO ] yarl = 1.9.4
[2024-05-29 06:46:55,660] kopf.activities.star [INFO ] websocket-client = 1.7.0
[2024-05-29 06:46:55,660] kopf.activities.star [INFO ] urllib3 = 2.2.0
[2024-05-29 06:46:55,660] kopf.activities.star [INFO ] typing-extensions = 4.9.0
[2024-05-29 06:46:55,661] kopf.activities.star [INFO ] six = 1.16.0
[2024-05-29 06:46:55,661] kopf.activities.star [INFO ] rsa = 4.9
[2024-05-29 06:46:55,661] kopf.activities.star [INFO ] requests = 2.31.0
[2024-05-29 06:46:55,661] kopf.activities.star [INFO ] requests-oauthlib = 1.3.1
[2024-05-29 06:46:55,661] kopf.activities.star [INFO ] PyYAML = 6.0.1
[2024-05-29 06:46:55,661] kopf.activities.star [INFO ] python-json-logger = 2.0.7
[2024-05-29 06:46:55,661] kopf.activities.star [INFO ] python-dateutil = 2.8.2
[2024-05-29 06:46:55,661] kopf.activities.star [INFO ] pyasn1 = 0.5.1
[2024-05-29 06:46:55,661] kopf.activities.star [INFO ] pyasn1-modules = 0.3.0
[2024-05-29 06:46:55,661] kopf.activities.star [INFO ] oauthlib = 3.2.2
[2024-05-29 06:46:55,661] kopf.activities.star [INFO ] multidict = 6.0.5
[2024-05-29 06:46:55,661] kopf.activities.star [INFO ] kubernetes = 23.6.0
[2024-05-29 06:46:55,661] kopf.activities.star [INFO ] kopf = 1.35.4
[2024-05-29 06:46:55,662] kopf.activities.star [INFO ] iso8601 = 2.1.0
[2024-05-29 06:46:55,662] kopf.activities.star [INFO ] idna = 3.6
[2024-05-29 06:46:55,662] kopf.activities.star [INFO ] google-auth = 2.27.0
[2024-05-29 06:46:55,662] kopf.activities.star [INFO ] frozenlist = 1.4.1
[2024-05-29 06:46:55,662] kopf.activities.star [INFO ] click = 8.1.7
[2024-05-29 06:46:55,662] kopf.activities.star [INFO ] charset-normalizer = 3.3.2
[2024-05-29 06:46:55,662] kopf.activities.star [INFO ] certifi = 2024.2.2
[2024-05-29 06:46:55,662] kopf.activities.star [INFO ] cachetools = 5.3.2
[2024-05-29 06:46:55,662] kopf.activities.star [INFO ] attrs = 23.2.0
[2024-05-29 06:46:55,662] kopf.activities.star [INFO ] async-timeout = 4.0.3
[2024-05-29 06:46:55,662] kopf.activities.star [INFO ] aiosignal = 1.3.1
[2024-05-29 06:46:55,662] kopf.activities.star [INFO ] aiohttp = 3.8.5
[2024-05-29 06:46:55,663] kopf.activities.star [INFO ] pytz = 2024.1
[2024-05-29 06:46:55,663] kopf.activities.star [INFO ] pyOpenSSL = 23.3.0
[2024-05-29 06:46:55,663] kopf.activities.star [INFO ] PyNaCl = 1.4.0
[2024-05-29 06:46:55,663] kopf.activities.star [INFO ] pycparser = 2.21
[2024-05-29 06:46:55,663] kopf.activities.star [INFO ] paramiko = 2.11.0
[2024-05-29 06:46:55,663] kopf.activities.star [INFO ] oci = 2.122.0
[2024-05-29 06:46:55,663] kopf.activities.star [INFO ] cryptography = 41.0.7
[2024-05-29 06:46:55,663] kopf.activities.star [INFO ] circuitbreaker = 1.4.0
[2024-05-29 06:46:55,663] kopf.activities.star [INFO ] cffi = 1.16.0
[2024-05-29 06:46:55,663] kopf.activities.star [INFO ] bcrypt = 3.2.2
[2024-05-29 06:46:55,664] kopf.activities.star [INFO ] antlr4-python3-runtime = 4.13.1
[2024-05-29 06:46:55,687] kopf.activities.star [ERROR ] Activity 'on_startup' failed with an exception. Will retry.
Traceback (most recent call last):
File "/usr/lib/mysqlsh/python-packages/kopf/_core/actions/execution.py", line 279, in execute_handler_once
result = await invoke_handler(
File "/usr/lib/mysqlsh/python-packages/kopf/_core/actions/execution.py", line 374, in invoke_handler
result = await invocation.invoke(
File "/usr/lib/mysqlsh/python-packages/kopf/_core/actions/invocation.py", line 139, in invoke
await asyncio.shield(future) # slightly expensive: creates tasks
File "/usr/lib64/python3.9/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
File "/usr/lib/mysqlsh/python-packages/mysqloperator/controller/operator.py", line 44, in on_startup
operator_cluster.monitor_existing_clusters(clusters, logger)
File "/usr/lib/mysqlsh/python-packages/mysqloperator/controller/innodbcluster/operator_cluster.py", line 45, in monitor_existing_clusters
g_group_monitor.monitor_cluster(
File "/usr/lib/mysqlsh/python-packages/mysqloperator/controller/group_monitor.py", line 196, in monitor_cluster
account = RetryLoop(logger).call(cluster.get_admin_account)
File "/usr/lib/mysqlsh/python-packages/mysqloperator/controller/shellutils.py", line 93, in call
return f(*args)
File "/usr/lib/mysqlsh/python-packages/mysqloperator/controller/innodbcluster/cluster_api.py", line 1920, in get_admin_account
secrets = self.get_private_secrets()
File "/usr/lib/mysqlsh/python-packages/mysqloperator/controller/innodbcluster/cluster_api.py", line 1822, in get_private_secrets
api_core.read_namespaced_secret(f"{self.name}-privsecrets", self.namespace))
File "/usr/lib/mysqlsh/python-packages/kubernetes/client/api/core_v1_api.py", line 24803, in read_namespaced_secret
return self.read_namespaced_secret_with_http_info(name, namespace, **kwargs) # noqa: E501
File "/usr/lib/mysqlsh/python-packages/kubernetes/client/api/core_v1_api.py", line 24890, in read_namespaced_secret_with_http_info
return self.api_client.call_api(
File "/usr/lib/mysqlsh/python-packages/kubernetes/client/api_client.py", line 348, in call_api
return self.__call_api(resource_path, method,
File "/usr/lib/mysqlsh/python-packages/kubernetes/client/api_client.py", line 180, in __call_api
response_data = self.request(
File "/usr/lib/mysqlsh/python-packages/kubernetes/client/api_client.py", line 373, in request
return self.rest_client.GET(url,
File "/usr/lib/mysqlsh/python-packages/kubernetes/client/rest.py", line 240, in GET
return self.request("GET", url,
File "/usr/lib/mysqlsh/python-packages/kubernetes/client/rest.py", line 234, in request
raise ApiException(http_resp=r)
kubernetes.client.exceptions.ApiException: (404)
Reason: Not Found
HTTP response headers: HTTPHeaderDict({'Audit-Id': '5c0f3f37-3732-4581-89e2-3bca443c832d', 'Cache-Control': 'no-cache, private', 'Content-Type': 'application/json', 'X-Kubernetes-Pf-Flowschema-Uid': 'b1d36932-a72f-4dcb-8aa3-d0a7c8ffd4d2', 'X-Kubernetes-Pf-Prioritylevel-Uid': 'b6ec6262-e0cf-415e-bf76-09433fc2daa3', 'Date': 'Wed, 29 May 2024 06:46:55 GMT', 'Content-Length': '224'})
HTTP response body: {"kind":"Status","apiVersion":"v1","metadata":{},"status":"Failure","message":"secrets \"mysql-cluster-privsecrets\" not found","reason":"NotFound","details":{"name":"mysql-cluster-privsecrets","kind":"secrets"},"code":404}
我创建了一个 SaaS 产品。我使用 PHP 8.3 和 MySQL 8.0 数据库。在本地,这速度非常快!不使用框架等。生产在 Azure 上运行。我在 Azure 上进行了以下设置:
数据库
Azure Database for MySQL flexible server
- Burstable, B1s, 1 vCores, 1 GiB RAM, 20 GiB storage
- MySQL version 8
费用约为20欧元/月。
应用服务
Azure Web App
Basic B1, 100 ACU/vCPU, 1 vCPU, 1.75 memory (GB), 10 GB storage
OS: Linux
费用约为10欧元/月
我遇到的问题是,最初当随机用户访问我的网站并执行需要数据库查询的操作时。数据库一开始非常慢。可能是 3-10 秒!经过这个“热身”之后,访问该网站的每个新用户都没有任何延迟,并且数据库查询非常快。假设 30-60 分钟过去了,网站上没有任何活动,并且有新用户访问该网站,速度又变得非常慢。这不是我想要的。我需要做什么才能消除这种“热身”?
有人会说每月约 20 欧元的数据库性能会更好。我有更便宜、性能更好的 MySQL 数据库。
笔记:
我正在使用 MySQL v8.0.35 以及 django 和 python。网站用于访问数据库,网站和数据库均托管在 AWS 上。当网站尝试以任何方式访问数据库时,它会抛出以下错误:
OperationalError: (1045, "Access denied for user '<user>'@'*****' (using password: NO)")
主要问题是我不明白为什么网站不使用密码,尽管它包含在我的 django settings.py 文件中的数据库配置中。
对我来说,这很奇怪,因为当通过 ssh 进入网站实例时,我能够运行以下命令:
mysqladmin -h <endpoint> -u <user> -p version
与上面相同,当提示我输入密码时,它执行得很好。
我还可以在 ssh 时运行此命令登录数据库:
mysql -h <endpoint> -u <user> -p
此时我输入相同的密码并被允许进入。 当我检查用户的权限时,它会显示以下内容
[
在 django 用于获取任何数据库信息的设置文件中,这就是我所拥有的:
DATABASES={
'default': {
'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
'NAME': 'zombeewatch', # Or path to database file if using sqlite3.
'USER': '<user>', # Not used with sqlite3.
'PASSWORD': '<password>', # Not used with sqlite3.
'HOST': '<endpoint>', # Set to empty string for localhost. Not used with sqlite3.
'PORT': '3306', # Set to empty string for default. Not used with sqlite3.
}
}
我也可以python manage.py
毫无问题地使用,因此该程序似乎能够从我的设置文件中获取数据库、用户名和密码。
老实说,我不知道从这里该去哪里。我认为主要问题在于为什么网站在提供密码的情况下尝试在没有密码的情况下登录数据库。我知道有几个问题存在同样的错误,但它们背后的上下文似乎非常不同。如果我可以提供更多信息,请告诉我!
**请注意,我已确认我在文件中使用的密码是正确的。至少,当提示输入 mysql 和 mysqladmin 命令的密码时,它与我复制和粘贴的内容相同。