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

#创建

mkdir /公司缩写/mysql
 

#停止数据库服务

systemctl status mariadb.service
systemctl stop mariadb.service
 

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

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

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

[root@iZkdZ ~]# cat /etc/my.cnf
[mysqld] 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 [mysqld_safe] 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
 

#启动数据库

systemctl start mariadb.service 
systemctl status mariadb.service
 

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

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

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

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

systemctl restart zabbix-server.service
 

参考资料:

http://www.cnblogs.com/seasonsstory/archive/2013/07/24/3209785.html——zabbix连不上数据库

http://blog.chinaunix.net/uid-20749043-id-1878317.html——更换mysql存储路径

猜你喜欢

转载自www.cnblogs.com/jianghanyang/p/11102562.html