目录
docker安装
JDK安装
redis安装
nacos控制台安装
sentinel控制台安装
rocketmq环境搭建
fastdfs安装
mysql安装
mycat安装
docker安装
yum -y install docker 安装
systemctl start docker 启动
systemctl restart docker 重启
systemctl stop docker 停止
systemctl enable docker 开机自启
前方有坑———如果你在 docker 运行期间操作了防火墙[启动或关闭]必须重启
docker systemctl restart docker
编辑配置文件
vi /etc/docker/daemon.json
拷贝下面的内容/etc/docker/daemon.json 中
{ "registry-mirrors":
["https://32xw0apq.mirror.aliyuncs.com"] }
systemctl daemon-reload
systemctl restart docker
JDK安装
安装JDK11
如果是tar.gz文件,则执行解压缩命令
tar -zxvf jdk-11.0.11_linux-x64_bin.tar.gz
解压缩后,默认安装在当前目录下
在/etc/profile文件中设置java环境变量
输入命令检查安装是否完成
java -version
出现上面的提示,表示jdk安装正常
redis安装
使用 docker 运行 redis
docker run -d --name redis -p 6390:6379 redis --requirepass "123456"
安装完成后,查看redis进程,如上图所示则安装正常
nacos控制台安装
下载nacos压缩包,使用下面的命令解压缩
tar -zxvf nacos-server-1.2.0.tar.gz
进入nacos安装路径下的bin目录执行启动命令
./startup.sh -m standalone
使用ps命令查看进程情况
输入http://你的ip:8848,启动nacos控制台
sentinel控制台安装
下载sentinel-dashboard-1.8.2.jar包,在jar包所在目录打开命令行窗口,执行以下命令启动控制台
java -jar sentinel-dashboard-1.8.2.jar
输入默认用户名、密码sentinel,进入主界面
rocketmq环境搭建
环境要求
JDK 11.0.5
4G+ free
可使用wget命令下载、解压缩并安装
wget
https://archive.apache.org/dist/rocketmq/4.5.1/
rocketmq-all-4.5.1-bin-release.zip
修改脚本
bin/runserver.sh
bin/runbroker.sh
bin/tools.sh
nameserver:
#!/bin/sh
# Licensed to the Apache Software Foundation
(ASF) under one or more
# contributor license agreements. See the
NOTICE file distributed with
# this work for additional information
regarding copyright ownership.
# The ASF licenses this file to You under the
Apache License, Version 2.0
# (the "License"); you may not use this file
except in compliance with
# the License. You may obtain a copy of the
License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed
to in writing, software
# distributed under the License is distributed
on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
either express or implied.
# See the License for the specific language
governing permissions and
# limitations under the License.
#==============================================
=============================================
# Java Environment Setting
#==============================================
=============================================
error_exit ()
{
echo "ERROR: $1 !!"
exit 1
}
[ ! -e "$JAVA_HOME/bin/java" ] &&
JAVA_HOME=$HOME/jdk/java
[ ! -e "$JAVA_HOME/bin/java" ] &&
JAVA_HOME=/usr/java
[ ! -e "$JAVA_HOME/bin/java" ] && error_exit
"Please set the JAVA_HOME variable in your
environment, We need java(x64)!"
export JAVA_HOME
export JAVA="$JAVA_HOME/bin/java"
export BASE_DIR=$(dirname $0)/..
export CLASSPATH=${BASE_DIR}/lib/rocketmqnamesrv4.5.0.jar:${BASE_DIR}/lib/*:${BASE_DIR}/conf:${
CLASSPATH}
#export
CLASSPATH=.:${BASE_DIR}/conf:${CLASSPATH}
#echo "BASE_DIR:$BASE_DIR"
#echo "CLASSPATH:$CLASSPATH"
#==============================================
=============================================
# JVM Configuration
#==============================================
=============================================
JAVA_OPT="${JAVA_OPT} -server -Xms1g -Xmx1g -
Xmn512m -XX:MetaspaceSize=128m -
XX:MaxMetaspaceSize=320m"
#JAVA_OPT="${JAVA_OPT} -server -Xms4g -Xmx4g -
Xmn2g -XX:MetaspaceSize=128m -
XX:MaxMetaspaceSize=320m"
JAVA_OPT="${JAVA_OPT} -
XX:CMSInitiatingOccupancyFraction=70 -
XX:+CMSParallelRemarkEnabled -
XX:SoftRefLRUPolicyMSPerMB=0 -
XX:+CMSClassUnloadingEnabled -
XX:SurvivorRatio=8"
JAVA_OPT="${JAVA_OPT} -verbose:gc -
Xlog:gc:/dev/shm/rmq_srv_gc.log"
JAVA_OPT="${JAVA_OPT} -XX:-
OmitStackTraceInFastThrow"
JAVA_OPT="${JAVA_OPT} -XX:-UseLargePages"
#JAVA_OPT="${JAVA_OPT} -Xdebug -
Xrunjdwp:transport=dt_socket,address=9555,serve
r=y,suspend=n"
JAVA_OPT="${JAVA_OPT} ${JAVA_OPT_EXT}"
JAVA_OPT="${JAVA_OPT} -cp ${CLASSPATH}"
$JAVA ${JAVA_OPT} $@
vim bin/runserver.sh
删除
UseCMSCompactAtFullCollection
UseParNewGC
UseConcMarkSweepGC
修改内存:
JAVA_OPT="${JAVA_OPT} -server -Xms256m -Xmx256m
-Xmn128m -
XX:MetaspaceSize=64mm -
XX:MaxMetaspaceSize=160mm"
-Xloggc修改为-Xlog:gc
broker:
#!/bin/sh
# Licensed to the Apache Software Foundation
(ASF) under one or more
# contributor license agreements. See the
NOTICE file distributed with
# this work for additional information
regarding copyright ownership.
# The ASF licenses this file to You under the
Apache License, Version 2.0
# (the "License"); you may not use this file
except in compliance with
# the License. You may obtain a copy of the
License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed
to in writing, software
# distributed under the License is distributed
on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
either express or implied.
# See the License for the specific language
governing permissions and
# limitations under the License.
#==============================================
============================
# Java Environment Setting
#==============================================
============================
error_exit ()
{
echo "ERROR: $1 !!"
exit 1
}
[ ! -e "$JAVA_HOME/bin/java" ] &&
JAVA_HOME=$HOME/jdk/java
[ ! -e "$JAVA_HOME/bin/java" ] &&
JAVA_HOME=/usr/java
[ ! -e "$JAVA_HOME/bin/java" ] && error_exit
"Please set the JAVA_HOME
variable in your environment, We need
java(x64)!"
export JAVA_HOME
export JAVA="$JAVA_HOME/bin/java"
export BASE_DIR=$(dirname $0)/..
export
CLASSPATH=.${JAVA_HOME}/jre/lib/ext:${BASE_DIR}
/lib/*:${BASE_DIR}/conf:${CLASSPATH}
#==============================================
============================
# JVM Configuration
#==============================================
============================
JAVA_OPT="${JAVA_OPT} -server -Xms256m -Xmx256m
-Xmn128m"
JAVA_OPT="${JAVA_OPT} -XX:+UseG1GC -
XX:G1HeapRegionSize=16m -XX:G1ReservePercent=25
-XX:InitiatingHeapOccupancyPercent=30 -
XX:SoftRefLRUPolicyMSPerMB=0"
JAVA_OPT="${JAVA_OPT} -verbose:gc -
Xloggc:/dev/shm/mq_gc_%p.log -
XX:+PrintGCDetails"
JAVA_OPT="${JAVA_OPT} -XX:-
OmitStackTraceInFastThrow"
JAVA_OPT="${JAVA_OPT} -XX:+AlwaysPreTouch"
JAVA_OPT="${JAVA_OPT} -
XX:MaxDirectMemorySize=15g"
JAVA_OPT="${JAVA_OPT} -XX:-UseLargePages -XX:-
UseBiasedLocking"
#JAVA_OPT="${JAVA_OPT} -Xdebug -
Xrunjdwp:transport=dt_socket,address=9555,serve
r=y,suspend=n"
JAVA_OPT="${JAVA_OPT} ${JAVA_OPT_EXT}"
JAVA_OPT="${JAVA_OPT} -cp ${CLASSPATH}"
numactl --interleave=all pwd > /dev/null 2>&1
if [ $? -eq 0 ]
then
if [ -z "$RMQ_NUMA_NODE" ] ; then
numactl --interleave=all $JAVA
${JAVA_OPT} $@
else
numactl --cpunodebind=$RMQ_NUMA_NODE --
membind=$RMQ_NUMA_NODE $JAVA
${JAVA_OPT} $@
fi
else
$JAVA ${JAVA_OPT} --addexports=java.base/jdk.internal.ref=ALL-UNNAMED
$@
fi
vim bin/runbroker.sh
删除:
PrintGCDateStamps
PrintGCApplicationStoppedTime
PrintAdaptiveSizePolicy
UseGCLogFileRotation
NumberOfGCLogFiles=5
GCLogFileSize=30m
tools:
#!/bin/sh
# Licensed to the Apache Software Foundation
(ASF) under one or more
# contributor license agreements. See the
NOTICE file distributed with
# this work for additional information
regarding copyright ownership.
# The ASF licenses this file to You under the
Apache License, Version 2.0
# (the "License"); you may not use this file
except in compliance with
# the License. You may obtain a copy of the
License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed
to in writing, software
# distributed under the License is distributed
on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
either express or implied.
# See the License for the specific language
governing permissions and
# limitations under the License.
#==============================================
============================
=================
# Java Environment Setting
#==============================================
============================
=================
error_exit ()
{
echo "ERROR: $1 !!"
exit 1
}
[ ! -e "$JAVA_HOME/bin/java" ] &&
JAVA_HOME=$HOME/jdk/java
[ ! -e "$JAVA_HOME/bin/java" ] &&
JAVA_HOME=/usr/java
[ ! -e "$JAVA_HOME/bin/java" ] && error_exit
"Please set the JAVA_HOME
variable in your environment, We need
java(x64)!"
export JAVA_HOME
export JAVA="$JAVA_HOME/bin/java"
export BASE_DIR=$(dirname $0)/..
# export
CLASSPATH=.:${BASE_DIR}/conf:${CLASSPATH}
export
CLASSPATH=.${JAVA_HOME}/jre/lib/ext:${BASE_DIR}
/lib/*:${BASE_DIR}/conf:${CL
ASSPATH}
#==============================================
============================
=================
# JVM Configuration
#==============================================
============================
=================
JAVA_OPT="${JAVA_OPT} -server -Xms256m -Xmx256m
-Xmn256m -XX:PermSize=128m
-XX:MaxPermSize=128m"
# JAVA_OPT="${JAVA_OPT} -
Djava.ext.dirs=${BASE_DIR}/lib:${JAVA_HOME}/jre
/lib/ext"
JAVA_OPT="${JAVA_OPT} -cp ${CLASSPATH}"
$JAVA ${JAVA_OPT} $@
vim bin/tools.sh
# 删除 JAVA_OPT="${JAVA_OPT} -
Djava.ext.dirs=${BASE_DIR}/lib:${JAVA_HOME}/jre
/lib/ext"
进入rocketmq目录,启动nameserver
nohup sh mqnamesrv > /dev/null 2>&1 &
然后启动broker
nohup sh mqbroker -n localhost:9876 > /dev/null
2>&1 &
fastdfs安装
1、下载fastdfs镜像
docker pull registry.cn-beijing.aliyuncs.com/tianzuo/fastdfs
2、启动镜像
docker run -d --restart=always --
privileged=true --net=host --name=fastdfs -e
IP=192.168.139.128 -e WEB_PORT=8888 -v
${HOME}/fastdfs:/var/local/fdfs registry.cn-beijing.aliyuncs.com/tianzuo/fastdfs
3、查看镜像
docker ps -a
5、测试上传
vim /etc/fdfs/client.conf
#需要修改的内容如下
base_path=/home/fastdfs
#tracker服务器IP和端口
tracker_server=192.168.139.128:22122
#保存后测试,返回ID表示成功 如:group1/M00/00/00/xxx.png
/usr/bin/fdfs_upload_file /etc/fdfs/client.conf /root/fastdfs/1.png
group1/M00/00/00/wKjTiF7h5EWASb5aAACGZa9JdFo611.png
mysql安装
下载必要的安装文件,按顺序执行安装命令,完成后初始化mysql, 修改初始密码
下载必要的安装文件,按顺序执行安装命令,完成后初始化mysql, 修改初始密码
先移除mariadb,再安装 解压缩mysql-5.7.28-1.el7.x86_64.rpm-bundle.tar,解压完成后会 生成一系列rpm安装包,安装的顺序是 1)mysql-community-common-5.7.28-1.el7.x86_64.rpm 2)mysql-community-libs-5.7.28-1.el7.x86_64.rpm 3)mysql-community-libs-compat-5.7.28-1.el7.x86_64.rpm 4)mysql-community-client-5.7.28-1.el7.x86_64.rpm 5)mysql-community-server-5.7.28-1.el7.x86_64.rpm 6)mysql-community-devel-5.7.28-1.el7.x86_64.rpm
初始化mysql
mysqld --initialize --user=mysql
查看初始密码
cat /var/log/mysqld.log
进入mysql,修改初始密码
>mysql -uroot -p
>set password=password('123456');
mycat安装
下载Mycat-server-1.6.7.5-release-linux.tar.gz,解压后进入 mycat/bin目录,执行启动命令
./mycat start 启动
./mycat stop 停止
./mycat restart 重启
./mycat status 查看状态
访问mycat,连接成功后和操作mysql一样
mysql -uroot -proot -h127.0.0.1 -P8066
mysql主从搭建
后面再细说
读写分离配置
后面再细说
idea安装
自行下载安装,项目中使用的是2020.2版本