1、RabbitMq 核心概念及AMQP协议
RabbitMq 高性能是如何做到的
RabbitMq 是采用Erlang语言开发的, Erlang 最初用于交换机领域
Erlang的优点 有着和sockte 语言一样的延迟和响应
2.使用brew来安装 RabbitMQ 与启动
brew install rabbitmq
安装成功
localhost:~ lidong$ brew install rabbitmq
Updating Homebrew...
==> Installing dependencies for rabbitmq: jpeg, libpng, libtiff, wxmac, erlang
==> Installing rabbitmq dependency: jpeg
==> Downloading https://homebrew.bintray.com/bottles/jpeg-8d.sierra.bottle.2.tar
######################################################################## 100.0%
==> Pouring jpeg-8d.sierra.bottle.2.tar.gz
�� /usr/local/Cellar/jpeg/8d: 19 files, 708.3K
==> Installing rabbitmq dependency: libpng
==> Downloading https://homebrew.bintray.com/bottles/libpng-1.6.28.sierra.bottle
######################################################################## 100.0%
==> Pouring libpng-1.6.28.sierra.bottle.tar.gz
�� /usr/local/Cellar/libpng/1.6.28: 26 files, 1.2M
==> Installing rabbitmq dependency: libtiff
==> Downloading https://homebrew.bintray.com/bottles/libtiff-4.0.7_1.sierra.bott
######################################################################## 100.0%
==> Pouring libtiff-4.0.7_1.sierra.bottle.tar.gz
�� /usr/local/Cellar/libtiff/4.0.7_1: 248 files, 3.4M
==> Installing rabbitmq dependency: wxmac
==> Downloading https://homebrew.bintray.com/bottles/wxmac-3.0.2_4.sierra.bottle
######################################################################## 100.0%
==> Pouring wxmac-3.0.2_4.sierra.bottle.tar.gz
�� /usr/local/Cellar/wxmac/3.0.2_4: 810 files, 24.6M
==> Installing rabbitmq dependency: erlang
==> Downloading https://homebrew.bintray.com/bottles/erlang-19.2.sierra.bottle.t
######################################################################## 100.0%
==> Pouring erlang-19.2.sierra.bottle.tar.gz
==> Caveats
Man pages can be found in:
/usr/local/opt/erlang/lib/erlang/man
Access them with `erl -man`, or add this directory to MANPATH.
==> Summary
�� /usr/local/Cellar/erlang/19.2: 7,310 files, 280.9M
==> Installing rabbitmq
==> Using the sandbox
==> Downloading https://www.rabbitmq.com/releases/rabbitmq-server/v3.6.6/rabbitm
######################################################################## 100.0%
==> /usr/bin/unzip -qq -j /usr/local/Cellar/rabbitmq/3.6.6/plugins/rabbitmq_mana
==> Caveats
Management Plugin enabled by default at http://localhost:15672
Bash completion has been installed to:
/usr/local/etc/bash_completion.d
To have launchd start rabbitmq now and restart at login:
brew services start rabbitmq
Or, if you don't want/need a background service you can just run:
rabbitmq-server
==> Summary
�� /usr/local/Cellar/rabbitmq/3.6.6: 188 files, 5.8M, built in 9 minutes 12
启动执行, sbin/rabbitmq-server
另外开一个窗口执行:./rabbitmq-plugins
在浏览器中访问:http://localhost:15672 账号: guest 密码 guest
当我们进入到sbin 的安装目录会有几个启动文件
cuttlefish
rabbitmq-env
rabbitmqadmin
rabbitmq-defaults
rabbitmq-plugins
管理插件
./rabbitmq-plugins enable rabbitmq_management
查看默认插件 ./rabbitmq-plugins list
./rabbitmq-plugins enable rabbitmq_management
现在是6个插件
The following plugins have been configured:
rabbitmq_amqp1_0
rabbitmq_management
rabbitmq_management_agent
rabbitmq_mqtt
rabbitmq_stomp
rabbitmq_web_dispatch
Applying plugin configuration to rabbit@localhost...
Plugin configuration unchanged.
The following plugins have been configured:
rabbitmq_amqp1_0
rabbitmq_management
rabbitmq_management_agent
rabbitmq_mqtt
rabbitmq_stomp
rabbitmq_web_dispatch
通过./rabbitmq-plugins 可以查看命令
rabbitmqctl 控制
关闭服务
./rabbitmqctl stop_app
./rabbitmqctl 可以查看一些命令,添加用户 ,添加虚拟主机,认证用户等;
rabbitmq-diagnostics
rabbitmq-server
启动服务
./rabbitmq-server start 或者 ./rabbitmq-server
./rabbitmq-server start & 表示后天启动
查看是否启动成功
lsof -i:5672
出现这样 的信息,则启动成功
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
beam.smp 7898 lizhi 85u IPv4 0x9c85d2cd7bc38149 0t0 TCP localhost:amqp
访问地址 http://localhost:15672/#/
查看rabbitmq 默认的一些插件
./rabbitmq-plugins list
————————————————————————————————
[E*] rabbitmq_amqp1_0 3.7.6
[ ] rabbitmq_auth_backend_cache 3.7.6
[ ] rabbitmq_auth_backend_http 3.7.6
[ ] rabbitmq_auth_backend_ldap 3.7.6
[ ] rabbitmq_auth_mechanism_ssl 3.7.6
[ ] rabbitmq_consistent_hash_exchange 3.7.6
[ ] rabbitmq_event_exchange 3.7.6
[ ] rabbitmq_federation 3.7.6
[ ] rabbitmq_federation_management 3.7.6
[ ] rabbitmq_jms_topic_exchange 3.7.6
[E*] rabbitmq_management 3.7.6
[e*] rabbitmq_management_agent 3.7.6
[E*] rabbitmq_mqtt 3.7.6
[ ] rabbitmq_peer_discovery_aws 3.7.6
[ ] rabbitmq_peer_discovery_common 3.7.6
[ ] rabbitmq_peer_discovery_consul 3.7.6
[ ] rabbitmq_peer_discovery_etcd 3.7.6
[ ] rabbitmq_peer_discovery_k8s 3.7.6
[ ] rabbitmq_random_exchange 3.7.6
[ ] rabbitmq_recent_history_exchange 3.7.6
[ ] rabbitmq_sharding 3.7.6
[ ] rabbitmq_shovel 3.7.6
[ ] rabbitmq_shovel_management 3.7.6
[E*] rabbitmq_stomp 3.7.6
[ ] rabbitmq_top 3.7.6
[ ] rabbitmq_tracing 3.7.6
[ ] rabbitmq_trust_store 3.7.6
[e*] rabbitmq_web_dispatch 3.7.6
[ ] rabbitmq_web_mqtt 3.7.6
[ ] rabbitmq_web_mqtt_examples 3.7.6
[ ] rabbitmq_web_stomp 3.7.6
[ ] rabbitmq_web_stomp_examples 3.7.6
命令行与管控台--基础操作
rabbitmqctl start_app
rabbitmqctl stop_app //
rabbitmqctl sttus 节点状态
rabbitmqctl add_user username password; 添加用户
rabbitmqctl list_user 列出所有用户;
rabbitmqctl delete_user username 删除用户
rabbitmqctl clear_parameter [-p <vhost>] <component_name> <key> 清楚用户权限
包括设置虚拟主机
等等,需要用到再去具体查看
命令行与管控台--高级操作
./rabbitmqctl reset 移除说有数据, 要在./rabbitmqctl stop_app 之后执行
rabbitmqctl join_cluster <clusterNode> [--ram] 组成集群命令 --ram 存储方式,有些是在内存中存储,磁盘或者一些其他的地方
rabbitmqctl change_cluster_node_type <disc|ram> ,修改节点的存储方式
rabbitmqctl forget_cluster_node [--offline] <existing_cluster_member_node> 忘记节点,摘除节点, --offline 支持在服务不启动的情况下忘记节点
rabbitmqctl rename_cluster_node <oldnode1> <newnode1> [oldnode2] [newnode2] ... 重命名集群节点名称
AMQP高级消息队列协议
交换机和交换机类型
交换机是用来发送消息的AMQP实体。交换机拿到一个消息之后将它路由给一个或零个队列。它使用哪种路由算法是由交换机类型和被称作绑定(bindings)的规则所决定的。AMQP 0-9-1的代理提供了四种交换机
Name(交换机类型) | Default pre-declared names(预声明的默认名称) |
---|---|
Direct exchange(直连交换机) | (Empty string) and amq.direct |
Fanout exchange(扇型交换机) | amq.fanout |
Topic exchange(主题交换机) | amq.topic |
Headers exchange(头交换机) | amq.match (and amq.headers in RabbitMQ) |
AMQP 核心概念
查看该文档
http://rabbitmq.mr-ping.com/AMQP/AMQP_0-9-1_Model_Explained.html