本地硬盘坏了,好坑,一夜回到解放前。这次自己弄个腾讯云耍一耍,环境得重新搭起来,这里索性就记录一下,不用到处查找了。
官方建议是在Ubuntu下安装,这里使用的服务器操作系统为CentOS 7.5 64位。
1、设置Yum源
(1)yum 包更新到最新
sudo yum update
(2)安装需要的软件包,yum-utils提供yum-config-manager功能,可用来设置Yum源,另外两个是devicemapper驱动依赖。
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
(3)设置yum源为阿里云
sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
2、Docker相关命令
(1)安装docker
sudo yum install docker-ce
(2)安装后查看docker版本
docker -v
(3)设置ustc的镜像,指定注册中心镜像地址,可加快拉取镜像的速度
编辑文件:
vim /etc/docker/daemon.json
添加:
{
"registry-mirrors": ["https://docker.mirrors.ustc.edu.cn"]
}
(4)Docker的启动与停止
启动docker:
systemctl start docker
开机启动:
systemctl enable docker
需要了解的一些命令(选看)
# 停止docker
systemctl stop docker
# 重启docker
systemctl restart docker
# 查看docker状态
systemctl status docker
# 查看docker概要信息
docker info
# 查看docker帮助文档
docker --help
(5)镜像相关命令
# 查找镜像
docker search 镜像名称
# 拉取镜像就是从中央仓库中下载镜像到本地
docker pull 镜像名称
# 查看镜像
docker images
# 按镜像ID删除镜像
docker rmi 镜像ID
# 删除所有镜像
docker rmi `docker images -q`
(6)容器相关命令
# 查看正在运行的容器
docker ps
#查看所有容器
docker ps –a
#查看最后一次运行的容器
docker ps –l
#查看停止的容器
docker ps -f status=exited
# 交互式方式创建容器
docker run -it --name=容器名称 镜像名称:标签 /bin/bash
# 退出当前容器
exit
# 守护式方式创建容器
docker run -di --name=容器名称 镜像名称:标签
# 登录守护式容器方式
docker exec -it 容器名称 (或者容器ID) /bin/bash
# 启动容器
docker start 容器名称(或者容器ID)
# 停止容器
docker stop 容器名称(或者容器ID)
# 删除指定的容器
docker rm 容器名称(容器ID)
# 查看IP地址
docker inspect --format='{{.NetworkSettings.IPAddress}}' 容器名称(容器ID)
# 文件拷贝
docker cp 需要拷贝的文件或目录 容器名称:容器目录
docker cp 容器名称:容器目录 需要拷贝的文件或目录
# 目录挂载
-v参数 宿主机目录:容器目录
3、安装JDK
# 解压
tar -zxvf jdk-11.0.3_linux-x64_bin.tar.gz
# 配置环境变量
vim /etc/profile
# set java environment
export JAVA_HOME=/usr/local/java/jdk-11.0.3
export CLASSPATH=$:CLASSPATH:$JAVA_HOME/lib/
export PATH=$PATH:$JAVA_HOME/bin
# 更新配置
source /etc/profile
4、MySQL
# 拉取镜像
docker pull mysql:5.7
# 创建容器
docker create --name mysql -v /data/mysql-data:/var/lib/mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=123456 mysql:5.7
# 启动容器
docker start mysql
5、MongoDB
# 拉取镜像
docker pull mongo:4.1.13
# 创建容器
docker create --name mongodb -v /data/mongodb:/data/db -p 27017:27017 mongo:4.1.13
# 启动容器
docker start mongodb
# 进入容器
docker exec -it mongodb /bin/bash
# 使用MongoDB客户端
mongo
6、RocketMQ
2m2s
配置文件需先创建对应的目录mkdir -p /orcas/rmq/rmqbroker01/conf/
# 拉取镜像
docker pull foxiswho/rocketmq:server-4.5.0
docker pull foxiswho/rocketmq:broker-4.5.0
# nameserver1
docker create -p 9876:9876 --name rmqserver01 \
-e "JAVA_OPT_EXT=-server -Xms128m -Xmx128m -Xmn128m" \
-e "JAVA_OPTS=-Duser.home=/opt" \
-v /orcas/rmq/rmqserver01/logs:/opt/logs \
-v /orcas/rmq/rmqserver01/store:/opt/store \
foxiswho/rocketmq:server-4.5.0
# nameserver2
docker create -p 9877:9876 --name rmqserver02 \
-e "JAVA_OPT_EXT=-server -Xms128m -Xmx128m -Xmn128m" \
-e "JAVA_OPTS=-Duser.home=/opt" \
-v /orcas/rmq/rmqserver02/logs:/opt/logs \
-v /orcas/rmq/rmqserver02/store:/opt/store \
foxiswho/rocketmq:server-4.5.0
# master broker01
docker create --net host --name rmqbroker01 \
-e "JAVA_OPTS=-Duser.home=/opt" \
-e "JAVA_OPT_EXT=-server -Xms128m -Xmx128m -Xmn128m" \
-v /orcas/rmq/rmqbroker01/conf/broker.conf:/etc/rocketmq/broker.conf \
-v /orcas/rmq/rmqbroker01/logs:/opt/logs \
-v /orcas/rmq/rmqbroker01/store:/opt/store \
foxiswho/rocketmq:broker-4.5.0
namesrvAddr=119.29.247.162:9876;119.29.247.162:9877
brokerClusterName=OrcasCluster
brokerName=broker01
brokerId=0
deleteWhen=04
fileReservedTime=48
brokerRole=SYNC_MASTER
flushDiskType=ASYNC_FLUSH
brokerIP1=119.29.247.162
brokerIp2=119.29.247.162
listenPort=10911
# master broker02
docker create --net host --name rmqbroker02 \
-e "JAVA_OPTS=-Duser.home=/opt" \
-e "JAVA_OPT_EXT=-server -Xms128m -Xmx128m -Xmn128m" \
-v /orcas/rmq/rmqbroker02/conf/broker.conf:/etc/rocketmq/broker.conf \
-v /orcas/rmq/rmqbroker02/logs:/opt/logs \
-v /orcas/rmq/rmqbroker02/store:/opt/store \
foxiswho/rocketmq:broker-4.5.0
# master broker02
namesrvAddr=119.29.247.162:9876;119.29.247.162:9877
brokerClusterName=OrcasCluster
brokerName=broker02
brokerId=0
deleteWhen=04
fileReservedTime=48
brokerRole=SYNC_MASTER
flushDiskType=ASYNC_FLUSH
brokerIP1=119.29.247.162
brokerIp2=119.29.247.162
listenPort=10811
# slave broker01
docker create --net host --name rmqbroker03 \
-e "JAVA_OPTS=-Duser.home=/opt" \
-e "JAVA_OPT_EXT=-server -Xms128m -Xmx128m -Xmn128m" \
-v /orcas/rmq/rmqbroker03/conf/broker.conf:/etc/rocketmq/broker.conf \
-v /orcas/rmq/rmqbroker03/logs:/opt/logs \
-v /orcas/rmq/rmqbroker03/store:/opt/store \
foxiswho/rocketmq:broker-4.5.0
# slave broker01
namesrvAddr=119.29.247.162:9876;119.29.247.162:9877
brokerClusterName=OrcasCluster
brokerName=broker01
brokerId=1
deleteWhen=04
fileReservedTime=48
brokerRole=SLAVE
flushDiskType=ASYNC_FLUSH
brokerIP1=119.29.247.162
brokerIp2=119.29.247.162
listenPort=10711
# slave broker02
docker create --net host --name rmqbroker04 \
-e "JAVA_OPTS=-Duser.home=/opt" \
-e "JAVA_OPT_EXT=-server -Xms128m -Xmx128m -Xmn128m" \
-v /orcas/rmq/rmqbroker04/conf/broker.conf:/etc/rocketmq/broker.conf \
-v /orcas/rmq/rmqbroker04/logs:/opt/logs \
-v /orcas/rmq/rmqbroker04/store:/opt/store \
foxiswho/rocketmq:broker-4.5.0
# slave broker02
namesrvAddr=119.29.247.162:9876;119.29.247.162:9877
brokerClusterName=OrcasCluster
brokerName=broker02
brokerId=1
deleteWhen=04
fileReservedTime=48
brokerRole=SLAVE
flushDiskType=ASYNC_FLUSH
brokerIP1=119.29.247.162
brokerIp2=119.29.247.162
listenPort=10611
# 启动容器
docker start rmqserver01 rmqserver02
docker start rmqbroker01 rmqbroker02 rmqbroker03 rmqbroker04
# 可视化管理工具
# 拉取镜像
docker pull styletang/rocketmq-console-ng:1.0.0
# 创建并启动容器
docker run -e "JAVA_OPTS=-Drocketmq.namesrv.addr=172.16.55.185:9876 \
-Dcom.rocketmq.sendMessageWithVIPChannel=false" -p 8082:8080 -t styletang/rocketmq-console-ng:1.0.0
7、Elasticsearch
单节点
# 拉取镜像
docker pull elasticsearch:7.1.0
# 创建并启动容器
docker run --name es -e "ES_JAVA_OPTS=-Xms128m -Xmx128m" \
-e "-Des.network.publish_host=119.29.247.162" \
-e "discovery.type=single-node" \
-d -p 9200:9200 -p 9300:9300 elasticsearch:7.1.0
# 日志
docker logs -f es
8、Redis
# 拉取镜像
docker pull redis:5.0.5
# 创建容器
docker create --name redis-node01 --net host -v /data/redis-data/node01:/data \
redis:5.0.5 --cluster-enabled yes --cluster-config-file nodes-node-01.conf --port 6379
docker create --name redis-node02 --net host -v /data/redis-data/node02:/data \
redis:5.0.5 --cluster-enabled yes --cluster-config-file nodes-node-02.conf --port 6380
docker create --name redis-node03 --net host -v /data/redis-data/node03:/data \
redis:5.0.5 --cluster-enabled yes --cluster-config-file nodes-node-03.conf --port 6381
# 启动容器
docker start redis-node01 redis-node02 redis-node03
#进入redis-node01容器进行操作
docker exec -it redis-node01 /bin/bash
redis-cli --cluster create 119.29.247.162:6379 119.29.247.162:6380 119.29.247.162:6381 --cluster-replicas 0
# 使用redis客户端
redis-cli -c
9、Zookeeper
docker pull zookeeper:3.5.5
docker create --name zk -p 2181:2181 zookeeper:3.5.5
docker start zk