20210606のMySQLに関する記事は9件です。

【M1 mac】docker-composeでMySQLを使用した時のエラー解消法

Laravelのwebアプリ作成のためにdocker-composeで環境構築をしており、MySQLを使用しようとしたらエラーが発生しました。 無事にエラーを解消できたので、エラー解消方法についてメモします。 開発環境 M1 mac使用 docker-compose version'3' MySQL '5.7' docker-compose.ymlの記載内容 docker-compose.ymlには以下のような内容で記載していました。 version: '3' services: web:   〜中略〜 app:   〜中略〜 mysql: image: mysql:5.7 environment: MYSQL_DATABASE: sample MYSQL_USER: user MYSQL_PASSWORD: password MYSQL_ROOT_PASSWORD: password ports: - "3306:3306" volumes: - mysql-data:/var/lib/mysql volumes: mysql-data: 発生したエラー 上記の内容の通り、docker-composeでMySQLを使用したところ以下のようなエラーが発生しました。 docker: no matching manifest for linux/arm64/v8 in the manifest list entries. エラーの原因と解消方法 調べたところM1macを使用していると発生するエラーとのこと。 解決方法としてdocker-compose.ymlにplatform指定をすれば良いらしい。 version: '3' services: web:   〜中略〜 app:   〜中略〜 mysql:          platform: linux/x86_64 #M1 mac対応のためこのコードを追記 image: mysql:5.7 environment: MYSQL_DATABASE: sample MYSQL_USER: user MYSQL_PASSWORD: password MYSQL_ROOT_PASSWORD: password ports: - "3306:3306" volumes: - mysql-data:/var/lib/mysql volumes: mysql-data: これで無事にdocker-composeでMySQLを使用することができました!!
  • このエントリーをはてなブックマークに追加
  • Qiitaで続きを読む

Redmine バージョンアップにおける番外編

はじめに 概要 調査・検討 / 構築 / 移行 / 番外編 のうちの、番外編 です バージョンアップに伴う他作業も含めてシステム移行として扱います 記事の全体構成 その1 概要・調査検討 その2 構築 その3 移行 その4 Redmine バージョンアップにおける番外編(このページ) バージョンアップ・移行とは異なる視点の内容です 番外編 RedMicaの説明 番外編1)RedmineのDockerをdocker-compose upで動かす例 番外編2)Redmine3.2を構築した事例 番外編3)VMWare仮想マシンへのディスク追加 番外編4)markdown用のプラグイン RedMica remica v1.3.0 を使うと、 Redmine5.0として取り込まれる機能が先行して使える、1ヶ月に1回くらいはリリースされる We are pleased to announce the release of RedMica 1.2.1 (2021-05). RedMica 1.3.0 is based on Redmine 4.2.1. This version delivers all the features provided in Redmine 4.2.1 and some new features that will be included in Redmine 5.0.0. 番外編1)docker使ってみる windows dockerでの試し 事前に、docker, WSL2 , docker-compose を利用できるようにしておく PS :Power shell のことです 事前準備ができていれば、10分かからずにRedmineが起動できます docker-compose.yml ファイルのサンプル redmine4.1のdockerイメージを使います version: '3.8' services: redmine: image: redmine:4.1 networks: - frontend volumes: - ./data/volume:/usr/src/redmine/files restart: always ports: - 8080:3000 environment: REDMINE_DB_MYSQL: db REDMINE_DB_PASSWORD: example REDMINE_SECRET_KEY_BASE: supersecretkey depends_on: - db db: image: mysql:5.7 command: mysqld --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci networks: - frontend volumes: - ./data/database:/var/lib/mysql restart: always environment: MYSQL_ROOT_PASSWORD: example MYSQL_DATABASE: redmine networks: frontend: コンテナ起動 PS > cd xxxx ymlファイルのある場所へ移動 PS > docker-compose up ホストの8080にアクセス、コンテナの3000をホストの8080へフォワードされているので、 http://127.0.0.1:8080/ でredmineにアクセスできる (左にホストのポートを、右にコンテナのポートを指定している) 番外編2)昔のRedmine3.2の環境整備(Apache + MySQL) Redmine3.2を構築した時にインストールした時の情報 Redmine3.2の当時の情報のため情報が古いため注意してください 5年以上古いです(2016年4,5月頃の情報です) 参考にした https://weblabo.oscasierra.net/install-redmine32-centos7-1/ とほぼ同じ手順で入れています Apacheをインストールする # yum install httpd # systemctl enable httpd.service MySQLをインストールする CentOS7に入っているmariadbを消してmysqlを入れている # yum remove mariadb-libs # rm -rf /var/lib/mysql/ # yum localinstall http://dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpm # yum info mysql # yum info mysql-community-server 起動 # systemctl start mysqld.service 停止 # systemctl stop mysqld.service Ruby 2.2.3をインストールする # yum install git # cd /opt # git clone git://github.com/sstephenson/rbenv.git # echo 'export RBENV_ROOT="/opt/rbenv"' >> /etc/profile # echo 'export PATH="${RBENV_ROOT}/bin:${PATH}"' >> /etc/profile # echo 'eval "$(rbenv init -)"' >> /etc/profile # mkdir /opt/rbenv/plugins # cd /opt/rbenv/plugins # git clone git://github.com/sstephenson/ruby-build.git 一度ターミナルを閉じて開き直し、続けて次のコマンド実行します。 # yum install gcc make openssl-devel readline-devel # rbenv install 2.2.3 # rbenv global 2.2.3 # ruby -v Phusion Passenger をインストールする # gem list passenger # gem install passenger  2-3分くらいかかる # gem list passenger # yum install gcc gcc-c++ libcurl-devel openssl-devel zlib-devel httpd-devel apr-devel apr-util-devel ImageMagick ImageMagick-devel 5分くらいはかかる Redmine 3.2 をインストールする # yum install ipa-pgothic-fonts # gem install bundle インストールが終わったら一度ターミナルを閉じて立ち上げなおしてください。 redmine3.2.1が最新なので、3.2.1にする。 # curl -O http://www.redmine.org/releases/redmine-3.2.1.tar.gz # tar xzvf redmine-3.2.1.tar.gz # mv redmine-3.2.1 /opt/ cd /opt/redmine-3.2.1/config vi database.yml Redmine に MySQL への接続設定を行います。 Redmine フォルダの下の config ディレクトリに database.yml というファイルを作成し、以下を記述します。 ※ 新規構築 する場合は encoding: utf8mb4 にする production: adapter: mysql2 database: xxxx host: localhost username: yyyyy password: zzzz encoding: utf8 Redmine yml 設定後 bundle コマンドにより、必要な GEM をインストールします。 # yum install mysql-devel # cd /opt/redmine-3.2.1/ # bundle install --without development test # bundle exec rake generate_secret_token # RAILS_ENV=production bundle exec rake db:migrate 最後に、Apache が Redmine の実行者になるので Redmine のファイルの所有者を apache ユーザーに変更します。 # chown -R apache:apache /opt/redmine-3.2.1 Apacheの設定,passengerを使う設定 LoadModule passenger_module /opt/rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/passenger-5.0.26/buildout/apache2/mod_passenger.so PassengerRoot /opt/rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/passenger-5.0.26 PassengerDefaultRuby /opt/rbenv/versions/2.2.3/bin/ruby <VirtualHost *:80> ServerName myhost.com DocumentRoot /opt/redmine-3.2.1/public <Directory /opt/redmine-3.2.1/public> AllowOverride all Options -MultiViews </Directory> </VirtualHost> apache、URLが http://domain/redmine のように ドメインの後に redmine がある場合(もしくは複数Redmineを1ドメインでホストするような場合 cd /var/www/html sudo ln -s /opt/redmine-3.2.1/public redmine ssl yum install mod_ssl firewalldでHTTPSを許可 番外編3)VMWare仮想マシンへのディスク追加 かなり古いvSphereで作業してて、新しいvCenterの方にもっていくその前段階の作業 参考 - https://qiita.com/a-killer-bee/items/564d51034c125d192df3 - https://qiita.com/kaihei777/items/082f1dce8840b333bf0b - http://webos-goodies.jp/archives/50480376.html のパーティション設定を参考に 仮想マシンにディスクを追加する CentOS7.x 作業はGUI vsphere使う vSphere 仮想マシン設定編集 → タブ「ハードウェア」、ボタン「追加」を押す →デバイスタイプで、ハードディスクを選択 →次へ →新規仮想ディスクを作成→ディスクサイズ 50GB → ディスクプロビジョニングがThin Provisionで選択不可 → 場所は、「仮想マシンで保存」の選択のまま →次へ→仮想デバイスノード SCSI(0:1)で良い(1つしかないならば、0:1で、2つあるならば0:2になる) →進めて 終了でディスク追加が動く、数分かからず完了する ディスク追加前 # df -k ファイルシス 1K-ブロック 使用 使用可 使用% マウント位置 /dev/mapper/centos-root 40456908 37540036 2916872 93% / devtmpfs 1925652 0 1925652 0% /dev tmpfs 1941196 84 1941112 1% /dev/shm tmpfs 1941196 9040 1932156 1% /run tmpfs 1941196 0 1941196 0% /sys/fs/cgroup /dev/sda1 508588 160904 347684 32% /boot /dev/mapper/centos-home 19748864 492600 19256264 3% /home tmpfs 388240 12 388228 1% /run/user/42 tmpfs 388240 0 388240 0% /run/user/0 # ls /dev/sd* /dev/sda /dev/sda1 /dev/sda2 ディスク追加 仮想マシンをシャットダウン 50GBをthinプロビジョニング(デフォルト)で追加 仮想マシンを電源オン # df -h; ファイルシス サイズ 使用 残り 使用% マウント位置 /dev/mapper/centos-root 39G 36G 3.5G 91% / devtmpfs 1.9G 0 1.9G 0% /dev tmpfs 1.9G 84K 1.9G 1% /dev/shm tmpfs 1.9G 8.9M 1.9G 1% /run tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup /dev/sda1 497M 158M 340M 32% /boot /dev/mapper/centos-home 19G 482M 19G 3% /home tmpfs 380M 12K 380M 1% /run/user/42 tmpfs 380M 0 380M 0% /run/user/0 # df -k; ファイルシス 1K-ブロック 使用 使用可 使用% マウント位置 /dev/mapper/centos-root 40456908 36812604 3644304 91% / devtmpfs 1925652 0 1925652 0% /dev tmpfs 1941196 84 1941112 1% /dev/shm tmpfs 1941196 9044 1932152 1% /run tmpfs 1941196 0 1941196 0% /sys/fs/cgroup /dev/sda1 508588 160904 347684 32% /boot /dev/mapper/centos-home 19748864 492600 19256264 3% /home tmpfs 388240 12 388228 1% /run/user/42 tmpfs 388240 0 388240 0% /run/user/0 # ls -l /dev/sd* brw-rw---- 1 root disk 8, 0 3月 23 16:27 /dev/sda brw-rw---- 1 root disk 8, 1 3月 23 16:27 /dev/sda1 brw-rw---- 1 root disk 8, 2 3月 23 16:27 /dev/sda2 brw-rw---- 1 root disk 8, 16 3月 23 16:27 /dev/sdb 追加されたのが、 /dev/sdb dev/sdb をファイルシステム作成、xfsで作成する、CentOS7のデフォルト # df -k ファイルシス 1K-ブロック 使用 使用可 使用% マウント位置 /dev/mapper/centos-root 40456908 37539028 2917880 93% / devtmpfs 1925652 0 1925652 0% /dev tmpfs 1941196 84 1941112 1% /dev/shm tmpfs 1941196 9044 1932152 1% /run tmpfs 1941196 0 1941196 0% /sys/fs/cgroup /dev/sda1 508588 160904 347684 32% /boot /dev/mapper/centos-home 19748864 492600 19256264 3% /home tmpfs 388240 12 388228 1% /run/user/42 tmpfs 388240 0 388240 0% /run/user/0 # ls /dev/sd* /dev/sda /dev/sda1 /dev/sda2 /dev/sdb # shutdown -h now ここから fdisk # fdisk /dev/sdb Welcome to fdisk (util-linux 2.23.2). Changes will remain in memory only, until you decide to write them. Be careful before using the write command. Device does not contain a recognized partition table Building a new DOS disklabel with disk identifier 0xc5f01c04. コマンド (m でヘルプ): n Partition type: p primary (0 primary, 0 extended, 4 free) e extended Select (default p): p ★pを選択する パーティション番号 (1-4, default 1): 1 ★1を入力する 最初 sector (2048-104857599, 初期値 2048): 初期値 2048 を使います Last sector, +sectors or +size{K,M,G} (2048-104857599, 初期値 104857599): 初期値 104857599 を使います Partition 1 of type Linux and of size 50 GiB is set コマンド (m でヘルプ): p ★pを入力する Disk /dev/sdb: 53.7 GB, 53687091200 bytes, 104857600 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O サイズ (最小 / 推奨): 512 バイト / 512 バイト Disk label type: dos ディスク識別子: 0xc5f01c04 デバイス ブート 始点 終点 ブロック Id システム /dev/sdb1 2048 104857599 52427776 83 Linux コマンド (m でヘルプ): w ★wを入力する パーティションテーブルは変更されました! ioctl() を呼び出してパーティションテーブルを再読込みします。 ディスクを同期しています。 終わり まだ、この時点ではマウントしていないので見えない # df -h; ファイルシス サイズ 使用 残り 使用% マウント位置 /dev/mapper/centos-root 39G 36G 3.5G 91% / devtmpfs 1.9G 0 1.9G 0% /dev tmpfs 1.9G 84K 1.9G 1% /dev/shm tmpfs 1.9G 8.9M 1.9G 1% /run tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup /dev/sda1 497M 158M 340M 32% /boot /dev/mapper/centos-home 19G 482M 19G 3% /home tmpfs 380M 16K 380M 1% /run/user/42 tmpfs 380M 0 380M 0% /run/user/0 # ls /dev/sd* /dev/sda /dev/sda1 /dev/sda2 /dev/sdb /dev/sdb1 xfsでフォーマットする mkfs -t xfs /dev/sdb1 # mkfs -t xfs /dev/sdb1 meta-data=/dev/sdb1 isize=256 agcount=4, agsize=3276736 blks = sectsz=512 attr=2, projid32bit=1 = crc=0 finobt=0 data = bsize=4096 blocks=13106944, imaxpct=25 = sunit=0 swidth=0 blks naming =version 2 bsize=4096 ascii-ci=0 ftype=0 log =internal log bsize=4096 blocks=6399, version=2 = sectsz=512 sunit=0 blks, lazy-count=1 realtime =none extsz=4096 blocks=0, rtextents=0 マウントする mkdir /mnt/disk2 mount /dev/sdb1 /mnt/disk2 # ls -l /dev/sd* brw-rw---- 1 root disk 8, 0 3月 23 16:27 /dev/sda brw-rw---- 1 root disk 8, 1 3月 23 16:27 /dev/sda1 brw-rw---- 1 root disk 8, 2 3月 23 16:27 /dev/sda2 brw-rw---- 1 root disk 8, 16 3月 23 16:38 /dev/sdb brw-rw---- 1 root disk 8, 17 3月 23 16:41 /dev/sdb1 # mount /dev/sdb1 /mnt/disk2 # df -h; ファイルシス サイズ 使用 残り 使用% マウント位置 /dev/mapper/centos-root 39G 36G 3.5G 91% / devtmpfs 1.9G 0 1.9G 0% /dev tmpfs 1.9G 84K 1.9G 1% /dev/shm tmpfs 1.9G 8.9M 1.9G 1% /run tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup /dev/sda1 497M 158M 340M 32% /boot /dev/mapper/centos-home 19G 482M 19G 3% /home tmpfs 380M 16K 380M 1% /run/user/42 tmpfs 380M 0 380M 0% /run/user/0 /dev/sdb1 50G 33M 50G 1% /mnt/disk2 fstabを編集する /dev/sdb1 /mnt/disk2 xfs defaults 1 2 # cat /etc/fstab # # /etc/fstab # Created by anaconda on Thu Apr 14 10:09:26 2016 # # Accessible filesystems, by reference, are maintained under '/dev/disk' # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info # /dev/mapper/centos-root / xfs defaults 0 0 UUID=XXXXXXXX-XXXX-XXXX-XXXX-2ac4b7f07fe8 /boot xfs defaults 0 0 /dev/mapper/centos-home /home xfs defaults 0 0 /dev/mapper/centos-swap swap swap defaults 0 0 /dev/sdb1 /mnt/disk2 xfs defaults 1 2 追加したディスクでRedmineのfilesを使えるようにする # cd /mnt/disk2 # mkdir redmine # mkdir redmine/files # chown -R apache:apache ./redmine # ls -l -R configuration.yml の修正 {path/to/redmine}/config/configuration.yml に 行追加、末尾のfilesの後に/スラッシュは不要 変更後例 # cat configuration.yml production: email_delivery: attachments_storage_path: /mnt/disk2/redmine/files filesのファイルコピー redmine3.2のfilesをマウントした、Redmine4でのconfig設定した場所へ # pwd /opt/redmine-3.2.0/files # cp -ap * /mnt/disk2/redmine/files/ & filesの動作確認 画面からファイルアップロードして確認 画面からファイルをダウンロードして確認 番外編4)markdownを使えるプラグイン Redmine全体のを変えてしまうと、独自のコンバートが必要 Redmineの利用者でチケットを主に使うのは設計者、テスターになり、プログラマーの利用率よりも多い 利用者はRedmineの記法を使う人はまあまあ多く、プログラマーだとmarkdown使う、そのため、全体を変えると影響が大きい プラグイン2種類 https://redmine.tokyo/issues/1036 を見ると redmine_per_project_formatting ( https://github.com/a-ono/redmine_per_project_formatting) PJ/Module単位でTextile/Markdownを選択できる。 4.0対応なのでdemoサーバで試行したところ動作良好。お勧めします。 redmine_persist_wfmt( https://github.com/pinzolo/redmine_persist_wfmt) wiki,コメント単位でTextile/Markdownを選択できる。 プロジェクト単位で切替えできるプラグインではmarkdownで書きたい人には向かない 途中から導入できコメント単位でmarkdownと従来記法が選べるプラグインがあるのでそれが良いか(でも都度選択するのは手間か・・・) プラグインredmine_persist_wfmtを試してみた https://github.com/pinzolo/redmine_persist_wfmt がコメント単位でmarkdwonを使うことができるようになるプラグイン プラグインのマイグレーションで約30分かかった プラグインの導入 githubのreadme.mdの手順通り cd /path/to/redmine/ Clone to your Redmine's plugins directory(Redmineのプラグインのディレクトリに git cloneする) $ git clone https://github.com/pinzolo/redmine_persist_wfmt.git plugins/redmine_persist_wfmt Install dependency gems If you are already using Redmine, you probably only call bundle.(既にRedmineを使っているのであれば、bundleを使う) $ bundle install --without test development Execute migration(プラグインのマイグレーションを実行する) $ bundle exec rake redmine:plugins:migrate NAME=redmine_persist_wfmt RAILS_ENV=production Execute persist_all task This task saves all wiki formats that already exist.(既にwiki記法の記載があるならばrakeコマンド実行する) # FORMAT is required and must be 'textile' or 'markdown' $ bundle exec rake pwfmt:persist_all FORMAT=textile RAILS_ENV=production Restart your Redmine(Redmineを再起動)
  • このエントリーをはてなブックマークに追加
  • Qiitaで続きを読む

Redmineのバージョンアップ(Redmine3.2 -> 4.1とRedmica1.2への切り替え)その3(移行)

はじめに 概要 調査・検討 / 構築 / 移行 / 番外編 のうちの、移行です バージョンアップに伴う他作業も含めてシステム移行として扱います 記事の全体構成 その1 概要・調査検討 その2 構築 その3 移行(このページ) その4 Redmine バージョンアップにおける番外編 事前 システム移行は、計画完了で8割は終わる、後は実作業とトラブル対応 リハーサル等を実施し、作業ごとの時間を計測しておく 簡易なタイムスケジュールを作成しておく どの作業に、XX分 同時並行はできないため、事前に停止日時を調整・アナウンスしておく 利用者が少ない段階では、大きな調整は不要。利用者が多くなると調整が難航する 何らかのシステムとリリースが絡むとRedmineを止められないケースがある 翌日が休みの場合は控える、金曜リリースは控える 切り戻しプランを考えておく システム切替え等は、中止がありえるため以前の状態で稼働させることが必要なケースがある 今回はVMWareかつ別のインスタンスへ切替えるため切り戻しはIPを戻す程度 同じインスタンス内でバージョンアップ等する場合は戻せることを確認しておく。また、VMWareのスナップショット機能を使うならば、いったんOSシャットダウンしてから取得すると高速に取得できる。 MySQLのmysqldumpはVMWareのスナップショット機能で戻せない場合のデータ復旧用。dumpしたファイルは別の場所に置くこと 稼働確認の確認手順、項目を洗い出しておくこと IP アドレスの例です、現行と新のIP切替えの想定表 移行前 IPアドレス 移行元(現行) 192.168.0.8 移行先 (新) 192.168.0.10 移行後 IPアドレス コメント 移行元(現行) 192.168.0.11 何らか調査用に別IPアドレスに変更して見られるよにしておく 移行先 (新) 192.168.0.8 現行のIPに変更することで、外側からのルーティング等の変更不要 タイムスケジュール 前提、Redmine4.1.1の後のRedmica1.2が動作検証していたRedmine関連ファイル・ディレクトリ等はそのままあること MySQLのデータ、files以外は全て移行後と同じ状態 Redmineでは、初期の頃は filesのファイルがfilesディレクトリ直下にファイルが置かれていたが、yyyy/mm のディレクトリにアップロードされるようになったため、差分や増分がわかりやすくなっている 移行の1ヶ月前くらいからのファイルを差分移行(上書き)することでfilesの移行容量は減らすことができる 日々 rsync等で移行する方法もある、rsync使う場合は移行時に最終のrsyncを実行すれば良い syncの注意点は、今回の環境移行では発生しないが、相互にrsyncすると 移行完了後に現行(移行後に使わない)を残したままにしておくと、新の方が消えることがありえるので注意 以下のタイムスケジュールを策定(サンプル) 対象 時間 所要時間 内容 新 事前作業 TD データベースは残したまま、テーブルをdropしておく。データベースへのアクエス権限許可設定があるため、設定をいかすためテーブル削除まで 新 事前作業 TD MySQLのconfとRedmineのdatabase.ymlは、utf8に戻しておく、移行元はutf8で、マイグレーション完了後にutf8mb4にする、Redmineが使うデータベースはutf8mb4のままでも良い 新 事前作業 TD filesの事前移行、rsync等で対応するか、事前に大量移行しておくか 現行 XX:XX 1 停止アナウンス 現行 XX:XX 1 Apacheの停止、ログを見てアクセスないことを確認する 現行 XX:XX 5 MySQLのデータベースのバックアップ mysqldumpの実行。結果ファイルを新へ転送、一部のシーケンスやテーブルのレコード件数を移行時のチェックに使う 現行 XX:XX 5 filesの特定ディレクトリを圧縮し、新へ転送 新 XX:XX 15 mysqldumpをインポート 新 XX:XX 1 インポート結果の確認(テーブル数、レコード件数等) 新 XX:XX 10 ALTERを実行(カラムのデフォルト値変更) 新 XX:XX 10 db:migrateを実行 新 XX:XX 5 プラグインのマイグレーションを実行 新 XX:XX 1 シークレットキー 新 XX:XX 1 キャッシュクリア 新 XX:XX 15 Redmineが使うテーブルとDatabaseの文字エンコーディング変更、Redmineのdatabase.ymlでのエンコード変更 新 XX:XX 1 Apache起動 新 XX:XX 15 ログイン、チケット一覧 程度の動作確認 新 XX:XX 1 テーマの変更 新 XX:XX 1 プラグインの設定変更 新 XX:XX 15 プラグイン等の動作確認 新 XX:XX 5 Git、SVN連けい 新 XX:XX 15 プラグイン切替えした代替の設定や変更 新 XX:XX 10 新の方に現行から転送したfilesの特定ディレクトリを反映(上書き) 新 XX:XX 5 動作確認 新 XX:XX 1 新に切替えるか判断 現行 XX:XX 1 IP変更する 新 XX:XX 1 IPを現行のIPに変更する 新 XX:XX 1 Apache reload 、外側インターネット越しに動作確認 新 XX:XX 1 移行完了のアナウンス 現行 XX:XX 1 cronを止める、後日にOSシャットダウン 新 XX:XX -- 翌日等に、バックアップ、ログ等の確認、モニタリング 移行作業結果 タイムスケジュール想定通り スケジュール上は余裕をもっていたが、稼働確認を入念にしたたため想定通りの終了時間になった アナウンス上での停止時間は90分 作業時の小手先スクリプト等 MySQLのmysqldumpのエクスポートとインポート 現行でエクスポート、gz圧縮も合わせてしている、ファイル出力先の容量に気をつける mysqldump -uユーザ -pパスワード --no-tablespaces 対象データベース | gzip > /var/tmp/redmine_`date +%y_%m_%d`.gz scpコマンドで現行から新に転送 コマンド割愛 新でRedmineが利用するデータベースはcreateせず、Redmica1.2で稼働させていたものが存在する前提 cd XXX mysql -u ユーザー(rootでも可) -pパスワード(後入力でも可) インポートするデータベース < redmine_21_04_XX テーブル数 インポート後は、75テーブル、Redmine4.1にバージョンアップすると76になる custom_values のテーブルに yyyymmddが付与されたテーブルの数により変わる MySQLの特定のデータベースのテーブル一覧をDropするSQL https://www.cyberciti.biz/faq/how-do-i-empty-mysql-database/ を参考に mysql-drop-tableForRedmine.sh のようなファイル名として #!/bin/bash MUSER="$1" MPASS="$2" MDB="$3" # Detect paths MYSQL=$(which mysql) AWK=$(which awk) GREP=$(which grep) if [ $# -ne 3 ] then echo "Usage: $0 {MySQL-User-Name} {MySQL-User-Password} {MySQL-Database-Name}" echo "Drops all tables from a MySQL" exit 1 fi TABLES=$($MYSQL -u $MUSER -p$MPASS $MDB -e 'show tables' | $AWK '{ print $1}' | $GREP -v '^Tables' ) for t in $TABLES do echo "Deleting $t table from $MDB database..." ## $MYSQL -u $MUSER -p$MPASS $MDB -e "drop table $t" done ## の コメント外すとdrop tableされる 実行 ./mysql-drop-tableForRedmine.sh user password database MySQLのALTER文を生成 MySQL 内 redmineが使うデータベースのテーブル一覧からALTER文を作成 (の記号からそのまんま実行する # (mysql -uXXXX -p データベース名 -e "show tables" --batch --skip-column-names | xargs -I{} echo 'alter table `'{}'` convert to character set utf8mb4;') > /tmp/alters_table_CHARSET.sql Enter password: 結果ファイル cat /tmp/alters.sql alter table `ar_internal_metadata` convert to character set utf8mb4; alter table `attachments` convert to character set utf8mb4; alter table `auth_sources` convert to character set utf8mb4; alter table `boards` convert to character set utf8mb4; alter table `changes` convert to character set utf8mb4; alter table `changeset_parents` convert to character set utf8mb4; alter table `changesets` convert to character set utf8mb4; ・・・ ・・ MySQLのテーブルの文字エンコーディングを確認する $ mysql -uユーザ -p 対象データベース > SELECT table_name,table_collation FROM information_schema.tables WHERE table_schema = DATABASE() ; ファイル所有者・パーミッション root作業が多いため、要所要所・最後に chown で所有者を Redmineを実行するユーザー(apache)に切替えすること Redmineにログインした後の不要なニュースの削除 既に終了、アーカイブしたプロジェクト内のニュースが表示されてしまう。プロジェクトを開いてニュースを編集してといった作業をしなくても表示を消す方法 select * from news ; id, project_id, title, created_on を見ると、Redmineの内部的なプロジェクトID番号、いつ作成したのかがわかる このテーブルで不要なレコードを消せば良い 全て不要だったので、 Delete From news; にて消した RedMica1.2へ RedMica1.2 では Redmine3.4 or 4.0 または4.1からのバージョンアップが想定だった模様 おそらく、メジャーバージョンでの最終のものからの移行想定と思われる。
  • このエントリーをはてなブックマークに追加
  • Qiitaで続きを読む

Redmineのバージョンアップ(Redmine3.2 -> 4.1とRedmica1.2への切り替え)その2(構築編)

はじめに その1 概要・調査検討 その2 構築(このページ) その3 移行(別ページ 作成中) その4 Redmine バージョンアップにおける番外編(別ページ 作成中) 環境構築 まずは、Redmine4.1を動く環境を構築せねばと思ってやり始めるが、バージョンアップ時に使うマイグレーションが途中でエラーになる。 Redmine4.0, 4.1 どちらのバージョンアップを試してみたが同じエラーになる。そのエラーの解消を含めてRedmine4.1とRedMica1.2について記載します 手順等、一部割愛しています 失敗・エラー時、実行ログを載せているため見にくいです Redmine4.1の環境構築 Ruby Redmine4.1のRubyバージョンは2.3以上が必要、Redmine3.2利用している状況では2.2.3を使っている 最初は 2.3を入れた。後で判明するが 2.6以上が必要 https://www.nslabs.jp/redmine-install.rhtml での対応表は最低2.3~だった。他に対応バージョンを記載しているサイト https://redmine.jp/tech_note/supported-rubies/ , http://guide.redmine.jp/RedmineInstall/ Redmineバージョン Ruby on Railsバージョン Rubyバージョン 4.1 5.2 2.3 〜 2.6 ★ 4.0 5.2 2.2.2 〜 2.6 ◎ 3.4.x 4.2 2.2 〜 2.4 EOL 3.3.x EOL 4.2 2.2 〜 2.3 EOL 3.2.x EOL 4.2 2.2 EOL rubyのバージョン管理は、'rbenv' を使っている rbenv-update があるか確認する find /opt -name ruby-build /opt/rbenv/plugins/ruby-build /opt/rbenv/plugins/ruby-build/bin/ruby-build /opt/rbenv/plugins/ruby-build/share/ruby-build 入っていないので入れる echo $RBENV_ROOT /opt/rbenv # cd /opt/rbenv/plugins/ # git clone https://github.com/rkh/rbenv-update.git "$RBENV_ROOT/plugins/rbenv-update" Cloning into '/opt/rbenv/plugins/rbenv-update'... remote: Enumerating objects: 242, done. remote: Total 242 (delta 0), reused 0 (delta 0), pack-reused 242 Receiving objects: 100% (242/242), 32.07 KiB | 0 bytes/s, done. Resolving deltas: 100% (51/51), done. # ls -l drwxr-xr-x 4 root root 57 3月 5 16:37 rbenv-update drwxr-xr-x 7 root root 145 5月 17 2016 ruby-build rbenv を updateする # cd /opt/rbenv/plugins/rbenv-update # rbenv update update中 Updating rbenv | From git://github.com/sstephenson/rbenv | 9fdce5d..d604acb master -> origin/master | From git://github.com/sstephenson/rbenv | * [new tag] v1.1.0 -> v1.1.0 | * [new tag] v1.1.1 -> v1.1.1 | * [new tag] v1.1.2 -> v1.1.2 Updating rbenv-update Updating ruby-build | From git://github.com/sstephenson/ruby-build # rbenv install -l 2.5.8 2.6.6 2.7.2 3.0.0 jruby-9.2.16.0 mruby-2.1.2 rbx-5.0 truffleruby-21.0.0 truffleruby+graalvm-21.0.0 Only latest stable releases for each Ruby implementation are shown. Use 'rbenv install --list-all / -L' to show all local versions. # openssl version OpenSSL 1.0.1e-fips 11 Feb 2013 # rbenv install 2.6.6 約10分くらいかかった 使えるバージョンを確認 # rbenv versions * 2.2.3 (set by /opt/rbenv/version) 2.6.6 globalを変更 # rbenv global 2.6.6 # rbenv versions 2.2.3 * 2.6.6 (set by /opt/rbenv/version) # ruby -v ruby 2.6.6p146 (2020-03-31 revision 67876) [x86_64-linux] Redmine本体の場所 ディレクトリ /path/to/redmine3.2.0 /path/to/redmine4.1.1 それぞれディレクトリ分けてインストールしている。 /opt/redmine3.2.0 , /opt/redmine4.1.1 のディレクトリとして運用 Redmine本体のインストール Redmine4.1.1 を https://www.redmine.org/releases/ から tar.gzをダウンロードして展開する cd /opt/ curl -O https://www.redmine.org/releases/redmine-4.1.1.tar.gz tar xvzf redmine-4.1.1.tar.gz 展開後、所有者変更 chown -R apache:apache redmine-4.1.1 cronやapache等のためにシンボリックリンクを使っているため、シンボリックリンクを変更 変更前 # cd /opt # ls -l 合計 8 drwxr-xr-x 13 root root 4096 3月 5 16:54 rbenv lrwxrwxrwx 1 root root 19 5月 18 2016 redmine -> /opt/redmine-3.2.0/ # unlink redmine # ln -s /opt/redmine-4.1.1/ redmine # ls -l 合計 2664 drwxr-xr-x 13 root root 4096 3月 5 16:54 rbenv lrwxrwxrwx 1 root root 19 3月 5 17:56 redmine -> /opt/redmine-4.1.1/ drwxrwxr-x 19 apache apache 4096 5月 28 2016 redmine-3.2.0 drwxrwxr-x 17 apache apache 4096 4月 7 2020 redmine-4.1.1 -rw-r--r-- 1 root root 2712056 3月 5 17:43 redmine-4.1.1.tar.gz drwxr-xr-x. 2 root root 6 3月 26 2015 rh 設定ファイルのコピー(DB接続情報、Redmineからのメール送信の情報) # cp -avp /opt/redmine-3.2.0/config/database.yml /opt/redmine-4.1.1/config/ # cp -avp /opt/redmine-3.2.0/config/configuration.yml /opt/redmine-4.1.1/config/ bundlerを入れる、 Gemfileに バージョン記載があるので、その範囲であること # gem install bundler:1.14.3 --no-rdoc --no-ri ERROR: While executing gem ... (OptionParser::InvalidOption) invalid option: --no-rdoc # bundler -v Bundler version 1.17.2 bundler 入れなくても良さげ(Redmine4.0の時はいれたけど) Redmineのインストールディレクトリで、必要な Gemを取得 # cd /opt/redmine-4.1.1 # bundle install --path vendor/bundler --without development test 最後に以下のメッセージが出た HEADS UP! i18n 1.1 changed fallbacks to exclude default locale. But that may break your application. Please check your Rails app for 'config.i18n.fallbacks = true'. If you're using I18n (>= 1.1.0) and Rails (< 5.2.2), this should be 'config.i18n.fallbacks = [I18n.default_locale]'. If not, fallbacks will be broken in your app by I18n 1.1.x. For more info see: https://github.com/svenfuchs/i18n/releases/tag/v1.1.0 対応 https://blog.goo.ne.jp/system-oni800/e/d63153bec6f9429f85c17d602bf16db5 https://mocomo012.hatenablog.com/entry/2019/10/16/194221 http://midnight-engineering.hatenadiary.jp/entry/2019/01/02/181645 を参考に、 # vi ./config/environments/production.rb config.logger.level = Logger::WARN config.i18n.fallbacks = [I18n.default_locale]  <<追加 # diff production.rb production.rb_bak 27d26 < config.i18n.fallbacks = [I18n.default_locale] production.rb + config.i18n.fallbacks = [I18n.default_locale] 再度、bundler を実行する cd /opt/redmine-4.1.1 bundle install --path vendor/bundler --without development test 以下となって正常終了 Using rouge 3.12.0 Bundle complete! 31 Gemfile dependencies, 59 gems now installed. Gems in the groups development and test were not installed. Bundled gems are installed into `./vendor/bundler` Passengerも入れる # cd /opt/redmine-4.1.1 # gem install passenger --no-rdoc --no-ri ERROR: While executing gem ... (OptionParser::InvalidOption) invalid option: --no-rdoc rbenv rehash は実施してみた。環境変数が古いのか。 引数変えれば良さげ(https://teratail.com/questions/151110) バージョン変わって引数かわったかも Passengerも入れる(引数変更) # gem install passenger --no-document 以下となって終了 Fetching rack-2.2.3.gem Fetching passenger-6.0.7.gem Successfully installed rack-2.2.3 Building native extensions. This could take a while... Successfully installed passenger-6.0.7 2 gems installed passenger の apache入れる(10-15分くらい?) # passenger-install-apache2-module (passenger-install-apache2-module --auto --languages ruby   という引数指定もある) Please edit your Apache configuration file, and add these lines: と出る、以下のメッセージはメモっておく LoadModule passenger_module /opt/rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/passenger-6.0.7/buildout/apache2/mod_passenger.so <IfModule mod_passenger.c> PassengerRoot /opt/rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/passenger-6.0.7 PassengerDefaultRuby /opt/rbenv/versions/2.6.6/bin/ruby </IfModule> 続けて、 Validating installation... * Checking whether this Passenger install is in PATH... ✓ * Checking whether there are no other Passenger installations... (!) You are currently validating against Phusion Passenger 6.0.7, located in: /opt/rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/passenger-6.0.7/bin/passenger Besides this Passenger installation, the following other Passenger installations have also been detected: /opt/rbenv/shims/passenger Please uninstall these other Passenger installations to avoid confusion or conflicts. * Checking whether Apache is installed... ✓ * Checking whether the Passenger module is correctly configured in Apache... ✗ Incorrect Passenger module path detected Phusion Passenger for Apache requires a 'LoadModule passenger_module' directive inside an Apache configuration file. This directive has been detected in the following config file: /etc/httpd/conf.d/redmine.conf However, the directive refers to the following Apache module, which is wrong: /opt/rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/passenger-5.0.28/buildout/apache2/mod_passenger.so Please edit the config file and change the directive to this instead: LoadModule passenger_module /opt/rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/passenger-6.0.7/buildout/apache2/mod_passenger.so Detected 1 error(s), 1 warning(s). Please solve the above issues, then press ENTER to continue. 既存のApacheのconfファイル redmine.conf は書き換えられなかったという エラー? 上記のメモの通り、Apacheのconfファイルを変更する cd /etc/httpd/conf.d/ vi redmine.conf また、/var/www でシンボリックリンクを作成しているため変更する # cd /var/www/html # ls -l redmine -> /opt/redmine-3.2.0/public ←前のバージョンのシンボリックリンク # unlink redmine # ln -s /opt/redmine-4.1.1/public redmine redmine -> /opt/redmine-4.1.1/public ←変更後のシンボリックリンク 新しいセッション保護用の秘密鍵を生成してください。 # cd /opt/redmine-4.1.1 # bundle exec rake generate_secret_token # ls -l /opt/redmine-4.1.1/config/initializers/ secret_token.rb ←このファイルが出来上がる bundle # cd /opt/redmine-4.1.1 # export RAILS_ENV=production # bundle update 以下メッセージでbundleの更新完了 Using rouge 3.12.0 Bundle updated! Gems in the groups development and test were not installed. rakeマイグレーション VMWareでクローンしているため、MySQLのデータベース内には Redmine3.2として使っていたデータが格納されている、そのためこの手順ではインポートしていないが、実行の移行時にはインポートする マイグレーション実行前のMySQLのバックアップ mysqldump -uXXXXX -pXXXXX データベース名| gzip > /home/redmine_`date +%y_%m_%d`.gz DBマイグレーションの実行、ここから緊張する、成功するか失敗するか、祈れ。 # cd /path/to/redmine # export RAILS_ENV=production # bundle exec rake db:migrate エラー発生!、原因究明をしていく bundle exec rake db:migrate == 20160404080304 ForcePasswordResetDuringSetup: migrating ==================== == 20160404080304 ForcePasswordResetDuringSetup: migrated (0.0782s) =========== == 20160416072926 RemovePositionDefaults: migrating =========================== -- change_column("boards", :position, :integer, {:default=>nil}) -> 0.0372s -- change_column("custom_fields", :position, :integer, {:default=>nil}) -> 0.0582s -- change_column("enumerations", :position, :integer, {:default=>nil}) -> 0.0333s -- change_column("issue_statuses", :position, :integer, {:default=>nil}) -> 0.0309s -- change_column("roles", :position, :integer, {:default=>nil}) -> 0.0286s -- change_column("trackers", :position, :integer, {:default=>nil}) -> 0.0219s == 20160416072926 RemovePositionDefaults: migrated (0.2921s) ================== == 20160529063352 AddRolesSettings: migrating ================================= -- add_column(:roles, :settings, :text, {}) -> 0.0745s == 20160529063352 AddRolesSettings: migrated (0.0746s) ======================== == 20161001122012 AddTrackerIdIndexToWorkflows: migrating ===================== -- add_index(:workflows, :tracker_id) -> 0.1898s == 20161001122012 AddTrackerIdIndexToWorkflows: migrated (0.1899s) ============ == 20161002133421 AddIndexOnMemberRolesInheritedFrom: migrating =============== -- add_index(:member_roles, :inherited_from) -> 0.2305s == 20161002133421 AddIndexOnMemberRolesInheritedFrom: migrated (0.2307s) ====== == 20161010081301 ChangeIssuesDescriptionLimit: migrating ===================== -- change_column(:issues, :description, :text, {:limit=>16777216}) -> 12.4342s == 20161010081301 ChangeIssuesDescriptionLimit: migrated (12.4345s) =========== == 20161010081528 ChangeJournalDetailsValueLimit: migrating =================== -- change_column(:journal_details, :value, :text, {:limit=>16777216}) -> 20.0198s -- change_column(:journal_details, :old_value, :text, {:limit=>16777216}) -> 18.6174s == 20161010081528 ChangeJournalDetailsValueLimit: migrated (38.6376s) ========= == 20161010081600 ChangeJournalsNotesLimit: migrating ========================= -- change_column(:journals, :notes, :text, {:limit=>16777216}) rake aborted! StandardError: An error has occurred, all later migrations canceled: Mysql2::Error: Invalid default value for 'created_on': ALTER TABLE `journals` CHANGE `notes` `notes` longtext DEFAULT NULL /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/mysql2-0.5.3/lib/mysql2/client.rb:131:in `_query' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/mysql2-0.5.3/lib/mysql2/client.rb:131:in `block in query' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/mysql2-0.5.3/lib/mysql2/client.rb:130:in `handle_interrupt' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/mysql2-0.5.3/lib/mysql2/client.rb:130:in `query' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:187:in `block (2 levels) in execute' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activesupport-5.2.4.2/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activesupport-5.2.4.2/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activesupport-5.2.4.2/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:186:in `block in execute' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/connection_adapters/abstract_adapter.rb:581:in `block (2 levels) in log' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/connection_adapters/abstract_adapter.rb:580:in `block in log' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activesupport-5.2.4.2/lib/active_support/notifications/instrumenter.rb:23:in `instrument' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/connection_adapters/abstract_adapter.rb:571:in `log' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:185:in `execute' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/connection_adapters/mysql/database_statements.rb:28:in `execute' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:371:in `change_column' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:871:in `block in method_missing' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:840:in `block in say_with_time' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:840:in `say_with_time' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:860:in `method_missing' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration/compatibility.rb:26:in `change_column' /opt/redmine-4.1.1/db/migrate/20161010081600_change_journals_notes_limit.rb:5:in `up' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:817:in `exec_migration' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:798:in `block (2 levels) in migrate' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:797:in `block in migrate' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:416:in `with_connection' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:796:in `migrate' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:977:in `migrate' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:1292:in `block in execute_migration_in_transaction' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:1345:in `ddl_transaction' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:1291:in `execute_migration_in_transaction' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:1263:in `block in migrate_without_lock' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:1262:in `each' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:1262:in `migrate_without_lock' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:1210:in `block in migrate' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:1363:in `with_advisory_lock' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:1210:in `migrate' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:1036:in `up' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:1011:in `migrate' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/tasks/database_tasks.rb:172:in `migrate' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/railties/databases.rake:60:in `block (2 levels) in <top (required)>' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/rake-13.0.3/exe/rake:27:in `<top (required)>' /opt/rbenv/versions/2.5.8/bin/bundle:23:in `load' /opt/rbenv/versions/2.5.8/bin/bundle:23:in `<main>' Caused by: ActiveRecord::StatementInvalid: Mysql2::Error: Invalid default value for 'created_on': ALTER TABLE `journals` CHANGE `notes` `notes` longtext DEFAULT NULL /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/mysql2-0.5.3/lib/mysql2/client.rb:131:in `_query' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/mysql2-0.5.3/lib/mysql2/client.rb:131:in `block in query' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/mysql2-0.5.3/lib/mysql2/client.rb:130:in `handle_interrupt' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/mysql2-0.5.3/lib/mysql2/client.rb:130:in `query' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:187:in `block (2 levels) in execute' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activesupport-5.2.4.2/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activesupport-5.2.4.2/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activesupport-5.2.4.2/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:186:in `block in execute' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/connection_adapters/abstract_adapter.rb:581:in `block (2 levels) in log' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/connection_adapters/abstract_adapter.rb:580:in `block in log' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activesupport-5.2.4.2/lib/active_support/notifications/instrumenter.rb:23:in `instrument' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/connection_adapters/abstract_adapter.rb:571:in `log' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:185:in `execute' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/connection_adapters/mysql/database_statements.rb:28:in `execute' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:371:in `change_column' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:871:in `block in method_missing' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:840:in `block in say_with_time' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:840:in `say_with_time' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:860:in `method_missing' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration/compatibility.rb:26:in `change_column' /opt/redmine-4.1.1/db/migrate/20161010081600_change_journals_notes_limit.rb:5:in `up' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:817:in `exec_migration' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:798:in `block (2 levels) in migrate' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:797:in `block in migrate' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:416:in `with_connection' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:796:in `migrate' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:977:in `migrate' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:1292:in `block in execute_migration_in_transaction' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:1345:in `ddl_transaction' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:1291:in `execute_migration_in_transaction' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:1263:in `block in migrate_without_lock' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:1262:in `each' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:1262:in `migrate_without_lock' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:1210:in `block in migrate' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:1363:in `with_advisory_lock' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:1210:in `migrate' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:1036:in `up' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:1011:in `migrate' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/tasks/database_tasks.rb:172:in `migrate' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/railties/databases.rake:60:in `block (2 levels) in <top (required)>' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/rake-13.0.3/exe/rake:27:in `<top (required)>' /opt/rbenv/versions/2.5.8/bin/bundle:23:in `load' /opt/rbenv/versions/2.5.8/bin/bundle:23:in `<main>' Caused by: Mysql2::Error: Invalid default value for 'created_on' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/mysql2-0.5.3/lib/mysql2/client.rb:131:in `_query' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/mysql2-0.5.3/lib/mysql2/client.rb:131:in `block in query' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/mysql2-0.5.3/lib/mysql2/client.rb:130:in `handle_interrupt' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/mysql2-0.5.3/lib/mysql2/client.rb:130:in `query' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:187:in `block (2 levels) in execute' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activesupport-5.2.4.2/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activesupport-5.2.4.2/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activesupport-5.2.4.2/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:186:in `block in execute' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/connection_adapters/abstract_adapter.rb:581:in `block (2 levels) in log' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/connection_adapters/abstract_adapter.rb:580:in `block in log' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activesupport-5.2.4.2/lib/active_support/notifications/instrumenter.rb:23:in `instrument' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/connection_adapters/abstract_adapter.rb:571:in `log' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:185:in `execute' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/connection_adapters/mysql/database_statements.rb:28:in `execute' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:371:in `change_column' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:871:in `block in method_missing' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:840:in `block in say_with_time' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:840:in `say_with_time' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:860:in `method_missing' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration/compatibility.rb:26:in `change_column' /opt/redmine-4.1.1/db/migrate/20161010081600_change_journals_notes_limit.rb:5:in `up' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:817:in `exec_migration' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:798:in `block (2 levels) in migrate' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:797:in `block in migrate' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:416:in `with_connection' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:796:in `migrate' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:977:in `migrate' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:1292:in `block in execute_migration_in_transaction' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:1345:in `ddl_transaction' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:1291:in `execute_migration_in_transaction' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:1263:in `block in migrate_without_lock' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:1262:in `each' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:1262:in `migrate_without_lock' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:1210:in `block in migrate' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:1363:in `with_advisory_lock' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:1210:in `migrate' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:1036:in `up' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:1011:in `migrate' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/tasks/database_tasks.rb:172:in `migrate' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/railties/databases.rake:60:in `block (2 levels) in <top (required)>' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/rake-13.0.3/exe/rake:27:in `<top (required)>' /opt/rbenv/versions/2.5.8/bin/bundle:23:in `load' /opt/rbenv/versions/2.5.8/bin/bundle:23:in `<main>' Tasks: TOP => db:migrate (See full trace by running task with --trace)``` 原因は、DATETIME型のカラムで DEFAULT '0000-00-00 00:00:00' があることで、ALTERが失敗する ALTERしているカラムが文字列やlogtext型への変更が要因ではなく、ALTERした後の定義に、DEFAULT '0000-00-00 00:00:00' が存在することがNG 長年RedmineをMySQLの古いバージョンから使いつづけ、今回のマイグレーションで見つかった問題 テーブル定義の一例 mysql> desc time_entries; +-------------+---------------+------+-----+---------------------+----------------+ | Field | Type | Null | Key | Default | Extra | +-------------+---------------+------+-----+---------------------+----------------+ | id | int(11) | NO | PRI | NULL | auto_increment | | project_id | int(11) | NO | MUL | 0 | | | user_id | int(11) | NO | MUL | 0 | | | issue_id | int(11) | YES | MUL | NULL | | | hours | float | NO | | 0 | | | comments | varchar(1024) | YES | | NULL | | | activity_id | int(11) | NO | MUL | 0 | | | spent_on | date | NO | | 0000-00-00 | | | tyear | int(11) | NO | | 0 | | | tmonth | int(11) | NO | | 0 | | | tweek | int(11) | NO | | 0 | | | created_on | datetime | NO | MUL | 0000-00-00 00:00:00 | | | updated_on | datetime | NO | | 0000-00-00 00:00:00 | | +-------------+---------------+------+-----+---------------------+----------------+ 対策 今後のためも考え、DEFAULT '0000-00-00 00:00:00' を撲滅させる DEFAULT CURRENT_TIMESTAMP にはしない、Redmine4.1を新規構築してDEFAULTはNULLであることは別で確認済 対策例、1回のALTER文で行うこと -- comments /* ALTER TABLE comments MODIFY created_on datetime DEFAULT null; ALTER TABLE comments MODIFY created_on datetime not null ; ALTER TABLE comments MODIFY updated_on datetime DEFAULT null; ALTER TABLE comments MODIFY updated_on datetime not null ; */ -- ↑のように2つのカラムがあると1つごとのSQLではダメ、なので↓のようにする ALTER TABLE comments MODIFY created_on datetime DEFAULT null , MODIFY updated_on datetime DEFAULT null; ALTER TABLE comments MODIFY created_on datetime not null , MODIFY updated_on datetime not null ; rakeマイグレーション前に、ALTERを実行する 先述の通り、ALTERしてからDBマイグレーションを行うと完走する # export RAILS_ENV=production # bundle exec rake db:migrate == 20160404080304 ForcePasswordResetDuringSetup: migrating ==================== == 20160404080304 ForcePasswordResetDuringSetup: migrated (0.1158s) =========== 略 == 20190620135549 ChangeRolesNameLimit: migrating ============================= -- change_column(:roles, :name, :string, {:limit=>255, :default=>""}) -> 0.0302s == 20190620135549 ChangeRolesNameLimit: migrated (0.0303s) ==================== キャッシュクリア bundle exec rake tmp:clear Redmineを起動(Apacheを起動) 構築なので、プラグインをいれない状態での動作確認 スーパーユーザーの権限(システム管理権限)を保持したユーザでログインする 管理 -> 情報 を見ると プラグインの導入 プラグイン導入の指標 Redmine公式のpluginのページ https://www.redmine.org/plugins いっぱいある、導入時の指標の1つとしてスターの数で判断 Redmine3.2.0で導入しているプラグイン、これらをバージョンアップ Redmine plugins: redmine_code_review 0.7.0 redmine_default_custom_query 1.2.0 redmine_messenger 1.0.3 redmine_slack 0.1 view_customize 1.1.4 redmine_code_review plugin のページ https://www.redmine.org/plugins/redmine_code_review https://www.r-labs.org/projects/r-labs/wiki/Code_Review Compatible with: Redmine 4.1.x, 4.0.x Githubリポジトリ https://github.com/haru/redmine_code_review https://github.com/haru/redmine_code_review/releases https://github.com/haru/redmine_code_review/releases/download/1.0.0/redmine_code_review-1.0.0.zip Changelog 1.0.0 (2018-12-31) Compatible with Redmine 4.1.x, 4.0.x. Download https://github.com/haru/redmine_code_review/releases/tag/1.0.0 1.0.0以降は出ていない、1.0.0でRedmine4.0も4.1も対応している install https://www.r-labs.org/projects/r-labs/wiki/Code_Review_en では 1.Copy the plugin into the vendor/plugins directory 2.Migrate plugin: rake db:migrate_plugins RAILS_ENV=production 3.Start Redmine ・・・ と記載があり、vendorディレクトリに入れるようになっているが Redmin3.2では vendorには入れていない。{redmine_dir}/plugins に入れている https://www.redmine.org/plugins/redmine_code_review の通りインストールする 1.Copy the plugin into the plugins directory ``` cd {redmine_path}/plugins curl -OL https://github.com/haru/redmine_code_review/releases/download/1.0.0/redmine_code_review-1.0.0.zip unzip redmine_code_review-1.0.0.zip rm -rf __MACOSX/ chown -R apache:apache redmine_code_review ```` 2.Migrate plugin: rake redmine:plugins:migrate RAILS_ENV=production ``` cd {redmine_path} bundle exec rake redmine:plugins:migrate RAILS_ENV=production ``` 3.Restart Redmine ``` systemctl reload httpd.service ``` 4.Enable the module on the project setting page. 5.Goto Code Review setting tab and select the tracker for code reviews. redmine_code_review-1.0.0.zip 展開すると、「__MACOSX」不要なファイルがたくさんある 検証 プロジェクト 設定-> モジュール「コードレビュー」をチェックON -> 保存 プロジェクト 設定 タブ「コードレビュー」が表示され、割り当てるトラッカー、アサインするトラッカーが表示・選択でき、「更新」できること redmine_default_custom_query plugin のページ https://www.redmine.org/plugins/redmine_default_custom_query 対応バージョン Redmine3.1.x ~ Redmine3.4.x の記載までgithubの情報が最新 https://github.com/hidakatsuya/redmine_default_custom_query/blob/master/README.md ここみると、Redmine4.0, Ruby2.6までの記載はある Version 1.5.0が最終リリースで 2019-10-27 issues の#48 で 4.1.1で error がある模様 (https://github.com/hidakatsuya/redmine_default_custom_query/issues/48) install cd /path/to/your-redmine/plugins git clone https://github.com/hidakatsuya/redmine_default_custom_query.git redmine_default_custom_query chown -R apache:apache redmine_default_custom_query cd ../ bundle install --without development test bundle exec rake redmine:plugins:migrate RAILS_ENV=production または rake redmine:plugins:migrate NAME=redmine_default_custom_query RAILS_ENV=production 検証 設定 -> プロジェクト -> モジュール「デフォルトカスタムクエリ」をチェックON -> 保存 -> プロジェクト設定にて タブ「デフォルトカスタムクエリ」が表示される -> タブを選択し、デフォルトカスタムクエリのプルダウンを選択 -> チケット一覧がその条件にあった一覧になること redmine_messenger slack,mattermost,rocketchatプラグインをforkしているのでいい感じに使える plugin のページ https://www.redmine.org/plugins/ Messenger plugin for Redmine with Slack, Discord, Rocket.Chat and Mattermost support. It notifies your chat server when something happened in your specific Redmine projects. This plugin is a fork of redmine_slack, redmine_mattermost and redmine_rocketchat. With one installation you can use all popular messengers and decide which one is the best for your team in order to collaborate and receive notifications about important Redmine changes in real-time. Changelog 1.0.6 (2019-12-31) Compatible with Redmine 4.1.x, 4.0.x. See Changelog at Github. Redmineからslackへの通知は、このpluginでいけるのでは?(プラグイン「redmine_slack」は「redmine_messenger」で代替可能そう) Redmine version 4.0.0以上、Ruby2.4以上となっている(昔は、古いRedmineのバージョンでも動いたと思われる、Redmine3.2で動かしていたので) install インストール方法 https://github.com/alphanodes/redmine_messenger#installation cd {$REDMINE_ROOT}/plugins git clone https://github.com/AlphaNodes/redmine_messenger.git redmine_messenger chown -R apache:apache redmine_messenger cd {$REDMINE_ROOT} bundle update bundle exec rake redmine:plugins:migrate RAILS_ENV=production 検証 設定例は以下がわかりやすい https://qiita.com/Yoto_3/items/417d40e900c65cae23ec redmineがインストールされたサーバから直にcurlでリクエストすると何がダメか切り分けしやすい https://docs.mattermost.com/developer/webhooks-incoming.html 例) curl -i -X POST -H "Content-Type: application/json" -d "{\"text\": \"Hello, this is some text\nThis is more text. :tada:\"}" https://xxx/hooks/5qqrphwdwbabcdfghijklmn MattermostのRedmine用のワークスペースを設定する場合は URL:https://xxx/hooks/h7z3ihg8qabcdefghijklmn チャンネル:redmine_hook Redmine Slack plugin のページ https://github.com/sciyoshi/redmine-slack だが、メンテナンスされていない https://www.redmine.org/plugins/redmine_slack (https://github.com/evolvingweb/redmine_slack) を変わりに導入するか? また、前述記載済の「redmine_messenger」でslack連携可能な記載があるのでそれを使う方が良いのではないか? → redmine_messangerを使う方針で決定 view_customize plugin のページ https://www.redmine.org/plugins/view_customize Githubリポジトリ https://github.com/onozaty/redmine-view-customize 対応バージョン Redmine 4.1.x, 4.0.x, 3.4.x, 3.3.x, 3.2.x, 3.1.x Changelog 2.8.1 (2021-02-13) Compatible with Redmine 4.1.x, 4.0.x, 3.4.x, 3.3.x, 3.2.x, 3.1.x. https://github.com/onozaty/redmine-view-customize/releases/tag/v2.8.1 インストール方法 Installation notes cd {RAILS_ROOT}/plugins git clone https://github.com/onozaty/redmine-view-customize.git view_customize chown -R apache:apache view_customize cd ../ bundle install --without development test bundle exec rake redmine:plugins:migrate RAILS_ENV=production 検証 http://redmineのホスト/admin 管理 -> 設定 プラグインにて、当該プラグインがエラーなく表示されること チケットのコメントの背景が薄い黄色になること チケットの関連するチケット と 履歴コメントの間に、 「show All」が表示されること、その切替が動作すること https://redmineのホスト/view_customizes での表示を確認する プラグイン入れたもの一覧とバージョン テーマとfavicon themesの適用と redmine_theme_farend_fancy-masterを従来から使っており、https://github.com/farend/redmine_theme_farend_fancy によると、 public/themes以下にテーマを保存 Redmineのインストールディレクトリで以下のコマンドを実行してください。 git clone https://github.com/farend/redmine_theme_farend_fancy.git public/themes/farend_fancy gitコマンドが利用できない場合、以下のURLからzipファイルをダウンロードし展開してください。 https://github.com/farend/redmine_theme_farend_fancy/archive/master.zip アーカイブを展開した結果作成されたディレクトリをRedmineインストールディレクトリ以下のpublic/themesディレクトリにfarend_fancyという名前でコピーしてください。 新しいテーマの利用 Redmineの管理画面で新しいテーマを利用する設定を行います。 「管理」→「設定」→「表示」画面内の項目「テーマ」で「Fare fancy」を選択、画面最下部の「保存」ボタンをクリックしてください。 設定例 install cd /opt/redmine-4.1.1/public/themes git clone https://github.com/farend/redmine_theme_farend_fancy.git farend_fancy chown -R apache:apache farend_fancy Redmine画面 管理 -> 表示 -> テーマのプルダウン、Farend fancy を選択 favicon.ico のコピー 単にファイルのコピーのみ cp -avp /opt/redmine-3.2.0/public/favicon.ico /opt/redmine-4.1.1/public/ `/opt/redmine-3.2.0/public/favicon.ico' -> `/opt/redmine-4.1.1/public/favicon.ico' ログローテーション Apache / Redmine / MySQL 等のログローテーション回数等を設定する Redmineはデフォルトだと1ファイルに出力するため、日々のローテーション等に変えておく方が良い Apacheはアクエス元、アクエス先などを保持しておくため長期保持する(RedmineのログはApacheよりも詳細な内容になる MySQLのログローテーション 参考 https://leben.mobi/blog/mysql-logrotate/linux/ https://pgmemo.tokyo/data/archives/1114.html https://blog.inouetakuya.info/entry/20130320/1363776504 # logrotate -dv /etc/logrotate.d/mysql テスト logrotate -dv /etc/logrotate.d/mysql 実際にローテーション logrotate -v /etc/logrotate.d/mysql 以下の日付を変更することで、ローテーションテストできる # cat /var/lib/logrotate.status |grep mysql "/var/log/mysql/mysqld.log" 2021-3-16-17:0:0 Redmineのログローテーション # cat /etc/logrotate.d/redmine /opt/redmine-3.2.0/log/*.log { daily notifempty missingok copytruncate compress rotate 14 su apache apache } 変更後、シンボリックリンクのパスでローテーションするようにした # cat /etc/logrotate.d/redmine /opt/redmine-3.2.0/log/*.log { daily notifempty missingok copytruncate compress rotate 14 su apache apache } # symbolic link /opt/redmine/log/*.log { dateext daily notifempty missingok copytruncate compress rotate 365 su apache apache } 動作確認 # logrotate -dv /etc/logrotate.d/redmine 以下の日付を変更することで、ローテーションテストできる # cat /var/lib/logrotate.status |grep redmine "/opt/redmine-3.2.0/log/production.log" 2021-3-5-14:36:5 実際にローテーション logrotate -v /etc/logrotate.d/redmine MySQLとテーブルの文字エンコードを変更(utf8 -> utf8mb4) 1.. ここまでの作業で、Redmineのバージョンアップとしての構築はできていますが、画面や連携等で絵文字入力、ファイル名に絵文字があるとエラーで登録できず不便なので対応する 2.. mysqlの設定ファイル確認 # cat /etc/my.cnf 3.. mysqlに接続して database 単位での characterを確認 mysql -uXXXX -p -h localhost mysql> show variables like "character%"; +--------------------------+----------------------------+ | Variable_name | Value | +--------------------------+----------------------------+ | character_set_client | utf8 | | character_set_connection | utf8 | | character_set_database | latin1 | | character_set_filesystem | binary | | character_set_results | utf8 | | character_set_server | latin1 | | character_set_system | utf8 | | character_sets_dir | /usr/share/mysql/charsets/ | +--------------------------+----------------------------+ 8 rows in set (0.01 sec) mysql> use databasenamaeXXXX; Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A show variables like "character%";Database changed mysql> show variables like "character%"; +--------------------------+----------------------------+ | Variable_name | Value | +--------------------------+----------------------------+ | character_set_client | utf8 | | character_set_connection | utf8 | | character_set_database | utf8 | # For advice on how to change settings please see | character_set_filesystem | binary | | character_set_results | utf8 | # For advice on how to change settings please see | character_set_server | latin1 | | character_set_system | utf8 | | character_sets_dir | /usr/share/mysql/charsets/ | +--------------------------+----------------------------+ 8 rows in set (0.00 sec) mysql> mysql> quit; Bye 4.. /etc/my.cnf に utf8mb4を設定追加 、2つのセクションに追加する [mysqld] character-set-server = utf8mb4 [client] default-character-set=utf8mb4 5.. mysqlインスタンスを再起動 systemctl restart mysqld.service 6.. データベース内の設定を変更 mysql> use redmine; Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed mysql> show variables like "character%"; +--------------------------+----------------------------+ | Variable_name | Value | +--------------------------+----------------------------+ | character_set_client | utf8mb4 | | character_set_connection | utf8mb4 | | character_set_database | utf8 | | character_set_filesystem | binary | | character_set_results | utf8mb4 | | character_set_server | utf8mb4 | | character_set_system | utf8 | | character_sets_dir | /usr/share/mysql/charsets/ | +--------------------------+----------------------------+ 8 rows in set (0.01 sec) 7.. database は utf8 のままなので、 mysql内のredmineデータベースの文字コードを変更 mysql> alter database redmine character set utf8mb4; Query OK, 1 row affected (0.00 sec) mysql> show variables like "character%"; +--------------------------+----------------------------+ | Variable_name | Value | +--------------------------+----------------------------+ | character_set_client | utf8mb4 | | character_set_connection | utf8mb4 | | character_set_database | utf8mb4 | | character_set_filesystem | binary | | character_set_results | utf8mb4 | | character_set_server | utf8mb4 | | character_set_system | utf8 | | character_sets_dir | /usr/share/mysql/charsets/ | +--------------------------+----------------------------+ 8 rows in set (0.00 sec) 8.. database内の全テーブルのエンコードを変える ALTER分の生成は移行編の記事の方で詳細を記載予定 ファイル /tmp/alters_table_CHARSET.sql としてSQL生成 alter table `ar_internal_metadata` convert to character set utf8mb4; alter table `attachments` convert to character set utf8mb4; alter table `auth_sources` convert to character set utf8mb4; alter table `boards` convert to character set utf8mb4; alter table `changes` convert to character set utf8mb4; ・・・ utf8mb4への変更するALTERをSQLファイル読み込みで実行する。ALTER文のコピー&ペーストは途中でエラーになることがあるので量が多いときは非推奨 mysql -uXXXX -p -D redmineが使うdatabasename < /tmp/alters_table_CHARSET.sql 9.. redmineのデータベース設定ファイルを変更する /opt/redmine-4.1.1/config/database.yml production: adapter: mysql2 database: redmineが使うデータベース host: localhost username: XXXX password: XXXX encoding: utf8mb4 redmine用 httpdを開始する # systemctl start httpd.service 動作確認 絵文字のサンプル、チケットの本文やコメント等に入力して反映できるか試す マグロ?スシ マグロ?スシ ここまでで、Redmine4.1の構築とバージョンは完了 RedMica1.2への切替え(バージョンアップ) 手順は、インストール済みのRedmineをRedMica 1.2に切り替える手順 を参考にすれば良い。その手順では 既存のredmine4.1の場所をベースに、 git clone して gitの管理ファイルを使い、 git pull, git checkout 運用でバージョンアップしていく場合に有用な手順です。 Redmine4.1とは別ディレクトリで運用していくケースでは少し異なり、途中でミスってます(なので最後まで手順確認してから行うようにしてください)。 ミスしている過程を載せているため、一部の後続手順を前に持ってきてください。 RedMicaを取得し配置する curl -O https://github.com/redmica/redmica/archive/refs/tags/v1.2.1.tar.gz curlが失敗、HTTPステータス304なのが要因なのかな。wgetでは成功する # cd /tmp # wget -c https://github.com/redmica/redmica/archive/refs/tags/v1.2.1.tar.gz ファイル名を変更 # mv v1.2.1.tar.gz redmica-1.2.1.tar.gz /opt/ にもっていくので移動 # mv redmica-1.2.1.tar.gz /opt/ # tar -xvzf redmica-1.2.1.tar.gz # cd /opt/redmica-1.2.1 git 関係ファイルがないことを確認 # gt status RedMica1.2を使う設定をしていく bundle cd /opt/redmica-1.2.1 bundle update bundle updateすると、データベースのymlを設定するメッセージ(Please configure your config/database.yml first)が表示されるが、updateは処理される config ファイル(database.yml、configuration.yml)をRedmine4.1の場所からコピーする # cp -avp /opt/redmine-4.1.1/config/database.yml /opt/redmica-1.2.1/config/ # cp -avp /opt/redmine-4.1.1/config/configuration.yml /opt/redmica-1.2.1/config/ 再度 bundle update を行う pluginsディレクトリまるごと redmine4.1からコピー cp -avp /opt/redmine-4.1.1/plugins/* /opt/redmica-1.2.1/plugins/ マイグレーション コマンド # export RAILS_ENV=production # bundle exec rake db:migrate または bin/rails db:migrate RAILS_ENV=production 実行 # cd /opt/redmica-1.2.1 # export RAILS_ENV=production # bundle exec rake db:migrate Could not find gem 'factory_girl' in any of the gem sources listed in your Gemfile. Run `bundle install` to install missing gems. RedMicaのディレクトリはRedmine4.1ディレクトリと同じ前提の手順のため、コマンドが不足している。 install の方をしないといけない cd /opt/redmica-1.2.1 bundle update bundle install 再度、dbマイグレーションを行う がエラーになる # cd /opt/redmica-1.2.1 # bin/rails db:migrate RAILS_ENV=production rails aborted! ArgumentError: Missing `secret_key_base` for 'production' environment, set this string with `rails credentials:edit` /opt/redmica-1.2.1/config/environment.rb:16:in `<top (required)>' bin/rails:4:in `require' bin/rails:4:in `<main>' Tasks: TOP => db:migrate => db:load_config => environment (See full trace by running task with --trace) 要因、シークレットキー生成しが必要なので、下記を実行する # cd /opt/redmica-1.2.1 # bundle exec rake generate_secret_token プラグインのマイグレーション # export RAILS_ENV=production # bundle exec rake redmine:plugins:migrate RAILS_ENV=production キャッシュクリア bundle exec rake tmp:clear テーマとfavicon cp -avp /opt/redmine-4.1.1/public/themes/farend_fancy /opt/redmica-1.2.1/public/themes/ cp -avp /opt/redmine-4.1.1/public/favicon.ico /opt/redmica-1.2.1/public/ RedMica関連ファイルのパーミッション変更しておく # cd /opt/redmica-1.2.1 # chown -R apache:apache * シンボリックリンク変更 Apacheの読み込み用、/var/www/html のサブディレクトリ、 Apacheのconfファイル Apacheのreload 画面でバージョン確認と動作確認 ここまでで、Redmica1.2へのバージョンアップ・切替えが完了 VMWareを使っている場合はスナップショット作成をしておくと戻しやすくなります rakeコマンドでメール送信しているがエラーになっている rake コマンド実行の #!/bin/bash echo $PATH export PATH="/opt/rbenv/shims:/opt/rbenv/shims:$PATH" echo $PATH cd /opt/redmine; rake redmine:send_reminders days=3 RAILS_ENV=production echo fix.`date +"%Y%m%d_%H%M%S"` エラー内容 Gemfileでは reke は 13.0.3 が必要だとなっているのでエラーになっている /opt/rbenv/shims:/opt/rbenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin /opt/rbenv/shims:/opt/rbenv/shims:/opt/rbenv/shims:/opt/rbenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin rake aborted! Gem::LoadError: You have already activated rake 12.3.3, but your Gemfile requires rake 13.0.3. Prepending `bundle exec` to your command may solve this. /opt/redmine-4.1.1/config/boot.rb:6:in `<top (required)>' /opt/redmine-4.1.1/config/application.rb:3:in `<top (required)>' /opt/redmine-4.1.1/Rakefile:5:in `<top (required)>' (See full trace by running task with --trace) バージョン確認 $ bundle -v Bundler version 1.17.2 $ which rake /opt/rbenv/shims/rake $ rake -v rake aborted! No Rakefile found (looking for: rakefile, Rakefile, rakefile.rb, Rakefile.rb) (See full trace by running task with --trace) $ rake --version rake, version 12.3.3 $ gem list rake *** LOCAL GEMS *** rake (12.3.3) いったん消して、別バージョンを入れる $ cd /path/to/redmine $ gem uninstall rake -v 12.3.3 $ gem uninstall rake -v 12.3.3 Gem 'rake' is not installed $ gem install rake -v 13.0.3 $ bundle update rake 指定バージョンインストール後 $ rake --version rake, version 13.0.3 $ which rake /opt/rbenv/shims/rake $ gem list rake *** LOCAL GEMS *** rake (13.0.3) rakeコマンド成功を確認する
  • このエントリーをはてなブックマークに追加
  • Qiitaで続きを読む

Redmineのバージョンアップ(Redmine3.2 -> 4.1とRedmica1.2への切り替え)その2(構築)

はじめに 概要 調査・検討 / 構築 / 移行 / 番外編 のうちの、構築です その1 概要・調査検討 その2 構築(このページ) その3 移行 その4 Redmine バージョンアップにおける番外編 環境構築 まずは、Redmine4.1を動く環境を構築せねばと思ってやり始めるが、バージョンアップ時に使うマイグレーションが途中でエラーになる。 Redmine4.0, 4.1 どちらのバージョンアップを試してみたが同じエラーになる。そのエラーの解消を含めてRedmine4.1とRedMica1.2について記載します 手順等、一部割愛しています 失敗・エラー時、実行ログを載せているため見にくいです Redmine4.1の環境構築 Ruby Redmine4.1のRubyバージョンは2.3以上が必要、Redmine3.2利用している状況では2.2.3を使っている 最初は 2.3を入れた。後で判明するが 2.6以上が必要 https://www.nslabs.jp/redmine-install.rhtml での対応表は最低2.3~だった。他に対応バージョンを記載しているサイト https://redmine.jp/tech_note/supported-rubies/ , http://guide.redmine.jp/RedmineInstall/ Redmineバージョン Ruby on Railsバージョン Rubyバージョン 4.1 5.2 2.3 〜 2.6 ★ 4.0 5.2 2.2.2 〜 2.6 ◎ 3.4.x 4.2 2.2 〜 2.4 EOL 3.3.x EOL 4.2 2.2 〜 2.3 EOL 3.2.x EOL 4.2 2.2 EOL rubyのバージョン管理は、'rbenv' を使っている rbenv-update があるか確認する find /opt -name ruby-build /opt/rbenv/plugins/ruby-build /opt/rbenv/plugins/ruby-build/bin/ruby-build /opt/rbenv/plugins/ruby-build/share/ruby-build 入っていないので入れる echo $RBENV_ROOT /opt/rbenv # cd /opt/rbenv/plugins/ # git clone https://github.com/rkh/rbenv-update.git "$RBENV_ROOT/plugins/rbenv-update" Cloning into '/opt/rbenv/plugins/rbenv-update'... remote: Enumerating objects: 242, done. remote: Total 242 (delta 0), reused 0 (delta 0), pack-reused 242 Receiving objects: 100% (242/242), 32.07 KiB | 0 bytes/s, done. Resolving deltas: 100% (51/51), done. # ls -l drwxr-xr-x 4 root root 57 3月 5 16:37 rbenv-update drwxr-xr-x 7 root root 145 5月 17 2016 ruby-build rbenv を updateする # cd /opt/rbenv/plugins/rbenv-update # rbenv update update中 Updating rbenv | From git://github.com/sstephenson/rbenv | 9fdce5d..d604acb master -> origin/master | From git://github.com/sstephenson/rbenv | * [new tag] v1.1.0 -> v1.1.0 | * [new tag] v1.1.1 -> v1.1.1 | * [new tag] v1.1.2 -> v1.1.2 Updating rbenv-update Updating ruby-build | From git://github.com/sstephenson/ruby-build # rbenv install -l 2.5.8 2.6.6 2.7.2 3.0.0 jruby-9.2.16.0 mruby-2.1.2 rbx-5.0 truffleruby-21.0.0 truffleruby+graalvm-21.0.0 Only latest stable releases for each Ruby implementation are shown. Use 'rbenv install --list-all / -L' to show all local versions. # openssl version OpenSSL 1.0.1e-fips 11 Feb 2013 # rbenv install 2.6.6 約10分くらいかかった 使えるバージョンを確認 # rbenv versions * 2.2.3 (set by /opt/rbenv/version) 2.6.6 globalを変更 # rbenv global 2.6.6 # rbenv versions 2.2.3 * 2.6.6 (set by /opt/rbenv/version) # ruby -v ruby 2.6.6p146 (2020-03-31 revision 67876) [x86_64-linux] Redmine本体の場所 ディレクトリ /path/to/redmine3.2.0 /path/to/redmine4.1.1 それぞれディレクトリ分けてインストールしている。 /opt/redmine3.2.0 , /opt/redmine4.1.1 のディレクトリとして運用 Redmine本体のインストール Redmine4.1.1 を https://www.redmine.org/releases/ から tar.gzをダウンロードして展開する cd /opt/ curl -O https://www.redmine.org/releases/redmine-4.1.1.tar.gz tar xvzf redmine-4.1.1.tar.gz 展開後、所有者変更 chown -R apache:apache redmine-4.1.1 cronやapache等のためにシンボリックリンクを使っているため、シンボリックリンクを変更 変更前 # cd /opt # ls -l 合計 8 drwxr-xr-x 13 root root 4096 3月 5 16:54 rbenv lrwxrwxrwx 1 root root 19 5月 18 2016 redmine -> /opt/redmine-3.2.0/ # unlink redmine # ln -s /opt/redmine-4.1.1/ redmine # ls -l 合計 2664 drwxr-xr-x 13 root root 4096 3月 5 16:54 rbenv lrwxrwxrwx 1 root root 19 3月 5 17:56 redmine -> /opt/redmine-4.1.1/ drwxrwxr-x 19 apache apache 4096 5月 28 2016 redmine-3.2.0 drwxrwxr-x 17 apache apache 4096 4月 7 2020 redmine-4.1.1 -rw-r--r-- 1 root root 2712056 3月 5 17:43 redmine-4.1.1.tar.gz drwxr-xr-x. 2 root root 6 3月 26 2015 rh 設定ファイルのコピー(DB接続情報、Redmineからのメール送信の情報) # cp -avp /opt/redmine-3.2.0/config/database.yml /opt/redmine-4.1.1/config/ # cp -avp /opt/redmine-3.2.0/config/configuration.yml /opt/redmine-4.1.1/config/ bundlerを入れる、 Gemfileに バージョン記載があるので、その範囲であること # gem install bundler:1.14.3 --no-rdoc --no-ri ERROR: While executing gem ... (OptionParser::InvalidOption) invalid option: --no-rdoc # bundler -v Bundler version 1.17.2 bundler 入れなくても良さげ(Redmine4.0の時はいれたけど) Redmineのインストールディレクトリで、必要な Gemを取得 # cd /opt/redmine-4.1.1 # bundle install --path vendor/bundler --without development test 最後に以下のメッセージが出た HEADS UP! i18n 1.1 changed fallbacks to exclude default locale. But that may break your application. Please check your Rails app for 'config.i18n.fallbacks = true'. If you're using I18n (>= 1.1.0) and Rails (< 5.2.2), this should be 'config.i18n.fallbacks = [I18n.default_locale]'. If not, fallbacks will be broken in your app by I18n 1.1.x. For more info see: https://github.com/svenfuchs/i18n/releases/tag/v1.1.0 対応 https://blog.goo.ne.jp/system-oni800/e/d63153bec6f9429f85c17d602bf16db5 https://mocomo012.hatenablog.com/entry/2019/10/16/194221 http://midnight-engineering.hatenadiary.jp/entry/2019/01/02/181645 を参考に、 # vi ./config/environments/production.rb config.logger.level = Logger::WARN config.i18n.fallbacks = [I18n.default_locale]  <<追加 # diff production.rb production.rb_bak 27d26 < config.i18n.fallbacks = [I18n.default_locale] production.rb + config.i18n.fallbacks = [I18n.default_locale] 再度、bundler を実行する cd /opt/redmine-4.1.1 bundle install --path vendor/bundler --without development test 以下となって正常終了 Using rouge 3.12.0 Bundle complete! 31 Gemfile dependencies, 59 gems now installed. Gems in the groups development and test were not installed. Bundled gems are installed into `./vendor/bundler` Passengerも入れる # cd /opt/redmine-4.1.1 # gem install passenger --no-rdoc --no-ri ERROR: While executing gem ... (OptionParser::InvalidOption) invalid option: --no-rdoc rbenv rehash は実施してみた。環境変数が古いのか。 引数変えれば良さげ(https://teratail.com/questions/151110) バージョン変わって引数かわったかも Passengerも入れる(引数変更) # gem install passenger --no-document 以下となって終了 Fetching rack-2.2.3.gem Fetching passenger-6.0.7.gem Successfully installed rack-2.2.3 Building native extensions. This could take a while... Successfully installed passenger-6.0.7 2 gems installed passenger の apache入れる(10-15分くらい?) # passenger-install-apache2-module (passenger-install-apache2-module --auto --languages ruby   という引数指定もある) Please edit your Apache configuration file, and add these lines: と出る、以下のメッセージはメモっておく LoadModule passenger_module /opt/rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/passenger-6.0.7/buildout/apache2/mod_passenger.so <IfModule mod_passenger.c> PassengerRoot /opt/rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/passenger-6.0.7 PassengerDefaultRuby /opt/rbenv/versions/2.6.6/bin/ruby </IfModule> 続けて、 Validating installation... * Checking whether this Passenger install is in PATH... ✓ * Checking whether there are no other Passenger installations... (!) You are currently validating against Phusion Passenger 6.0.7, located in: /opt/rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/passenger-6.0.7/bin/passenger Besides this Passenger installation, the following other Passenger installations have also been detected: /opt/rbenv/shims/passenger Please uninstall these other Passenger installations to avoid confusion or conflicts. * Checking whether Apache is installed... ✓ * Checking whether the Passenger module is correctly configured in Apache... ✗ Incorrect Passenger module path detected Phusion Passenger for Apache requires a 'LoadModule passenger_module' directive inside an Apache configuration file. This directive has been detected in the following config file: /etc/httpd/conf.d/redmine.conf However, the directive refers to the following Apache module, which is wrong: /opt/rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/passenger-5.0.28/buildout/apache2/mod_passenger.so Please edit the config file and change the directive to this instead: LoadModule passenger_module /opt/rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/passenger-6.0.7/buildout/apache2/mod_passenger.so Detected 1 error(s), 1 warning(s). Please solve the above issues, then press ENTER to continue. 既存のApacheのconfファイル redmine.conf は書き換えられなかったという エラー? 上記のメモの通り、Apacheのconfファイルを変更する cd /etc/httpd/conf.d/ vi redmine.conf また、/var/www でシンボリックリンクを作成しているため変更する # cd /var/www/html # ls -l redmine -> /opt/redmine-3.2.0/public ←前のバージョンのシンボリックリンク # unlink redmine # ln -s /opt/redmine-4.1.1/public redmine redmine -> /opt/redmine-4.1.1/public ←変更後のシンボリックリンク 新しいセッション保護用の秘密鍵を生成してください。 # cd /opt/redmine-4.1.1 # bundle exec rake generate_secret_token # ls -l /opt/redmine-4.1.1/config/initializers/ secret_token.rb ←このファイルが出来上がる bundle # cd /opt/redmine-4.1.1 # export RAILS_ENV=production # bundle update 以下メッセージでbundleの更新完了 Using rouge 3.12.0 Bundle updated! Gems in the groups development and test were not installed. rakeマイグレーション VMWareでクローンしているため、MySQLのデータベース内には Redmine3.2として使っていたデータが格納されている、そのためこの手順ではインポートしていないが、実行の移行時にはインポートする マイグレーション実行前のMySQLのバックアップ mysqldump -uXXXXX -pXXXXX データベース名| gzip > /home/redmine_`date +%y_%m_%d`.gz DBマイグレーションの実行、ここから緊張する、成功するか失敗するか、祈れ。 # cd /path/to/redmine # export RAILS_ENV=production # bundle exec rake db:migrate エラー発生!、原因究明をしていく bundle exec rake db:migrate == 20160404080304 ForcePasswordResetDuringSetup: migrating ==================== == 20160404080304 ForcePasswordResetDuringSetup: migrated (0.0782s) =========== == 20160416072926 RemovePositionDefaults: migrating =========================== -- change_column("boards", :position, :integer, {:default=>nil}) -> 0.0372s -- change_column("custom_fields", :position, :integer, {:default=>nil}) -> 0.0582s -- change_column("enumerations", :position, :integer, {:default=>nil}) -> 0.0333s -- change_column("issue_statuses", :position, :integer, {:default=>nil}) -> 0.0309s -- change_column("roles", :position, :integer, {:default=>nil}) -> 0.0286s -- change_column("trackers", :position, :integer, {:default=>nil}) -> 0.0219s == 20160416072926 RemovePositionDefaults: migrated (0.2921s) ================== == 20160529063352 AddRolesSettings: migrating ================================= -- add_column(:roles, :settings, :text, {}) -> 0.0745s == 20160529063352 AddRolesSettings: migrated (0.0746s) ======================== == 20161001122012 AddTrackerIdIndexToWorkflows: migrating ===================== -- add_index(:workflows, :tracker_id) -> 0.1898s == 20161001122012 AddTrackerIdIndexToWorkflows: migrated (0.1899s) ============ == 20161002133421 AddIndexOnMemberRolesInheritedFrom: migrating =============== -- add_index(:member_roles, :inherited_from) -> 0.2305s == 20161002133421 AddIndexOnMemberRolesInheritedFrom: migrated (0.2307s) ====== == 20161010081301 ChangeIssuesDescriptionLimit: migrating ===================== -- change_column(:issues, :description, :text, {:limit=>16777216}) -> 12.4342s == 20161010081301 ChangeIssuesDescriptionLimit: migrated (12.4345s) =========== == 20161010081528 ChangeJournalDetailsValueLimit: migrating =================== -- change_column(:journal_details, :value, :text, {:limit=>16777216}) -> 20.0198s -- change_column(:journal_details, :old_value, :text, {:limit=>16777216}) -> 18.6174s == 20161010081528 ChangeJournalDetailsValueLimit: migrated (38.6376s) ========= == 20161010081600 ChangeJournalsNotesLimit: migrating ========================= -- change_column(:journals, :notes, :text, {:limit=>16777216}) rake aborted! StandardError: An error has occurred, all later migrations canceled: Mysql2::Error: Invalid default value for 'created_on': ALTER TABLE `journals` CHANGE `notes` `notes` longtext DEFAULT NULL /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/mysql2-0.5.3/lib/mysql2/client.rb:131:in `_query' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/mysql2-0.5.3/lib/mysql2/client.rb:131:in `block in query' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/mysql2-0.5.3/lib/mysql2/client.rb:130:in `handle_interrupt' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/mysql2-0.5.3/lib/mysql2/client.rb:130:in `query' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:187:in `block (2 levels) in execute' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activesupport-5.2.4.2/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activesupport-5.2.4.2/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activesupport-5.2.4.2/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:186:in `block in execute' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/connection_adapters/abstract_adapter.rb:581:in `block (2 levels) in log' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/connection_adapters/abstract_adapter.rb:580:in `block in log' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activesupport-5.2.4.2/lib/active_support/notifications/instrumenter.rb:23:in `instrument' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/connection_adapters/abstract_adapter.rb:571:in `log' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:185:in `execute' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/connection_adapters/mysql/database_statements.rb:28:in `execute' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:371:in `change_column' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:871:in `block in method_missing' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:840:in `block in say_with_time' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:840:in `say_with_time' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:860:in `method_missing' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration/compatibility.rb:26:in `change_column' /opt/redmine-4.1.1/db/migrate/20161010081600_change_journals_notes_limit.rb:5:in `up' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:817:in `exec_migration' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:798:in `block (2 levels) in migrate' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:797:in `block in migrate' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:416:in `with_connection' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:796:in `migrate' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:977:in `migrate' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:1292:in `block in execute_migration_in_transaction' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:1345:in `ddl_transaction' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:1291:in `execute_migration_in_transaction' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:1263:in `block in migrate_without_lock' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:1262:in `each' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:1262:in `migrate_without_lock' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:1210:in `block in migrate' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:1363:in `with_advisory_lock' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:1210:in `migrate' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:1036:in `up' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:1011:in `migrate' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/tasks/database_tasks.rb:172:in `migrate' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/railties/databases.rake:60:in `block (2 levels) in <top (required)>' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/rake-13.0.3/exe/rake:27:in `<top (required)>' /opt/rbenv/versions/2.5.8/bin/bundle:23:in `load' /opt/rbenv/versions/2.5.8/bin/bundle:23:in `<main>' Caused by: ActiveRecord::StatementInvalid: Mysql2::Error: Invalid default value for 'created_on': ALTER TABLE `journals` CHANGE `notes` `notes` longtext DEFAULT NULL /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/mysql2-0.5.3/lib/mysql2/client.rb:131:in `_query' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/mysql2-0.5.3/lib/mysql2/client.rb:131:in `block in query' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/mysql2-0.5.3/lib/mysql2/client.rb:130:in `handle_interrupt' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/mysql2-0.5.3/lib/mysql2/client.rb:130:in `query' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:187:in `block (2 levels) in execute' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activesupport-5.2.4.2/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activesupport-5.2.4.2/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activesupport-5.2.4.2/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:186:in `block in execute' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/connection_adapters/abstract_adapter.rb:581:in `block (2 levels) in log' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/connection_adapters/abstract_adapter.rb:580:in `block in log' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activesupport-5.2.4.2/lib/active_support/notifications/instrumenter.rb:23:in `instrument' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/connection_adapters/abstract_adapter.rb:571:in `log' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:185:in `execute' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/connection_adapters/mysql/database_statements.rb:28:in `execute' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:371:in `change_column' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:871:in `block in method_missing' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:840:in `block in say_with_time' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:840:in `say_with_time' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:860:in `method_missing' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration/compatibility.rb:26:in `change_column' /opt/redmine-4.1.1/db/migrate/20161010081600_change_journals_notes_limit.rb:5:in `up' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:817:in `exec_migration' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:798:in `block (2 levels) in migrate' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:797:in `block in migrate' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:416:in `with_connection' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:796:in `migrate' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:977:in `migrate' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:1292:in `block in execute_migration_in_transaction' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:1345:in `ddl_transaction' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:1291:in `execute_migration_in_transaction' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:1263:in `block in migrate_without_lock' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:1262:in `each' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:1262:in `migrate_without_lock' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:1210:in `block in migrate' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:1363:in `with_advisory_lock' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:1210:in `migrate' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:1036:in `up' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:1011:in `migrate' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/tasks/database_tasks.rb:172:in `migrate' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/railties/databases.rake:60:in `block (2 levels) in <top (required)>' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/rake-13.0.3/exe/rake:27:in `<top (required)>' /opt/rbenv/versions/2.5.8/bin/bundle:23:in `load' /opt/rbenv/versions/2.5.8/bin/bundle:23:in `<main>' Caused by: Mysql2::Error: Invalid default value for 'created_on' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/mysql2-0.5.3/lib/mysql2/client.rb:131:in `_query' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/mysql2-0.5.3/lib/mysql2/client.rb:131:in `block in query' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/mysql2-0.5.3/lib/mysql2/client.rb:130:in `handle_interrupt' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/mysql2-0.5.3/lib/mysql2/client.rb:130:in `query' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:187:in `block (2 levels) in execute' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activesupport-5.2.4.2/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activesupport-5.2.4.2/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activesupport-5.2.4.2/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:186:in `block in execute' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/connection_adapters/abstract_adapter.rb:581:in `block (2 levels) in log' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/connection_adapters/abstract_adapter.rb:580:in `block in log' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activesupport-5.2.4.2/lib/active_support/notifications/instrumenter.rb:23:in `instrument' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/connection_adapters/abstract_adapter.rb:571:in `log' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:185:in `execute' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/connection_adapters/mysql/database_statements.rb:28:in `execute' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:371:in `change_column' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:871:in `block in method_missing' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:840:in `block in say_with_time' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:840:in `say_with_time' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:860:in `method_missing' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration/compatibility.rb:26:in `change_column' /opt/redmine-4.1.1/db/migrate/20161010081600_change_journals_notes_limit.rb:5:in `up' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:817:in `exec_migration' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:798:in `block (2 levels) in migrate' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:797:in `block in migrate' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:416:in `with_connection' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:796:in `migrate' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:977:in `migrate' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:1292:in `block in execute_migration_in_transaction' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:1345:in `ddl_transaction' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:1291:in `execute_migration_in_transaction' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:1263:in `block in migrate_without_lock' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:1262:in `each' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:1262:in `migrate_without_lock' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:1210:in `block in migrate' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:1363:in `with_advisory_lock' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:1210:in `migrate' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:1036:in `up' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/migration.rb:1011:in `migrate' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/tasks/database_tasks.rb:172:in `migrate' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/railties/databases.rake:60:in `block (2 levels) in <top (required)>' /opt/redmine-4.1.1/vendor/bundler/ruby/2.5.0/gems/rake-13.0.3/exe/rake:27:in `<top (required)>' /opt/rbenv/versions/2.5.8/bin/bundle:23:in `load' /opt/rbenv/versions/2.5.8/bin/bundle:23:in `<main>' Tasks: TOP => db:migrate (See full trace by running task with --trace)``` 原因は、DATETIME型のカラムで DEFAULT '0000-00-00 00:00:00' があることで、ALTERが失敗する ALTERしているカラムが文字列やlogtext型への変更が要因ではなく、ALTERした後の定義に、DEFAULT '0000-00-00 00:00:00' が存在することがNG 長年RedmineをMySQLの古いバージョンから使いつづけ、今回のマイグレーションで見つかった問題 テーブル定義の一例 mysql> desc time_entries; +-------------+---------------+------+-----+---------------------+----------------+ | Field | Type | Null | Key | Default | Extra | +-------------+---------------+------+-----+---------------------+----------------+ | id | int(11) | NO | PRI | NULL | auto_increment | | project_id | int(11) | NO | MUL | 0 | | | user_id | int(11) | NO | MUL | 0 | | | issue_id | int(11) | YES | MUL | NULL | | | hours | float | NO | | 0 | | | comments | varchar(1024) | YES | | NULL | | | activity_id | int(11) | NO | MUL | 0 | | | spent_on | date | NO | | 0000-00-00 | | | tyear | int(11) | NO | | 0 | | | tmonth | int(11) | NO | | 0 | | | tweek | int(11) | NO | | 0 | | | created_on | datetime | NO | MUL | 0000-00-00 00:00:00 | | | updated_on | datetime | NO | | 0000-00-00 00:00:00 | | +-------------+---------------+------+-----+---------------------+----------------+ 対策 今後のためも考え、DEFAULT '0000-00-00 00:00:00' を撲滅させる DEFAULT CURRENT_TIMESTAMP にはしない、Redmine4.1を新規構築してDEFAULTはNULLであることは別で確認済 対策例、1回のALTER文で行うこと -- comments /* ALTER TABLE comments MODIFY created_on datetime DEFAULT null; ALTER TABLE comments MODIFY created_on datetime not null ; ALTER TABLE comments MODIFY updated_on datetime DEFAULT null; ALTER TABLE comments MODIFY updated_on datetime not null ; */ -- ↑のように2つのカラムがあると1つごとのSQLではダメ、なので↓のようにする ALTER TABLE comments MODIFY created_on datetime DEFAULT null , MODIFY updated_on datetime DEFAULT null; ALTER TABLE comments MODIFY created_on datetime not null , MODIFY updated_on datetime not null ; rakeマイグレーション前に、ALTERを実行する 先述の通り、ALTERしてからDBマイグレーションを行うと完走する # export RAILS_ENV=production # bundle exec rake db:migrate == 20160404080304 ForcePasswordResetDuringSetup: migrating ==================== == 20160404080304 ForcePasswordResetDuringSetup: migrated (0.1158s) =========== 略 == 20190620135549 ChangeRolesNameLimit: migrating ============================= -- change_column(:roles, :name, :string, {:limit=>255, :default=>""}) -> 0.0302s == 20190620135549 ChangeRolesNameLimit: migrated (0.0303s) ==================== キャッシュクリア bundle exec rake tmp:clear Redmineを起動(Apacheを起動) 構築なので、プラグインをいれない状態での動作確認 スーパーユーザーの権限(システム管理権限)を保持したユーザでログインする 管理 -> 情報 を見ると プラグインの導入 プラグイン導入の指標 Redmine公式のpluginのページ https://www.redmine.org/plugins いっぱいある、導入時の指標の1つとしてスターの数で判断 Redmine3.2.0で導入しているプラグイン、これらをバージョンアップ Redmine plugins: redmine_code_review 0.7.0 redmine_default_custom_query 1.2.0 redmine_messenger 1.0.3 redmine_slack 0.1 view_customize 1.1.4 redmine_code_review plugin のページ https://www.redmine.org/plugins/redmine_code_review https://www.r-labs.org/projects/r-labs/wiki/Code_Review Compatible with: Redmine 4.1.x, 4.0.x Githubリポジトリ https://github.com/haru/redmine_code_review https://github.com/haru/redmine_code_review/releases https://github.com/haru/redmine_code_review/releases/download/1.0.0/redmine_code_review-1.0.0.zip Changelog 1.0.0 (2018-12-31) Compatible with Redmine 4.1.x, 4.0.x. Download https://github.com/haru/redmine_code_review/releases/tag/1.0.0 1.0.0以降は出ていない、1.0.0でRedmine4.0も4.1も対応している install https://www.r-labs.org/projects/r-labs/wiki/Code_Review_en では 1.Copy the plugin into the vendor/plugins directory 2.Migrate plugin: rake db:migrate_plugins RAILS_ENV=production 3.Start Redmine ・・・ と記載があり、vendorディレクトリに入れるようになっているが Redmin3.2では vendorには入れていない。{redmine_dir}/plugins に入れている https://www.redmine.org/plugins/redmine_code_review の通りインストールする 1.Copy the plugin into the plugins directory ``` cd {redmine_path}/plugins curl -OL https://github.com/haru/redmine_code_review/releases/download/1.0.0/redmine_code_review-1.0.0.zip unzip redmine_code_review-1.0.0.zip rm -rf __MACOSX/ chown -R apache:apache redmine_code_review ```` 2.Migrate plugin: rake redmine:plugins:migrate RAILS_ENV=production ``` cd {redmine_path} bundle exec rake redmine:plugins:migrate RAILS_ENV=production ``` 3.Restart Redmine ``` systemctl reload httpd.service ``` 4.Enable the module on the project setting page. 5.Goto Code Review setting tab and select the tracker for code reviews. redmine_code_review-1.0.0.zip 展開すると、「__MACOSX」不要なファイルがたくさんある 検証 プロジェクト 設定-> モジュール「コードレビュー」をチェックON -> 保存 プロジェクト 設定 タブ「コードレビュー」が表示され、割り当てるトラッカー、アサインするトラッカーが表示・選択でき、「更新」できること redmine_default_custom_query plugin のページ https://www.redmine.org/plugins/redmine_default_custom_query 対応バージョン Redmine3.1.x ~ Redmine3.4.x の記載までgithubの情報が最新 https://github.com/hidakatsuya/redmine_default_custom_query/blob/master/README.md ここみると、Redmine4.0, Ruby2.6までの記載はある Version 1.5.0が最終リリースで 2019-10-27 issues の#48 で 4.1.1で error がある模様 (https://github.com/hidakatsuya/redmine_default_custom_query/issues/48) install cd /path/to/your-redmine/plugins git clone https://github.com/hidakatsuya/redmine_default_custom_query.git redmine_default_custom_query chown -R apache:apache redmine_default_custom_query cd ../ bundle install --without development test bundle exec rake redmine:plugins:migrate RAILS_ENV=production または rake redmine:plugins:migrate NAME=redmine_default_custom_query RAILS_ENV=production 検証 設定 -> プロジェクト -> モジュール「デフォルトカスタムクエリ」をチェックON -> 保存 -> プロジェクト設定にて タブ「デフォルトカスタムクエリ」が表示される -> タブを選択し、デフォルトカスタムクエリのプルダウンを選択 -> チケット一覧がその条件にあった一覧になること redmine_messenger slack,mattermost,rocketchatプラグインをforkしているのでいい感じに使える plugin のページ https://www.redmine.org/plugins/ Messenger plugin for Redmine with Slack, Discord, Rocket.Chat and Mattermost support. It notifies your chat server when something happened in your specific Redmine projects. This plugin is a fork of redmine_slack, redmine_mattermost and redmine_rocketchat. With one installation you can use all popular messengers and decide which one is the best for your team in order to collaborate and receive notifications about important Redmine changes in real-time. Changelog 1.0.6 (2019-12-31) Compatible with Redmine 4.1.x, 4.0.x. See Changelog at Github. Redmineからslackへの通知は、このpluginでいけるのでは?(プラグイン「redmine_slack」は「redmine_messenger」で代替可能そう) Redmine version 4.0.0以上、Ruby2.4以上となっている(昔は、古いRedmineのバージョンでも動いたと思われる、Redmine3.2で動かしていたので) install インストール方法 https://github.com/alphanodes/redmine_messenger#installation cd {$REDMINE_ROOT}/plugins git clone https://github.com/AlphaNodes/redmine_messenger.git redmine_messenger chown -R apache:apache redmine_messenger cd {$REDMINE_ROOT} bundle update bundle exec rake redmine:plugins:migrate RAILS_ENV=production 検証 設定例は以下がわかりやすい https://qiita.com/Yoto_3/items/417d40e900c65cae23ec redmineがインストールされたサーバから直にcurlでリクエストすると何がダメか切り分けしやすい https://docs.mattermost.com/developer/webhooks-incoming.html 例) curl -i -X POST -H "Content-Type: application/json" -d "{\"text\": \"Hello, this is some text\nThis is more text. :tada:\"}" https://xxx/hooks/5qqrphwdwbabcdfghijklmn MattermostのRedmine用のワークスペースを設定する場合は URL:https://xxx/hooks/h7z3ihg8qabcdefghijklmn チャンネル:redmine_hook Redmine Slack plugin のページ https://github.com/sciyoshi/redmine-slack だが、メンテナンスされていない https://www.redmine.org/plugins/redmine_slack (https://github.com/evolvingweb/redmine_slack) を変わりに導入するか? また、前述記載済の「redmine_messenger」でslack連携可能な記載があるのでそれを使う方が良いのではないか? → redmine_messangerを使う方針で決定 view_customize plugin のページ https://www.redmine.org/plugins/view_customize Githubリポジトリ https://github.com/onozaty/redmine-view-customize 対応バージョン Redmine 4.1.x, 4.0.x, 3.4.x, 3.3.x, 3.2.x, 3.1.x Changelog 2.8.1 (2021-02-13) Compatible with Redmine 4.1.x, 4.0.x, 3.4.x, 3.3.x, 3.2.x, 3.1.x. https://github.com/onozaty/redmine-view-customize/releases/tag/v2.8.1 インストール方法 Installation notes cd {RAILS_ROOT}/plugins git clone https://github.com/onozaty/redmine-view-customize.git view_customize chown -R apache:apache view_customize cd ../ bundle install --without development test bundle exec rake redmine:plugins:migrate RAILS_ENV=production 検証 http://redmineのホスト/admin 管理 -> 設定 プラグインにて、当該プラグインがエラーなく表示されること チケットのコメントの背景が薄い黄色になること チケットの関連するチケット と 履歴コメントの間に、 「show All」が表示されること、その切替が動作すること https://redmineのホスト/view_customizes での表示を確認する プラグイン入れたもの一覧とバージョン テーマとfavicon themesの適用と redmine_theme_farend_fancy-masterを従来から使っており、https://github.com/farend/redmine_theme_farend_fancy によると、 public/themes以下にテーマを保存 Redmineのインストールディレクトリで以下のコマンドを実行してください。 git clone https://github.com/farend/redmine_theme_farend_fancy.git public/themes/farend_fancy gitコマンドが利用できない場合、以下のURLからzipファイルをダウンロードし展開してください。 https://github.com/farend/redmine_theme_farend_fancy/archive/master.zip アーカイブを展開した結果作成されたディレクトリをRedmineインストールディレクトリ以下のpublic/themesディレクトリにfarend_fancyという名前でコピーしてください。 新しいテーマの利用 Redmineの管理画面で新しいテーマを利用する設定を行います。 「管理」→「設定」→「表示」画面内の項目「テーマ」で「Fare fancy」を選択、画面最下部の「保存」ボタンをクリックしてください。 設定例 install cd /opt/redmine-4.1.1/public/themes git clone https://github.com/farend/redmine_theme_farend_fancy.git farend_fancy chown -R apache:apache farend_fancy Redmine画面 管理 -> 表示 -> テーマのプルダウン、Farend fancy を選択 favicon.ico のコピー 単にファイルのコピーのみ cp -avp /opt/redmine-3.2.0/public/favicon.ico /opt/redmine-4.1.1/public/ `/opt/redmine-3.2.0/public/favicon.ico' -> `/opt/redmine-4.1.1/public/favicon.ico' ログローテーション Apache / Redmine / MySQL 等のログローテーション回数等を設定する Redmineはデフォルトだと1ファイルに出力するため、日々のローテーション等に変えておく方が良い Apacheはアクエス元、アクエス先などを保持しておくため長期保持する(RedmineのログはApacheよりも詳細な内容になる MySQLのログローテーション 参考 https://leben.mobi/blog/mysql-logrotate/linux/ https://pgmemo.tokyo/data/archives/1114.html https://blog.inouetakuya.info/entry/20130320/1363776504 # logrotate -dv /etc/logrotate.d/mysql テスト logrotate -dv /etc/logrotate.d/mysql 実際にローテーション logrotate -v /etc/logrotate.d/mysql 以下の日付を変更することで、ローテーションテストできる # cat /var/lib/logrotate.status |grep mysql "/var/log/mysql/mysqld.log" 2021-3-16-17:0:0 Redmineのログローテーション # cat /etc/logrotate.d/redmine /opt/redmine-3.2.0/log/*.log { daily notifempty missingok copytruncate compress rotate 14 su apache apache } 変更後、シンボリックリンクのパスでローテーションするようにした # cat /etc/logrotate.d/redmine /opt/redmine-3.2.0/log/*.log { daily notifempty missingok copytruncate compress rotate 14 su apache apache } # symbolic link /opt/redmine/log/*.log { dateext daily notifempty missingok copytruncate compress rotate 365 su apache apache } 動作確認 # logrotate -dv /etc/logrotate.d/redmine 以下の日付を変更することで、ローテーションテストできる # cat /var/lib/logrotate.status |grep redmine "/opt/redmine-3.2.0/log/production.log" 2021-3-5-14:36:5 実際にローテーション logrotate -v /etc/logrotate.d/redmine MySQLとテーブルの文字エンコードを変更(utf8 -> utf8mb4) 1.. ここまでの作業で、Redmineのバージョンアップとしての構築はできていますが、画面や連携等で絵文字入力、ファイル名に絵文字があるとエラーで登録できず不便なので対応する 2.. mysqlの設定ファイル確認 # cat /etc/my.cnf 3.. mysqlに接続して database 単位での characterを確認 mysql -uXXXX -p -h localhost mysql> show variables like "character%"; +--------------------------+----------------------------+ | Variable_name | Value | +--------------------------+----------------------------+ | character_set_client | utf8 | | character_set_connection | utf8 | | character_set_database | latin1 | | character_set_filesystem | binary | | character_set_results | utf8 | | character_set_server | latin1 | | character_set_system | utf8 | | character_sets_dir | /usr/share/mysql/charsets/ | +--------------------------+----------------------------+ 8 rows in set (0.01 sec) mysql> use databasenamaeXXXX; Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A show variables like "character%";Database changed mysql> show variables like "character%"; +--------------------------+----------------------------+ | Variable_name | Value | +--------------------------+----------------------------+ | character_set_client | utf8 | | character_set_connection | utf8 | | character_set_database | utf8 | # For advice on how to change settings please see | character_set_filesystem | binary | | character_set_results | utf8 | # For advice on how to change settings please see | character_set_server | latin1 | | character_set_system | utf8 | | character_sets_dir | /usr/share/mysql/charsets/ | +--------------------------+----------------------------+ 8 rows in set (0.00 sec) mysql> mysql> quit; Bye 4.. /etc/my.cnf に utf8mb4を設定追加 、2つのセクションに追加する [mysqld] character-set-server = utf8mb4 [client] default-character-set=utf8mb4 5.. mysqlインスタンスを再起動 systemctl restart mysqld.service 6.. データベース内の設定を変更 mysql> use redmine; Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed mysql> show variables like "character%"; +--------------------------+----------------------------+ | Variable_name | Value | +--------------------------+----------------------------+ | character_set_client | utf8mb4 | | character_set_connection | utf8mb4 | | character_set_database | utf8 | | character_set_filesystem | binary | | character_set_results | utf8mb4 | | character_set_server | utf8mb4 | | character_set_system | utf8 | | character_sets_dir | /usr/share/mysql/charsets/ | +--------------------------+----------------------------+ 8 rows in set (0.01 sec) 7.. database は utf8 のままなので、 mysql内のredmineデータベースの文字コードを変更 mysql> alter database redmine character set utf8mb4; Query OK, 1 row affected (0.00 sec) mysql> show variables like "character%"; +--------------------------+----------------------------+ | Variable_name | Value | +--------------------------+----------------------------+ | character_set_client | utf8mb4 | | character_set_connection | utf8mb4 | | character_set_database | utf8mb4 | | character_set_filesystem | binary | | character_set_results | utf8mb4 | | character_set_server | utf8mb4 | | character_set_system | utf8 | | character_sets_dir | /usr/share/mysql/charsets/ | +--------------------------+----------------------------+ 8 rows in set (0.00 sec) 8.. database内の全テーブルのエンコードを変える ALTER分の生成は移行編の記事の方で詳細を記載予定 ファイル /tmp/alters_table_CHARSET.sql としてSQL生成 alter table `ar_internal_metadata` convert to character set utf8mb4; alter table `attachments` convert to character set utf8mb4; alter table `auth_sources` convert to character set utf8mb4; alter table `boards` convert to character set utf8mb4; alter table `changes` convert to character set utf8mb4; ・・・ utf8mb4への変更するALTERをSQLファイル読み込みで実行する。ALTER文のコピー&ペーストは途中でエラーになることがあるので量が多いときは非推奨 mysql -uXXXX -p -D redmineが使うdatabasename < /tmp/alters_table_CHARSET.sql 9.. redmineのデータベース設定ファイルを変更する /opt/redmine-4.1.1/config/database.yml production: adapter: mysql2 database: redmineが使うデータベース host: localhost username: XXXX password: XXXX encoding: utf8mb4 redmine用 httpdを開始する # systemctl start httpd.service 動作確認 絵文字のサンプル、チケットの本文やコメント等に入力して反映できるか試す マグロ?スシ マグロ?スシ ここまでで、Redmine4.1の構築とバージョンは完了 RedMica1.2への切替え(バージョンアップ) 手順は、インストール済みのRedmineをRedMica 1.2に切り替える手順 を参考にすれば良い。その手順では 既存のredmine4.1の場所をベースに、 git clone して gitの管理ファイルを使い、 git pull, git checkout 運用でバージョンアップしていく場合に有用な手順です。 Redmine4.1とは別ディレクトリで運用していくケースでは少し異なり、途中でミスってます(なので最後まで手順確認してから行うようにしてください)。 ミスしている過程を載せているため、一部の後続手順を前に持ってきてください。 RedMicaを取得し配置する curl -O https://github.com/redmica/redmica/archive/refs/tags/v1.2.1.tar.gz curlが失敗、HTTPステータス304なのが要因なのかな。wgetでは成功する # cd /tmp # wget -c https://github.com/redmica/redmica/archive/refs/tags/v1.2.1.tar.gz ファイル名を変更 # mv v1.2.1.tar.gz redmica-1.2.1.tar.gz /opt/ にもっていくので移動 # mv redmica-1.2.1.tar.gz /opt/ # tar -xvzf redmica-1.2.1.tar.gz # cd /opt/redmica-1.2.1 git 関係ファイルがないことを確認 # gt status RedMica1.2を使う設定をしていく bundle cd /opt/redmica-1.2.1 bundle update bundle updateすると、データベースのymlを設定するメッセージ(Please configure your config/database.yml first)が表示されるが、updateは処理される config ファイル(database.yml、configuration.yml)をRedmine4.1の場所からコピーする # cp -avp /opt/redmine-4.1.1/config/database.yml /opt/redmica-1.2.1/config/ # cp -avp /opt/redmine-4.1.1/config/configuration.yml /opt/redmica-1.2.1/config/ 再度 bundle update を行う pluginsディレクトリまるごと redmine4.1からコピー cp -avp /opt/redmine-4.1.1/plugins/* /opt/redmica-1.2.1/plugins/ マイグレーション コマンド # export RAILS_ENV=production # bundle exec rake db:migrate または bin/rails db:migrate RAILS_ENV=production 実行 # cd /opt/redmica-1.2.1 # export RAILS_ENV=production # bundle exec rake db:migrate Could not find gem 'factory_girl' in any of the gem sources listed in your Gemfile. Run `bundle install` to install missing gems. RedMicaのディレクトリはRedmine4.1ディレクトリと同じ前提の手順のため、コマンドが不足している。 install の方をしないといけない cd /opt/redmica-1.2.1 bundle update bundle install 再度、dbマイグレーションを行う がエラーになる # cd /opt/redmica-1.2.1 # bin/rails db:migrate RAILS_ENV=production rails aborted! ArgumentError: Missing `secret_key_base` for 'production' environment, set this string with `rails credentials:edit` /opt/redmica-1.2.1/config/environment.rb:16:in `<top (required)>' bin/rails:4:in `require' bin/rails:4:in `<main>' Tasks: TOP => db:migrate => db:load_config => environment (See full trace by running task with --trace) 要因、シークレットキー生成しが必要なので、下記を実行する # cd /opt/redmica-1.2.1 # bundle exec rake generate_secret_token プラグインのマイグレーション # export RAILS_ENV=production # bundle exec rake redmine:plugins:migrate RAILS_ENV=production キャッシュクリア bundle exec rake tmp:clear テーマとfavicon cp -avp /opt/redmine-4.1.1/public/themes/farend_fancy /opt/redmica-1.2.1/public/themes/ cp -avp /opt/redmine-4.1.1/public/favicon.ico /opt/redmica-1.2.1/public/ RedMica関連ファイルのパーミッション変更しておく # cd /opt/redmica-1.2.1 # chown -R apache:apache * シンボリックリンク変更 Apacheの読み込み用、/var/www/html のサブディレクトリ、 Apacheのconfファイル Apacheのreload 画面でバージョン確認と動作確認 ここまでで、Redmica1.2へのバージョンアップ・切替えが完了 VMWareを使っている場合はスナップショット作成をしておくと戻しやすくなります rakeコマンドでメール送信しているがエラーになっている rake コマンド実行の #!/bin/bash echo $PATH export PATH="/opt/rbenv/shims:/opt/rbenv/shims:$PATH" echo $PATH cd /opt/redmine; rake redmine:send_reminders days=3 RAILS_ENV=production echo fix.`date +"%Y%m%d_%H%M%S"` エラー内容 Gemfileでは reke は 13.0.3 が必要だとなっているのでエラーになっている /opt/rbenv/shims:/opt/rbenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin /opt/rbenv/shims:/opt/rbenv/shims:/opt/rbenv/shims:/opt/rbenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin rake aborted! Gem::LoadError: You have already activated rake 12.3.3, but your Gemfile requires rake 13.0.3. Prepending `bundle exec` to your command may solve this. /opt/redmine-4.1.1/config/boot.rb:6:in `<top (required)>' /opt/redmine-4.1.1/config/application.rb:3:in `<top (required)>' /opt/redmine-4.1.1/Rakefile:5:in `<top (required)>' (See full trace by running task with --trace) バージョン確認 $ bundle -v Bundler version 1.17.2 $ which rake /opt/rbenv/shims/rake $ rake -v rake aborted! No Rakefile found (looking for: rakefile, Rakefile, rakefile.rb, Rakefile.rb) (See full trace by running task with --trace) $ rake --version rake, version 12.3.3 $ gem list rake *** LOCAL GEMS *** rake (12.3.3) いったん消して、別バージョンを入れる $ cd /path/to/redmine $ gem uninstall rake -v 12.3.3 $ gem uninstall rake -v 12.3.3 Gem 'rake' is not installed $ gem install rake -v 13.0.3 $ bundle update rake 指定バージョンインストール後 $ rake --version rake, version 13.0.3 $ which rake /opt/rbenv/shims/rake $ gem list rake *** LOCAL GEMS *** rake (13.0.3) rakeコマンド成功を確認する
  • このエントリーをはてなブックマークに追加
  • Qiitaで続きを読む

M1 Mac で Docker mysql イメージをビルドする

M1 Mac で Docker の mysql イメージをビルドするには linux/amd64 を明示的に指定する必要がある。 Dockerfile Dockerfile を利用している場合は FROM にオプションを渡すことができる。 FROM --platform=linux/amd64 mysql:5.7 docker-compose.yaml docker-compose.yaml を利用している場合は platform を設定する。 services: db: image: mysql platform: linux/amd64
  • このエントリーをはてなブックマークに追加
  • Qiitaで続きを読む

[Prometheus] MySQL Exporter with Docker

概要 Prometheusでの、MySQLのメトリクス収集用のMySQL ExporterのDocker環境構築手順。 前提条件 以下の手順でPrometheus環境を構築していることを前提とする。 https://qiita.com/Esfahan/items/0feaedfd771f49ac7ee4 Prometheus公式のexporter 環境 mysqld_exporter v0.13.0 MySQL 5.7(監視対象) 注意 MySQLのperformance_schemaから情報を収集する。 performance_schemaはMySQL 5.5.3から導入されたパフォーマンスをモニタリングするためのスキーマ。 MySQL 5.6以降ではデフォルトでONになっているが、それ以前のバージョンではOFFになっている可能性があるので注意。 監視対象のMySQLの設定 監視対象のMySQLに以下のユーザーを追加。 MySQL Exporterから監視対象のperformance_schemaにアクセスできるようになっている必要がある。 CREATE USER 'exporter'@'%' IDENTIFIED BY 'XXXXXXXXX' WITH MAX_USER_CONNECTIONS 3; GRANT PROCESS, REPLICATION CLIENT ON *.* TO 'exporter'@'%'; GRANT SELECT ON performance_schema.* TO 'exporter'@'%'; MySQL Exporterの環境構築 docker-compose.yaml version: '3' services: mysqld-exporter: container_name: mysqld-exporter image: prom/mysqld-exporter env_file: - .env ports: - 9104:9104 .env DATA_SOURCE_NAME=exporter:XXXXXXXXX@tcp(your_db_name:3306)/performance_schema $ docker-compose up -d --build Prometheusの設定 こちらの記事で構築したPrometheus環境の設定ファイルを編集する。 監視対象を追加 prometheus/node.yaml - labels: env: development targets: # 監視対象のMySQLのホスト名:9104を追記する - your-mysql-exporter-hostname:9104 ルールを追加 /etc/prometheus/alert.rules groups: - name: sample001 rules: # MySQL用のルールを追記 - alert: mysql_down # MySQLが起動しているかのPromQL。 expr: mysql_up == 0 # 5分間応答がなければアラートを飛ばす for: 5m labels: severity: critical # エラー文言 annotations: firing_text: "[{{ $labels.env }}] {{ $labels.instance }} MySQL has been down for more than 5 minutes." resolved_text: "[{{ $labels.env }}] {{ $labels.instance }} MySQL has recoverd." UI確認 http://your_prometeus.com:9090/graph mysql_upで検索すると、正常時は 1 となっている。 監視対象のMySQLをダウンさせると、 0 として検出される。 Slackへの通知 異常時にはSlackに通知される。 関連記事 Prometheus Postgres Exporter with Docker Prometheus, Grafana, AlertMamager, Exporter with Docker
  • このエントリーをはてなブックマークに追加
  • Qiitaで続きを読む

Prometheus MySQL Exporter with Docker

概要 Prometheusでの、MySQLのメトリクス収集用のMySQL ExporterのDocker環境構築手順。 前提条件 以下の手順でPrometheus環境を構築していることを前提とする。 https://qiita.com/Esfahan/items/0feaedfd771f49ac7ee4 Prometheus公式のexporter 環境 mysqld_exporter v0.13.0 MySQL 5.7(監視対象) 注意 MySQLのperformance_schemaから情報を収集する。 performance_schemaはMySQL 5.5.3から導入されたパフォーマンスをモニタリングするためのスキーマ。 MySQL 5.6以降ではデフォルトでONになっているが、それ以前のバージョンではOFFになっている可能性があるので注意。 監視対象のMySQLの設定 監視対象のMySQLに以下のユーザーを追加。 MySQL Exporterから監視対象のperformance_schemaにアクセスできるようになっている必要がある。 CREATE USER 'exporter'@'%' IDENTIFIED BY 'XXXXXXXXX' WITH MAX_USER_CONNECTIONS 3; GRANT PROCESS, REPLICATION CLIENT ON *.* TO 'exporter'@'%'; GRANT SELECT ON performance_schema.* TO 'exporter'@'%'; MySQL Exporterの環境構築 docker-compose.yaml version: '3' services: mysqld-exporter: container_name: mysqld-exporter image: prom/mysqld-exporter env_file: - .env ports: - 9104:9104 .env DATA_SOURCE_NAME=exporter:XXXXXXXXX@tcp(your_db_name:3306)/performance_schema $ docker-compose up -d --build Prometheusの設定 こちらの記事で構築したPrometheus環境の設定ファイルを編集する。 監視対象を追加 prometheus/node.yaml - labels: env: development targets: # 監視対象のMySQLのホスト名:9104を追記する - your-mysql-exporter-hostname:9104 ルールを追加 /etc/prometheus/alert.rules groups: - name: sample001 rules: # MySQL用のルールを追記 - alert: mysql_down # MySQLが起動しているかのPromQL。 expr: mysql_up == 0 # 5分間応答がなければアラートを飛ばす for: 5m labels: severity: critical # エラー文言 annotations: firing_text: "[{{ $labels.env }}] {{ $labels.instance }} MySQL has been down for more than 5 minutes." resolved_text: "[{{ $labels.env }}] {{ $labels.instance }} MySQL has recoverd." UI確認 http://your_prometeus.com:9090/graph mysql_upで検索すると、正常時は 1 となっている。 監視対象のMySQLをダウンさせると、 0 として検出される。 Slackへの通知 異常時にはSlackに通知される。 関連記事 Prometheus Postgres Exporter with Docker Prometheus, Grafana, AlertMamager, Exporter with Docker
  • このエントリーをはてなブックマークに追加
  • Qiitaで続きを読む

初めてのローカル環境構築(MacでHomebrewを経由しRailsを導入する)

はじめに railsチュートリアルを1周した後に、オリジナルアプリ作成のためにローカル環境を構築しました。 チュートリアル学習時は、cloud9を使用していた為、初めての作業でした。 初学者のため、必須ではないコマンドが含まれているかもしれませんが、どうかご了承ください。 なかなか苦戦しながら環境設定をしたので、同じ境遇の方に少しでも参考になると幸いです。 もし、修正箇所がございましたら、ぜひ、お知らせください。 作業内容 railsに新規アプリ作成 MySQLの設定および導入 Git・GitHubの設定 herokuサーバにアプリをデプロイ 前提 PC仕様 OS:macOS(Catalina) 選定技術 バックエンド:ruby(バージョン:2.7.3) フレームワーク:rails(バージョン:6.1.3.2) データベース:MySQL(バージョン:8.0.25) インフラ:heroku 1.homebrewの導入 はじめに、ターミナル(私の場合はVScodeのターミナル)に入力します。 上手くいけば、homebrewが使用可能になります。 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" homebrewはAppleで提供してないツールをインストールする時に使う便利なソフトのようです。 詳しくは、下記URLを参考にしてください。 ■Homebrew公式ページ 念のため、homebrewがインストールできているか確認します。 brew -v 〜〜実行結果〜〜 Homebrew <バージョン> ここで、homebrewのバージョンが表示されれば、インストールされています。 2.Ruby,Railsのインストール まず、homebrew経由で必要なgem一式をインストールします。 (もしかすると不要かも:ここはrailsチュートリアルを参考にしました) brew install libtool libxslt libksba openssl libyaml rubyのバージョン管理ツールrbenvとrubyをインストールします。 これでrubyを土台にしてRubyGemを使って、railsが構成できる準備が整います。 brew install rbenv ruby-build rubyバージョンを指定して、インストール&コンパイルします。 rbenv install <バージョン> ここで、ターミナルで使用しているシェルを調べておきます。 echo $SHELL 〜〜実行結果〜〜 /bin/zsh 私の場合、上記通り、zshが動作しているようでした。 先程に調べたシェルに対して、rbenv初期化コードを書き込みます。 (おそらく、MacOSがCatalinaの方は、zshかと思います) echo 'eval "$(rbenv init -)"' >> ~/bin/zsh 初期化した内容をすぐに反映させます。 (ターミナルを再起動しても同じ動作となるはずです。) source .bash_profile 土台となるrubyをバージョン指定してインストールします。 (globalは全範囲で使われる設定で、localとするとディレクトリ毎で制御できるようです。) ※railsインストールする前に行います。 rbenv global <バージョン> 一度、rubyがインストールできているか確認します。 ruby -v railsのバージョンを指定して、インストールします。 (RubyGemsをもって、railsをインストールしている) gem install rails -v <バージョン> ちゃんと、railsがインストールできているか確認します。 rails -v これで、rubyとrailsがインストールできました!良かった良かった! 3.MySQLのインストールから設定まで 続いて、データベースの設定していきます。 まず、homebrewを使ってmysqlをインストールします。 brew install mysql mysqlがインストールできたか確認します。 brew info mysql さっそく、mysqlサーバーを起動させてみます。 (停止する時はstartではなくstopをコマンドとします。) mysql.server start root権限でログインします。 mysql -uroot ログインできた所で、セキュリティ設定を行います。 (現状はパスワード無しで、ログイン可能な為) mysql_secure_installation 上記コマンドを行うと、下記質問をMySQLから聞かれるので、それぞれ回答していきます。 (基本は全てy(YES)の回答で良いのかなと。) 質問内容 パスワードの設定を行うか                 → 回答:y パスワードの強度はどうするか               → 回答:0 ~ 2 (Low:0, Medium:1, Strong:2) 登録パスワードは入力してください             → 設定するパスワードを入力 入力されたパスワードで設定して良いか           → 回答:y 匿名ユーザーを削除するか                 → 回答:y リモートサーバーからrootユーザーへのアクセスを遮断するか → 回答:y テスト用のデータベースを削除するか            → 回答:y (最後)入力内容をすぐに反映するか            → 回答:y ここまでで、ちゃんとパスワード設定できているか確認します。 mysql -uroot -p 上記コマンドで「Enter password:」とプロンプト表示されれば、設定が上手くできています。 この後に、railsアプリケーションを作成するので、念のため、 homebrewでインストールされたものを一覧で確認しておきます。 brew list 開発する作業ディレクトリ(environment)を作成して、そこに移動します。 mkdir environment cd environment railsバージョンとデータベースをMySQLに指定して、アプリケーションを作成します。 rails _<バージョン>_ new <アプリケーション名> -d mysql 作成できたアプリケーションのディレクトリに移動します。 cd <アプリ名> アプリを作成すると、gemfileとdatabase.ymlが自動で編集されます。 Gemfileのdatabase欄にあるgemが「sqlite(デフォルト)」ではなく「mysql2」となっています。 アプリ名/Gemfile 〜省略〜 # Use mysql as the database for Active Record gem 'mysql2', '~> 0.5' 〜省略〜 config/database.ymlでは、usernameとpasswordが空白になっています。 そこで、先程MySQLで設定したものを記入していきます。 config/database.yml default: &default adapter: mysql2 encoding: utf8mb4 pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> username: <設定したユーザー名> password: <設定したパスワード> socket: /tmp/mysql.sock development: <<: *default database: アプリ名_development test: <<: *default database: アプリ名_test production: <<: *default database: アプリ名_production username: アプリ名 password: <%= ENV['アプリ名_DATABASE_PASSWORD'] %> 設定するusernameとpasswordですが、 セキュリティ上、root権限で開発作業を行うのは望ましくないので、 後には、新規ユーザーを作った方が良いかもしれません。 MySQLの新規ユーザー設定は、下記記事を参考にさせて頂きました。 @reeenapi さん、ありがとうございました。 ■RailsのDBを(初めから| |後から)MySQLに変更する ここで、railsにDBを作成しておきます。 rails db:create 【下記は、必要に応じて導入してみてください。】 ・rubyのコード解析ツール(rubocop) rubocop導入には、下記記事が参考にさせて頂きました。 @d0ne1s さん、ありがとうございました。 ■VSCodeでRubocopを使う もし、新しくコード解析ツールなどのgemを書いていればバンドルを起動しておきます。 bundle install これでMySQLのインストールと設定が完了しました! 4.Git/GitHubの設定 ここからは、変更履歴を残すGit/GitHubの設定をしていきます。 Gitがインストールされているか、念のため、確認します。 (railsでは標準で搭載されていたはずです) git --version まず、Gitの設定(名前)をします。 git config --global user.name "名前" 続いて、Gitの設定(メールアドレス)をします。 git config --global user.email Eメールアドレス 任意で、Gitのパスワードを1日(86,400秒)保持する設定します。 git config --global credential.helper "cache --timeout=86400" 一旦、Gitの設定状況を確認します。 git config -l railsアプリケーションのディレクトリに移動しておきます。 cd <アプリ名> ここで、Gitの初期化を行う。 (.gitファイルが生成されて記録が残る) git init .gitファイルが存在することを、念のため、確認します。 (ls:現ディレクトリ内のファイル一覧を表示, -a:隠しファイルも含める) ls -a gitの現況を確認します。 (未add・未commitの状態を把握) git status 新規作成および変更を加えた全ファイルをgitのステージングエリアへ追加します。 git add -A ステージングエリアの変更分に問題がなければ、コミットします。 (-mでメッセージ付ける) git commit -m "メッセージ" これまでのcommit履歴を表示します。 (オプションの--onelineは1行表示) git log (--oneline) ■GitHub公式ページ(まず、こちらでリポジトリを作成する) 上記URLからリポジトリを作成後、GitHubと現在のGitのリポジトリを紐付けます。 git remote add origin https://github.com/GitHubアカウント名/アプリ名.git Git commitで変更したファイルをGitHubへpushします。 git push -u origin master これで、Git/GitHubの設定が完了です! 5.Herokuの設定からデプロイまで herokuに関しては、下記記事の一部を実行しています。 @murakami-mm さん、ありがとうございました。 ■Herokuへのデプロイ方法【Heroku+Rails+MySQL】 まず、herokuのインストールします。 ■heroku公式ページ(参考) brew tap heroku/brew && brew install heroku いつものように、herokuがインストールできているかの確認します。 heroku -v インストールできていれば、herokuサーバにアプリケーションを作成します。 heroku apps:create アプリ名 作成したアプリに、MySQLベースのClearDBというデータベースを適用させます。 無料ですが、容量が5MBです。詳細は下記にあります。 ■heroku(ClearDB概要) heroku addons:create cleardb:ignite 次は、設定のためにClearDBのURLを確認します。 heroku config 〜〜実行結果〜〜 === アプリ名 Config Vars CLEARDB_DATABASE_URL: mysql://<ユーザー名>:<パスワード>@<ホスト名>/<データベース名>?reconnect=true そして、上記で取得したURLを参考にして、各種設定をしていきます。 heroku config:add DB_NAME='<データベース名>' heroku config:add DB_USERNAME='<ユーザー名>' heroku config:add DB_PASSWORD='<パスワード>' heroku config:add DB_HOSTNAME='<ホスト名>' heroku config:add DB_PORT='3306' heroku config:add DATABASE_URL='mysql2://<ユーザー名>:<パスワード>@<ホスト名>/<データベース名>?reconnect=true' 再度、設定確認のコマンドを打って、ちゃんと設定できているか確認します。 heroku config 最後に、ローカルリポジトリの内容をherokuへpushします。 git push heroku master git push Heroku masterコマンドを打つと、返答メッセージの文末あたりに 自分が作ったWEBアプリのURLが参照されます。 そのURLをクリックして、本番環境(heroku)でアプリが起動できているか確認してみてください!! 終わりに Qiita記事を中心に情報収集しながら、はじめて環境構築をした内容をまとめました。 現在、railsで新規アプリを実装していますが、毎日エラーと戦ってます。笑 今後は、学習内容のアウトプットのために、投稿記事を増やせればと思っています。 拙い文章でしたが、最後までお読みいただき、ありがとうございました!!!!! それでは、また。
  • このエントリーをはてなブックマークに追加
  • Qiitaで続きを読む