CentOS 7+ 部署指南
1. 系统基础配置
1.1 设置中文环境
# 查看可用语言包
locale -a
# 安装中文字体包(如未安装)
yum groupinstall "fonts" -y
# 设置系统语言为中文
localectl set-locale LANG=zh_CN.gb2312
# 验证语言设置
cat /etc/locale.conf
# 重启系统使设置生效
reboot
1.2 安装基础工具
yum update -y
yum install -y patch wget make gcc gcc-c++ gcc-gfortran \
kernel-devel ncurses ncurses-devel gd gd-devel \
libicu lua vim net-tools
2. MySQL 6.0 编译安装
2.1 准备安装环境
# 创建安装目录
mkdir -p /usr/local/mysql
2.2 上传并解压源码包
# 上传mysql-6.0.11-alpha.tar.gz到服务器
tar -zxvf mysql-6.0.11-alpha.tar.gz
cd mysql-6.0.11-alpha
2.3 编译配置
./configure --prefix=/usr/local/mysql \
--enable-thread-safe-client \
--with-charset=latin1 \
--with-collation=latin1_general_ci \
--with-extra-charsets=all \
--enable-shared \
--with-fast-mutexes \
--with-plugins=max-no-ndb \
--with-ssl \
--with-libwrap \
--with-mysqld-libs="-lrt -lpthread" \
--with-zlib=system \
--with-big-tables
2.4 编译安装
make -j$(nproc)
make install
3. MySQL 配置与优化
3.1 创建系统用户和组
groupadd mysql
useradd -r -g mysql -s /bin/false mysql
3.2 目录结构与权限
mkdir -p /usr/local/mysql/{data,run,log,var}
chown -R mysql:mysql /usr/local/mysql
3.3 配置文件设置
cp support-files/my-huge.cnf /etc/my.cnf
# 编辑配置文件
vim /etc/my.cnf
# 添加/修改以下内容:
[mysqld]
datadir=/usr/local/mysql/data
socket=/usr/local/mysql/mysql.sock
skip-name-resolve
character-set-server=utf8
collation-server=utf8_general_ci
max_connections=500
3.4 环境变量配置
echo 'export PATH=/usr/local/mysql/bin:$PATH' >> /etc/profile
source /etc/profile
echo '/usr/local/mysql/lib/mysql' >> /etc/ld.so.conf
ldconfig
4. MySQL 服务管理
4.1 初始化数据库
su - mysql -c "mysql_install_db --user=mysql"
4.2 启动服务
su - mysql -c "mysqld_safe --skip-name-resolve --open-files-limit=4096 &"
4.3 设置开机启动
cp support-files/mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
chkconfig --add mysqld
chkconfig mysqld on
service mysqld start
5. 数据库安全配置
5.1 设置root密码
mysqladmin -u root password 'your_secure_password'
5.2 创建应用数据库
CREATE DATABASE FLServerDB;
CREATE DATABASE ZtGameDB;
CREATE DATABASE LoginServer;
CREATE DATABASE roleChangeServer;
CREATE DATABASE roleregServer;
CREATE DATABASE unify00;
CREATE DATABASE zt;
5.3 创建应用用户
grant ALL PRIVILEGES on *.* to ztgame@"localhost" Identified by "secure_password" WITH GRANT OPTION;
grant ALL PRIVILEGES on *.* to ztgame@"127.0.0.1" Identified by "secure_password" WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON *.* TO 'ztgame'@'%' IDENTIFIED BY 'secure_password' WITH GRANT OPTION;
FLUSH PRIVILEGES;
6. 游戏服务端部署
6.1 上传服务端文件
mkdir -p /home/gameserver
# 上传游戏服务端压缩包到/home/gameserver
tar -zxvf gameserver.tar.gz -C /home/gameserver
6.2 设置权限
chown -R 777 /home/gameserver
find /home/gameserver -type d -exec chmod 755 {} \;
find /home/gameserver -type f -exec chmod 644 {} \;
6.3 链接库文件
ln -s /usr/local/mysql/lib/mysql/libmysqlclient.so.18 /usr/lib64/
ldconfig
7. 防火墙配置
firewall-cmd --permanent --add-port=3306/tcp
firewall-cmd --permanent --add-port=7000-9000/tcp
firewall-cmd --reload