SpringCloud开发实战系列笔记(一)nacos安装

linux下docker安装

yum install -y yum-utils
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
yum install -y docker-ce-19.03.8 docker-ce-cli-19.03.8 containerd.io

linux下docker启动配置 

  • 将下面配置信息保存至文件路径:/usr/lib/systemd/system/docker.service

[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
BindsTo=containerd.service
After=network-online.target firewalld.service containerd.service
Wants=network-online.target
Requires=docker.socket

[Service]
Type=notify
# the default is not to use systemd for cgroups because the delegate issues still
# exists and systemd currently does not support the cgroup feature set required
# for containers run by docker
ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock -H tcp://0.0.0.0:2375 --default-ulimit nofile=555550 --default-ulimit memlock=128849018880 --default-ulimit core=-1 --default-ulimit nproc=-1 --default-ulimit stack=-1
ExecReload=/bin/kill -s HUP $MAINPID
TimeoutSec=0
RestartSec=2
Restart=always

# Note that StartLimit* options were moved from "Service" to "Unit" in systemd 229.
# Both the old, and new location are accepted by systemd 229 and up, so using the old location
# to make them work for either version of systemd.
StartLimitBurst=3

# Note that StartLimitInterval was renamed to StartLimitIntervalSec in systemd 230.
# Both the old, and new name are accepted by systemd 230 and up, so using the old name to make
# this option work for either version of systemd.
StartLimitInterval=60s

# Having non-zero Limit*s causes performance problems due to accounting overhead
# in the kernel. We recommend using cgroups to do container-local accounting.
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity

# Comment TasksMax if your systemd version does not support it.
# Only systemd 226 and above support this option.
TasksMax=infinity

# set delegate yes so that systemd does not reset the cgroups of docker containers
Delegate=yes

# kill only the docker process, not all processes in the cgroup
KillMode=process

[Install]
WantedBy=multi-user.target

  •  将下面配置信息保存至文件路径:/etc/docker/daemon.json

{
  "registry-mirrors": ["https://oafyokwd.mirror.aliyuncs.com"],
  "data-root":"/data/docker"
}

  • 启动docker 
systemctl stop docker.service
systemctl stop docker.socket
systemctl enable docker
systemctl daemon-reload
systemctl start docker

linux下docker-compose安装 

  • 在安装docker-compose之前,需要确认您已经安装了Docker。您可以在命令行中运行以下命令来检查您的Docker版本:
Compose file formatDocker Engine
11.9.0+
2.01.10.0+
2.11.12.0+
2.2, 3.0, 3.1, 3.21.13.0+
2.3, 3.3, 3.4, 3.517.06.0+
2.417.12.0+
3.618.02.0+
3.718.06.0+
  • 查看docker版本命令(我使用的版本19.03.8)
docker version
  • docker-compose下载 

改用官方提供的docker-compose,从1.25.5版本开始,可以直接按操作系统平台下载安装包:

项目地址:https://github.com/docker/compose/releases

对于1.25.4或者更早的版本,可以参考下面的方法使用:(我使用的版本1.25.5)

curl -L https://github.com/docker/compose/releases/download/1.25.5/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
  • 验证docker-compose版本
docker-compose --version

如果终端窗口中能正常输出版本信息,则说明成功安装了docker-compose。 

  • 配置docker-compose环境变量
sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose

这个命令会创建一个指向docker-compose二进制文件的符号链接,使其可以在任何目录下使用。安装和配置完成后,您就可以开始使用docker-compose来管理和运行Docker容器了。

linux下使用docker-compose安装nacos

  • 将下面配置保存至文件路径/data/project/nacos/nacos-install.yaml

version: "2"
services:
  nacos:
    image: nacos/nacos-server:v2.2.3
    container_name: nacos
    restart: always
    environment:
      - LANG=en_US.utf8
      - LOG4J_FORMAT_MSG_NO_LOOKUPS=true
      - JVM_OPTS="-Dlog4j2.formatMsgNoLookups=true"
      - JAVA_OPT_EXT=--server.tomcat.uri-encoding=UTF-8
      - JVM_XMS=2g
      - JVM_XMX=2g
      - JVM_XMN=1g
      - PREFER_HOST_MODE=hostname
      - MODE=standalone
      - SPRING_DATASOURCE_PLATFORM=mysql
      - MYSQL_SERVICE_HOST=mysql-host
      - MYSQL_SERVICE_DB_NAME=nacos
      - MYSQL_SERVICE_PORT=3306
      - MYSQL_SERVICE_USER=mysql_user
      - MYSQL_SERVICE_PASSWORD=mysql_password

    volumes:
      - /data/project/nacos/logs:/home/nacos/logs
      - /data/project/nacos/config/custom.properties:/home/nacos/init.d/custom.properties
    ports:
      - "8848:8848"
      - "9848:9848"
      - "9849:9849"

  • 启动nacos命令
docker-compose -f /data/project/nacos-install.yaml up -d

 总结:

后面系列笔记的代码都需要基于nacos来进行,所以这里纤细记录下nacos的暗转流程。后续不断努力更新该系列笔记。希望能给其他看到我文章小伙伴带来一点点帮助

  • 12
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值