Last active
November 29, 2018 01:47
-
-
Save nimzo6689/d26799f50fcc9e72f3b075e47694fd77 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
lookFile=/home/vagrant/provisioner.lock | |
if [ -e $lookFile ]; then | |
exit | |
fi | |
touch $lookFile | |
# mariaDBとの競合を防ぐため | |
yum -y remove mariadb-libs | |
rm -rf /var/lib/mysql | |
# https://dev.mysql.com/downloads/repo/yum/を参照 | |
yum -y localinstall http://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm | |
yum -y install mysql-community-server | |
# 必要最小限のMySQLの設定内容を書き込む | |
cat << __CONF__ >> /etc/my.cnf | |
character-set-server = utf8 | |
default_password_lifetime = 0 | |
__CONF__ | |
# MySQLの自動起動を有効化し起動する | |
systemctl enable mysqld | |
systemctl start mysqld | |
# 初期パスワードを取得する | |
password=`cat /var/log/mysqld.log | grep "A temporary password" | tr ' ' '\n' | tail -n1` | |
mysql -u root -p${password} --connect-expired-password < /vagrant/provisioner.sql |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 初回のパスワードポリシーを満たすパスワードを設定(適当でよい) | |
SET password FOR root@localhost=password('uQvdquWj3=bW'); | |
-- パスワードポリシーの変更 | |
SET global validate_password_policy=LOW; | |
SET global validate_password_length=6; | |
-- パスワードの変更 | |
SET password FOR root@localhost=password('vagrant'); | |
-- ユーザーの作成 | |
CREATE USER nimzo_user@localhost identified BY 'devnimzo'; | |
-- データベースの作成 | |
CREATE database nimzo; | |
-- テーブルの作成 | |
CREATE TABLE IF NOT EXISTS `nimzo`.`users` (`user_id` INT NOT NULL COMMENT '', | |
`is_deleted` TINYINT NOT NULL COMMENT '', | |
`updated_at` TIMESTAMP COMMENT '', | |
PRIMARY KEY (`user_id`) COMMENT '', | |
UNIQUE INDEX `user_id_UNIQUE` (`user_id` ASC) COMMENT '') | |
ENGINE = InnoDB; | |
-- 権限の付与(IPアドレスによるアクセス元の制限は指定しない) | |
GRANT ALL ON *.* TO 'nimzo_user'@'localhost' IDENTIFIED BY 'devnimzo'; | |
GRANT ALL ON *.* TO 'nimzo_user'@'%' IDENTIFIED BY 'devnimzo'; | |
FLUSH PRIVILEGES; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- mode: ruby -*- | |
# vi: set ft=ruby : | |
VAGRANTFILE_API_VERSION = "2" | |
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| | |
# マウント失敗する場合、vbgeustかyum -y upgradeを行うこと。 | |
config.vm.box = "geerlingguy/centos7" | |
config.vm.box_check_update = false | |
# ホストマシンとのマウント先を定義(デフォルトの設定通り) | |
config.vm.synced_folder ".", "/vagrant" | |
# ネットワーク上の設定 | |
config.vm.network :forwarded_port, guest: 22, host: 2222 | |
config.vm.network :private_network, ip: "192.168.33.19" | |
# ホスト名を定義 | |
# 管理者権限で実行する必要がある。 | |
if Vagrant.has_plugin?("vagrant-hostsupdater") | |
config.vm.hostname = "intra.nimzo.jp.local" | |
end | |
# パフォーマンス改善用 | |
# ローカルPCが32bitであっても64bitで仮想マシンを起動する。 | |
config.vm.provider "virtualbox" do |vb| | |
vb.name = "centos-mysql" | |
vb.memory = 4096 | |
vb.cpus = 2 | |
vb.customize [ | |
"modifyvm", :id, | |
"--ostype", "RedHat_64", | |
"--hwvirtex", "on", | |
"--nestedpaging", "on", | |
"--largepages", "on", | |
"--ioapic", "on", | |
"--pae", "on", | |
"--paravirtprovider", "kvm", | |
] | |
end | |
# パフォーマンス改善用 | |
if Vagrant.has_plugin?("vagrant-vbguest") then | |
config.vbguest.auto_update = false | |
end | |
if Vagrant.has_plugin?("vagrant-cachier") | |
config.cache.scope = :box | |
end | |
# 基本的なライブラリのインストール | |
config.vm.provision "shell", inline: <<-SHELL | |
yum -y upgrade | |
yum -y install man-pages.noarch vim git | |
SHELL | |
config.vm.provision "shell", :path => "provisioner.sh" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment