Rabbitmq消息队列服务
rabbitmqctl add_user chinaskill
rabbitmqctl set_permissions chinaskill “." ".” “.*”
rabbitmqctl set_user_tags chinaskill administrator
RabbitMQ集群
创建三台云主机 rabbitmq1 和 rabbitmq2 和 rabbitmq3 并配好 hosts 文件
hosts 文件:
192.168.200.3 rabbitmq1
192.168.200.6 rabbitmq2
192.168.200.8 rabbitmq3
可以在 rabbitmq1 处 scp 到其他节点
scp /etc/hosts rabbitmq2:/etc/
scp /etc/hosts rabbitmq3:/etc/
从 controller 端用 scp 上传附件提供的 rabbitmq-repo.tar.gz 文件到云主机里
scp rabbitmq-repo.tar.gz 192.168.200.3:/root/
scp rabbitmq-repo.tar.gz 192.168.200.6:/root/
scp rabbitmq-repo.tar.gz 192.168.200.8:/root/
解压到 /opt 目录下
tar -zxvf rabbitmq-repo.tar.gz -C /opt/
local.repo
[rabbitmq]
name=rabbitmq
baseurl=file:///opt/rabbitmq-repo
enabled=1
gpgcheck=0
用
yum repolist
检查 yum 源是否配置正确
安装 rabbitmq-server
yum install -y rabbitmq-server
启动 rabbitmq-server 服务
systemctl start rabbitmq-server
启动 rabbitmq-server 的网页界面访问服务
rabbitmq-plugins enable rabbitmq_management
重新启用 rabbitmq-server 以应用网页界面访问服务,默认用户名密码都是 guest
systemctl restart rabbitmq-server
若用
netstat -ntpl
命令查询到开放的 15672 端口,则服务启动成功
保证所有节点的 cookie 一致
scp /var/lib/rabbitmq/.erlang.cookie rabbitmq2:/var/lib/rabbitmq/
scp /var/lib/rabbitmq/.erlang.cookie rabbitmq3:/var/lib/rabbitmq/
给 .erlang.cookie 文件添加权限:
cd /var/lib/rabbitmq/
chown rabbitmq:rabbitmq .erlang.cookie
配置 rabbitmq2 和 rabbitmq3 作为 ram 节点加入 rabbitmq1
rabbitmqctl stop_app
rabbitmqctl join_cluster --ram rabbit@rabbitmq1
rabbitmqctl start_app
如果 stop_app 遇到问题,先重启 rabbitmq-server 即
systemctl restart rabbitmq-server
RabbitMQ集群常用命令
# 查看插件打开情况
rabbitmq-plugins list
# 启动监控管理器
rabbitmq-plugins enable rabbitmq_management
# 关闭监控管理器
rabbitmq-plugins disable rabbitmq_management
# 查看所有的队列
rabbitmqctl list_queues
# 清除所有的队列
rabbitmqctl reset
# 查看用户
rabbitmqctl list_users
# 查看状态
rabbitmqctl status
# 查看集群状态
rabbitmqctl cluster_status
# 新增用户admin,并设置密码为admin
rabbitmqctl add_user admin admin
# 修改admin用户的密码为admin123
rabbitmqctl change_password admin admin123
# 删除admin用户
rabbitmqctl delete_user admin
# 设置角色
rabbitmqctl set_user_tags admin administrator monitoring policymaker management
# 设置用户权限
rabbitmqctl set_permissions -p VHostPath admin ConfP WriteP ReadP
# 查询所有权限
rabbitmqctl list_permissions [-p VHostPath]
# 指定用户权限
rabbitmqctl list_user_permissions admin
# 清除用户权限
rabbitmqctl clear_permissions [-p VHostPath] admin
创建安全组和规则
openstack security group create all
openstack security group rule list all | grep None >> rules.txt
sed -i "s/None//g" rules.txt
sed -i "s/|//g" rules.txt
sed -i s/[[:space:]]//g rules.txt
SECURITY_RULE1=$(sed -n 1p rules.txt)
SECURITY_RULE2=$(sed -n 2p rules.txt)
openstack security group rule delete $SECURITY_RULE1
openstack security group rule delete $SECURITY_RULE2
rm -rf rules.txt
openstack security group rule create --ingress --protocol tcp all
openstack security group rule create --ingress --protocol udp all
openstack security group rule create --ingress --protocol icmp all
openstack security group rule create --egress --protocol tcp all
openstack security group rule create --egress --protocol udp all
openstack security group rule create --egress --protocol icmp all
创建浮动IP并绑定至云主机
openstack floating ip create ext-net --floating-ip-address 192.168.200.10
openstack floating ip create ext-net --floating-ip-address 192.168.200.20
openstack server add floating ip master 192.168.200.10
openstack server add floating ip node 192.168.200.20
[创建磁盘阵列]在OpenStack私有云平台,创建一台云主机,并创建一个40G大小的cinder块存储,将块存储连接到云主机,然后在云主机上对云硬盘进行操作。要求分出4个大小为5G的分区,使用这4个分区,创建名为/dev/md5、raid级别为5的磁盘阵列加一个热备盘(使用最后一个分区作为热备盘)。
mdadm -Cv /dev/md5 -l5 -n3 /dev/vdb[1-3] --spare-devices=1 /dev/vdb4
H3C交换机配置
<H3C>undo terminal monitor # 关闭日志打印
<H3C>system-view # 从用户视图进入进入系统视图
[H3C]undo info-center enable # 关闭消息中心
[H3C]sysname sw-student1 # 重命名为sw-student1
[sw-student1]interface Vlan-interface 1 # 进入vlan1的接口
[sw-student1-Vlan-interface1]ip address 172.16.1.1 255.255.255.0 # 设置vlan1接口ip为172.16.1.1
[sw-student1-Vlan-interface1]vlan 100 # 创建并进入vlan100
[sw-student1-vlan100]port GigabitEthernet 1/0/1 to GigabitEthernet 1/0/8 # 设置vlan添加端口1-8
[sw-student1-vlan100]interface range GigabitEthernet 1/0/1 to GigabitEthernet 1/0/8 # 批量设置端口1-8
[sw-student1-if-range]port link-type access # 设置端口类型为access
[sw-student1-if-range]port access vlan 100 # 设置trunk通过vlan100
[sw-student1-if-range]interface Vlan-interface 100 # 进入vlan100的接口
[sw-student1-Vlan-interface100]ip address 192.168.100.1 255.255.255.0 # 设置vlan1接口ip为192.168.100.1
[sw-student1-Vlan-interface100]vlan 200 # 创建并进入vlan200
[sw-student1-vlan200]interface range GigabitEthernet 1/0/9 to GigabitEthernet 1/0/16 # 批量设置端口9-16
[sw-student1-if-range]port link-type trunk # 设置端口类型为trunk
[sw-student1-if-range]port trunk permit vlan 1 200 # 设置trunk通过vlan1和vlan200
[sw-student1-if-range]interface Vlan-interface 200 # 进入vlan200的接口
[sw-student1-Vlan-interface200]ip address 192.168.200.1 255.255.255.0 # 设置vlan1接口ip为192.168.200.1
[sw-student1-Vlan-interface200]ip route-static 0.0.0.0 0 172.16.1.254 # 设置路由,出口ip为172.16.1.254
[sw-student1]quit # 退出系统视图,回到用户视图(ctrl+z)
<sw-student1>save safely force # 保存交换机配置
H3C交换机清空配置
<sw-student1>reset saved-configuration y # 确认清空所有保存的配置
<sw-student1>reboot n y # 确认不保存配置,确认重启设备