11

诛仙私服1378端物理机搭建全流程

 3 years ago
source link: https://sobird.me/zhuxian-private-service-1378.htm
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

本文只做教程笔记,不提供服务端下载,其实网上都可以找到,自行下载即可。另,本文所有内容均来自网络,仅做学习整理。

目前网上搜到的诛仙服务端程序,仅只是BIN文件,并没有源码,所以实际上很难进行二次开发,如此对安装的平台环境其实有要求,在Ubuntu 18.04 x86_64平台下实测发现改程序依赖的库文件为32位,故如果你在64位操作系统下进行部署服务,则需要安装32位兼容包。同时在Ubuntu 16.04.6 server i386(即32位操作系统)实测发现,进入游戏后创建角色后,进入游戏会弹Debug窗口,无法进入游戏。 最后,在CentOS 6.5 Final x86_64平台架构下实测部署成功,本文记录下折腾的过程。

CentOS 6.5 Final x86_64

为什么不选择32位的?因为考虑到32位的操作系统支持的最大内存只用4GB,而我的物理主机内存有8GB,并且游戏服务端的内存当然是越大越好。

下载操作系统镜像文件

下载CentOS-6.5-x86_64-minimal.iso,这是CentOS的精简版本,因为部署服务,所以并不需要桌面GUI软件,精简版本是最好的选择。

将操作系统镜像文件写入U盘

写入U盘的目的是将系统通过U盘作为启动盘安装到物理机上。本文以macOS下制作系统启动盘为例:

将U盘插入电脑USB接口,打开macOS终端(#行表示注释):

$ diskutil list
/dev/disk0 (internal, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *251.0 GB   disk0
   1:                        EFI EFI                     209.7 MB   disk0s1
   2:                 Apple_APFS Container disk1         250.8 GB   disk0s2

/dev/disk1 (synthesized):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      APFS Container Scheme -                      +250.8 GB   disk1
                                 Physical Store disk0s2
   1:                APFS Volume Macintosh HD            222.9 GB   disk1s1
   2:                APFS Volume Preboot                 42.6 MB    disk1s2
   3:                APFS Volume Recovery                510.5 MB   disk1s3
   4:                APFS Volume VM                      3.2 GB     disk1s4

/dev/disk2 (external, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:     FDisk_partition_scheme                        *1.0 GB     disk2
   1:               Windows_NTFS KINGSTON                1.0 GB     disk2s4

# 解挂U盘,Finder中看不到这个U盘,但diskutil list命令还可以看到
$ diskutil unmountDisk /dev/disk2

# 写系统镜像到U盘
$ sudo dd if=/Users/sobird/Downloads/CentOS-6.5-x86_64-minimal.iso of=/dev/disk2 bs=1m

# 大约过5,6分钟输出如下日志,表示U盘镜像制作完成
398+0 records in
398+0 records out
417333248 bytes transferred in 319.759561 secs (1305147 bytes/sec)

通过U盘安装CentOS

将制作好的U盘插入待安装的物理机,开机长按F12键进入启动驱动器的选择界面,选择U盘,进入CentOS安装的引导程序,一路next即可,不赘述。

如果你的主机带WIFI,默认装的系统是无法上网的,需要先准备一根网线,将主机连接到路由器上。修改网卡配置:

vi /etc/sysconfig/network-scripts/ifcfg-eth0

# 里面的参数
NM_CONTROLLED=yes 表明Network manager服务缺省情况是启动的 这里要关掉
# 开机时自动启动网络连接
ONBOOT=yes

# 重启网络
service network restart

# 查看本机IP
ifconfig

设置静态IP

为了防止主机IP因重启等原因导致ip变化,需要配置静态IP,或者在路由器管理界面通过绑定mac的方式固定主机IP。

# 注意:此操作会将操作系统升级到 CentOS release 6.10 (Final) 版本
yum update

Java环境变量设置

CentOS 6.5 x86_64系统已准备完毕,假设开机后的IP为192.168.1.100,该IP下面将会用到。

下载jdk-8u231-linux-x64.tar.gz,解压缩:

$ mkdir /usr/java
$ tar -zxvf jdk-8u231-linux-x64.tar.gz
$ mv jdk1.8.0_231 /usr/java

注:经实测,jdk的版本或位数不会影响诛仙服务的启动,所以选择合适的版本即可,否则你仍可以选择使用jdk1.6.0_12这个版本。

配置JAVA_HOME等环境变量

# 在该文件尾部添加如下代码
$ vi /etc/profile

export JAVA_HOME=/usr/java/jdk1.8.0_231
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

此处的环境变量配置可有可无,可在启动./authd服务时,在脚本里设置即可,主要是CLASSPATH变量的设置。

防火墙配置

查看防火墙状态

service iptables status

# 防火墙处于开启状态且只开放了22端口,所以如果不配置防火墙所有22端口外的服务均无法访问
Table: filter
Chain INPUT (policy ACCEPT)
num  target     prot opt source               destination
1    ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0           state RELATED,ESTABLISHED
2    ACCEPT     icmp --  0.0.0.0/0            0.0.0.0/0
3    ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0
4    ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           state NEW tcp dpt:22
5    REJECT     all  --  0.0.0.0/0            0.0.0.0/0           reject-with icmp-host-prohibited

Chain FORWARD (policy ACCEPT)
num  target     prot opt source               destination
1    REJECT     all  --  0.0.0.0/0            0.0.0.0/0           reject-with icmp-host-prohibited

Chain OUTPUT (policy ACCEPT)
num  target     prot opt source               destination

开启80和443端口

vi /etc/sysconfig/iptables
# 加入如下代码
# -A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT

# Allow HTTP and HTTPS connections from anywhere (the normal ports for websites and SSL).
-A INPUT -p tcp --dport 80 -j ACCEPT
-A INPUT -p tcp --dport 443 -j ACCEPT

# 诛仙游戏端口
-A INPUT -p tcp --dport 29000 -j ACCEPT

保存后重启防火墙
service iptables restart

httpd服务安装

httpd服务承载,游戏账号的注册,账号查询等功能,虽然不是启动游戏必备选项,但可以方便对外提供游戏账号的注册,网页部署等。

yum install httpd

# 启动httpd服务
service httpd start

# 设置开机启动
chkconfig httpd on

php环境安装

为了可以运行phpMyAdmin,以及其他PHP程序

yum install php

MySql数据库服务

游戏账号的登录和注册功能需要用MySql进行数据的存取,主要有:元宝充值、账户权限,账户封禁等功能。

yum install mysql mysql-server

# 启动mysql服务
service mysqld start

# 成功启动后输出下面信息
Initializing MySQL database:  Installing MySQL system tables...
OK
Filling help tables...
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:

/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h CentOS password 'new-password'

Alternatively you can run:
/usr/bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon with:
cd /usr ; /usr/bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl
cd /usr/mysql-test ; perl mysql-test-run.pl

Please report any problems with the /usr/bin/mysqlbug script!

# 执行mysql_secure_installation 设置数据库密码等信息
mysql_secure_installation

#设置开机启动mysql

chkconfig mysqld on

安装phpMyAdmin phpMyAdmin是一个Web界面的的数据库管理工具,使用它可以很方便的查询和处理数据库数据。

yum install epel-release
yum install phpmyadmin

# 更改所属用户和组
chown -R apache:apache /usr/share/phpMyAdmin

vi /etc/httpd/conf.d/phpMyAdmin.conf

# 添加一行 Allow from All 处于安全考虑,如果使用独立IP将服务部署在公网环境,建议不要加此行
<IfModule !mod_authz_core.c>
   # Apache 2.2
   Order Deny,Allow
   Deny from All
   Allow from 127.0.0.1
   Allow from ::1
   Allow from All
</IfModule>

# 如果不注释掉,phpMyAdmin访问不了

重启httpd服务
service httpd restart

将游戏账号相关的SQL文件导入数据库 通过phpMyAdmin的Web界面,创建一个名为zhuxian的数据库,编码不填,然后将数据库文件导入。

安装32位兼容程序包

yum install xulrunner.i686

安装游戏运行所需的lib文件

  • libstdc++.so.5
  • libskill.so
  • libtask.so

将以上三个文件拷贝到/lib或者/usr/lib目录下均可,这里就放在/usr/lib吧。

安装 libpcre.so.0 库文件

yum install libpcre.so.0

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK