〇構築方法
以下のVagrantfileを使用して、sysbenchとPostgreSQL10がインストールされた仮想マシン(CentOS7.5)を構築します。
Vagrantfile
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "bento/centos-7.5"
config.vm.hostname = "co75sysbenchmariadb"
config.vm.provider :virtualbox do |vbox|
vbox.name = "co75sysbenchmariadb"
vbox.cpus = 2
vbox.memory = 2048
vbox.customize ["modifyvm", :id, "--nicpromisc2","allow-all"]
end
# private network
config.vm.network "private_network", ip: "192.168.55.65", :netmask => "255.255.255.0"
# bridge netwrok
config.vm.network "public_network", ip: "192.168.1.65", :netmask => "255.255.255.0"
config.vm.provision "shell", inline: <<-SHELL
localectl set-locale LANG=ja_JP.UTF-8
timedatectl set-timezone Asia/Tokyo
# download and install postgresql.
wget https://download.postgresql.org/pub/repos/yum/10/redhat/rhel-7-x86_64/pgdg-centos10-10-2.noarch.rpm
rpm -Uvh pgdg-centos10-10-2.noarch.rpm
yum -y update
yum -y install postgresql10-server postgresql10-devel postgresql10-contrib
systemctl enable postgresql-10
# initialize postgresql server
/usr/pgsql-10/bin/postgresql-10-setup initdb
echo "listen_addresses='*'" >> /var/lib/pgsql/10/data/postgresql.conf
sed -i 's/host.*all.*all.*127.0.0.1/#host all all 127.0.0.1/g' /var/lib/pgsql/10/data/pg_hba.conf
sed -i 's#^host.*all.*all.*::1/128.*ident#host all all ::1/128 password#g' /var/lib/pgsql/10/data/pg_hba.conf
echo "host all all 127.0.0.1/32 password" >> /var/lib/pgsql/10/data/pg_hba.conf
echo "host all all 192.168.1.0/24 password" >> /var/lib/pgsql/10/data/pg_hba.conf
echo "host all all 192.168.55.0/24 password" >> /var/lib/pgsql/10/data/pg_hba.conf
systemctl restart postgresql-10.service
su - postgres << EOF
createdb -T template0 --locale=ja_JP.UTF-8 --encoding=UTF8 sysbench
psql -c "
alter user postgres with password 'postgres';
create user sysbench with password 'sysbench';
grant all privileges on database sysbench to sysbench;
"
EOF
echo "postgres:postgres" | chpasswd
# install and execute sysbench.
yum -y install epel-release
yum --enablerepo=epel -y install sysbench
sysbench cpu run --threads=2
sysbench memory run --threads=2
sysbench fileio run --file-test-mode=seqwr --threads=2
sysbench fileio run --file-test-mode=rndwr --threads=2
sysbench /usr/share/sysbench/oltp_read_write.lua prepare --db-driver=pgsql --pgsql-host=localhost --pgsql-port=5432 --pgsql-user=sysbench --pgsql-password=sysbench --pgsql-db=sysbench
sysbench /usr/share/sysbench/oltp_read_write.lua run --db-driver=pgsql --pgsql-host=localhost --pgsql-port=5432 --pgsql-user=sysbench --pgsql-password=sysbench --pgsql-db=sysbench --threads=2
SHELL
end
○関連情報
・sysbenchに関する他の記事はこちらを参照してください。
0 件のコメント:
コメントを投稿