仮想マシン構築後、ブラウザからhttp://192.168.55.101:15672/にアクセスします。デフォルトユーザはrabbitmq、パスワードはrabbitmqです。
Vagrantfile
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "bento/debian-9.3"
config.vm.hostname = "db93rabbitmq"
config.vm.provider :virtualbox do |vbox|
vbox.name = "db93rabbitmq"
vbox.cpus = 2
vbox.memory = 1024
vbox.customize ["modifyvm", :id, "--nicpromisc2","allow-all"]
end
config.vm.network "private_network", ip: "192.168.55.101", :netmask => "255.255.255.0"
config.vm.network "public_network", ip:"192.168.1.101", :netmask => "255.255.255.0"
config.vm.provision "shell", inline: <<-SHELL
apt-get -y install task-japanese
sed -i -e 's/# ja_JP.UTF-8 UTF-8/ja_JP.UTF-8 UTF-8/' /etc/locale.gen
locale-gen
update-locale LANG=ja_JP.UTF-8
localectl set-locale LANG=ja_JP.UTF-8
localectl set-keymap jp106
apt-get update
#DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" upgrade
# install rabbitmq
apt-get -y install rabbitmq-server
rabbitmq-plugins enable rabbitmq_management
systemctl enable rabbitmq-server
systemctl restart rabbitmq-server
# setup management web interface
rabbitmqctl add_user rabbitmq rabbitmq
rabbitmqctl set_user_tags rabbitmq administrator
rabbitmqctl set_permissions -p / rabbitmq ".*" ".*" ".*"
# install anaconda & pika
wget https://repo.continuum.io/archive/Anaconda3-5.0.1-Linux-x86_64.sh
chmod +x Anaconda3-5.0.1-Linux-x86_64.sh
./Anaconda3-5.0.1-Linux-x86_64.sh -b -p /opt/anaconda
source /opt/anaconda/bin/activate
pip install --upgrade pip
pip install pika
# execute a sample program to put a message.
cat << EOF > put-helloworld.py
import pika
connection = pika.BlockingConnection(pika.ConnectionParameters('localhost'))
channel = connection.channel()
channel.queue_declare(queue='hello')
channel.basic_publish(exchange='',
routing_key='hello',
body='Hello World!')
print(" put 'Hello World!'")
EOF
python put-helloworld.py
# exeucte a sample program to get a message
cat << EOF > get-helloworld.py
import pika
connection = pika.BlockingConnection(pika.ConnectionParameters('localhost'))
channel = connection.channel()
method_frame, header_frame, body = channel.basic_get('hello')
if method_frame:
print(method_frame, header_frame, body)
channel.basic_ack(method_frame.delivery_tag)
else:
print('no message')
EOF
python get-helloworld.py
echo 'management web interface : http://192.168.55.101:15672/'
echo 'user : rabbitmq password rabbitmq'
SHELL
end
〇RabbitMQの管理者画面
○関連情報
・RabbitMQに関する他の記事はこちらを参照してください。
0 件のコメント:
コメントを投稿