Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Docker makes mysql image and automatically installs the script.

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)05/31 Report--

This article editor for you a detailed introduction of "docker production mysql image and automatic installation script how to write", the content is detailed, the steps are clear, the details are handled properly, I hope this "docker production mysql image and automatic installation script how to write" article can help you solve doubts, the following follow the editor's ideas slowly in-depth, together to learn new knowledge.

Create mysql docker image with one click in centos7 environment, and install it

The shell script contains the following:

# docker automatic installation mysqlecho-e "\ 033 [32m'> default installation parameters: >'\ 033 [0m" echo-e "\ 033 [32m 'port: 3309'\ 033 [0m" echo-e "\ 033 [32m' mapping host path: / mysql'\ 033 [0m" echo-e "\ 033 [32m 'password: xxxxxx'\ 033 [0m" echo-e "\ 033 [32m' container name: mysql8'\ 0m" Echo-e "\ 033 [32m 'enable binlog'\ 033 [0m" echo-e "\ 033 [32m' set the number of connections 1k'\ 033 [0m" echo-e "\ 033 [32m 'set connection timeout 24h'\ 033 [0m" echo-e "\ 033 [32m' setting use 4 cpu cores'\ 033 [0m" mkdir-p / mysql### 1 to download image docker pull mysqlif [$?-eq 0] then Echo-e "\ 033 [32m'> > 1 download image finish > >'> 033 [0m" else echo-e "\ 033 [31m'_ 1 download image bad And EXIT'\ 033 [0m "exit 1fielding rooms _ # create dockerfilerm-rf. / mymysql.yamlecho'# dockerfile custom mysql container image'> >. / mymysql.yamlecho 'FROM mysql:latest' > >. / mymysql.yamlecho' # use the official mysql image latest version'>. / mymysql.yamlecho''> >. / mymysql.yamlecho 'RUN echo "#" > / etc/mysql/my.cnf' > >. / mymysql.yamlecho''> >. / mymysql.yamlecho 'RUN echo "log_bin = 1" > > / etc/mysql / my.cnf' > >. / mymysql.yamlecho'# Open binlog log Stored in the default location'>. / mymysql.yamlecho''> >. / mymysql.yamlecho 'RUN echo "max_connections = 1050" > > / etc/mysql/my.cnf' > >. / mymysql.yamlecho' RUN echo "mysqlx_max_connections = 1000" > > / etc/mysql/my.cnf' >. / mymysql.yamlecho'# maximum number of connections'>. / mymysql.yamlecho''> >. / mymysql.yamlecho 'RUN echo "wait_timeout=86400" > / etc/mysql/my.cnf' > >. / mymysql .yamlecho 'RUN echo "interactive_timeout=86400" > > / etc/mysql/my.cnf' > >. / mymysql.yamlecho' # Idle disconnect duration Seconds'>. / mymysql.yamlecho''> >. / mymysql.yamlecho 'RUN echo "innodb_read_io_threads=4" > > / etc/mysql/my.cnf' > >. / mymysql.yamlecho' RUN echo "innodb_write_io_threads=4" > > / etc/mysql/my.cnf' > >. / mymysql.yamlecho'# setting uses multicore cpu. The default is 4 cores. Set'>. / mymysql.yaml###_ according to the number of cpu cores # using mymysql.yaml to build an image mymysql:1docker build-f. / mymysql.yaml-t "mymysql:1" .if [$?-eq 0] then echo-e "\ 033 [32m'> mymysql:1 image built successfully >'> 033 [0m" else echo-e "\ 033 [31m'_ _ _ mymysql:1 image build failed And EXIT'\ 033 [0m "exit 1fi### 2 create container docker create-p 3309 restart=always-- name mysql8-v / mysql/mysql_08/log:/var/log/mysql-v / mysql/mysql_08/data:/var/lib/mysql-v / etc/localtime:/etc/localtime-e MYSQL_ROOT_PASSWORD=xxxxx-it mymysql:1if [$?-eq 0] then echo-e"\ 033 [32m'> > 2 Create container finish > >'\ 033 [0m "else echo-e"\ 033 [31m'_ 2 create container bad And EXIT'\ 033 [0m "exit 1fi### 3 launch container docker start mysql8if [$?-eq 0] then echo-e"\ 033 [32m'> > 3 launch container finish > > '033 [0m "else echo-e"\ 033 [31m' _ 3 launch container bad And EXIT'\ 033 [0m "exit 1fi### displays container status echo-e"\ 033 [32m'> shows running container: '033 [0m "docker ps reads here This article "docker makes mysql image and automatically installs the script" has been introduced. If you want to master the knowledge of this article, you still need to practice and use it. If you want to know more about the article, please follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report