以下のVagrantfileを使用して、Percona Serverがインストールされた仮想マシン(CentOS7.4)を構築する事ができます。
Vagrantfile
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "bento/centos-7.4"
config.vm.hostname = "co74percona"
config.vm.network :public_network, ip:"192.168.1.117"
config.vm.network "private_network", ip: "192.168.55.117", :netmask => "255.255.255.0"
config.vm.provider :virtualbox do |vbox|
vbox.name = "co74percona"
vbox.cpus = 2
vbox.memory = 2048
vbox.customize ["modifyvm", :id, "--nicpromisc2","allow-all"]
end
config.vm.provision "shell", inline: <<-SHELL
localectl set-locale LANG=ja_JP.UTF-8
yum install -y epel-release
yum check-update
yum -y update
# install Percona Server
yum -y install http://www.percona.com/downloads/percona-release/redhat/0.1-4/percona-release-0.1-4.noarch.rpm
yum -y install Percona-Server-server-57
service mysql start
export MYSQL_ROOTPWD='Root123#'
export MYSQL_PWD=`cat /var/log/mysqld.log | awk '/temporary password/ {print $NF}'`
mysql -uroot -p$MYSQL_PWD --connect-expired-password -e "SET PASSWORD = PASSWORD('$MYSQL_ROOTPWD');"
mysql -uroot -p$MYSQL_ROOTPWD --connect-expired-password -e "UNINSTALL PLUGIN validate_password;"
mysql -uroot -p$MYSQL_ROOTPWD --connect-expired-password -e "SET PASSWORD = PASSWORD('root'); FLUSH PRIVILEGES;"
export MYSQL_PWD='root'
mysql -uroot -p$MYSQL_PWD --connect-expired-password -e "CREATE DATABASE test DEFAULT CHARACTER SET utf8mb4;"
mysql -uroot -p$MYSQL_PWD --connect-expired-password -e "CREATE USER test@localhost IDENTIFIED BY 'test';"
mysql -uroot -p$MYSQL_PWD --connect-expired-password -e "GRANT ALL PRIVILEGES ON test.* TO 'test'@'localhost';"
mysql -uroot -p$MYSQL_PWD --connect-expired-password -e "FLUSH PRIVILEGES;"
mysql -utest -ptest test -e "create table messages (message_id integer not null, message varchar(100));"
mysql -utest -ptest test -e "insert into messages value (1, 'hello world.');"
mysql -utest -ptest test -e "insert into messages value (2, 'test message.');"
mysql -utest -ptest test -e "select * from messages;"
SHELL
end
0 件のコメント:
コメントを投稿