将多块硬盘合并

注:操作系统使用Centos7.6版本

#yum install lvm2 -y && yum -y install parted

初始化并挂载硬件

#!/bin/bash

#要将所有的盘符都写上

for n in b c ;do 

parted /dev/vd${n} mklabel gpt

parted /dev/vd${n} mkpart vdb ext4 0 100%   << EOF

I

EOF

parted  /dev/vd${n} toggle 1 lvm   

done

#要将所有的硬盘标识都写上

disk="/dev/vdb1 /dev/vdc1" 

pvcreate -f $disk   

vgcreate vg $disk

pesize=$(vgdisplay  vg |awk '/Total/{print $NF}')

#2表示只有两块硬盘写,如果有多块硬盘,需要按实际的写

lvcreate -i 2 -I 512 -l $pesize -n data vg

mkfs.xfs -f /dev/vg/data

mkdir -p /data/

echo '/dev/vg/data /data xfs defaults,noatime 0 0' >> /etc/fstab

mount -a



系统优化参数

#/bin/bash

cat >>/etc/security/limits.conf<<EOF

baseuser soft nofile 655360

baseuser hard nofile 655360

EOF

cat >>/etc/sysctl.conf<<EOF

vm.overcommit_memory=1

vm.drop_caches=1

vm.zone_reclaim_mode=0

vm.max_map_count=655360

vm.dirty_background_ratio=25

vm.dirty_ratio=50

vm.dirty_writeback_centisecs=360000

vm.page-cluster=3

vm.swappiness=1

EOF

sysctl -p /etc/sysctl.conf


创建rocketmq数据

rocketmq数据目录存放:/data/rocketmq-a

#mkdir /data/rocketmq-a && mkdir /data/logs-a &&chown -R deploy. /data/  && ll /data


解压安装包

默认将4.7的安装下载到服务器上

$unzip rocketmq-all-4.7.0-bin-release.zip -d /workspace/ && mv /workspace/rocketmq-all-4.7.0-bin-release /workspace/rocketmq-a


修改log存放路径

rocketmq日志目录存放:/data/logs-a

$cd /workspace/rocketmq-a/conf

$sed -i 's#\${user.home}/logs#/data/logs-a#g' logback_broker.xml 

$sed -i 's#\${user.home}/logs#/data/logs-a#g' logback_tools.xml 


修改jvm参数

$cd /workspace/rocketmq-a/

$vim bin/runbroker.sh 

调整启动参数

JAVA_OPT="${JAVA_OPT} -server -Xms10g -Xmx10g -Xmn4g"


更改主节点配置文件

$vim 2m-2s-async/broker-a.properties

#请修改

brokerClusterName=ClusterA

brokerName=broker-a

brokerId=0

listenPort=10911

#请修改

namesrvAddr=x.x.x.x:9876;x.x.x.x::9876

defaultTopicQueueNums=4

autoCreateTopicEnable=false

autoCreateSubscriptionGroup=false

deleteWhen=04

fileReservedTime=48

mapedFileSizeCommitLog=1073741824

mapedFileSizeConsumeQueue=50000000

destroyMapedFileIntervalForcibly=120000

redeleteHangedFileInterval=120000

diskMaxUsedSpaceRatio=88

#存储路径

storePathRootDir=/data/rocketmq-a/store

#commitLog存储路径

storePathCommitLog=/data/rocketmq-a/store/commitlog

#消费队列存储路径

storePathConsumeQueue=/data/rocketmq-a/store/consumequeue

# 消息索引存储路径

storePathIndex=/data/rocketmq-a/store/index

# checkpoint 文件存储路径

storeCheckpoint=/data/rocketmq-a/store/checkpoint

#abort 文件存储路径

abortFile=/data/rocketmq-a/store/abort

maxMessageSize=65536

flushCommitLogLeastPages=4

flushConsumeQueueLeastPages=2

flushCommitLogThoroughInterval=10000

flushConsumeQueueThoroughInterval=60000

brokerRole=ASYNC_MASTER

flushDiskType=ASYNC_FLUSH

checkTransactionMessageEnable=false

maxTransferCountOnMessageInMemory=1000

transientStorePoolEnable=true

warmMapedFileEnable=false

pullMessageThreadPoolNums=128

slaveReadEnable=true

transferMsgByHeap=true

waitTimeMillsInSendQueue=1000


从节点配置

$vim 2m-2s-async/broker-a-s.properties

#请修改

brokerClusterName=ClusterA

brokerName=broker-a

brokerId=1

listenPort=10915

#请修改

namesrvAddr=x.x.x.x:9876;x.x.x.x:9876

defaultTopicQueueNums=4

autoCreateTopicEnable=false

autoCreateSubscriptionGroup=false

deleteWhen=04

fileReservedTime=120

mapedFileSizeCommitLog=1073741824

mapedFileSizeConsumeQueue=50000000

destroyMapedFileIntervalForcibly=120000

redeleteHangedFileInterval=120000

diskMaxUsedSpaceRatio=88

#存储路径

storePathRootDir=/data/rocketmq-slavea/store

#commitLog存储路径

storePathCommitLog=/data/rocketmq-slavea/store/commitlog

#消费队列存储路径

storePathConsumeQueue=/data/rocketmq-slavea/store/consumequeue

# 消息索引存储路径

storePathIndex=/data/rocketmq-slavea/store/index

# checkpoint 文件存储路径

storeCheckpoint=/data/rocketmq-slavea/store/checkpoint

#abort 文件存储路径

abortFile=/data/rocketmq-slavea/store/abort

maxMessageSize=65536

flushCommitLogLeastPages=4

flushConsumeQueueLeastPages=2

flushCommitLogThoroughInterval=10000

flushConsumeQueueThoroughInterval=60000

brokerRole=SLAVE

flushDiskType=ASYNC_FLUSH

checkTransactionMessageEnable=false

maxTransferCountOnMessageInMemory=1000

transientStorePoolEnable=true

warmMapedFileEnable=false

pullMessageThreadPoolNums=128

slaveReadEnable=true

transferMsgByHeap=true


启动broker节点

$cd /workspace/rocketmq-a/

$nohup binmq/broker -c /workspace/rocketmq-a/conf/2m-2s-async/broker-a.properties &