安装erlang
cd /tmp wget http://erlang.org/download/otp_src_18.3.tar.gz tar -zxvf otp_src_18.3.tar.gz /opt/otp_src_18.3 cd /opt/otp_src_18.3 yum -y install gcc glibc-devel make ncurses-devel openssl-devel autoconf ./configure && make && make install ln -s /usr/local/lib/erlang/bin/erl /usr/bin/. ln -s /usr/local/lib/erlang/bin/erl /bin/.
note:
安装了erlang , 而且输入erl可以查看到版本号, 但是在安装rabbitmq的时候提示没安装erlang或者版本不够,
那么可以用下面代码进行映射, 然后忽略rabbitmq的依赖直接安装
ln -s /usr/local/lib/erlang/bin/erl /usr/bin/. ln -s /usr/local/lib/erlang/bin/erl /bin/.
rabbitmq安装
1. 去https://www.rabbitmq.com/下载rpm
rpm 带 --nodeps 表示安装时忽略依赖
cd /tmp rpm --import https://www.rabbitmq.com/rabbitmq-signing-key-public.asc rpm -ivh rabbitmq-server-3.6.1-1.noarch.rpm --nodeps service rabbitmq-server restart
rabbitmq 增加用户, web插件
rabbitmqctl add_user jsapi 123456 rabbitmqctl set_user_tags jsapi administrator rabbitmqctl add_vhost applications rabbitmqctl set_permissions -p applications jsapi ".*" ".*" ".*" rabbitmq-plugins enable rabbitmq_management service rabbitmq-server restart
http://{IP}:15672/
rabbitmq 节点cluster配置
1. 把master, slave的ip分别加入到host中:
a. 查看机子hostname # hostname
b. 修改host # vi /etc/hosts note:如果hostname包含. 那么只要第一个点前面的字符串
masterIP masterHostName
slaveIP slaveHostName
2. 记录下master的cookie: cat /var/lib/rabbitmq/.erlang.cookie
3. 停止slave的rabbitmq: service rabbitmq-server stop
4. 修改slave的cookie为master的: sudo vim /var/lib/rabbitmq/.erlang.cookie
service rabbitmq-server start rabbitmqctl stop_app rabbitmqctl join_cluster [email protected]{masterHostName.split(".")[0]} rabbitmqctl start_app
nginx 配置rabbitmq
#/etc/nginx/conf.d/rabbitmq.conf server { listen 80; server_name rabbitmq.jobstreet.com; #access_log /var/log/rabbitmq_access_log main; #error_log /var/log/rabbitmq_error_log debug_http; client_max_body_size 60M; client_body_buffer_size 512k; location / { port_in_redirect on; proxy_pass http://localhost:15672; proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } }
open rabbitmq.jobstreet.com 直接访问 note: 记得把rabbitmq.jobstreet.com加入到host中
时间: 2024-11-05 14:52:58