The following example server operating system is used: Centos7.2-X8.6_64_Lite
Software used: Mysql5.6; Nginx1.8.1; Nodejs6.9.5; Redis3.2.3
The code and related environment can be downloaded here
https://code.csdn.net/typesdk_code/typesdk_server/tree/master
1. After installing Centos7.x , install Git and clone related programs directly from the source code repository
1. Install git
yum install -y git
2.
Clone the code
from
git
git clone https://code.csdn.net/typesdk_code/typesdk_server.git
2. Install Mysql and import the database ( the root user can only log in locally, not remotely, and the password is typesdk.com )
1. Install mysql5.6 , here use the official source installation
cdtypesdk_server/Tools/
rpm -ivhmysql57-community-release-el7-9.noarch.rpm
cpmysql-community.repo /etc/yum.repos.d/mysql-community.repo
yum install -ymysql-server
mkdir -p/data/typesdk_server/mysql_data
chown -R mysql.mysql/data/typesdk_server/mysql_data
cp /etc/my.cnf/etc/my.cnf.bak
>/etc/my.cnf
vi /etc/my.cnf
The following is the full text of the configuration file, just copy and copy it in
[mysqld]
datadir=/data/typesdk_server/mysql_data
socket=/var/lib/mysql/mysql.sock
symbolic-links=0
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
character-set-server=utf8
[client]
default-character-set=utf8
[mysql]
default-character-set=utf8
2. Start the database
service mysql start
3. Import database
mysql <../SdkServer_free_git/typesdk_server.sql
mysqladmin-u root password "typesdk.com"
3. Install redis and import data ( redis is only for local login, remote access is not open, the password is typesdk.com )
1. Install redis using RPM
rpm -ivhjemalloc-3.6.0-1.el7.x86_64.rpm
rpm -ivhredis-3.2.3-1.el7.x86_64.rpm
mkdir -p /data/typesdk_server/redis_data
chown -R redis.redis/data/typesdk_server/redis_data
cp /etc/redis.conf /etc/redis.conf.bak
>/etc/redis.conf
vi /etc/redis.conf
The following is the full text of the configuration file, just copy and copy it in
bind127.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 /var/log/redis/redis.log
databases 16
save 900 1
save 300 10
save 60 10000
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
dbfilename sdk.rdb
dir /data/typesdk_server/redis_data
slave-serve-stale-data yes
slave-read-only yes
requirepass typesdk.com
repl-diskless-sync no
repl-diskless-sync-delay 5
repl-disable-tcp-nodelay no
slave-priority 100
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
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
activerehashing yes
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit slave 256mb64mb 60
client-output-buffer-limit pubsub 32mb8mb 60
hz 10
aof-rewrite-incremental-fsync yes
2. Start redis
service redis start
3. Import redis database
sh../SdkServer_free_git/init_redis.sh
Pay special attention to the redis configuration information in init_redis.sh must be configured correctly. The apikey is the key for communication between the sdk server and the game server. Please modify it to be consistent according to the actual situation. For other channel-related parameters, please refer to the script notes
There is a graphical configuration tool in the TypeSdk packaging tool, and you can also use that tool to generate and synchronize
Fourth, install and configure nginx
1. rpm install nginx
rpm -ivhnginx-1.8.1-1.el7.ngx.x86_64.rpm
mkdir -p/data/typesdk_server/nginx_html/config
cp/etc/nginx/nginx.conf /etc/nginx/nginx.conf.bak
mkdir -p/data/typesdk_server/nginx_html/config/
cp -rfNginx_SwitchConfig/1001/ /data/typesdk_server/nginx_html/config/
>/etc/nginx/nginx.conf
vi/etc/nginx/nginx.conf
The following is the full text of the configuration file, just copy and copy it in
#user nobody;
worker_processes auto;
events {
worker_connections 102400;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
gzip on;
server {
listen 80;
#server_name your.domain.name;
location /config {
root /data/typesdk_server/nginx_html;
index index.html index.htm;
}
location / {
proxy_pass http://127.0.0.1:40000;
}
location/getIp {
default_type application/json;
return 200 '{"ip":"$remote_addr"}';
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
2. Start nginx
service nginx start
5. Install node environment and configure TypeSdkServer
1. rpm install node
rpm -ivh nodejs-6.9.5-1nodesource.el7.centos.x86_64.rpm
npm config set registry http://registry.cnpmjs.org
cp -rf ../SdkServer_free_git/ /data/typesdk_server/
chmod +x /data/typesdk_server/SdkServer_free_git/node_modules/pm2/bin/pm2
ln -s /data/typesdk_server/SdkServer_free_git/node_modules/pm2/bin/pm2/usr/bin/pm2
Pay special attention to the /data/typesdk_server/SdkServer_free_git/config.json file
Please modify according to the configuration of the installed mysql and redis , if you use the above configuration directly, you do not need to modify
2. Start TypeSdkServer
cd/data/typesdk_server/SdkServer_free_git/bin/
pm2 start www
6. Check whether the installation is complete
Open a browser to access the following interfaces
The above two interfaces will appear json
http://192.168.206.19/config/1001/3/config.txt
The above can read the configuration file
The above can get the client IP address
If they all appear normally, it means that the server has been deployed