教程开始:
1,修改服务端文件/data/server_5601/Config/ServerConfigList.txt 复制一区的字段,开几个区复制几个
如图所示:
里面需要改的是:
- 5601是一区,二区就是5602以此类推
- 56001是一区,二区就是56002以此类推
- actor_5601是一区,二区就是actor_5602以此类推
- log_5601是一区,二区就是log_5601以此类推
2,导入数据库:这里是四个区的配置,复制到ssh里面运行
- HOSTNAME=“localhost”
- PORT=“3306”
- USERNAME=“root”
- PASSWORD=“123456”
- DB1=“actor_5602”
- DB2=“actor_5603”
- DB3=“actor_5604”
- DB4=“log_5602”
- DB5=“log_5603”
- DB6=“log_5604”
- sql1=“create database ${DB1} DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;”
- sql2=“create database ${DB2} DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;”
- sql3=“create database ${DB3} DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;”
- sql4=“create database ${DB4} DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;”
- sql5=“create database ${DB5} DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;”
- sql6=“create database ${DB6} DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;”
- mysql -h${HOSTNAME} -P${PORT} -u${USERNAME} -p${PASSWORD} -e “${sql1}“
- mysql -h${HOSTNAME} -P${PORT} -u${USERNAME} -p${PASSWORD} -e “${sql2}“
- mysql -h${HOSTNAME} -P${PORT} -u${USERNAME} -p${PASSWORD} -e “${sql3}“
- mysql -h${HOSTNAME} -P${PORT} -u${USERNAME} -p${PASSWORD} -e “${sql4}“
- mysql -h${HOSTNAME} -P${PORT} -u${USERNAME} -p${PASSWORD} -e “${sql5}“
- mysql -h${HOSTNAME} -P${PORT} -u${USERNAME} -p${PASSWORD} -e “${sql6}“
- mysql -u${USERNAME} -p${PASSWORD} ${DB1} < /data/sql/actor_5601.sql
- mysql -u${USERNAME} -p${PASSWORD} ${DB2} < /data/sql/actor_5601.sql
- mysql -u${USERNAME} -p${PASSWORD} ${DB3} < /data/sql/actor_5601.sql
- mysql -u${USERNAME} -p${PASSWORD} ${DB4} < /data/sql/log_5601.sql
- mysql -u${USERNAME} -p${PASSWORD} ${DB5} < /data/sql/log_5601.sql
- mysql -u${USERNAME} -p${PASSWORD} ${DB6} < /data/sql/log_5601.sql
3,修改服务器列表\data\www\serverlist.txt
- 1 外网 一区 139.155.232.43 5601
- 2 外网 二区 139.155.232.43 5602
- 3 外网 三区 139.155.232.43 5603
- 4 外网 四区 139.155.232.43 5604
4,启动四个区
- cd /data/server_5601 && nohup ./5601 -worldid 5601 -assert 1 & //这是一区
- cd /data/server_5601 && nohup ./5601 -worldid 5602 -assert 1 & //这是二区
- cd /data/server_5601 && nohup ./5601 -worldid 5603 -assert 1 & //这是三区
- cd /data/server_5601 && nohup ./5601 -worldid 5604 -assert 1 & //这是四区
5,后台配置多区
先修改\data\www\gm\config\config.php添加2 3 4区数据库配置,
如下所示:
- $qus=array(
- ‘1’=> array(
- ‘name’=> ‘一区’,
- ‘DB_NAME’=> ‘actor_5601’,
- ‘SERVER_ID’=> ‘5601’
- )
- ,
- ‘2’=> array(
- ‘name’=> ‘二区’,
- ‘DB_NAME’=> ‘actor_5602’,
- ‘SERVER_ID’=> ‘5602’
- ),
- ‘3’=> array(
- ‘name’=> ‘三区’,
- ‘DB_NAME’=> ‘actor_5603’,
- ‘SERVER_ID’=> ‘5603’
- ),
- ‘4’=> array(
- ‘name’=> ‘四区’,
- ‘DB_NAME’=> ‘actor_5604’,
- ‘SERVER_ID’=> ‘5604’
- ),
- );
PS:转自35博客
有没有办法打开,跨服务器?