首页 > 其他分享 >Easy Mock的部署及使用

Easy Mock的部署及使用

时间:2024-03-27 16:45:00浏览次数:29  
标签:https Easy 部署 mongodb redis mock easy local Mock

Easy Mock 是一个可视化,并且能快速生成模拟数据的持久化服务。

GitHub地址:https://github.com/easy-mock/easy-mock

中文介绍文档:https://github.com/easy-mock/easy-mock/blob/dev/README.zh-CN.md

一、部署

1. 传统部署

建议使用docker部署,传统部署坑太多了

参考:https://coder.itclan.cn/fontend/tools/local-deploy-easy-mock/#%E5%89%8D%E8%A8%80

1.1 安装Redis

# 下载源码包
version='6.0.9'
wget https://download.redis.io/releases/redis-${version}.tar.gz

# 安装依赖
yum install gcc gcc-c++ make -y
yum install centos-release-scl -y
yum install devtoolset-9-gcc devtoolset-9-gcc-c++ devtoolset-9-binutils -y

# 启用gcc9
scl enable devtoolset-9 bash
echo "source /opt/rh/devtoolset-9/enable" >> /etc/profile

# 解压源码包
tar xf redis-${version}.tar.gz

# 编译安装
cd redis-${version}
make -j 2
make PREFIX=/usr/local/redis install

# 修改系统参数
echo net.core.somaxconn=511 >> /etc/sysctl.conf
echo vm.overcommit_memory=1 >> /etc/sysctl.conf
sysctl -p
echo never > /sys/kernel/mm/transparent_hugepage/enabled

# 添加配置文件
mkdir /usr/local/redis/conf
cat > /usr/local/redis/conf/redis.conf << EOF
bind 127.0.0.1
protected-mode yes
port 6379
tcp-backlog 511
timeout 0
tcp-keepalive 300
daemonize no
supervised no
pidfile /var/run/redis_6379.pid
loglevel notice
logfile ""
databases 16
always-show-logo yes
save 900 1
save 300 10
save 60 10000
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
dbfilename dump.rdb
rdb-del-sync-files no
dir ./
replica-serve-stale-data yes
replica-read-only yes
repl-diskless-sync no
repl-diskless-sync-delay 5
repl-diskless-load disabled
repl-disable-tcp-nodelay no
replica-priority 100
acllog-max-len 128
lazyfree-lazy-eviction no
lazyfree-lazy-expire no
lazyfree-lazy-server-del no
replica-lazy-flush no
lazyfree-lazy-user-del no
oom-score-adj no
oom-score-adj-values 0 200 800
appendonly no
appendfilename "appendonly.aof"
appendfsync everysec
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
aof-load-truncated yes
aof-use-rdb-preamble yes
lua-time-limit 5000
slowlog-log-slower-than 10000
slowlog-max-len 128
latency-monitor-threshold 0
notify-keyspace-events ""
hash-max-ziplist-entries 512
hash-max-ziplist-value 64
list-max-ziplist-size -2
list-compress-depth 0
set-max-intset-entries 512
zset-max-ziplist-entries 128
zset-max-ziplist-value 64
hll-sparse-max-bytes 3000
stream-node-max-bytes 4096
stream-node-max-entries 100
activerehashing yes
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit replica 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60
hz 10
dynamic-hz yes
aof-rewrite-incremental-fsync yes
rdb-save-incremental-fsync yes
jemalloc-bg-thread yes
EOF

# 启动redis
mkdir /usr/local/redis/logs
nohup /usr/local/redis/bin/redis-server /usr/local/redis/conf/redis.conf >> /usr/local/redis/logs/redis.log 2>&1 &

1.2 安装MongoDB

# 下载二进制包
wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-5.0.3.tgz

# 解压
tar -xf mongodb-linux-x86_64-rhel70-5.0.3.tgz
mv mongodb-linux-x86_64-rhel70-5.0.3 /usr/local/mongodb

# 新建数据目录、日志目录和配置文件目录
mkdir /usr/local/mongodb/{data,logs,conf}

# 添加配置文件
cat > /usr/local/mongodb/conf/mongo.conf << EOF
port=27017
dbpath=/usr/local/mongodb/data
logpath=/usr/local/mongodb/logs/mongod.log
pidfilepath=/usr/local/mongodb/mongod.pid
logappend=true
fork=true
journal=true
bind_ip=localhost
EOF

# 启动MongoDB
/usr/local/mongodb/bin/mongod --config /usr/local/mongodb/conf/mongo.conf

1.3 部署easy-mock

需要先安装git和nodejs

注意:要在Redis和MongoDB已经启动的条件下部署easy-mock

  1. 从GitHub拉取easy-mock
git clone https://github.com/easy-mock/easy-mock.git

cd easy-mock && npm install
  1. 修改配置文件 easy-mock/config/default.json
{
  "port": 7300,
  // 将此处的"host": "0.0.0.0"修改为localhost
  "host": "localhost",
  "pageSize": 30,
  "proxy": false,
  "db": "mongodb://localhost/easy-mock",
  "unsplashClientId": "",
  "redis": {
    "keyPrefix": "[Easy Mock]",
    "port": 6379,
    "host": "localhost",
    "password": "",
    "db": 0
  },
  "blackList": {
    "projects": [],
    "ips": []
  },
  "rateLimit": {
    "max": 1000,
    "duration": 1000
  },
  "jwt": {
    "expire": "14 days",
    "secret": "shared-secret"
  },
  "upload": {
    "types": [".jpg", ".jpeg", ".png", ".gif", ".json", ".yml", ".yaml"],
    "size": 5242880,
    "dir": "../public/upload",
    "expire": {
      "types": [".json", ".yml", ".yaml"],
      "day": -1
    }
  },
  "ldap": {
    "server": "",
    "bindDN": "",
    "password": "",
    "filter": {
      "base": "",
      "attributeName": ""
    }
  },
  "fe": {
    "copyright": "",
    "storageNamespace": "easy-mock_",
    "timeout": 25000,
    "publicPath": "/dist/"
  }
}

启动easy-mock

npm run dev

2. Docker部署Easy Mock

官方GitHub仓库:https://github.com/easy-mock/easy-mock-docker

参考:https://juejin.cn/post/7081459518642585613

需要先安装好docker和docker-compose

创建docker-compose.yml

version: '3'

services:
  mongodb:
    image: mongo:3.4.1
    volumes:
      #  /apps/easy-mock/data/db 是数据库文件存放地址,根据需要修改为本地地址
      - '/apps/easy-mock/data/db:/data/db'
    networks:
      - easy-mock
    restart: always

  redis:
    image: redis:4.0.6
    command: redis-server --appendonly yes
    volumes:
      #  /apps/easy-mock/data/redis 是 redis 数据文件存放地址,根据需要修改为本地地址
      - '/apps/easy-mock/data/redis:/data'
    networks:
      - easy-mock
    restart: always

  web:
    image: easymock/easymock:1.6.0
    # easy-mock 官方给出的文件,这里是 npm start,这里修改为 npm run dev
    command: /bin/bash -c "npm run dev"
    ports: 
      - 7300:7300
    volumes:
      # 日志地址,根据需要修改为本地地址
      - '/apps/easy-mock/logs:/home/easy-mock/easy-mock/logs'
    networks:
      - easy-mock
    restart: always

networks:
  easy-mock:

启动

docker-compose up -d

访问ip:7300

二、使用Easy Mock

可用的在线的easymock页面:https://mock.mengxuegu.com/login

[email protected]/[email protected]

1. 登录注册

2. 创建项目

3. 创建接口

标签:https,Easy,部署,mongodb,redis,mock,easy,local,Mock
From: https://www.cnblogs.com/CharrammaBlog/p/18099632

相关文章

  • ChatGLM3在Docker环境部署
    ChatGLM3docker部署1.下载项目到本地gitclonehttps://github.com/THUDM/ChatGLM3cdChatGLM3这目录ChatGLM3下应该还需要包含chatglm3-6b-32kHuggingFace或者ModelScope,需要手动下载。2.制作Docker镜像1)配置基础的Dockerfile:#基于的基础镜像FROMpython:3.11.6......
  • java笔记_16_EasyExcel表头设计
    导出对象:importcom.alibaba.excel.annotation.ExcelProperty;importcom.fasterxml.jackson.annotation.JsonFormat;importlombok.Data;@DatapublicclassProdEvaluatResultExcelVO{//ExcelProperty设置默认表头(无自定义表头时,直接生成)@ExcelProperty("表......
  • 基于vite多页面实现多端同构开发和部署
    背景由于在开发前端项目中,后台管理端和用户端存在多个模块和页面逻辑可以复用,管理模块和用户端渲染模块使用同一套状态管理机制,只是在管理端和用户端的入口和路由模块不同,为了能够在开发时同时修改管理端和用户端共用模块,不用多项目工程修改和发布,我们基于vite多页面的基础上实现......
  • .net6 core web项目发布部署到IIS,以Windows服务的形式部署启动,报错1053,报1067错误解
    安装NuGet包Microsoft.Extensions.Hosting.WindowsServices  varbuilder=WebApplication.CreateBuilder(newWebApplicationOptions{ContentRootPath=AppContext.BaseDirectory,Args=args});//Addservicestothecontainer.builder.Services.Add......
  • Flink - [02] 安装部署(Standalone)
     一、准备1、角色规划FlinkStandalone角色规划节点名称node01node02node03master○  worker ○○zookeeper○○○   二、部署1、解压:tar-zxvfflink-1.11.2-bin-scala_2.11.tgz2、      — 要养成终生学习的习惯—......
  • sensitive-word-admin v1.3.0 发布 如何支持敏感词控台分布式部署?
    拓展阅读sensitive-word-adminv1.3.0发布如何支持分布式部署?sensitive-word-admin敏感词控台v1.2.0版本开源sensitive-word基于DFA算法实现的高性能敏感词工具介绍更多技术交流业务背景如果我们的敏感词部署之后,不会变化,那么其实不用考虑这个问题。......
  • openEuler20.03操作系统上安装部署MogDB2.1.1
    openEuler20.03操作系统上安装部署MogDB2.1.1本文出处:https://www.modb.pro/db/378319openEuler操作系统上安装mogdb:下载openEuler镜像文件:openEuler-20.03-LTS-x86_64-dvd.iso可以到各镜像源网站下载:例如:清华源下载地址:https://mirrors.tuna.tsinghua.edu.cn/openeule......
  • 手把手带你用RT-DETR模型部署训练自己的数据集
    本文主要介绍如何部署、训练RT-DETR模型,将从两种方式进行介绍:一种是RTDETR自带的项目文件,另一种是ultralytics仓库下将训练的模型改为rtdetr的基本模型。1.配置环境1.1新建虚拟环境我们可以在电脑上新建一个虚拟环境condacreate-nRT-DETRpython=3.10激活环境condaac......
  • 手工安装部署openGauss3.0一主一备(非om工具安装)
    手工安装部署openGauss3.0一主一备(非om工具安装)本文出处:https://www.modb.pro/db/425385一、操作系统配置(centos7.6)1.关闭防火墙systemctlstopfirewalldsystemctldisablefirewalld2.关闭selinux服务setenforce0vim/etc/selinux/configSELINUX=disabled3.......
  • Hudi部署
    目录前言Hudi的介绍一、Hudi是什么?二、Hudi的特点功能和优势三、Hudi的使用场景Hudi的搭建部署一、准备二、搭建1)搭建JAVA环境和Hadoop环境2)部署zookeeper3)部署Sparkonyarn4)部署maven环境5)部署Hudi环境三、执行编译,构建mavenHudi的简单使用一、准备案例二、......