仮想マシン構築後、ブラウザからhttp://192.168.55.102:15672/にアクセスします。デフォルトユーザはrabbitmq、パスワードはrabbitmqです。
Vagrantfile
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "bento/centos-7.4"
config.vm.hostname = "co74rabbitmq"
config.vm.provider :virtualbox do |vbox|
vbox.name = "co74rabbitmq"
vbox.cpus = 2
vbox.memory = 1024
vbox.customize ["modifyvm", :id, "--nicpromisc2","allow-all"]
end
config.vm.network "private_network", ip: "192.168.55.102", :netmask => "255.255.255.0"
config.vm.network "public_network", ip:"192.168.1.102", :netmask => "255.255.255.0"
config.vm.provision "shell", inline: <<-SHELL
# update packages
yum -y install epel-release
yum -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-4.4.0-Linux-x86_64.sh
chmod +x Anaconda3-4.4.0-Linux-x86_64.sh
./Anaconda3-4.4.0-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.102:15672/'
echo 'user : rabbitmq password rabbitmq'
SHELL
end
○Management Web Interfaceの画面
○関連情報
・RabbitMQに関する他の記事はこちらを参照してください。
0 件のコメント:
コメントを投稿