534523 发表于 2016-12-7 08:50:15

zabbix的MariaDB数据库改变存储位置

#创建

1
mkdir /公司缩写/mysql





#停止数据库服务

1
2
systemctl status mariadb.service
systemctl stop mariadb.service





#把数据库文件移动到新的存储位置

1
cp -rp /var/lib/mysql/ /公司缩写/mysql/





#修改后的数据库配置文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# cat /etc/my.cnf

datadir=/公司缩写/mysql
socket=/公司缩写/mysql/mysql.sock
lower_case_table_names         = 1
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mariadb according to the
# instructions in http://fedoraproject.org/wiki/Systemd


log-error=/var/log/mariadb/mariadb.log
pid-file=/var/run/mariadb/mariadb.pid

#
# include all files from the config directory
#
!includedir /etc/my.cnf.d





#启动数据库

1
2
systemctl start mariadb.service
systemctl status mariadb.service





#新的登录数据库的命令,需要指定mysql.sock

1
mysql -uzabbix -p123456 -S /公司缩写/mysql/mysql.sock





#创建软链接,否则,zabbix页面无法打开

1
2
mkdir /var/lib/mysql
ln -s /公司缩写/mysql/mysql.sock /var/lib/mysql/mysql.sock




  在这一步之前,我是把原始的/var/lib/mysql目录改名为/var/lib/mysql_ori。所以,会有创建/var/lib/mysql的命令。在下面确认重启zabbix服务端没有问题,web界面可以正常打开。我才把原始的/var/lib/mysql目录移动到/tmp目录,后来又移动到公司默认的目录,作为备份存放。

#重启zabbix

1
systemctl restart zabbix-server.service



页: [1]
查看完整版本: zabbix的MariaDB数据库改变存储位置