Docker/系统运维/银河麒麟

【深度学习KylinOS七】【麒麟系统环境安装之Nacos】Docker部署 Nacos超详细步骤

daimafengzi · 11月23日 · 2023年 · · · · · 本文共3369个字 · 预计阅读12分钟12次已读
docker pull caplike/nacos-server:v2.1.0
mkdir -p /home/nacos-server2.1.0/conf
mkdir -p /home/nacos-server2.1.0/logs
mkdir -p /home/nacos-server2.1.0/data

在 conf 目录中创建配置文件 nacos-logback.xml

<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="10 seconds">

    <springProperty scope="context" name="logPath" source="nacos.logs.path" defaultValue="${nacos.home}/logs"/>
    <property name="LOG_HOME" value="${logPath}"/>

    <appender name="cmdb-main"
              class="ch.qos.logback.core.rolling.RollingFileAppender">
        <file>${nacos.home}/logs/cmdb-main.log</file>
        <append>true</append>
        <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
            <fileNamePattern>${nacos.home}/logs/cmdb-main.log.%d{yyyy-MM-dd}.%i</fileNamePattern>
            <maxFileSize>2GB</maxFileSize>
            <maxHistory>7</maxHistory>
            <totalSizeCap>7GB</totalSizeCap>
            <cleanHistoryOnStart>true</cleanHistoryOnStart>
        </rollingPolicy>
        <encoder>
            <Pattern>%date %level %msg%n%n</Pattern>
            <charset>UTF-8</charset>
        </encoder>
    </appender>

    <appender name="rootFile"
              class="ch.qos.logback.core.rolling.RollingFileAppender">
        <file>${LOG_HOME}/nacos.log</file>
        <append>true</append>
        <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
            <fileNamePattern>${LOG_HOME}/nacos.log.%d{yyyy-MM-dd}.%i</fileNamePattern>
            <maxFileSize>50MB</maxFileSize>
            <maxHistory>7</maxHistory>
            <totalSizeCap>512MB</totalSizeCap>
            <cleanHistoryOnStart>true</cleanHistoryOnStart>
        </rollingPolicy>
        <encoder>
            <Pattern>%date %level %msg%n%n</Pattern>
            <charset>UTF-8</charset>
        </encoder>
    </appender>

    <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
        <encoder>
            <Pattern>%date %level %msg%n%n</Pattern>
            <charset>UTF-8</charset>
        </encoder>
    </appender>

    <appender name="naming-server"
              class="ch.qos.logback.core.rolling.RollingFileAppender">
        <file>${LOG_HOME}/naming-server.log</file>
        <append>true</append>
        <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
            <fileNamePattern>${LOG_HOME}/naming-server.log.%d{yyyy-MM-dd}.%i</fileNamePattern>
            <maxFileSize>1GB</maxFileSize>
            <maxHistory>7</maxHistory>
            <totalSizeCap>7GB</totalSizeCap>
            <cleanHistoryOnStart>true</cleanHistoryOnStart>
        </rollingPolicy>
        <encoder>
            <Pattern>%date %level %msg%n%n</Pattern>
            <charset>UTF-8</charset>
        </encoder>
    </appender>

    <springProfile name="standalone">
        <logger name="org.springframework">
            <appender-ref ref="CONSOLE"/>
            <level value="INFO"/>
        </logger>

        <logger name="org.apache.catalina.startup.DigesterFactory">
            <appender-ref ref="CONSOLE"/>
            <level value="INFO"/>
        </logger>

        <logger name="org.apache.catalina.util.LifecycleBase">
            <appender-ref ref="CONSOLE"/>
            <level value="ERROR"/>
        </logger>

        <logger name="org.apache.coyote.http11.Http11NioProtocol">
            <appender-ref ref="CONSOLE"/>
            <level value="WARN"/>
        </logger>

        <logger name="org.apache.tomcat.util.net.NioSelectorPool">
            <appender-ref ref="CONSOLE"/>
            <level value="WARN"/>
        </logger>
    </springProfile>

    <logger name="com.alibaba.nacos.core.listener.StartingApplicationListener">
        <appender-ref ref="CONSOLE"/>
        <level value="INFO"/>
    </logger>

    <root>
        <level value="INFO"/>
        <appender-ref ref="rootFile"/>
    </root>
</configuration>
docker run -d -p 8848:8848 -p 9848:9848 -p 9849:9849 \
 --name nacos-server2.1.0 \
 -v /home/nacos-server2.1.0/conf:/home/nacos/conf \
 -v /home/nacos-server2.1.0/data:/home/nacos/data \
 -v /home/nacos-server2.1.0/logs:/home/nacos/logs \
 -e MODE=standalone \
 --restart=always \
 caplike/nacos-server:v2.1.0

在浏览器中访问 Nacos

http://localhost:8848/nacos

默认用户名和密码都是 nacos
【深度学习KylinOS七】【麒麟系统环境安装之Nacos】Docker部署 Nacos超详细步骤

0 条回应