PHP Redis 세션 클러스터링 테스트

1 개요[ | ]

PHP Redis 세션 클러스터링 테스트

2 Vagrantfile[ | ]

offerings = {
	'1C0.5M' => { :cpus => 1, :memory => 512 },
	'1C1G' => { :cpus => 1, :memory => 1024 }
}
default = {
	:box => 'ubuntu/xenial64',
	:offering => '1C0.5M',
	:inline => <<-SCRIPT
sudo sed -i 's/^PermitRootLogin .*/PermitRootLogin yes/g' /etc/ssh/sshd_config
sudo sed -i 's/^PasswordAuthentication .*/PasswordAuthentication yes/g' /etc/ssh/sshd_config
sudo systemctl restart sshd
sudo echo 'root:P@ssw0rd' | chpasswd
SCRIPT
}
nodes = [
	{ :hostname => 'web1', :ip => '192.168.0.11' },
	{ :hostname => 'web2', :ip => '192.168.0.12' },
	{ :hostname => 'redis', :ip => '192.168.0.13' },
	{ :hostname => 'varnish', :ip => '192.168.0.14' }
]

Vagrant.configure("2") do |config|
	nodes.each do |node|
		config.vm.define node[:hostname] do |c|
			box = node[:box] ? node[:box] : default[:box]
			offering = node[:offering] ? node[:offering] : default[:offering]
			inline = node[:inline] ? node[:inline] : default[:inline]

			c.vm.hostname = node[:hostname]
			c.vm.box = box
			c.vm.box_check_update = false
			c.vm.network :private_network, ip: node[:ip]
			c.vm.provider :virtualbox do |v|
				v.cpus = offerings[offering][:cpus]
				v.memory = offerings[offering][:memory]
			end
			c.ssh.shell = "bash -c 'BASH_ENV=/etc/profile exec bash'"
			c.vm.provision "shell", inline: inline, run: "always"
		end
	end
end

3 provision 쉘스크립트[ | ]

_provision_common.sh
apt update
read -r -d '' HOSTS <<EOF
192.168.0.11 web1
192.168.0.12 web2
192.168.0.13 redis
192.168.0.14 varnish
EOF
echo "$HOSTS"
while IFS= read -r line; do
	grep -q "$line" /etc/hosts || echo $line >> /etc/hosts
done < <(echo "$HOSTS")
provision_web.sh
LC_ALL=C.UTF-8 add-apt-repository -y ppa:ondrej/php
apt update
apt install -y php7.1 php-redis redis-tools
provision_redis.sh
apt update
apt install -y redis-server
sed -i 's/^bind .*/bind 0.0.0.0/g' /etc/redis/redis.conf
systemctl restart redis
provision_varnish.sh
apt update
curl -s https://packagecloud.io/install/repositories/varnishcache/varnish5/script.deb.sh | sudo bash
apt install -y varnish

4 참고[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}