Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1867241
  • 博文数量: 473
  • 博客积分: 13997
  • 博客等级: 上将
  • 技术积分: 5953
  • 用 户 组: 普通用户
  • 注册时间: 2010-01-22 11:52
文章分类

全部博文(473)

文章存档

2014年(8)

2013年(38)

2012年(95)

2011年(181)

2010年(151)

分类: LINUX

2011-03-17 13:43:18

Contents

[]

Server Setup

This guide will help you quickly setup a Mangos Server with SD2/Acid support on the UDB database. Follow this guide in the same order listed in the contents, if all goes well you will have a server in 2 hours.


Before we start

This is written with the following assumptions:

  1. You are building a revision within 50 of 8797.
  2. Your using 32-bit Ubuntu Server 8.04 / 8.10 or Debian 5.0
  3. You have the required map, vmap, and dbc files.
  4. You have at least some knowledge of the Linux command line.
  5. You have direct or ssh access to the machine.
  6. You have some good music to listen to, gotta have good music.
  7. You have 2 hours to waste.


Install the software

This will install the packages required by MaNGOS.

Your going to get a MySQL root password prompt if you havn't setup MySQL before, pick a secure password, make sure you remember this.

~# cd ~
~# apt-get update
~# apt-get install build-essential gcc g++ cpp automake git-core autoconf make patch libmysql++-dev libtool libcurl4-openssl-dev libssl-dev grep binutils subversion zlibc libc6 nano mysql-server unrar-free unzip

Get the source

We get the current mangos version and SD2 version.

~# git clone git://github.com/mangos/mangos.git
~# cd mangos
~# svn co https://scriptdev2.svn.sourceforge.net/svnroot/scriptdev2/ src/bindings/ScriptDev2/


Patch MaNGOS w/ SD2

Where going to apply the SD2 patch

~# git am src/bindings/ScriptDev2/patches/MaNGOS-*


Compile MaNGOS

Now where going to compile, this takes anywhere from 30 minutes up to a few hours.

This is going to get everything ready, we will compile in the "objdir" so if we are to ever recompile for some reason, we can just remove this folder and have a clean slate.

~# autoreconf --install --force
~# mkdir objdir
~# cd objdir

This will configure MaNGOS.

~# ../configure --prefix=/opt/mangos --sysconfdir=/opt/mangos/etc --datadir=/opt/mangos

The last step is to start the compiler, this part takes the longest.

~# make -j [#ofCores]
~# make install

If you have a quad core CPU then "-j 4" is what you would use, dual core "-j 2". With experience compiling source, for each core, add about 375MB of ram usage, at 4 cores, compiling uses up to 1.5GB of RAM, if your server runs out of ram during the compile process make WILL fail, be aware of this.

Below is what a memory error would look like, if you get this, try lowering your # of cores used during the compile process.

virtual memory exhausted: Cannot allocate memory
virtual memory exhausted: Cannot allocate memory
make[3]: *** [DestinationHolder.o] Error 1
make[3]: *** Waiting for unfinished jobs....
virtual memory exhausted: Cannot allocate memory
virtual memory exhausted: Cannot allocate memory
virtual memory exhausted: Cannot allocate memory
virtual memory exhausted: Cannot allocate memory
virtual memory exhausted: Cannot allocate memory
make[3]: *** [FleeingMovementGenerator.o] Error 1
virtual memory exhausted: Cannot allocate memory
make[3]: *** [ChannelHandler.o] Error 1
make[3]: *** [Creature.o] Error 1

Setup MaNGOS

We need to enter the MaNGOS install directory.

~# cd /opt/mangos/

First we copy the config files the compiler made, we don't rename them because you might mess one up, this way, you have a backup.

~# cp etc/mangosd.conf.dist etc/mangosd.conf
~# cp etc/realmd.conf.dist etc/realmd.conf

Now we edit them. Update the database setting to include your root password. You can use the editor of choice, I choose to use nano.

~# nano etc/mangosd.conf
~# nano etc/realmd.conf

I'm going to assume you know how to change the files respectively, if you do not, you probably shouldn't be trying to setup a server.


Download the Database

This will download the world database. We are using UDB and Acid in this tutorial.

cd ~ && mkdir udb && cd udb
svn co  unifieddb

cd ~ && mkdir acid && cd acid
svn co  sd2-acid 

Setup the Database

You will need your mysql root user's password. (You should have set the password when you installed mysql.)

Note that if you mess up creating the databases, you can delete them and start over

mysql -u root -p 
SHOW DATABASES;
DROP DATABASE mangos;
DROP DATABASE characters;
DROP DATABASE realmd;
DROP DATABASE scriptdev2;
SHOW DATABASES;
exit;

Create the mangos mysql user and databases

This will create a user "mangos" with password "mangos" and a bunch of database tables (mangos, characters, realmd, and scriptdev2). Enter the root password when prompted.

mysql -u root -p < /opt/mangos/mangos/sql/create_mysql.sql
mysql -u root -p < ~/mangos/src/bindings/ScriptDev2/sql/scriptdev2_create_database.sql

Note that if you want to run these commands without entering your password (e.g. in a script), you can put the password directly after the "-p" option (with no space after "-p").

mysql -u root -ppassword < /opt/mangos/mangos/sql/create_mysql.sql
mysql -u root -ppassword < ~/mangos/src/bindings/ScriptDev2/sql/scriptdev2_create_database.sql

Populate the databases

Now use the mangos user to populate the databases.

mysql -u mangos -pmangos mangos < /opt/mangos/mangos/sql/mangos.sql
mysql -u mangos -pmangos characters < /opt/mangos/mangos/sql/characters.sql
mysql -u mangos -pmangos realmd < /opt/mangos/mangos/sql/realmd.sql
mysql -u mangos -pmangos scriptdev2 < ~/mangos/src/bindings/ScriptDev2/sql/scriptdev2_create_structure_mysql.sql
mysql -u mangos -pmangos scriptdev2 < ~/mangos/src/bindings/ScriptDev2/sql/scriptdev2_script_full.sql

World Database

This will actually make the world have NPC's and proper gear.

cd ~/udb/unifieddb/trunk/Full_DB 
unzip *.zip
mysql -u mangos -pmangos mangos < ./*.sql
mysql -u mangos -pmangos mangos < ~/acid/sd2-acid/trunk/wotlk/3.0.7/3.0.7_acid.sql
mysql -u mangos -pmangos mangos < ~/mangos/src/bindings/ScriptDev2/sql/mangos_scriptname_full.sql
Database Updates

Now apply MySQL updates in the /opt/mangos/mangos/sql/updates/ folder, starting from the oldest to latest UDB version.
In my case there've been 200 patches and i don't want to import each manually with phpmyadmin, so i wrote a small python script which does the work for me. Put the script in /opt/mangos/mangos/sql/updates/updatescript.py and make it executable

chmod +x /opt/mangos/mangos/sql/updates/updatescript.py

Now here it is

#!/usr/bin/env python
import glob, os
patches = glob.glob('*.sql')
patches = sorted(patches)

for x in patches:
  db = x.split("_")[2].replace('.sql', '')
  os.system("mysql -u mangos -pmangos -v " + db + " < " + x)

Now just run the script

cd /opt/mangos/mangos/sql/updates
./updatescript.py

Realm Database

We're going to update the realm name and IP so it can be accessed from other computers.

mysql -u mangos -pmangos
use realmd;
UPDATE realmlist SET name = 'Your Realm Name' WHERE id = 1;
UPDATE realmlist SET address = 'Your IP' WHERE id = 1;
exit

Datafiles

Be sure you have enabled sshd on your Ubuntu box in case you are using the Desktop version.

~# apt-get install openssh-server
~# /etc/init.d/ssh start

Copy the data extraction tools from the ~/mangos/contrib folder in the MaNGOS source to your Windows game machine. You can copy to/from your Windows machine with the open source program, as it supports SFTP.

Place the files listed below in your retail game client's installation folder. Find them in the contrib/vmap_extract_assembler_bin/ and contrib/extractor/ directories.

contrib/extractor/
    ad.exe
contrib/vmap_extract_assembler_bin/
    makevmaps_SIMPLE.bat
    make vmaps.bat  
    splitConfig.txt  
    vmap_assembler.exe  
    vmapextract_v2.exe

This run could take a long time, and will require ~ 2GB of free space. When its done you will have 4 new folders. You need to upload the "maps", "dbc", and "vmaps" directories to the Ubuntu server. Place these in the /opt/mangos/bin folder (or whatever path you chose for the installation of the MaNGOS server binaries).

Clean Up

Now we can clean up the mess we made.

~# rm /root/*.rar -f
~# rm /root/*.sql -f
~# rm /root/*.deb -f

(Optional) For extra security, you can also change the password for the mangos mysql user. (You will also have to change the password in the MaNGOS config files).

mysql -u root -p
SET PASSWORD FOR 'mangos'@'localhost' = PASSWORD('newpassword');
exit;

Starting the Server

You're going to need two shell windows open for this next part.

In your first screen, change to your MaNGOS bin.

~# cd /opt/mangos/bin && ./mangos-realmd

Now switch to your second screen, and change to the same directory.

~# cd /opt/mangos/bin && ./mangos-worldd

If all is well you should now have a server running.

阅读(1045) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~