我正在尝试使用来自此处的任务定义来在ECS上安装Wordpress:https://docs.aws.amazon.com/AmazonECS/latest/developerguide/example_task_definitions.html。我在ECS(2个容器)上执行以下任务-json格式:
{
"ipcMode": null,
"executionRoleArn": "arn:aws:iam::548086034478:role/wpstream-ecsTaskExecution",
"containerDefinitions": [
{
"dnsSearchDomains": null,
"logConfiguration": {
"logDriver": "awslogs",
"secretOptions": null,
"options": {
"awslogs-group": "/ecs/wordpress-simple",
"awslogs-region": "us-east-1",
"awslogs-stream-prefix": "ecs"
}
},
"entryPoint": null,
"portMappings": [
{
"hostPort": 80,
"protocol": "tcp",
"containerPort": 80
}
],
"command": null,
"linuxParameters": null,
"cpu": 0,
"environment": [],
"resourceRequirements": null,
"ulimits": null,
"dnsServers": null,
"mountPoints": [],
"workingDirectory": null,
"secrets": null,
"dockerSecurityOptions": null,
"memory": null,
"memoryReservation": null,
"volumesFrom": [],
"stopTimeout": null,
"image": "wordpress",
"startTimeout": null,
"dependsOn": null,
"disableNetworking": null,
"interactive": null,
"healthCheck": null,
"essential": true,
"links": [
"mysql"
],
"hostname": null,
"extraHosts": null,
"pseudoTerminal": null,
"user": null,
"readonlyRootFilesystem": null,
"dockerLabels": null,
"systemControls": null,
"privileged": null,
"name": "wordpress"
},
{
"dnsSearchDomains": null,
"logConfiguration": {
"logDriver": "awslogs",
"secretOptions": null,
"options": {
"awslogs-group": "/ecs/wordpress-simple",
"awslogs-region": "us-east-1",
"awslogs-stream-prefix": "ecs"
}
},
"entryPoint": null,
"portMappings": [],
"command": null,
"linuxParameters": null,
"cpu": 0,
"environment": [
{
"name": "MYSQL_ROOT_PASSWORD",
"value": "cretu"
}
],
"resourceRequirements": null,
"ulimits": null,
"dnsServers": null,
"mountPoints": [],
"workingDirectory": null,
"secrets": null,
"dockerSecurityOptions": null,
"memory": null,
"memoryReservation": null,
"volumesFrom": [],
"stopTimeout": null,
"image": "mysql",
"startTimeout": null,
"dependsOn": null,
"disableNetworking": null,
"interactive": null,
"healthCheck": null,
"essential": true,
"links": null,
"hostname": null,
"extraHosts": null,
"pseudoTerminal": null,
"user": null,
"readonlyRootFilesystem": null,
"dockerLabels": null,
"systemControls": null,
"privileged": null,
"name": "mysql"
}
],
"memory": "512",
"taskRoleArn": "arn:aws:iam::548086034478:role/wpstream-ecsTaskExecution",
"family": "wordpress-simple",
"pidMode": null,
"requiresCompatibilities": [
"EC2"
],
"networkMode": "bridge",
"cpu": "256",
"inferenceAccelerators": [],
"proxyConfiguration": null,
"volumes": [],
"placementConstraints": [],
"tags": []
}
但是由于某种原因,worpdress容器无法连接到mysql容器。当我通过公共ip访问它时,在日志
中出现“建立数据库连接时出错”MySQL连接错误:(2002)连接被拒绝
我尝试在wordpress容器上添加WORDPRESS_DB_HOST,WORDPRESS_DB_USER,WORDPRESS_DB_NAME和WORDPRESS_DB_PASSWORD环境变量,但是没有运气。
你能告诉我我在做什么错吗? 谢谢
答案 0 :(得分:0)
问题是由新的mysql版本(8.0)更改了身份验证方法引起的。解决方案是使用旧的mysql映像(5.17)或在创建容器时使用此命令
default-authentication-plugin = mysql_native_password