# Env **Repository Path**: SmartWin/Env ## Basic Information - **Project Name**: Env - **Description**: 环境和安装 - **Primary Language**: Shell - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-04-09 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 中台部署文档 # 一、安装环境 ## 安装golang 执行命令:`yum install -y golang` * 如果失败需要先更新源 `rpm --import https://mirror.go-repo.io/centos/RPM-GPG-KEY-GO-REPO` `curl -s https://mirror.go-repo.io/centos/go-repo.repo | tee /etc/yum.repos.d/go-repo.repo` ## 安装git `yum install -y git` # 二、安装数据库 ## 安装 mariadb * 安装命令 `yum -y install mariadb mariadb-server` * 安装完成MariaDB,首先启动MariaDB `systemctl start mariadb` * 设置开机启动 `systemctl enable mariadb` * 进入mysql创建初始 `mysql -uroot -p` * 执行SQL脚本 ````sql create database game; ```` * 接下来进行MariaDB的相关简单配置并且修改密码 `mysql_secure_installation` ## 安装redis * 安装命令 `yum install -y epel-release` `yum install -y redis` * 启动redis服务 `systemctl start redis` * 设置开机启动 `systemctl enable redis` ## 安装mongodb * 配置MongoDB的yum源 `vim /etc/yum.repos.d/mongodb-org-4.0.repo` * 添加以下内容 ```` [mongodb-org-4.0] name=MongoDB Repository baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/4.0/x86_64/ gpgcheck=0 enabled=1 gpgkey=https://www.mongodb.org/static/pgp/server-4.0.asc ```` 安装命令: `yum -y install mongodb-org` 启动mongodb : `systemctl start mongod.service` 自启动 `systemctl enable mongod.service` # 三. 拉取代码 `cd` * 创建文件夹 `mkdir go/src/git.chinalbr.com` `mkdir go/src/git.chinalbr.com/Gin` `cd go/src/git.chinalbr.com/Gin` * 克隆项目 `git clone http://git.chinalbr.com:3000/Gin/MiddleServer.git` `mkdir /home/hongHuProgram` `mkdir /home/hongHuProgram/log/` # 四. 编译 * 进入目录 `cd go/src/git.chinalbr.com/Gin/MiddleServer/build` * 设置代理 `export GOPROXY=https://goproxy.cn` * 编译 `sh buildAdmin.sh` `sh buildApi.sh` `sh buildGame.sh` # 五. 启动程序 * 进入目录 `cd /home/hongHuProgram/` * 修改用户配置 `vim configUser.yaml` ```` database: conn: root:123456@tcp(localhost:3306)/game?charset=utf8&parseTime=True&loc=Local&multiStatements=true conn: 用户名:密码@tcp(地址:端口)/数据库?charset=utf8&parseTime=True&loc=Local&multiStatements=true ```` * 启动游戏 `chmod -R 777 ./hongHuGame; nohup ./hongHuGame >/dev/null 2>&1 &` * 启动API `chmod -R 777 ./hongHuApi; nohup ./hongHuApi >/dev/null 2>&1 &` * 启动后台 `chmod -R 777 ./hongHuAdmin; nohup ./hongHuAdmin >/dev/null 2>&1 &`