Rabbitmq centos 安装

2018-12-14  本文已影响0人  ma8345

安装依赖包

    yum update
    yum -y install gcc gcc-c++ make openssl openssl-devel zlib zlib-devel erlang erlang-ssl autoconf libmcrypt* ncurses*

下载rabbitmq安装包

     wget http://www.rabbitmq.com/releases/rabbitmq-server/v3.6.15/rabbitmq-server-3.6.15-1.el6.noarch.rpm
      yum -y install rabbitmq-server-3.6.15-1.el6.noarch.rpm

启动rabbitmq

    systemctl start rabbitmq-server

启动web管理

    rabbitmq-plugins enable rabbitmq_management

用户

    rabbitmq默认创建的用户guest,密码也是guest,这个用户默认只能是本机访问,若需其他访问新增配置文件。
    
    vim /etc/rabbtimq/rabbitmq.config
    [{rabbit, [{loopback_users, []}]}].
    systemctl restart rabbitmq-server
用户管理

list_users,用户列表
add_user {username} {password},添加用户
delete_user {username},删除用户
change_password {username} {newpassword},修改密码
clear_password {username},删除密码 This user now cannot log in with a password (but may be able to through e.g. SASL EXTERNAL if configured)
authenticate_user {username} {password},用户认证
set_user_tags {username} {tag ...},为用户设置角色,tag可以是0个、一个、或多个,eg:rabbitmqctl set_user_tags admin administrator,设置为管理员;rabbitmqctl set_user_tags admin,清除admin与角色的关联。

    #用户列表查看
    rabbitmqctl list_users
    Listing users
    guest   [administrator]
    #添加用户
    rabbitmqctl add_user admin 12345
    Creating user "admin"
    #为用户分配权限
    rabbitmqctl set_user_tags admin administrator
    Setting tags for user "admin" to [administrator]
    #通过http://127.0.0.1:15672 登录界面管理rabbitmq,但用户admin没有访问队列资源的权限。
权限

list_vhosts [vhostinfoitem ...],获取vhosts列表
add_vhost {vhost}, eg:rabbitmqctl add_vhost test
delete_vhost {vhost}
set_permissions [-p vhost] {user} {conf} {write} {read},给用户分在对应的vhost上分配相应的权限。eg:rabbitmqctl set_permissions -p /myvhost admin "^admin-." "." ".*",这条指令,给用户admin在myvhost分配了权限,权限包括:以"chris-"开头的全部资源的配置权限,和所有资源的读写权限
clear_permissions [-p vhost] {username},清除权限
list_permissions [-p vhost],vhost权限分配列表
list_user_permissions {username},user权限列表

    rabbitmqctl set_permissions -p / admin ".*" ".*" ".*"
      Setting permissions for user "chris" in vhost "/"        

端口

上一篇 下一篇

猜你喜欢

热点阅读