Centos deployment KBengine
Install Mysql5.7
It is recommended to only use version 5.7, other versions are not recommended.
add warehouse
sudo rpm -ivh https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm
confirm
sudo yum repolist all | grep mysql | grep enabled
Install
sudo yum -y install mysql-community-server
if this
The GPG keys listed for the "MySQL 5.7 Community Server" repository are already installed but they are not correct for this package. Check that the correct key URLs are configured for this repository. Failing package is: mysql-community-common-5.7.42-1.el7.x86_64 GPG Keys are configured as: file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
fix with this
rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022
Then reinstall
start up
sudo systemctl start mysqld
Set to start automatically at system startup
sudo systemctl enable mysqld
View startup status
sudo systemctl status mysqld
The root default password on CentOS can be found in the file /var/log/mysqld.log, which can be printed out by the following command
cat /var/log/mysqld.log | grep -i 'temporary password'
Execute the following command for security settings, this command will set the root password, remove anonymous users, prohibit root users from connecting remotely, etc.
mysql_secure_installation
The first step is to enter the password, use the password you just found
The second step is to enter the new password, pay attention to the strength
The third step is to remove anonymous users, answer Y
The fourth allows remote login, which can be changed later.
The fifth test database, point Y
Modify my.cnf
vim /etc/my.cnf
Set the database encoding to utf8
Add encoding settings under [mysqld], [client], [mysql] nodes
[client] default-character-set=utf8 [mysql] default-character-set=utf8 [mysqld] collation-server=utf8_unicode_ci init-connect='SET NAMES utf8' character-set-server=utf8
Just restart Mysql
systemctl restart mysqld
If you want to set up root remote login, you can:
mysql -u root -p use mysql GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'your password!!' WITH GRANT OPTION; mysql> FLUSH PRIVILEGES;
Execute the following statement, if you can successfully connect, it proves that remote login is available, pay attention to replace the password and IP with your actual password and IP.
[root@localhost ~]# mysql -uroot -p password -h 192.168.170.128
Skills
You can use where mysql to query the database installation location
Add Centos user
configure user
add kbe1 user
adduser kbe1 passwd kbe1
Password setting: kbeuser1234567
Set uid, set the same uid for the game servers in the same group
usermod -u 101 kbe1
Configure KBEngine
upload kbe engine
decompress
tar -zxvf kbengine-2.5.12.tar.gz -C /mnt
Change the kbengine-2.5.12 directory to server
Enter the server directory
Modify vim.bashrc
vim /mnt/server/.bashrc
Put the following content
ulimit -c unlimited export KBE_ROOT=/mnt/server/ export KBE_RES_PATH=$KBE_ROOT/kbe/res/:$KBE_ROOT/assets/:$KBE_ROOT/assets/scripts/:$KBE_ROOT/assets/res/ export KBE_BIN_PATH=$KBE_ROOT/kbe/bin/server/
take effect
source /mnt/server/.bashrc
Add database user:
grant all privileges on . to kbe1@'%' identified by 'Pd123456'; grant select,insert,update,delete,create,drop on . to kbe1@'%' identified by 'Pd123456'; FLUSH PRIVILEGES; set password for kbe1 = password('Pd123456'); quit;
To test whether you can connect, you can use the following syntax
mysql -ukbe1 -p'Pd123456 -hlocalhost -P3306
Optimize Centos network
Optimize with the py script that comes with the engine
Server script
Copy the latest code (scripts) from assets to assets-server
Modify game configuration
asserts-server/res/server/kbengine.xml
<externalAddress> 66.191.24.1 </externalAddress> <!-- Type: String --> <!-- Automatic backup time (seconds) (Automatic backup time period(secs)) --> <backupPeriod>500</backupPeriod> </baseapp> <loginapp> <externalAddress> 66.191.24.1 </externalAddress> <!-- Type: String --> </loginapp>
There is also the user kbe1 and password of the database part
It is also necessary to modify the kbe engine directory configuration table kbe\res\server\kbengine_defaults.xml in batches, and change the default password of other pwd123456 to the user password.
Compile engine
Check openssl version -a, whether it is installed, if not installed by yourself
If you don’t have gcc, you need to install it
yum -y install gcc yum -y install gcc-c++
install auto
yum install autoconf
Install automake
yum install automake
install libtool
yum install libtool
install mysql-devel
yum install mysql-devel
Enter the engine’s src directory
cd /mnt/server/kbe/src chmod -R 755 .
start compiling
make
Notice:
1: If you use other versions of the compiler, it is best to recompile openssl, log4cxx and others (kbengine/kbe/src/libs/*a.).
2: mysql_config may not be the path address /usr/bin/mysql_config on some operating system versions
You can manually modify kbengine/kbe/src/build/common.mak where MYSQL_CONFIG_PATH=/usr/bin/mysql_config.
3: After compiling on Linux, there may be a problem that the Python interpreter cannot be initialized and the server cannot be started (this is a Python bug, see: http://bugs.python.org/issue11320)
You can execute the following command to solve this problem
[root @ localhost ~] cd kbengine/src/lib/python [root@localhost ~] ./configure [root@localhost ~] make [root@localhost ~] make install
The sh script for opening the server, the first line is added
cd /mnt/server/assets
To open the server, please use the kbe1 user to open the server. In addition, it is convenient and fast to use xshell, and you can edit the button to execute commands.
server opening command
sh /mnt/server/assets/start_server.sh
Closing instructions
sh /mnt/server/assets/safe_kill.sh
query command
python /mnt/server/kbe/tools/server/pycluster/cluster_controller.py
kill service
sh /mnt/server/assets/kill_server.sh
Skills
See who uses a certain port netstat -alnp |grep 20005
LOG4 configuration
After the server is officially launched. The log is too large, you can modify kbe/res/server/log4xx_properties_defaults/baseapp, etc.
Change log4j.rootLogger=debug, R to more advanced log4j.rootLogger=WARN, R