質問編集履歴
2
タイトルを変更
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
Docker
|
1
|
+
DockerでMroongaストレージエンジンを持つMySQLを起動したい
|
test
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
### Docker
|
1
|
+
### DockerでMroongaストレージエンジンを持つMySQLを起動したい
|
2
2
|
|
3
3
|
### 前提
|
4
4
|
|
1
「試したこと」の内容を編集しました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -176,53 +176,245 @@
|
|
176
176
|
|
177
177
|
### 試したこと
|
178
178
|
|
179
|
-
Mroonga
|
179
|
+
公式のMySQLイメージにMroongaをインストールするのではなく、mroonga/docker(https://github.com/mroonga/docker)を使用する方法で対応してみました。
|
180
|
+
|
181
|
+
|
182
|
+
|
183
|
+
各ファイルを編集しました。
|
184
|
+
|
185
|
+
Dockerfileやmy.cnf は
|
186
|
+
|
187
|
+
https://github.com/mroonga/docker/blob/master/Dockerfile/mysql5723_mroonga807/Dockerfile
|
188
|
+
|
189
|
+
の内容を参考に、内容を変更しました。
|
180
190
|
|
181
191
|
|
182
192
|
|
183
193
|
```Dockerfile
|
184
194
|
|
185
|
-
FROM
|
195
|
+
FROM centos:centos6.9
|
196
|
+
|
186
|
-
|
197
|
+
MAINTAINER groonga
|
187
|
-
|
188
|
-
|
198
|
+
|
199
|
+
|
200
|
+
|
189
|
-
RUN
|
201
|
+
RUN yum upgrade -y
|
190
|
-
|
191
|
-
|
202
|
+
|
192
|
-
|
193
|
-
RUN
|
203
|
+
RUN yum install -y which
|
194
|
-
|
204
|
+
|
195
|
-
RUN a
|
205
|
+
RUN yum install -y http://packages.groonga.org/centos/groonga-release-1.4.0-1.noarch.rpm && yum clean all
|
206
|
+
|
196
|
-
|
207
|
+
RUN yum install -y https://dev.mysql.com/get/mysql80-community-release-el6-1.noarch.rpm && yum clean all
|
208
|
+
|
197
|
-
|
209
|
+
RUN yum install --enablerepo=mysql56-community --disablerepo=mysql57-community --disablerepo=mysql80-community -y mysql-community-client-5.6.41 mysql-community-server-5.6.41 && yum clean all
|
210
|
+
|
198
|
-
|
211
|
+
RUN yum install -y mysql-community-mroonga-8.07 groonga-8.0.7 groonga-tokenizer-mecab-8.0.7 groonga-normalizer-mysql && yum clean all
|
212
|
+
|
213
|
+
RUN chown -R mysql. /var/lib/mysql ; service mysqld start && mysql -e "GRANT ALL ON *.* TO root@'%' WITH GRANT OPTION" && mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql mysql && service mysqld stop
|
214
|
+
|
215
|
+
COPY my.cnf /etc/my.cnf
|
216
|
+
|
217
|
+
RUN rpm -q --scripts mysql-community-mroonga | sed -n '/^postinstall scriptlet/,/^[a-z][a-z]* scriptlet/p' | tail -n +2 | head -n -1 > /root/postinstall.sh
|
218
|
+
|
219
|
+
RUN rm /var/lib/mysql/auto.cnf /var/lib/mysql/groonga.log
|
220
|
+
|
199
|
-
|
221
|
+
COPY entrypoint.sh /root/entrypoint.sh
|
200
|
-
|
201
|
-
RUN apt-get update
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
RUN apt-get install -y -V mysql-server-mroonga
|
206
222
|
|
207
223
|
|
208
224
|
|
209
225
|
EXPOSE 3306
|
210
226
|
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
227
|
+
ENTRYPOINT ["/root/entrypoint.sh"]
|
228
|
+
|
229
|
+
```
|
230
|
+
|
231
|
+
|
232
|
+
|
233
|
+
```myCnf
|
234
|
+
|
235
|
+
# For advice on how to change settings please see
|
236
|
+
|
237
|
+
# http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html
|
238
|
+
|
239
|
+
|
240
|
+
|
241
|
+
[mysqld]
|
242
|
+
|
243
|
+
#
|
244
|
+
|
245
|
+
# Remove leading # and set to the amount of RAM for the most important data
|
246
|
+
|
247
|
+
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
|
248
|
+
|
249
|
+
# innodb_buffer_pool_size = 128M
|
250
|
+
|
251
|
+
#
|
252
|
+
|
253
|
+
# Remove leading # to turn on a very important data integrity option: logging
|
254
|
+
|
255
|
+
# changes to the binary log between backups.
|
256
|
+
|
257
|
+
# log_bin
|
258
|
+
|
259
|
+
#
|
260
|
+
|
261
|
+
# Remove leading # to set options mainly useful for reporting servers.
|
262
|
+
|
263
|
+
# The server defaults are faster for transactions and fast SELECTs.
|
264
|
+
|
265
|
+
# Adjust sizes as needed, experiment to find the optimal values.
|
266
|
+
|
267
|
+
# join_buffer_size = 128M
|
268
|
+
|
269
|
+
# sort_buffer_size = 2M
|
270
|
+
|
271
|
+
# read_rnd_buffer_size = 2M
|
272
|
+
|
273
|
+
datadir=/var/lib/mysql
|
274
|
+
|
275
|
+
socket=/var/lib/mysql/mysql.sock
|
276
|
+
|
277
|
+
|
278
|
+
|
279
|
+
# Disabling symbolic-links is recommended to prevent assorted security risks
|
280
|
+
|
281
|
+
symbolic-links=0
|
282
|
+
|
283
|
+
|
284
|
+
|
285
|
+
# Recommended in standard MySQL setup
|
286
|
+
|
287
|
+
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
|
288
|
+
|
289
|
+
|
290
|
+
|
291
|
+
### Added by yoku0825
|
292
|
+
|
293
|
+
character_set_server= utf8mb4
|
294
|
+
|
295
|
+
|
296
|
+
|
297
|
+
[mysqld_safe]
|
298
|
+
|
299
|
+
log-error=/var/log/mysqld.log
|
300
|
+
|
301
|
+
pid-file=/var/run/mysqld/mysqld.pid
|
302
|
+
|
303
|
+
```
|
304
|
+
|
305
|
+
|
306
|
+
|
307
|
+
```composeYml
|
308
|
+
|
309
|
+
version: "3"
|
310
|
+
|
311
|
+
services:
|
312
|
+
|
313
|
+
db:
|
314
|
+
|
315
|
+
build: ./mysql
|
316
|
+
|
317
|
+
ports:
|
318
|
+
|
319
|
+
- 3307:3306
|
320
|
+
|
321
|
+
environment:
|
322
|
+
|
323
|
+
MYSQL_ROOT_PASSWORD: root
|
324
|
+
|
325
|
+
TZ: Asia/Tokyo
|
326
|
+
|
327
|
+
volumes:
|
328
|
+
|
329
|
+
- ./mysql/mysql_data:/var/lib/mysql groonga/mroonga
|
330
|
+
|
331
|
+
container_name: "groonga"
|
332
|
+
|
333
|
+
phpmyadmin:
|
334
|
+
|
335
|
+
image: phpmyadmin/phpmyadmin:latest
|
336
|
+
|
337
|
+
links:
|
338
|
+
|
339
|
+
- db
|
340
|
+
|
341
|
+
ports:
|
342
|
+
|
343
|
+
- 8081:80
|
344
|
+
|
345
|
+
environment:
|
346
|
+
|
347
|
+
- PMA_ARBITRARY=1
|
348
|
+
|
349
|
+
- PMA_HOST=db
|
350
|
+
|
351
|
+
container_name: "phpmyamin-la"
|
352
|
+
|
353
|
+
```
|
354
|
+
|
355
|
+
|
356
|
+
|
357
|
+
また、Dockerfileとmy.cnfと同じディレクトリに、 entrypoint.sh を下記内容で配置しました。
|
358
|
+
|
359
|
+
|
360
|
+
|
361
|
+
```entrypointSh
|
362
|
+
|
363
|
+
#!/bin/bash
|
364
|
+
|
365
|
+
|
366
|
+
|
367
|
+
if [ ! -e /var/lib/mysql/ibdata1 ] ; then
|
368
|
+
|
369
|
+
### If overroded my.cnf is there, rename and restore it.
|
370
|
+
|
371
|
+
### See https://github.com/mroonga/docker/issues/59
|
372
|
+
|
373
|
+
[[ -e /etc/my.cnf ]] && mv -n /etc/my.cnf /etc/my.cnf.save
|
374
|
+
|
375
|
+
|
376
|
+
|
377
|
+
chown -R mysql. /var/lib/mysql
|
378
|
+
|
379
|
+
bash /root/postinstall.sh
|
380
|
+
|
381
|
+
service mysqld start
|
382
|
+
|
383
|
+
mysql -e "GRANT ALL ON *.* TO root@'%' WITH GRANT OPTION"
|
384
|
+
|
385
|
+
mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql mysql
|
386
|
+
|
387
|
+
service mysqld stop
|
388
|
+
|
389
|
+
|
390
|
+
|
391
|
+
### Restore my.cnf
|
392
|
+
|
393
|
+
[[ -e /etc/my.cnf.save ]] && mv /etc/my.cnf.save /etc/my.cnf
|
394
|
+
|
395
|
+
fi
|
396
|
+
|
397
|
+
|
398
|
+
|
399
|
+
oldowner=$(ls -ln /var/lib/mysql/ibdata1 | awk '{print $3}')
|
400
|
+
|
401
|
+
oldgroup=$(ls -ln /var/lib/mysql/ibdata1 | awk '{print $4}')
|
402
|
+
|
403
|
+
|
404
|
+
|
405
|
+
chown -R mysql. /var/lib/mysql
|
406
|
+
|
407
|
+
/usr/sbin/mysqld --user=mysql "$@"
|
408
|
+
|
409
|
+
|
410
|
+
|
411
|
+
chown -R $oldowner.$oldgroup /var/lib/mysql
|
412
|
+
|
413
|
+
```
|
414
|
+
|
415
|
+
|
416
|
+
|
417
|
+
上記の設定でbuildを行いました。
|
226
418
|
|
227
419
|
|
228
420
|
|
@@ -232,35 +424,25 @@
|
|
232
424
|
|
233
425
|
Building db
|
234
426
|
|
235
|
-
Step 1/1
|
427
|
+
Step 1/15 : FROM centos:centos6.9
|
428
|
+
|
236
|
-
|
429
|
+
centos6.9: Pulling from library/centos
|
430
|
+
|
431
|
+
993c50d47469: Already exists
|
432
|
+
|
433
|
+
Digest: sha256:48623f1cc1ff287ef4843888bcee22285066adf2d5da6daf000070bee83cd93a
|
434
|
+
|
435
|
+
Status: Downloaded newer image for centos:centos6.9
|
436
|
+
|
237
|
-
--->
|
437
|
+
---> e88c611d16a0
|
238
|
-
|
438
|
+
|
239
|
-
Step 2/1
|
439
|
+
Step 2/15 : MAINTAINER groonga
|
240
|
-
|
440
|
+
|
241
|
-
---> Running in 1
|
441
|
+
---> Running in 2bcced1f2a82
|
242
|
-
|
243
|
-
|
442
|
+
|
244
|
-
|
245
|
-
Get:3 http://repo.mysql.com/apt/debian stretch/mysql-5.7 amd64 Packages [5675 B]
|
246
|
-
|
247
|
-
Ign:2 http://cdn-fastly.deb.debian.org/debian stretch InRelease
|
248
|
-
|
249
|
-
Get:4 http://cdn-fastly.deb.debian.org/debian stretch-updates InRelease [91.0 kB]
|
250
|
-
|
251
|
-
Get:5 http://security.debian.org/debian-security stretch/updates InRelease [94.3 kB]
|
252
|
-
|
253
|
-
Get:6 http://cdn-fastly.deb.debian.org/debian stretch Release [118 kB]
|
254
|
-
|
255
|
-
Get:7 http://cdn-fastly.deb.debian.org/debian stretch-updates/main amd64 Packages [5152 B]
|
256
|
-
|
257
|
-
Get:8 http://security.debian.org/debian-security stretch/updates/main amd64 Packages [454 kB]
|
258
|
-
|
259
|
-
Get:9 http://cdn-fastly.deb.debian.org/debian stretch Release.gpg [2434 B]
|
260
|
-
|
261
|
-
Get:10 http://cdn-fastly.deb.debian.org/debian stretch/main amd64 Packages [7099 kB]
|
262
|
-
|
263
|
-
|
443
|
+
Removing intermediate container 2bcced1f2a82
|
444
|
+
|
445
|
+
---> 6a8b3793b27d
|
264
446
|
|
265
447
|
|
266
448
|
|
@@ -268,19 +450,75 @@
|
|
268
450
|
|
269
451
|
|
270
452
|
|
271
|
-
Step
|
453
|
+
Step 13/15 : COPY entrypoint.sh /root/entrypoint.sh
|
454
|
+
|
272
|
-
|
455
|
+
---> 79b9820f0b6a
|
456
|
+
|
457
|
+
Step 14/15 : EXPOSE 3306
|
458
|
+
|
459
|
+
---> Running in 4dee21467386
|
460
|
+
|
461
|
+
Removing intermediate container 4dee21467386
|
462
|
+
|
463
|
+
---> 934e3e1567b0
|
464
|
+
|
465
|
+
Step 15/15 : ENTRYPOINT ["/root/entrypoint.sh"]
|
466
|
+
|
273
|
-
---> Running in 5
|
467
|
+
---> Running in 5eb08b8d6109
|
468
|
+
|
274
|
-
|
469
|
+
Removing intermediate container 5eb08b8d6109
|
470
|
+
|
471
|
+
---> 1afe083dfee4
|
472
|
+
|
473
|
+
Successfully built 1afe083dfee4
|
474
|
+
|
475
|
+
Successfully tagged mysql_db:latest
|
476
|
+
|
275
|
-
|
477
|
+
phpmyadmin uses an image, skipping
|
276
|
-
|
277
|
-
|
478
|
+
|
278
|
-
|
279
|
-
```
|
479
|
+
```
|
480
|
+
|
481
|
+
|
482
|
+
|
280
|
-
|
483
|
+
buildは通りました。
|
281
|
-
|
282
|
-
|
484
|
+
|
485
|
+
|
486
|
+
|
283
|
-
|
487
|
+
コンテナを起動しました。
|
488
|
+
|
489
|
+
|
490
|
+
|
491
|
+
```
|
492
|
+
|
493
|
+
PS C:\Docker\Mysql> docker-compose up -d
|
494
|
+
|
495
|
+
Starting groonga ... done
|
496
|
+
|
497
|
+
Creating phpmyamin-la ... done
|
498
|
+
|
499
|
+
```
|
500
|
+
|
501
|
+
|
502
|
+
|
503
|
+
確認したところ
|
504
|
+
|
505
|
+
|
506
|
+
|
507
|
+
```
|
508
|
+
|
509
|
+
PS C:\Docker\Mysql> docker ps
|
510
|
+
|
511
|
+
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
|
512
|
+
|
513
|
+
9866db4e93cf phpmyadmin/phpmyadmin:latest "/run.sh supervisord…" 39 seconds ago Up 35 seconds 9000/tcp, 0.0.0.0:8081->80/tcp phpmyamin-la
|
514
|
+
|
515
|
+
```
|
516
|
+
|
517
|
+
|
518
|
+
|
519
|
+
PHP MyAdminのみコンテナが起動し、Mroongaは起動していませんでした。
|
520
|
+
|
521
|
+
MySQLへの接続もできない状態でした。
|
284
522
|
|
285
523
|
|
286
524
|
|