From 32885945919ad4325ebad7cb6c3f12360b3f437b Mon Sep 17 00:00:00 2001 From: Guilherme Andrade Del Cantoni Date: Sun, 2 Oct 2016 01:03:40 -0300 Subject: [PATCH] Atualização do MySQL para a versão 5.7 --- mysql/Dockerfile | 56 +++++--------------------------------------------------- mysql/install.sh | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ mysql/my.cnf | 23 ++++++++++++++++++----- 3 files changed, 82 insertions(+), 56 deletions(-) create mode 100644 mysql/install.sh diff --git a/mysql/Dockerfile b/mysql/Dockerfile index 6584ab5..f158e34 100644 --- a/mysql/Dockerfile +++ b/mysql/Dockerfile @@ -14,60 +14,14 @@ MAINTAINER PEN - Processo Eletrônico Nacional ################## INICIO DA INSTALACAO ###################### # Instalação do MySQL seguindo as recomendações descritas na documentação do SEI -# Instalar o yum repo rpm package -RUN yum install -y wget && \ - wget http://repo.mysql.com/mysql-community-release-el6-5.noarch.rpm && \ - rpm -ivh mysql-community-release-el6-5.noarch.rpm - -# Instalação do MySQL Server 5.X -RUN yum update -y && \ - yum install -y mysql-server && \ - yum -y clean all - # Cópia dos backups dos bancos de dados do SEI e SIP -ADD sei-db-ref-executivo/mysql/sei_2_6_0_BD_Ref_Exec.sql /tmp/sei_mysql.sql -ADD sei-db-ref-executivo/mysql/sip_2_6_0_BD_Ref_Exec.sql /tmp/sip_mysql.sql +ADD sei-db-ref-executivo/mysql/sei_2_6_0_BD_Ref_Exec.sql /opt/sei_mysql.sql +ADD sei-db-ref-executivo/mysql/sip_2_6_0_BD_Ref_Exec.sql /opt/sip_mysql.sql ADD my.cnf /etc/my.cnf +ADD install.sh /install.sh -# Configuração da estrutura inicial do banco de dados -RUN mysql_install_db - -# Criação dos bancos de dados do sistema -RUN /etc/init.d/mysqld start && \ - mysqladmin create sip && \ - mysqladmin create sei - -# Criação dos usuários utilizados na conexão com SEI e SIP -RUN /etc/init.d/mysqld start && \ - mysql -e "CREATE USER 'sip_user'@'%' IDENTIFIED BY 'sip_user'" sip && \ - mysql -e "CREATE USER 'sei_user'@'%' IDENTIFIED BY 'sei_user'" sei && \ - mysql -e "GRANT ALL PRIVILEGES ON sip.* TO 'sip_user'@'%'" sip && \ - mysql -e "GRANT ALL PRIVILEGES ON sei.* TO 'sei_user'@'%'" sei - -# Restauração dos bancos de dados -RUN /etc/init.d/mysqld start && cd /tmp && \ - mysql sei < sei_mysql.sql && \ - mysql sip < sip_mysql.sql && \ - rm -f /tmp/sei_mysql.sql /tmp/sip_mysql.sql - -# Atualização dos parâmetros do SEI e do SIP -RUN /etc/init.d/mysqld start && \ - mysql -e "update orgao set sigla='ABC', descricao='ORGAO ABC' where id_orgao=0;" sip && \ - mysql -e "update sistema set pagina_inicial='http://localhost/sip' where sigla='SIP';" sip && \ - mysql -e "update sistema set pagina_inicial='http://localhost/sei/inicializar.php', web_service='http://localhost/sei/controlador_ws.php?servico=sip' where sigla='SEI';" sip && \ - mysql -e "update orgao set sigla='ABC', descricao='ORGAO ABC' where id_orgao=0;" sei - -# Temp: Remove registros de auditoria presentes na base de referência -RUN /etc/init.d/mysqld start && \ - mysql -e "delete from auditoria_protocolo;" sei - -# Configuração para utilizar autenticação nativa do SEI/SIP -RUN /etc/init.d/mysqld start && \ - mysql -e "update orgao set sin_autenticar='N' where id_orgao=0;" sip - -# Atribuição de permissões de acesso externo para o usuário root, senha root -RUN /etc/init.d/mysqld start && \ - mysql -e "GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root' WITH GRANT OPTION;" +# Instalação do MySQL 5.7 e demais componentes +RUN bash install.sh ##################### FIM DA INSTALACAO ##################### diff --git a/mysql/install.sh b/mysql/install.sh new file mode 100644 index 0000000..4debff8 --- /dev/null +++ b/mysql/install.sh @@ -0,0 +1,59 @@ +#!/usr/bin/env bash + +set -e +set -u +set -o pipefail + +yum update -y + +# Instalar o yum repo rpm package +yum install -y wget +wget http://dev.mysql.com/get/mysql57-community-release-el6-7.noarch.rpm +yum localinstall -y mysql57-community-release-el6-7.noarch.rpm + +# Instalação do MySQL Server 5.X +yum install -y mysql-community-server + +# Inicialização do diretório de armazenamento do MySQL. +# PS: Utilizando configuração insegura apenas para propósito de desenvolvimento +rm -rf /var/lib/mysql/* +chown -R mysql:mysql /var/lib/mysql +mysqld --user=mysql --initialize-insecure + +# Inicialização do banco de dados +/etc/init.d/mysqld start + +# Criação dos bancos de dados do sistema +mysqladmin create sip +mysqladmin create sei + +# Criação dos usuários utilizados na conexão com SEI e SIP +mysql -e "CREATE USER 'sip_user'@'%' IDENTIFIED BY 'sip_user'" sip +mysql -e "CREATE USER 'sei_user'@'%' IDENTIFIED BY 'sei_user'" sei +mysql -e "GRANT ALL PRIVILEGES ON sip.* TO 'sip_user'@'%'" sip +mysql -e "GRANT ALL PRIVILEGES ON sei.* TO 'sei_user'@'%'" sei + +# Restauração dos bancos de dados +mysql sei < /opt/sei_mysql.sql +mysql sip < /opt/sip_mysql.sql +rm -f /opt/sei_mysql.sql /opt/sip_mysql.sql + +# Atualização dos parâmetros do SEI e do SIP +mysql -e "update orgao set sigla='ABC', descricao='ORGAO ABC' where id_orgao=0;" sip +mysql -e "update sistema set pagina_inicial='http://localhost/sip' where sigla='SIP';" sip +mysql -e "update sistema set pagina_inicial='http://localhost/sei/inicializar.php', web_service='http://localhost/sei/controlador_ws.php?servico=sip' where sigla='SEI';" sip +mysql -e "update orgao set sigla='ABC', descricao='ORGAO ABC' where id_orgao=0;" sei + +# Temp: Remove registros de auditoria presentes na base de referência +mysql -e "delete from auditoria_protocolo;" sei + +# Configuração para utilizar autenticação nativa do SEI/SIP +mysql -e "update orgao set sin_autenticar='N' where id_orgao=0;" sip + +# Atribuição de permissões de acesso externo para o usuário root, senha root +mysql -e "GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root' WITH GRANT OPTION;" + +yum clean -y all + + +exit 0 diff --git a/mysql/my.cnf b/mysql/my.cnf index c87f1cb..c5e0223 100644 --- a/mysql/my.cnf +++ b/mysql/my.cnf @@ -1,13 +1,26 @@ [mysqld] +# +# Remove leading # and set to the amount of RAM for the most important data +# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%. +# innodb_buffer_pool_size = 128M +# +# Remove leading # to turn on a very important data integrity option: logging +# changes to the binary log between backups. +# log_bin +# +# Remove leading # to set options mainly useful for reporting servers. +# The server defaults are faster for transactions and fast SELECTs. +# Adjust sizes as needed, experiment to find the optimal values. +# join_buffer_size = 128M +# sort_buffer_size = 2M +# read_rnd_buffer_size = 2M datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock -user=mysql + +# Disabling symbolic-links is recommended to prevent assorted security risks symbolic-links=0 -sql-mode=STRICT_TRANS_TABLES + max_allowed_packet=268435456 -innodb_change_buffering=none -[mysqld_safe] log-error=/var/log/mysqld.log pid-file=/var/run/mysqld/mysqld.pid - -- libgit2 0.21.2