因爲rabbitmq是基於erlang語言開發的,因此必須先安裝erlang。html
curl -s https://packagecloud.io/install/repositories/rabbitmq/erlang/script.rpm.sh | sudo bash yum -y install erlang
curl -s https://packagecloud.io/install/repositories/rabbitmq/rabbitmq-server/script.rpm.sh | sudo bash yum -y install rabbitmq-server
有兩個限制:操做系統內核容許的最大打開文件數(fs.file-max)和每一個用戶的限制(ulimit -n)。前者必須高於後者。node
咱們建議在生產環境中爲用戶Rabbitmq至少容許65536個文件描述符git
查看內核容許的最大文件數github
sysctl -n fs.file-max
不夠則修改/etc/sysctl.conf,而後運行sysvtl -pweb
修改rabbitmq進程容許的最大文件數,systemd編輯bash
/usr/lib/systemd/system/rabbitmq-server.service中的LimitNOFILE參數
[root@node2 ~]# cat /usr/lib/systemd/system/rabbitmq-server.service |grep LimitNOFILE # To override LimitNOFILE, create the following file: # LimitNOFILE=65536 LimitNOFILE=65536
若是是舊版的系統,沒有systemd的。能夠修改服務器
cat /etc/security/limits.conf ....... * soft nofile 65535 * hard nofile 65535
重啓服務後驗證限制網絡
[root@node2 ~]# lsof -i:15672 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME beam.smp 129344 rabbitmq 96u IPv4 103591373 0t0 TCP *:15672 (LISTEN) [root@node2 ~]# cat /proc/129344/limits |grep "Max open files" Max open files 65536 65536 files
systemctl start rabbitmq-server systemctl stop rabbitmq-server
/var/log/rabbitmq/rabbitcurl
日誌每週輪詢一次,配置文件在: /etc/logrotate.d/rabbitmq-serveide
rabbitmq-plugins enable rabbitmq_management
默認帳號密碼:guest guest(這個帳號只容許本機訪問)
6.1 建立一個用戶,具備管理員權限
rabbitmqctl add_user admin password rabbitmqctl set_user_tags admin administrator
6.2 建立一個用戶和虛擬主機,並容許該用戶訪問該虛擬主機
rabbitmqctl add_user celery celery rabbitmqctl add_vhost celery_vhos rabbitmqctl set_user_tags celery celery_tag rabbitmqctl set_permissions -p celery_vhost celery ".*" ".*" ".*"
參考文檔: