TypeSdkServer手动安装部署

以下范例服务器操作系统使用:Centos7.2_X8.6_64_Lite

       软件使用:Mysql5.6

                     Nginx1.8.1

                     Nodejs6.9.5

                     Redis3.2.3

代码和相关环境可以在这里下载

https://code.csdn.net/typesdk_code/typesdk_server/tree/master

一、安装完Centos7.x之后,安装Git,直接从源码库克隆相关程序

1、 安装git

yum install -y git

2、 从git上克隆代码

git clone https://code.csdn.net/typesdk_code/typesdk_server.git

二、安装Mysql并导入数据库(root用户仅本地登入,未开放远程,密码为typesdk.com)

1、 安装mysql5.6,这里使用官方源安装

cd typesdk_server/Tools/

rpm -ivh mysql57-community-release-el7-9.noarch.rpm

cp mysql-community.repo /etc/yum.repos.d/mysql-community.repo

yum install -y mysql-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

以下是配置文件全文,直接复制拷贝进去

[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、 启动数据库

service mysql start

3、 导入数据库

mysql < ../SdkServer_free_git/typesdk_server.sql

mysqladmin -u root password "typesdk.com"

三、安装redis并导入数据(redis仅本地登入,未开放远程,密码为typesdk.com)

1、 使用RPM安装redis

rpm -ivh jemalloc-3.6.0-1.el7.x86_64.rpm

rpm -ivh redis-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

以下是配置文件全文,直接复制拷贝进去

bind 127.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 256mb 64mb 60

client-output-buffer-limit pubsub 32mb 8mb 60

hz 10

aof-rewrite-incremental-fsync yes

2、 启动redis      

service redis start

3、 导入redis数据库

sh ../SdkServer_free_git/init_redis.sh

特别注意init_redis.sh里的redis配置信息必须配置正确,apikey为sdk服务器与游戏服务器通讯的密钥,请根据实际情况修改成一致,其他渠道相关参数请看脚本注释

TypeSdk打包工具中有图形化配置工具,也可以用那个工具生成后同步

四、安装配置nginx

1、 rpm安装nginx

rpm -ivh nginx-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 -rf Nginx_SwitchConfig/1001/ /data/typesdk_server/nginx_html/config/

>/etc/nginx/nginx.conf

vi /etc/nginx/nginx.conf

以下是配置文件全文,直接复制拷贝进去

#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、 启动nginx

service nginx start

五、安装node环境并配置TypeSdkServer

1、 rpm安装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

特别注意/data/typesdk_server/SdkServer_free_git/config.json文件

请按照安装的mysql和redis的配置来修改,如直接使用以上配置则不需要修改

2、 启动TypeSdkServer

cd /data/typesdk_server/SdkServer_free_git/bin/

pm2 start www

六、检查是否安装完成

  打开浏览器访问以下几个接口

       http://IP/1001/3/Login

       http://IP/1001/3/Pay

       以上两个接口会出现json

       http://IP/config/1001/3/config.txt

  以上可以读取配置文件

      http://IP/getIp

  以上可以获得客户端IP地址

  都正常出现就说明server已经部署完成

posted on 2017-03-13 16:45  老海贼  阅读(793)  评论(0编辑  收藏  举报

导航