Install opemim-server on ubuntu

Open source address

https://github.com/OpenIMSDK/Open-IM-Server
official website

Software installation

Zookeeper

docker pull zookeeper
# docker run -d --name zookeeper --privileged=true -p 2181:2181 zookeeper
docker run -d --name zookeeper -p 2181:2181 zookeeper


MySQL(version:5.7)

docker pull mysql:5.7
docker run -p 3306:3306 --name mysql5.7 -e MYSQL_ROOT_PASSWORD=wujialiang -d mysql:5.7


MongoDB(version:4.0.28)

docker pull mongo
docker run -itd --name mongodb -p 27017:27017 mongo
docker exec -it mongodb mongo admin
db.createUser({<!-- --> user: 'admin', pwd: 'admin123456', roles: [ {<!-- --> role: "userAdminAnyDatabase", db: "admin" } ] }) ;
db.auth("admin","admin123456");
exit





Redis(version:redis_version:7.0.0)

docker pull redis:7.0
docker run -itd -p 6379:6379 --name redis -d redis:7.0


Kafka(version:kafka_2.13-2.8.1)

# docker pull bitnami/kafka:2.8.1
# docker run -itd -p 9092:9092 --name kafka-server -e ALLOW_PLAINTEXT_LISTENER=yes bitnami/kafka:2.8.1
docker pull wurstmeister/kafka:2.13-2.8.1
docker run -d --name kafka -p 9092:9092 \
--link zookeeper \
--env KAFKA_ZOOKEEPER_CONNECT=zookeeper:2181 \
--env KAFKA_ADVERTISED_HOST_NAME=localhost \
--env KAFKA_ADVERTISED_PORT=9092 \
--env KAFKA_LOG_DIRS=/kafka/logs \
wurstmeister/kafka:2.13-2.8.1


Minio(version:minio version RELEASE.2022-05-26T05-48-41Z)

# docker pull minio/minio
docker pull minio/minio:RELEASE.2022-05-26T05-48-41Z
# docker run -p 9000:9000 -p 9090:9090 --name minio -d --restart=always -e "MINIO_ACCESS_KEY=minioadmin" -e "MINIO_SECRET_KEY=minioadmin" minio/minio:RELEASE.2022-05-26T05- 48-41Z server --console-address ":9090" -address ":9000"
docker run --name minio -d -e "MINIO_ACCESS_KEY=minioadmin" -e "MINIO_SECRET_KEY=minioadmin" -p 9000:9000 -p 9001:9001 minio/minio:RELEASE.2022-05-26T05-48-41Z server /data --console-address ":9001"



access 9001

View the final effect

ubuntu install go

refer to
Turn on proxy

go env -w GOPROXY=https://goproxy.cn

Deploy openim-server

Pull source code

git clone https://github.com/OpenIMSDK/Open-IM-Server.git

Modify configuration file

Modify config/config.yaml

zookeeper:
  schema: openim #It is not recommended to modify
  address: [ 127.0.0.1:2181 ] #
  username: #username
  password: #password

mysql:
  address: [ 127.0.0.1:3306 ] #Currently only supports stand-alone
  username: root #username
  password: wujialiang #password
  database: openIM_v3 #It is not recommended to modify
  maxOpenConn: 1000 #Maximum number of connections
  maxIdleConn: 100 #Maximum number of idle connections
  maxLifeTime: 60 #The maximum time that a connection can be reused (seconds)
  logLevel: 4 #log level 1=slient 2=error 3=warn 4=info
  slowThreshold: 500 #Slow statement threshold (milliseconds)

mongo:
  uri: #If it is not empty, use this value directly
  address: [ 127.0.0.1:27017 ] #Mongo address for single machine, mongos address for fragmented cluster
  database: openIM_v3 #mongo db default
  username: admin #username
  password: admin123456 #password
  maxPoolSize: 100

redis:
  address: [ 127.0.0.1:6379 ] #
  username: #only redis version 6.0 + need username
  password: #password

kafka:
  username: #username
  password: #password
  addr: [ 127.0.0.1:9092 ] #
  latestMsgToRedis:
    topic: "latestMsgToRedis" #It is not recommended to modify
  offlineMsgToMongo:
    topic: "offlineMsgToMongoMysql" #It is not recommended to modify
  msgToPush:
    topic: "msgToPush" #It is not recommended to modify
  consumerGroupID: #consumer group, it is not recommended to modify
    msgToRedis: redis#
    msgToMongo: mongo #
    msgToMySql: mysql#
    msgToPush: push #
object:
  enable: "minio" #use minio
  apiURL: "http://127.0.0.1:10002/object/"
  minio:
    bucket: "openim" #It is not recommended to modify
    endpoint: "http://127.0.0.1:9000" #The ip and port of minio's external service, the app must be able to access this ip and port
    accessKeyID: "minioadmin" #ID
    secretAccessKey: "minioadmin" #secret key
    sessionToken: "" #token
  cos: #tencent cos
    bucketURL: "https://temp-1252357374.cos.ap-chengdu.myqcloud.com"
    secretID: ""
    secretKey: ""
    sessionToken: ""
  oss: #ali oss
    endpoint: "https://oss-cn-chengdu.aliyuncs.com"
    bucket: "demo-9999999"
    bucketURL: "https://demo-9999999.oss-cn-chengdu.aliyuncs.com"
    accessKeyID: ""
    accessKeySecret: ""
    sessionToken: ""

modify.evn

USER=root
PASSWORD=openIM123
MINIO_ENDPOINT=http://127.0.0.1:9000
API_URL=http://127.0.0.1:10002/object/
DATA_DIR=./


Modify build_all_service.sh, function.sh, path_info.sh to unix format

Install required packages

sudo apt-get update
sudo apt-get install libncurses-dev
sudo apt-get install openssl
sudo apt-get install libssl-dev
# sudo apt-get install ncurses-devel
sudo apt install libncurses-dev
sudo apt-get install libncurses5-dev
sudo apt-get install gcc automake autoconf libtool make

execute compile

cd Open-IM-server/scripts
chmod +x *.sh
./build_all_service.sh



Start the service

start_all.sh, start_rpc_service.sh, push_start.sh, msg_transfer_start.sh, msg_gateway_start.sh, start_cron.sh changed to unix format

./start_all.sh

Check all services

check_all.sh modified to unix format

./check_all.sh

Stop service

stop_all.sh modified to unix format

./stop_all.sh

Install chat service

Pull item

git clone https://github.com/OpenIMSDK/chat.git


Compress it as tar and upload it to the server and decompress it

Modify the configuration file chat/config/config.yaml

If you have applied for Alibaba Cloud SMS service, modify the chat/config/config.yaml configuration item. If you have not applied for it, skip it first. The default verification code is 666666

verifyCode:
  validTime: 300 # Verification code valid time
  validCount: 5 # Verification code valid times
  uintTime: 86400 # unit time interval
  maxCount: 10 # The maximum number of acquisitions per unit time
  superCode: 666666 # Default mobile phone verification code (valid only when use is empty)
  len: 6 # verification code length
  use: # If you have applied for Ali SMS service, set it to ali to make it effective
  Ali:
    endpoint: "dysmsapi.aliyuncs.com"
    accessKeyId: ""
    accessKeySecret: ""
    signName: ""
    verificationCodeTemplateCode: ""

There is no application here so no modification

Compile code

Modify all sh under the scripts file to unix format

cd chat/scripts
chmod +x *.sh
./build_all_service.sh


Start the service

./start_all.sh

Check service

./check_all.sh

Stop service

./stop_all.sh