diff --git a/README.md b/README.md index d739385..ec87e87 100644 --- a/README.md +++ b/README.md @@ -53,10 +53,76 @@ im-system-whale-shark * [x] 采用读扩散实现单聊、群聊离线消息拉取 ## 快速开始 -### 数据库环境 + +### 服务器方式部署 + +> 采用 docker compose 实现快速部署 + +首先要确保您的服务器上有 git、docker 以及 docker-compose + +可参考自行下载: [服务器下载 Git、Docker、Docker-Compose](docker/docker.md) + +1. 克隆本项目 + +```bash +git clone https://github.com/BanTanger/im-whale-shark.git +``` +2. 项目打包 + +```bash +mvn clean package +``` + +此过程可能有点长,请耐心等待 + +3. 为脚本执行赋予权限并执行 + +```bash +chmod +x *.sh +``` +```bash +./copy.sh +``` +- 将各个模块的 jar 包和 Dockerfile 移动到 docker/build 包下 + +4. 部署项目 + +```bash +sh deploy.sh base +``` +- 将基础组件部署到 docker +```bash +sh deploy.sh serives +``` +- 将后端的三个模块部署到 docker + +5. 开启防火墙 +```bash +./open_port.sh +``` + +停用、删除: +```bash +sh deploy.sh stop +``` +- 将 docker 的所有容器停用 + +```bash +sh deploy.sh rm +``` +- 将 docker 的所有容器删除 + +清空 build 文件夹: +```bash +./clean.sh +``` + +### 本地方式部署 + +#### 数据库环境 导入 `whale-shark/assert/sql/im_core.sql` 文件 -### Docker 环境部署 +#### Docker 环境部署 **如果是部署到服务端,注意防火墙是否拦截端口** redis: @@ -73,7 +139,7 @@ docker run -d -p 5672:5672 -p 15672:15672 --name rabbitmq ``` + 其中 15672 端口是连接 web 端页面的, 5672 端口是 Java 后端程序访问 rabbitmq 的 -### 后端启动 +#### 后端启动 后端有三个服务需要开启, 分别为: + im-tcp 包下的 Starter 程序 `com.bantanger.im.tcp.Starter`。它用于构建 TCP 网关服务, WebSocket、Socket 的连接, 消息发送, 回调以及路由等等基层操作。socket 的端口号是 `9001`, websocket 的端口号是 `19001` + im-domain 包下的 Application 程序 `com.bantanger.im.domain.Application`。它用于构建业务逻辑服务, 如用户、好友、群组的创建, 更改, 删除, 与数据库、缓存进行逻辑交互。端口号为 `8000` diff --git a/assert/sql/im_core.sql b/assert/sql/im_core.sql index 5977202..e1e27b3 100644 --- a/assert/sql/im_core.sql +++ b/assert/sql/im_core.sql @@ -1,42 +1,45 @@ -create table app_user +CREATE DATABASE IF NOT EXISTS im_core; +USE im_core; + +CREATE TABLE app_user ( - user_id varchar(20) not null - primary key, - user_name varchar(255) null, - password varchar(255) null, - mobile varchar(255) null, - create_time bigint null, - update_time bigint null + user_id VARCHAR(20) NOT NULL + PRIMARY KEY, + user_name VARCHAR(255) NULL, + password VARCHAR(255) NULL, + mobile VARCHAR(255) NULL, + create_time BIGINT NULL, + update_time BIGINT NULL ); -create table im_conversation_set +CREATE TABLE im_conversation_set ( - conversation_id varchar(255) not null, - conversation_type int(10) null comment '0 单聊 1群聊 2机器人 3公众号', - from_id varchar(50) null, - to_id varchar(50) null, - is_mute int(10) null comment '是否免打扰 1免打扰', - is_top int(10) null comment '是否置顶 1置顶', - sequence bigint null comment 'sequence', - read_sequence bigint null, - app_id int(10) not null, - primary key (app_id, conversation_id) + conversation_id VARCHAR(255) NOT NULL, + conversation_type INT(10) NULL COMMENT '0 单聊 1群聊 2机器人 3公众号', + from_id VARCHAR(50) NULL, + to_id VARCHAR(50) NULL, + is_mute INT(10) NULL COMMENT '是否免打扰 1免打扰', + is_top INT(10) NULL COMMENT '是否置顶 1置顶', + sequence BIGINT NULL COMMENT 'sequence', + read_sequence BIGINT NULL, + app_id INT(10) NOT NULL, + PRIMARY KEY (app_id, conversation_id) ); -create table im_friendship +CREATE TABLE im_friendship ( - app_id int(20) not null comment 'app_id', - from_id varchar(50) not null comment 'from_id', - to_id varchar(50) not null comment 'to_id', - remark varchar(50) null comment '备注', - status int(10) null comment '状态 1正常 2删除', - black int(10) null comment '1正常 2拉黑', - create_time bigint null, - friend_sequence bigint null, - black_sequence bigint null, - add_source varchar(20) null comment '来源', - extra varchar(1000) null comment '来源', - primary key (app_id, from_id, to_id) + app_id INT(20) NOT NULL COMMENT 'app_id', + from_id VARCHAR(50) NOT NULL COMMENT 'from_id', + to_id VARCHAR(50) NOT NULL COMMENT 'to_id', + remark VARCHAR(50) NULL COMMENT '备注', + status INT(10) NULL COMMENT '状态 1正常 2删除', + black INT(10) NULL COMMENT '1正常 2拉黑', + create_time BIGINT NULL, + friend_sequence BIGINT NULL, + black_sequence BIGINT NULL, + add_source VARCHAR(20) NULL COMMENT '来源', + extra VARCHAR(1000) NULL COMMENT '来源', + PRIMARY KEY (app_id, from_id, to_id) ); INSERT INTO im_core.im_friendship (app_id, from_id, to_id, remark, status, black, create_time, friend_sequence, black_sequence, add_source, extra) VALUES (10001, '10001', '10002', 'minim tempor', 1, 1, 1680608016816, null, null, 'cillum', 'dolore fugiat'); @@ -46,7 +49,7 @@ INSERT INTO im_core.im_friendship (app_id, from_id, to_id, remark, status, black INSERT INTO im_core.im_friendship (app_id, from_id, to_id, remark, status, black, create_time, friend_sequence, black_sequence, add_source, extra) VALUES (10001, 'bantanger', '10001', 'minim tempor', 1, 1, 1680608016850, null, null, 'cillum', 'dolore fugiat'); INSERT INTO im_core.im_friendship (app_id, from_id, to_id, remark, status, black, create_time, friend_sequence, black_sequence, add_source, extra) VALUES (10001, 'bantanger', '10002', 'minim tempor', 1, 1, 1681024987165, 1, null, 'cillum', 'dolore fugiat'); -create table im_friendship_group +CREATE TABLE im_friendship_group ( app_id int(20) null comment 'app_id', from_id varchar(50) null comment 'from_id', @@ -61,77 +64,75 @@ create table im_friendship_group unique (app_id, from_id, group_name) ); -create table im_friendship_group_member +CREATE TABLE im_friendship_group_member ( - group_id bigint not null - primary key, - to_id varchar(50) null + group_id BIGINT NOT NULL + PRIMARY KEY, + to_id VARCHAR(50) NULL ); -create table im_friendship_request +CREATE TABLE im_friendship_request ( - id int(20) auto_increment comment 'id' - primary key, - app_id int(20) null comment 'app_id', - from_id varchar(50) null comment 'from_id', - to_id varchar(50) null comment 'to_id', - remark varchar(50) null comment '备注', - read_status int(10) null comment '是否已读 1已读', - add_source varchar(20) null comment '好友来源', - add_wording varchar(50) null comment '好友验证信息', - approve_status int(10) null comment '审批状态 1同意 2拒绝', - create_time bigint null, - update_time bigint null, - sequence bigint null + id INT(20) AUTO_INCREMENT COMMENT 'id' + PRIMARY KEY, + app_id INT(20) NULL COMMENT 'app_id', + from_id VARCHAR(50) NULL COMMENT 'from_id', + to_id VARCHAR(50) NULL COMMENT 'to_id', + remark VARCHAR(50) NULL COMMENT '备注', + read_status INT(10) NULL COMMENT '是否已读 1已读', + add_source VARCHAR(20) NULL COMMENT '好友来源', + add_wording VARCHAR(50) NULL COMMENT '好友验证信息', + approve_status INT(10) NULL COMMENT '审批状态 1同意 2拒绝', + create_time BIGINT NULL, + update_time BIGINT NULL, + sequence BIGINT NULL ); INSERT INTO im_core.im_friendship_request (id, app_id, from_id, to_id, remark, read_status, add_source, add_wording, approve_status, create_time, update_time, sequence) VALUES (1, 10001, '10003', 'bantanger', 'minim tempor', 0, 'cillum', 'ipsum id', 0, 1681025483768, null, 1); -create table im_group +CREATE TABLE im_group ( - app_id int(20) not null comment 'app_id', - group_id varchar(50) not null comment 'group_id', - owner_id varchar(50) not null comment '群主 -', - group_type int(10) null comment '群类型 1私有群(类似微信) 2公开群(类似qq)', - group_name varchar(100) null, - mute int(10) null comment '是否全员禁言,0 不禁言;1 全员禁言', - apply_join_type int(10) null comment '// 申请加群选项包括如下几种: + app_id INT(20) NOT NULL COMMENT 'app_id', + group_id VARCHAR(50) NOT NULL COMMENT 'group_id', + owner_id VARCHAR(50) NOT NULL COMMENT '群主', + group_type INT(10) NULL COMMENT '群类型 1私有群(类似微信) 2公开群(类似QQ)', + group_name VARCHAR(100) NULL, + mute INT(10) NULL COMMENT '是否全员禁言,0 不禁言;1 全员禁言', + apply_join_type INT(10) NULL COMMENT '// 申请加群选项包括如下几种: // 0 表示禁止任何人申请加入 // 1 表示需要群主或管理员审批 // 2 表示允许无需审批自由加入群组', - photo varchar(300) null, - max_member_count int(20) null, - introduction varchar(100) null comment '群简介', - notification varchar(1000) null comment '群公告', - status int(5) null comment '群状态 0正常 1解散', - sequence bigint null, - create_time bigint null, - extra varchar(1000) null comment '来源', - update_time bigint null, - primary key (app_id, group_id) + photo VARCHAR(300) NULL, + max_member_count INT(20) NULL, + introduction VARCHAR(100) NULL COMMENT '群简介', + notification VARCHAR(1000) NULL COMMENT '群公告', + status INT(5) NULL COMMENT '群状态 0正常 1解散', + sequence BIGINT NULL, + create_time BIGINT NULL, + extra VARCHAR(1000) NULL COMMENT '来源', + update_time BIGINT NULL, + PRIMARY KEY (APP_ID, GROUP_ID) ); INSERT INTO im_core.im_group (app_id, group_id, owner_id, group_type, group_name, mute, apply_join_type, photo, max_member_count, introduction, notification, status, sequence, create_time, extra, update_time) VALUES (10001, '158e4d1df28d42ba9c23bf0d47e03be1', 'bantanger', 1, 'Java 后端必胜组', 0, 2, 'http://dummyimage.com/400x400', null, 'laborum irure minim', 'qui ipsum ut tempor', 1, 1, 1681028052204, 'ullamco consequat pariatur', null); INSERT INTO im_core.im_group (app_id, group_id, owner_id, group_type, group_name, mute, apply_join_type, photo, max_member_count, introduction, notification, status, sequence, create_time, extra, update_time) VALUES (10001, '27a35ff2f9be4cc9a8d3db1ad3322804', 'bantanger', 1, '半糖的IM小屋', 0, 2, 'http://dummyimage.com/400x400', 200, '半糖的IM聊天室小屋', '大家好,我是 BanTanger 半糖 ', 0, null, 1680055132161, 'aliquip esse eiusmod Duis ullamco', null); INSERT INTO im_core.im_group (app_id, group_id, owner_id, group_type, group_name, mute, apply_join_type, photo, max_member_count, introduction, notification, status, sequence, create_time, extra, update_time) VALUES (10001, '5ce492e515a346acbf316233d303e213', 'bantanger', 1, 'Java 后端必胜组2', 0, 2, 'http://dummyimage.com/400x400', null, 'laborum irure minim', 'qui ipsum ut tempor', 1, 2, 1681028156991, 'ullamco consequat pariatur', null); -create table im_group_member +CREATE TABLE im_group_member ( - group_member_id bigint auto_increment - primary key, - group_id varchar(50) not null comment 'group_id', - app_id int(10) null, - member_id varchar(50) not null comment '成员id -', - role int(10) null comment '群成员类型,0 普通成员, 1 管理员, 2 群主, 3 禁言,4 已经移除的成员', - speak_date bigint(100) null, - mute int(10) null comment '是否全员禁言,0 不禁言;1 全员禁言', - alias varchar(100) null comment '群昵称', - join_time bigint null comment '加入时间', - leave_time bigint null comment '离开时间', - join_type varchar(50) null comment '加入类型', - extra varchar(1000) null + group_member_id BIGINT AUTO_INCREMENT + PRIMARY KEY, + group_id VARCHAR(50) NOT NULL COMMENT 'group_id', + app_id INT(10) NULL, + member_id VARCHAR(50) NOT NULL COMMENT '成员ID', + role INT(10) NULL COMMENT '群成员类型,0 普通成员, 1 管理员, 2 群主, 3 禁言,4 已经移除的成员', + speak_date BIGINT(100) NULL, + mute INT(10) NULL COMMENT '是否全员禁言,0 不禁言;1 全员禁言', + alias VARCHAR(100) NULL COMMENT '群昵称', + join_time BIGINT NULL COMMENT '加入时间', + leave_time BIGINT NULL COMMENT '离开时间', + join_type VARCHAR(50) NULL COMMENT '加入类型', + extra VARCHAR(1000) NULL ); INSERT INTO im_core.im_group_member (group_member_id, group_id, app_id, member_id, role, speak_date, mute, alias, join_time, leave_time, join_type, extra) VALUES (1, '9122c352bbcb411f9a6cb365961dced3', 10001, '10002', 1, 20180210, null, 'consectetur quis nisi labore', 1679400643055, null, null, null); @@ -140,67 +141,65 @@ INSERT INTO im_core.im_group_member (group_member_id, group_id, app_id, member_i INSERT INTO im_core.im_group_member (group_member_id, group_id, app_id, member_id, role, speak_date, mute, alias, join_time, leave_time, join_type, extra) VALUES (4, '27a35ff2f9be4cc9a8d3db1ad3322804', 10001, '10002', 0, null, null, null, 1679400643080, null, null, null); INSERT INTO im_core.im_group_member (group_member_id, group_id, app_id, member_id, role, speak_date, mute, alias, join_time, leave_time, join_type, extra) VALUES (5, '27a35ff2f9be4cc9a8d3db1ad3322804', 10001, 'bantanger', 2, 20200411, null, 'sit reprehenderit', 1681471124554, null, 'id', null); -create table im_group_message_history +CREATE TABLE im_group_message_history ( - app_id int(20) not null comment 'app_id', - from_id varchar(50) not null comment 'from_id', - group_id varchar(50) not null comment 'group_id', - message_key bigint(50) not null comment 'messageBodyId', - create_time bigint null, - sequence bigint null, - message_random int(20) null, - message_time bigint null comment '来源', - primary key (app_id, group_id, message_key) + app_id INT(20) NOT NULL COMMENT 'app_id', + from_id VARCHAR(50) NOT NULL COMMENT 'from_id', + group_id VARCHAR(50) NOT NULL COMMENT 'group_id', + message_key BIGINT(50) NOT NULL COMMENT 'messageBodyId', + create_time BIGINT NULL, + sequence BIGINT NULL, + message_random INT(20) NULL, + message_time BIGINT NULL COMMENT '来源', + PRIMARY KEY (app_id, group_id, message_key) ); -create table im_message_body +CREATE TABLE im_message_body ( - app_id int(10) not null, - message_key bigint(50) not null - primary key, - message_body varchar(5000) null, - security_key varchar(100) null, - message_time bigint null, - create_time bigint null, - extra varchar(1000) null, - del_flag int(10) null + app_id INT(10) NOT NULL, + message_key BIGINT(50) NOT NULL + PRIMARY KEY, + message_body VARCHAR(5000) NULL, + security_key VARCHAR(100) NULL, + message_time BIGINT NULL, + create_time BIGINT NULL, + extra VARCHAR(1000) NULL, + del_flag INT(10) NULL ); -create table im_message_history +CREATE TABLE im_message_history ( - app_id int(20) not null comment 'app_id', - from_id varchar(50) not null comment 'from_id', - to_id varchar(50) not null comment 'to_id -', - owner_id varchar(50) not null comment 'owner_id -', - message_key bigint(50) not null comment 'messageBodyId', - create_time bigint null, - sequence bigint null, - message_random int(20) null, - message_time bigint null comment '来源', - primary key (app_id, owner_id, message_key) + app_id INT(20) NOT NULL COMMENT 'app_id', + from_id VARCHAR(50) NOT NULL COMMENT 'from_id', + to_id VARCHAR(50) NOT NULL COMMENT 'to_id', + owner_id VARCHAR(50) NOT NULL COMMENT 'owner_id', + message_key BIGINT(50) NOT NULL COMMENT 'messageBodyId', + create_time BIGINT NULL, + sequence BIGINT NULL, + message_random INT(20) NULL, + message_time BIGINT NULL COMMENT '来源', + PRIMARY KEY (app_id, owner_id, message_key) ); -create table im_user_data +CREATE TABLE im_user_data ( - user_id varchar(50) not null, - app_id int not null, - nick_name varchar(100) null comment '昵称', - password varchar(255) null, - photo varchar(255) null, - user_sex int(10) null, - birth_day varchar(50) null comment '生日', - location varchar(50) null comment '地址', - self_signature varchar(255) null comment '个性签名', - friend_allow_type int(10) default 1 not null comment '加好友验证类型(Friend_AllowType) 1无需验证 2需要验证', - forbidden_flag int(10) default 0 not null comment '禁用标识 1禁用', - disable_add_friend int(10) default 0 not null comment '管理员禁止用户添加加好友:0 未禁用 1 已禁用', - silent_flag int(10) default 0 not null comment '禁言标识 1禁言', - user_type int(10) default 1 not null comment '用户类型 1普通用户 2客服 3机器人', - del_flag int(20) default 0 not null, - extra varchar(1000) null, - primary key (app_id, user_id) + user_id VARCHAR(50) NOT NULL, + app_id INT NOT NULL, + nick_name VARCHAR(100) NULL COMMENT '昵称', + password VARCHAR(255) NULL, + photo VARCHAR(255) NULL, + user_sex INT(10) NULL, + birth_day VARCHAR(50) NULL COMMENT '生日', + location VARCHAR(50) NULL COMMENT '地址', + self_signature VARCHAR(255) NULL COMMENT '个性签名', + friend_allow_type INT(10) DEFAULT 1 NOT NULL COMMENT '加好友验证类型(Friend_AllowType) 1无需验证 2需要验证', + forbidden_flag INT(10) DEFAULT 0 NOT NULL COMMENT '禁用标识 1禁用', + disable_add_friend INT(10) DEFAULT 0 NOT NULL COMMENT '管理员禁止用户添加加好友:0 未禁用 1 已禁用', + silent_flag INT(10) DEFAULT 0 NOT NULL COMMENT '禁言标识 1禁言', + user_type INT(10) DEFAULT 1 NOT NULL COMMENT '用户类型 1普通用户 2客服 3机器人', + del_flag INT(20) DEFAULT 0 NOT NULL, + extra VARCHAR(1000) NULL, + PRIMARY KEY (app_id, user_id) ); INSERT INTO im_core.im_user_data (user_id, app_id, nick_name, password, photo, user_sex, birth_day, location, self_signature, friend_allow_type, forbidden_flag, disable_add_friend, silent_flag, user_type, del_flag, extra) VALUES ('10001', 10001, '段勇', 'consequat fugiat commodo eu ut', 'http://dummyimage.com/400x400', 1, '2004-01-28', 'nisi enim veniam minim Duis', 'velit consequat dolor Duis in', 1, 0, 0, 0, 1, 0, 'ad nostrud'); diff --git a/clean.sh b/clean.sh new file mode 100644 index 0000000..30b87dc --- /dev/null +++ b/clean.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +echo "::: Welcome to IM-WhaleShark :::" + +# 删除 build 文件夹 +echo "开始清理 build 文件夹 .." +rm -rf docker/build/ +echo "清理完成" \ No newline at end of file diff --git a/copy.sh b/copy.sh index 98fdf3a..45b2236 100644 --- a/copy.sh +++ b/copy.sh @@ -1,5 +1,6 @@ #!/bin/bash +echo "::: Welcome to IM-WhaleShark :::" # 创建目标目录 mkdir -p docker/build/domain/jar mkdir -p docker/build/message-store/jar diff --git a/deploy.sh b/deploy.sh index 13d42a0..d93a3ac 100644 --- a/deploy.sh +++ b/deploy.sh @@ -2,28 +2,49 @@ # 使用说明,用来提示输入参数 usage(){ + echo "::: Welcome to IM-WhaleShark :::" echo "Usage: sh 执行脚本.sh [base|services|stop|rm]" exit 1 } +# Check if Docker is installed +if ! command -v docker >/dev/null 2>&1; then + echo "Error: Docker is not installed. Please install Docker before running this script." + exit 1 +fi + +# Check if Docker Compose is installed and set the appropriate command +if command -v docker-compose &> /dev/null +then + COMPOSE_COMMAND="docker-compose" +else + if command -v docker compose &> /dev/null + then + COMPOSE_COMMAND="docker compose" + else + echo "Error: Docker Compose is not installed. Please install Docker Compose before running this script." + exit 1 + fi +fi + # 启动基础环境(必须) base(){ - docker compose up -d im-mysql im-redis im-zookeeper im-rabbitmq + $COMPOSE_COMMAND up -d im-mysql im-redis im-zookeeper im-rabbitmq } # 启动程序模块(必须) services(){ - docker compose up -d im-domain im-message-store im-tcp + $COMPOSE_COMMAND up -d im-domain im-message-store im-tcp } # 关闭所有环境/模块 stop(){ - docker compose stop + $COMPOSE_COMMAND stop } # 删除所有环境/模块 rm(){ - docker compose rm + $COMPOSE_COMMAND rm } # 根据输入参数,选择执行对应方法,不输入则执行使用说明 diff --git a/docker-compose.yml b/docker-compose.yml index 3614e4e..649b470 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,8 +6,9 @@ services: container_name: im-mysql image: mysql:8.0.11 build: - context: ./build/mysql + context: ./mysql restart: always + privileged: true volumes: - ./docker/mysql/conf:/etc/mysql/conf.d - ./docker/mysql/logs:/logs @@ -29,10 +30,10 @@ services: healthcheck: test: ["CMD", "mysqladmin", "ping", "-h", "localhost"] interval: 10s - timeout: 5s + timeout: 20s retries: 3 ports: - - "3306:3306" + - "13306:3306" networks: - im-network @@ -41,13 +42,14 @@ services: container_name: im-zookeeper image: zookeeper:latest restart: always + privileged: true environment: ZOO_MY_ID: 1 ZOO_SERVERS: server.1=localhost:2888:3888 healthcheck: test: ["CMD-SHELL", "zkOk=$(echo stat | nc localhost 2181 | grep Mode); if [ -z \"$zkOk\" ]; then exit 1; fi"] interval: 10s - timeout: 5s + timeout: 20s retries: 3 ports: - "2181:2181" @@ -75,7 +77,7 @@ services: container_name: im-redis image: redis:6.0.8 build: - context: ./build/redis + context: ./redis restart: always ports: - "6379:6379" diff --git a/docker/docker.md b/docker/docker.md new file mode 100644 index 0000000..af28c55 --- /dev/null +++ b/docker/docker.md @@ -0,0 +1,53 @@ +# 1. docker +## 安装 +```bash +curl -sSL https://get.daocloud.io/docker | sh +``` +或者 +```bash +curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun +``` +## 启动、停止 + +### systemctl 方式 + +重启docker服务 + +``` +sudo systemctl restart docker +``` + +关闭docker + +``` +sudo systemctl stop docker +``` + +### service 方式 + +重启docker服务 + +```bash + sudo service docker restart +``` + +关闭docker + +```bash + sudo service docker stop +``` + +# 2. docker-compose安装 + +```bash +sudo curl -L "https://github.com/docker/compose/releases/download/1.24.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose +``` + +```bash +chmod +x /usr/local/bin/docker-compose +``` + +# 3. 安装git +``` +ubuntu系统上执行 apt install git +``` diff --git a/docker/mysql/db/im_core.sql b/docker/mysql/db/im_core.sql index 70a73cb..ee610e0 100644 --- a/docker/mysql/db/im_core.sql +++ b/docker/mysql/db/im_core.sql @@ -170,10 +170,10 @@ CREATE TABLE im_message_body CREATE TABLE im_message_history ( - app_id INT(20) NOT NULL COMMENT 'APP_ID', - from_id VARCHAR(50) NOT NULL COMMENT 'FROM_ID', - to_id VARCHAR(50) NOT NULL COMMENT 'TO_ID', - owner_id VARCHAR(50) NOT NULL COMMENT 'OWNER_ID', + app_id INT(20) NOT NULL COMMENT 'app_id', + from_id VARCHAR(50) NOT NULL COMMENT 'from_id', + to_id VARCHAR(50) NOT NULL COMMENT 'to_id', + owner_id VARCHAR(50) NOT NULL COMMENT 'owner_id', message_key BIGINT(50) NOT NULL COMMENT 'messageBodyId', create_time BIGINT NULL, sequence BIGINT NULL, diff --git a/open_port.sh b/open_port.sh new file mode 100644 index 0000000..61b1836 --- /dev/null +++ b/open_port.sh @@ -0,0 +1,52 @@ +#!/bin/bash + +# 检查是否为root用户 +if [ "$(id -u)" -ne 0 ]; then + echo "Error: This script must be run as root." + exit 1 +fi + +echo "::: Welcome to IM-WhaleShark :::" + +# 定义要开启的端口列表 +ports=(3306 13306 6379 18000 18001 19001 19002 2181 2888 3888 5672 15672) + +# 开启端口 +open_ports() { + for port in "${ports[@]}"; do + echo "Opening port $port..." + firewall-cmd --zone=public --add-port=$port/tcp --permanent + done + echo "Reloading firewall..." + firewall-cmd --reload + echo "Ports opened successfully!" +} + +# 关闭端口 +close_ports() { + for port in "${ports[@]}"; do + echo "Closing port $port..." + firewall-cmd --zone=public --remove-port=$port/tcp --permanent + done + echo "Reloading firewall..." + firewall-cmd --reload + echo "Ports closed successfully!" +} + +# 判断是否传入参数 +if [[ $# -eq 0 ]]; then + echo "Usage: $0 [open|close]" + exit 1 +fi + +# 根据传入的参数调用相应的函数 +if [[ $1 == "open" ]]; then + open_ports +elif [[ $1 == "close" ]]; then + close_ports +else + echo "Usage: $0 [open|close]" + exit 1 +fi + +exit 0