You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
210 lines
7.5 KiB
210 lines
7.5 KiB
服务器的系统用的是ubuntu server 18.04
|
|
|
|
注意:腾讯云服务器使用缺省用户帐号ubuntu,登录后可以通过sudo su 命令切换到root用户
|
|
|
|
云盘需要挂载,首先用fdisk -l 查看一下系统连接了哪些磁盘,这里附加的数据盘是/dev/vdb
|
|
对 “/dev/vdb” 裸设备直接创建文件系统格式
|
|
mkfs -t ext4 /dev/vdb
|
|
新建挂载点 /data
|
|
mkdir /data
|
|
mount /dev/vdb /data
|
|
|
|
重启后的自动挂载需要修改文件 /etc/fstab
|
|
vi /etc/fstab
|
|
添加
|
|
/dev/vdb /data ext4 defaults 0 0
|
|
执行以下命令,检查 /etc/fstab 文件是否写入成功。
|
|
mount -a
|
|
|
|
安装完系统后
|
|
1.把dash环境改成bash
|
|
dpkg-reconfigure dash
|
|
|
|
没有安装vim的话安装一下
|
|
2.安装下vim
|
|
apt-get install vim
|
|
|
|
3.创建用户mmog用来运行游戏
|
|
参考命令如下
|
|
groupadd mmog
|
|
useradd -g mmog mmog
|
|
passwd mmog 修改密码
|
|
|
|
|
|
4.创建/data/mmogrun目录,用来放游戏运行文件
|
|
mkdir /data
|
|
mkdir /data/mmogrun
|
|
chown mmog:mmog /data/mmogrun
|
|
mkdir /data/wwwroot
|
|
chown mmog:mmog /data/wwwroot
|
|
mkdir /home/mmog
|
|
chown mmog:mmog /home/mmog
|
|
cp /root/.bashrc /root/.profile /home/mmog/
|
|
chown mmog:mmog /home/mmog/.bashrc
|
|
chown mmog:mmog /home/mmog/.profile
|
|
ln -s /data/mmogrun /home/mmog/mmogrun
|
|
|
|
配置zsh
|
|
sudo apt-get install zsh
|
|
sudo apt-get install autojump
|
|
mmog下
|
|
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
|
|
git clone git://github.com/zsh-users/zsh-autosuggestions $ZSH_CUSTOM/plugins/zsh-autosuggestions
|
|
git clone git://github.com/zsh-users/zsh-syntax-highlighting $ZSH_CUSTOM/plugins/zsh-syntax-highlighting
|
|
chsh -s /bin/zsh
|
|
配置文件是 ~/.zshrc
|
|
|
|
5.修改文件打开数量限制,core文件大小限制,共享内存大小限制
|
|
#修改 /etc/security/limits.conf 添加或修改(直接echo似乎有问题,执行后请检查和确认是否成功)
|
|
sh -c 'echo "@mmog soft nofile 50000" >> /etc/security/limits.conf'
|
|
sh -c 'echo "@mmog hard nofile 65536" >> /etc/security/limits.conf'
|
|
sh -c 'echo "@mmog soft core 1024000" >> /etc/security/limits.conf'
|
|
|
|
6.修改core文件路径
|
|
mkdir /data/corefile
|
|
chmod 777 /data/corefile
|
|
echo "/data/corefile/core-%e-%p-%t" > /proc/sys/kernel/core_pattern
|
|
|
|
7.修改 /etc/ssh/sshd_config #PermitRootLogin yes为no 禁止root直接ssh登录服务器
|
|
添加配置项
|
|
AllowUsers ubuntu mmog mmogguest
|
|
#修改ssh默认登录端口为56000
|
|
修改完成后重启ssh服务
|
|
service ssh restart
|
|
|
|
#修改hostname,要改2个地方,改完重启生效,注意hostname不能含有下划线_,可以用连接符-
|
|
|
|
/etc/hostname youname
|
|
/etc/hosts 127.0.1.1 youname
|
|
修改后临时使hostname生效,执行命令 hostname youname
|
|
|
|
8.安装以下.Net Core运行需要的依赖
|
|
wget https://packages.microsoft.com/config/ubuntu/18.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
|
|
sudo dpkg -i packages-microsoft-prod.deb
|
|
rm packages-microsoft-prod.deb
|
|
|
|
sudo apt-get update; \
|
|
sudo apt-get install -y apt-transport-https && \
|
|
sudo apt-get update && \
|
|
sudo apt-get install -y dotnet-sdk-5.0
|
|
|
|
9.game和log服务器改一下dns
|
|
/etc/resolv.conf
|
|
vi /etc/resolvconf/resolv.conf.d/base
|
|
#添加2行
|
|
nameserver 8.8.8.8
|
|
nameserver 8.8.4.4
|
|
|
|
10.修改时区,注:土耳其在欧洲 Europe/Istanbul,不要设置土耳其时间(有夏令时问题,直接设置时区+3)
|
|
dpkg-reconfigure tzdata
|
|
选择 None of the above
|
|
选择 GMT-3 按回车
|
|
|
|
通用的服务器环境这里算初始化好了===========================================================================
|
|
|
|
接下来处理2台数据库服务器
|
|
注意,要保证2台数据库服务器不在同一台物理机上,需要设置 置放群组
|
|
数据库服务器安装mysql
|
|
apt-get install mysql-server mysql-client
|
|
mysql_secure_installation
|
|
1.(是否设置随机密码,Y/y随机密码, N/n自己输入密码)
|
|
VALIDATE PASSWORD PLUGIN can be used to test passwords...
|
|
Press y|Y for Yes, any other key for No: N (我的选项)
|
|
后面全是Y
|
|
service mysql stop
|
|
mv /var/lib/mysql /data/
|
|
ln -s /data/mysql /var/lib/mysql
|
|
chown -R mysql:mysql /data/mysql
|
|
vim /etc/mysql/mysql.conf.d/mysqld.cnf
|
|
修改 datadir=/data/mysql
|
|
修改apparmor的配置文件use.sbin.mysqld
|
|
vim /etc/apparmor.d/usr.sbin.mysqld
|
|
将
|
|
/var/lib/mysql/ r,
|
|
/var/lib/mysql/** rwk,
|
|
修改为
|
|
/data/mysql/ r,
|
|
/data/mysql/** rwk,
|
|
service apparmor reload
|
|
service apparmor restart
|
|
重启mysql
|
|
service mysql restart
|
|
|
|
修改配置
|
|
[client]
|
|
default-character-set=utf8
|
|
[mysqld]
|
|
default_authentication_plugin=mysql_native_password
|
|
innodb_buffer_pool_size = 4G(物理内存的70%)
|
|
innodb_log_file_size = 512M
|
|
innodb_log_buffer_size = 16M
|
|
innodb_buffer_pool_instances=8
|
|
innodb_thread_concurrency=100
|
|
innodb_flush_log_at_trx_commit = 0 (log buffer在每次事务提交的时候都会写入log file,但是,flush(刷到磁盘)操作并不会同时进行。这种模式下,MySQL会每秒一次地去做flush(刷到磁盘)操作)
|
|
sync_binlog = 0
|
|
max_connections = 500
|
|
character-set-server=utf8
|
|
启用binlog
|
|
启用binlog,通过配置 /etc/my.cnf 或 /etc/mysql/mysql.conf.d/mysqld.cnf 配置文件的 log-bin 选项:
|
|
[mysqld]
|
|
server-id = 1
|
|
log-bin = /data/mysql/mysql-bin.log
|
|
expire-logs-days = 7
|
|
max-binlog-size = 1000M
|
|
#安装好后如果用mmog用户无法登录mysql,则可以先su到root用户再登录,应该是可以的,再修改root登录密码
|
|
use mysql;
|
|
update user set authentication_string=PASSWORD("这里输入你要改的密码") where User='root'; #更改密码
|
|
update user set plugin="mysql_native_password"; #如果没这一行可能也会报一个错误,因此需要运行这一行
|
|
> flush privileges; #更新所有操作权限
|
|
|
|
#mysql主从配置,主建立用户slave 10.135.71.25是从,10.135.71.46是主
|
|
#修改mysql配置后重启
|
|
service mysql start
|
|
#主
|
|
GRANT REPLICATION SLAVE, REPLICATION CLIENT ON *.* TO 'slave'@'10.135.71.25' IDENTIFIED BY 'slave';
|
|
#主
|
|
server-id=1
|
|
log_bin=xxxx
|
|
#从
|
|
server-id=2
|
|
log_bin =xxxx
|
|
#master-host=10.135.71.46
|
|
#master-user=slave
|
|
#master-password=slave
|
|
#master-password=slave
|
|
#replicate-do-db=mstest
|
|
|
|
#在slave上执行mysql
|
|
stop slave;
|
|
change master to master_host='10.135.71.46',master_user='slave',master_password='slave';
|
|
start slave;
|
|
#验证下是否成功
|
|
show slave status\G;
|
|
#显示 Slave_IO_Running: Yes
|
|
# Slave_SQL_Running: Yes
|
|
#表示成功
|
|
|
|
#使用数据库脚本 x_proj_svr\tools\sql目录下 dbgame.sql,dbaccount.sql,toss.sql
|
|
#建立数据库后,赋予mysql的mmog用户访问权限
|
|
grant all privileges on dbmaccount.* to mmog@'localhost' identified by 'mmog';
|
|
grant all privileges on dbmaccount.* to mmog@'127.0.0.1' identified by 'mmog';
|
|
grant all privileges on dbmgame.* to mmog@'localhost' identified by 'mmog';
|
|
grant all privileges on dbmgame.* to mmog@'127.0.0.1' identified by 'mmog';
|
|
grant all privileges on toss.* to mmog@'localhost' identified by 'mmog';
|
|
grant all privileges on toss.* to mmog@'127.0.0.1' identified by 'mmog';
|
|
flush privileges;
|
|
|
|
8.0 mysql后需要创建用户和赋权限分开
|
|
create user 'mmog'@'localhost' identified by 'mmog';
|
|
create user 'mmog'@'127.0.0.1' identified by 'mmog';
|
|
grant all privileges on dbmaccount.* to mmog@'localhost';
|
|
grant all privileges on dbmaccount.* to mmog@'127.0.0.1';
|
|
grant all privileges on dbmgame.* to mmog@'localhost';
|
|
grant all privileges on dbmgame.* to mmog@'127.0.0.1';
|
|
|
|
|
|
log服务器特殊要求
|
|
在log服务器安装nginx服务,经营分析系统以及自动更新下载文件使用
|
|
log服务器建立/data/wwwroot目录,赋予mmog用户权限
|
|
|
|
服务器初始化完成后请把game和log这2台的ip匹配到自己的一个dns,比如xv.itgnetwork.com xg1.itgnetwork.com
|