centos7下rabbitmq-3.6.14安装配置

官网: http://www.rabbitmq.com/install-rpm.html

目前最新稳定版:rabbitmq-server-3.6.14
下载地址: https://dl.bintray.com/rabbitmq/rabbitmq-server-rpm/rabbitmq-server-3.6.14-1.el7.noarch.rpm

系统版本:centos7.3:
[root@localhost ~]# wget -c https://dl.bintray.com/rabbitmq/rabbitmq-server-rpm/rabbitmq-server-3.6.14-1.el7.noarch.rpm
[root@localhost ~]# rpm -ivh rabbitmq-server-3.6.14-1.el7.noarch.rpm
warning: rabbitmq-server-3.6.14-1.el7.noarch.rpm: Header V4 RSA/SHA512 Signature, key ID 6026dfca: NOKEY
error: Failed dependencies:
erlang >= R16B-03 is needed by rabbitmq-server-3.6.14-1.el7.noarch
socat is needed by rabbitmq-server-3.6.14-1.el7.noarch

安装epel源,否则可能没有erlang的包
[root@localhost ~]# yum install -y epel-*
[root@localhost ~]# yum install -y erlang socat
[root@localhost ~]# rpm -ivh rabbitmq-server-3.6.14-1.el7.noarch.rpm
安装完成。

启动服务:
[root@localhost ~]# rabbitmq-server &  # 停止用 rabbitmqctl stop
[root@localhost ~]# netstat -tnlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:4369 0.0.0.0:* LISTEN 14457/epmd
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 555/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 747/master
tcp 0 0 0.0.0.0:25672 0.0.0.0:* LISTEN 14893/beam.smp
tcp6 0 0 :::4369 :::* LISTEN 14457/epmd
tcp6 0 0 :::22 :::* LISTEN 555/sshd
tcp6 0 0 ::1:25 :::* LISTEN 747/master
tcp6 0 0 :::5672 :::* LISTEN 14893/beam.smp
可以看到 5672 端口启动了,mq的端口。

# 开启rabbitmq的web管理界面
[root@localhost ~]# rabbitmq-plugins enable rabbitmq_management
The following plugins have been enabled:
amqp_client
cowlib
cowboy
rabbitmq_web_dispatch
rabbitmq_management_agent
rabbitmq_management

Applying plugin configuration to rabbit@localhost… started 6 plugins.
[root@localhost ~]# netstat -tnlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:4369 0.0.0.0:* LISTEN 14457/epmd
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 555/sshd
tcp 0 0 0.0.0.0:15672 0.0.0.0:* LISTEN 14893/beam.smp
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 747/master
tcp 0 0 0.0.0.0:25672 0.0.0.0:* LISTEN 14893/beam.smp
tcp6 0 0 :::4369 :::* LISTEN 14457/epmd
tcp6 0 0 :::22 :::* LISTEN 555/sshd
tcp6 0 0 ::1:25 :::* LISTEN 747/master
tcp6 0 0 :::5672 :::* LISTEN 14893/beam.smp
可以看到15672端口启动了(web界面)

在web登陆的时候,提示 User can only log in via localhost 。如图:

rabbitmq从3.3.0开始禁止使用guest权限通过除localhost外的访问。

# 允许远程登陆,默认没有这个文件
[root@localhost ~]# vi /etc/rabbitmq/rabbitmq.config

[{rabbit, [{loopback_users, []}]}].

注意后面有个点,重启服务。

评论关闭

配置 haproxy 4层代理

官网下载 http://www.haproxy.org/
目前最新稳定版: http://www.haproxy.org/download/1.7/src/haproxy-1.7.9.tar.gz

解压安装:

[root@localhost ~]# yum install -y make gcc gcc-c++
[root@localhost ~]# tar zxvf haproxy-1.7.9
[root@localhost ~]# cd haproxy-1.7.9
[root@localhost haproxy-1.7.9]# make TARGET=linux2628 PREFIX=/usr/local/haproxy
[root@localhost haproxy-1.7.9]# make TARGET=linux2628 PREFIX=/usr/local/haproxy install

linux2628 是for Linux内核大于 2.6.28, 3.x的,可以通过readme查看。

配置文件(百度了个现成的):

[root@localhost ~]# mkdir /usr/local/haproxy/conf
[root@localhost ~]# vi /usr/local/haproxy/conf/haproxy.cfg
###########全局配置#########
global
chroot /usr/local/haproxy
daemon
nbproc 1
group nobody
user nobody
pidfile /usr/local/haproxy/haproxy.pid
ulimit-n 65536
#spread-checks 5m
#stats timeout 5m
#stats maxconn 100

########默认配置############
defaults
mode tcp #默认的模式mode { tcp|http|health },tcp是4层,http是7层,health只会返回OK
retries 3 #两次连接失败就认为是服务器不可用,也可以通过后面设置
option redispatch #当serverId对应的服务器挂掉后,强制定向到其他健康的服务器
option abortonclose #当服务器负载很高的时候,自动结束掉当前队列处理比较久的链接
maxconn 65535 #默认的最大连接数
timeout connect 5000ms #连接超时
timeout client 30000ms #客户端超时
timeout server 30000ms #服务器超时
#timeout check 2000 #心跳检测超时
log 127.0.0.1 local0 err #[err warning info debug]

########mysql代理配置#################
listen mysql
bind 0.0.0.0:3306
mode tcp # 4层代理
balance roundrobin
server s1 172.31.4.48:3306 weight 1 maxconn 60000 check inter 3s
server s2 172.31.4.49:3306 weight 1 maxconn 60000 check inter 3s
server s3 172.31.4.50:3306 weight 1 maxconn 60000 check inter 3s

########rabbitmq代理配置##############
listen rabbitmq
bind 0.0.0.0:5672
mode tcp # 4层代理
balance roundrobin
server s1 172.31.4.48:5672 weight 1 maxconn 60000 check inter 3s
server s2 172.31.4.49:5672 weight 1 maxconn 60000 check inter 3s
server s3 172.31.4.50:5672 weight 1 maxconn 60000 check inter 3s

########统计页面配置########
listen admin
bind 0.0.0.0:8888 #监听端口
mode http #http代理
option httplog #采用http日志格式
#log 127.0.0.1 local0 err
maxconn 10
stats refresh 3s #统计页面自动刷新时间
stats uri /stats #统计页面url
stats realm RootopHaproxy #统计页面密码框上提示文本
stats auth admin:admin #统计页面用户名和密码设置
stats hide-version #隐藏统计页面上HAProxy的版本信息

启动服务:

[root@localhost ~]# /usr/local/haproxy/sbin/haproxy -f /usr/local/haproxy/conf/haproxy.cfg

用浏览器访问 http://ip:8888/stats 就可以看到类似下面的监控图。

评论关闭

docker拉取私有仓库 (http: server gave HTTP response to HTTPS client)

# 拉取镜像

[root@node2 ~]# docker pull 192.168.10.26:5000/apache_del
Using default tag: latest
# 报错
Error response from daemon: Get https://192.168.10.26:5000/v2/: http: server gave HTTP response to HTTPS client

原因是docker客户端使用https去访问仓库,但是仓库是http。

解决方法,修改客户端用http拉取

# 查看docker版本

[root@node2 ~]# docker -v
Docker version 17.06.0-ce, build 02c1d87

这台机器是用docker-machine安装的。配置文件不在 /etc/sysconfig/docker

如果你是yum安装的docker,可以直接编辑 /etc/sysconfig/docker
添加 insecure-registry 部分

OPTIONS='--selinux-enabled --log-driver=journald --signature-verification=false --insecure-registry=192.168.10.26:5000'

如果是docker-machine安装的,如果没有 /etc/docker/daemon.json 配置文件,就直接vi创建一个新的,配置如下:

{ "insecure-registries":["192.168.10.26:5000"] }

重启docker服务。

再次pull即可。

[root@node2 ~]# docker pull 192.168.10.26:5000/apache_del
Using default tag: latest
latest: Pulling from apache_del
250a76a4fbba: Pull complete
de16a7f8f7fc: Pull complete
6a7fb93f5e5b: Pull complete
0c32765487b0: Pull complete
052b33f149ad: Pull complete
28202e866555: Pull complete
0018537e5b08: Pull complete
Digest: sha256:8f55fc9d6241c4b2b7b809954d73be391b16f10358f180ee4b758807e2f1a617
Status: Downloaded newer image for 192.168.10.26:5000/apache_del:latest
评论关闭