1.0.0
This commit is contained in:
30
tools/help.sh
Normal file
30
tools/help.sh
Normal file
@@ -0,0 +1,30 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
# 复制Nginx、服务配置配置
|
||||
sudo cp -r ./tools/centos/* /
|
||||
|
||||
# 复制后端服务到运行目录
|
||||
sudo rm -rf /data/wwwroot/server
|
||||
sudo cp -r ./server /data/wwwroot/
|
||||
|
||||
# 创建游戏引擎服务端运行目录
|
||||
if [ ! -d "/data/wwwroot/game" ]; then
|
||||
mkdir -p /data/wwwroot/game
|
||||
fi
|
||||
|
||||
# 编译后端服务
|
||||
cd /data/wwwroot/server/
|
||||
/usr/local/go/bin/go env -w GOSUMDB=off
|
||||
export GO111MODULE=on && export GOPROXY=https://goproxy.io && /usr/local/go/bin/go build main.go
|
||||
|
||||
# 重启Nginx服务
|
||||
sudo systemctl restart nginx.service
|
||||
|
||||
# 重启后端服务和游戏服务
|
||||
sudo systemctl daemon-reload
|
||||
sudo systemctl enable server.service
|
||||
sudo systemctl restart server.service
|
||||
sudo systemctl enable game.service
|
||||
sudo systemctl restart game.service
|
||||
@@ -2,33 +2,37 @@
|
||||
|
||||
set -e
|
||||
|
||||
# 更新系统并安装一些常用软件和依赖
|
||||
sudo yum update -y && sudo yum install -y vim curl git openssl openssl-devel
|
||||
GREEN='\033[0;32m'
|
||||
BLUE='\033[0;34m'
|
||||
YELLOW='\033[0;33m'
|
||||
|
||||
# 安装Nginx(安装后启动、设置为开机自启动)
|
||||
yum install -y nginx
|
||||
sudo systemctl start nginx.service
|
||||
sudo systemctl enable nginx.service
|
||||
# shellcheck disable=SC2039
|
||||
echo -e "${BLUE}一些常用的命令脚本:${NC}"
|
||||
|
||||
# 设置防火墙规则并重启防火墙
|
||||
sudo firewall-cmd --zone=public --add-port=443/tcp --permanent
|
||||
sudo firewall-cmd --zone=public --add-port=9000/udp --permanent
|
||||
sudo firewall-cmd --reload
|
||||
echo -e "${GREEN}查看所有服务状态${NC}"
|
||||
# shellcheck disable=SC2039
|
||||
echo -e "${GREEN}sudo systemctl status server.service game.service${NC}"
|
||||
|
||||
# 安装Golang编译环境
|
||||
if [ ! -d "/usr/local/go/bin/" ]; then
|
||||
wget https://studygolang.com/dl/golang/go1.19.4.linux-amd64.tar.gz
|
||||
tar -C /usr/local -xzf go1.19.4.linux-amd64.tar.gz
|
||||
sudo sh -c 'echo "export PATH=/usr/local/go/bin:$PATH" >> /etc/profile'
|
||||
# shellcheck disable=SC2039
|
||||
# shellcheck disable=SC1090
|
||||
source /etc/profile && source ~/.bashrc
|
||||
sudo rm -rf go1.19.4.linux-amd64.tar.gz
|
||||
fi
|
||||
# shellcheck disable=SC2039
|
||||
echo -e "${GREEN}重启后端服务${NC}"
|
||||
# shellcheck disable=SC2039
|
||||
echo -e "${GREEN}sudo systemctl restart server.service${NC}"
|
||||
# shellcheck disable=SC2039
|
||||
echo -e "${GREEN}重启游戏服务器${NC}"
|
||||
# shellcheck disable=SC2039
|
||||
echo -e "${GREEN}sudo systemctl restart game.service${NC}"
|
||||
|
||||
# 安装Redis、MySQL数据库
|
||||
if [ ! -d "/data/mysql" ]; then
|
||||
wget -c http://mirrors.oneinstack.com/oneinstack-full.tar.gz && tar xzf oneinstack-full.tar.gz && ./oneinstack/install.sh --db_option 2 --dbinstallmethod 1 --dbrootpwd 88888888 --redis
|
||||
sudo rm -rf oneinstack-full.tar.gz
|
||||
sudo rm -rf oneinstack*
|
||||
fi
|
||||
# shellcheck disable=SC2039
|
||||
echo -e "${GREEN}监听后端服务实时日志${NC}"
|
||||
# shellcheck disable=SC2039
|
||||
echo -e "${GREEN}sudo journalctl -fu server.service${NC}"
|
||||
# shellcheck disable=SC2039
|
||||
echo -e "${GREEN}监听游戏服务器实时日志${NC}"
|
||||
# shellcheck disable=SC2039
|
||||
echo -e "${GREEN}sudo journalctl -fu game.service${NC}"
|
||||
# shellcheck disable=SC2039
|
||||
|
||||
echo -e "${GREEN}重启Nginx服务${NC}"
|
||||
# shellcheck disable=SC2039
|
||||
echo -e "${GREEN}sudo systemctl restart nginx.service${NC}"
|
||||
# shellcheck disable=SC2039
|
||||
@@ -1,5 +1,2 @@
|
||||
@echo off
|
||||
|
||||
scp -r ./engine/release/server* root@172.21.245.0:/data/wwwroot/game/
|
||||
|
||||
ssh root@172.21.245.0 "chmod +x /data/wwwroot/game/* && cd /opt/Engine2D && sudo ./tools/update.sh"
|
||||
158
wiki/course/0002.md
Normal file
158
wiki/course/0002.md
Normal file
@@ -0,0 +1,158 @@
|
||||
## 第一课
|
||||
|
||||
> 第一课时操作引导文档。
|
||||
|
||||
### 一、游戏资源下载
|
||||
|
||||
> 1、访问:[GitHub](https://www.github.com)
|
||||
|
||||
> 2、下载安装Git:[Git](https://git-scm.com)
|
||||
|
||||
````shell
|
||||
# 生成GitHub SSH KEY
|
||||
ssh-keygen -t rsa -C "你的GitHub登录账号"
|
||||
````
|
||||
|
||||
```shell
|
||||
git config -global user.name "你的GitHub用户名"
|
||||
git config -global user.email "你的GitHub登录账号"
|
||||
```
|
||||
|
||||
````shell
|
||||
# 获取生成的GitHub SSH KEY
|
||||
C:\Users\admin/.ssh/id_rsa.pub
|
||||
````
|
||||
|
||||
```shell
|
||||
# 下载游戏源码
|
||||
git clone --depth=1 git@github.com:makeryangcom/Engine2D.git
|
||||
```
|
||||
|
||||
### 二、虚拟机的安装和配置
|
||||
|
||||
> 1、CentOS系统镜像下载地址:[CentOS-8.5.2111-x86_64-dvd1.iso](https://mirrors.aliyun.com/centos/8/isos/x86_64/CentOS-8.5.2111-x86_64-dvd1.iso)
|
||||
|
||||
> 2、切换到root用户,密码为`root`
|
||||
|
||||
```shell
|
||||
su
|
||||
```
|
||||
|
||||
> 3、修改SSH配置,防止后续SSH远程登录时因连接超时自动断开
|
||||
|
||||
```shell
|
||||
vim /etc/ssh/sshd_config
|
||||
```
|
||||
|
||||
> 4、获取虚拟机服务器内网IP地址
|
||||
|
||||
```shell
|
||||
ifconfig
|
||||
```
|
||||
|
||||
> 5、在本地电脑的命令行工具中通过SSH远程登录到虚拟机服务器
|
||||
|
||||
```shell
|
||||
ssh root@服务器内网IP地址
|
||||
```
|
||||
|
||||
> 6、更新软件源
|
||||
|
||||
```shell
|
||||
sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-*
|
||||
sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-*
|
||||
# 设置阿里云软件源
|
||||
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-8.repo
|
||||
# 清理缓存
|
||||
yum clean all
|
||||
yum makecache
|
||||
```
|
||||
|
||||
> 7、游戏资源下载
|
||||
|
||||
````shell
|
||||
# 安装git
|
||||
yum install -y git
|
||||
````
|
||||
|
||||
````shell
|
||||
# 生成GitHub SSH KEY
|
||||
ssh-keygen -t rsa -C "你的GitHub登录账号"
|
||||
````
|
||||
|
||||
````shell
|
||||
# 获取生成的GitHub SSH KEY
|
||||
cat /root/.ssh/id_rsa.pub
|
||||
````
|
||||
|
||||
```shell
|
||||
git config --global user.name "你的GitHub用户名"
|
||||
git config --global user.email "你的GitHub登录账号"
|
||||
```
|
||||
|
||||
```shell
|
||||
cd /opt
|
||||
# 下载游戏源码
|
||||
git clone --depth=1 git@github.com:makeryangcom/Engine2D.git
|
||||
```
|
||||
|
||||
> 8、自动化部署
|
||||
|
||||
```shell
|
||||
cd /opt/Engine2D
|
||||
sudo ./tools/init.sh
|
||||
```
|
||||
|
||||
```shell
|
||||
# 取消CRYPTO_POLICY=的注释
|
||||
vim /etc/sysconfig/sshd
|
||||
# MySQL数据库远程连接配置
|
||||
vim /etc/ssh/sshd_config
|
||||
# 在最后添加下面的配置
|
||||
Ciphers aes128-ctr,aes192-ctr,aes256-ctr,3des-cbc
|
||||
KexAlgorithms diffie-hellman-group1-sha1
|
||||
# 重启服务
|
||||
sudo systemctl restart sshd
|
||||
```
|
||||
|
||||
```shell
|
||||
cd /opt/Engine2D
|
||||
sudo ./tools/update.sh
|
||||
```
|
||||
|
||||
> 9、本地解析服务器域名
|
||||
|
||||
```shell
|
||||
C:\Windows\System32\drivers\etc
|
||||
```
|
||||
|
||||
> 10、日常维护使用的命令
|
||||
|
||||
``` bash
|
||||
# 监听后端服务日志
|
||||
sudo journalctl -fu server.service
|
||||
# 监听游戏服务器日志
|
||||
sudo journalctl -fu game.service
|
||||
|
||||
# 常用维护命令-重启Nginx服务
|
||||
sudo systemctl restart nginx.service
|
||||
# 常用维护命令-停止Nginx服务
|
||||
sudo systemctl stop nginx.service
|
||||
# 常用维护命令-启动Nginx服务
|
||||
sudo systemctl start nginx.service
|
||||
|
||||
# 查看后端服务、游戏服务器状态
|
||||
sudo systemctl status server.service game.service
|
||||
|
||||
# 停止、重启后端服务
|
||||
sudo systemctl stop|restart server.service
|
||||
# 停止、重启游戏服务器
|
||||
sudo systemctl stop|restart game.service
|
||||
```
|
||||
|
||||
> 11、其他配置
|
||||
|
||||
```shell
|
||||
Host 0.0.0.0
|
||||
KexAlgorithms +diffie-hellman-group1-sha1
|
||||
```
|
||||
Reference in New Issue
Block a user