安装MariaDB 10.2.6

Mysql与MariaDB

    Mysql是一个关系型数据库,由mysql ab公司开发,在2008年被sun公司收购,2009年被oracle公司收购。mysql最新版本是5.7GA/8.0DMR。mysql 5.6版本变化比较大,5.7版本性能上有很大提升。

    Mariadb是mysql的一个分支,最新版本是10.2版本。它是由Mysql原作者带领大部分原班人马创立的SkySQL公司维护。

    Mariadb5.5版本对应MySQL的5.5版本,10.0版本对应MySQL的5.6版本。

1
2
3
4
5
Tips:
Community 社区版本,Enterprise 企业版,
GA(Generally Available)指通用版本,在生产环境中用的,
DMR(Development Milestone Release)开发里程碑发布版,
RC(Release Candidate)发行候选版本,Beta开放测试版本,Alpha内部测试版本。


安装MariaDB

1、下载安装文件

1
2
3
4
5
6
7
8
9
[root@juispan src] # wget https://downloads.mariadb.com/MariaDB/mariadb-10.2.6/bintar-linux-glibc_214-x86_64/mariadb-10.2.6-linux-glibc_214-x86_64.tar.gz
--2017-07-21 07:01:06--  https: //downloads .mariadb.com /MariaDB/mariadb-10 .2.6 /bi              ntar-linux-glibc_214-x86_64 /mariadb-10 .2.6-linux-glibc_214-x86_64. tar .gz
正在解析主机 downloads.mariadb.com (downloads.mariadb.com)... 51.255.94.155, 200             1:41d0:1004:249b::
正在连接 downloads.mariadb.com (downloads.mariadb.com)|51.255.94.155|:443... 已             连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:541295045 (516M) [application /octet-stream ]
正在保存至: “mariadb-10.2.6-linux-glibc_214-x86_64. tar .gz”
 
  5% [====>                                                                              7% [==>                                          ] 38,395,559  62.6KB /s  剩余 1h 40m

2、解压并移动

1
2
3
[root@juispan src] # tar zxvfmariadb-10.2.6-linux-glibc_214-x86_64.tar.gz
......
[root@juispan src] # mv mariadb-10.2.6-linux-glibc_214-x86_64 /usr/local/mariadb

3、创建用户

1
[root@juispan mariadb] # useradd mysql

4、初始化数据库

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
[root@juispan src] # cd /usr/local/mariadb
[root@juispan mariadb] # ls
bin                 data               include         mysql- test     share
COPYING             DESTINATION        INSTALL-BINARY  README.md     sql-bench
COPYING.thirdparty  docs               lib             README-wsrep  support-files
CREDITS             EXCEPTIONS-CLIENT   man              scripts
[root@server02 mariadb] # ./scripts/mysql_install_db --user=mysql --datadir=/data/mariadb
Installing MariaDB /MySQL  system tables  in  '/data/mariadb'  ...
OK
 
To start mysqld at boot  time  you have to copy
support-files /mysql .server to the right place  for  your system
 
PLEASE REMEMBER TO SET A PASSWORD FOR THE MariaDB root USER !
To  do  so, start the server,  then  issue the following commands:
 
'./bin/mysqladmin'  -u root password  'new-password'
'./bin/mysqladmin'  -u root -h server02 password  'new-password'
 
Alternatively you can run:
'./bin/mysql_secure_installation'
 
which  will also give you the option of removing the  test
databases and anonymous user created by default.  This is
strongly recommended  for  production servers.
 
See the MariaDB Knowledgebase at http: //mariadb .com /kb  or the
MySQL manual  for  more  instructions.
 
You can start the MariaDB daemon with:
cd  '.'  ; . /bin/mysqld_safe  --datadir= '/data/mariadb'
 
You can  test  the MariaDB daemon with mysql- test -run.pl
cd  './mysql-test'  ; perl mysql- test -run.pl
 
Please report any problems at http: //mariadb .org /jira
 
The latest information about MariaDB is available at http: //mariadb .org/.
You can  find  additional information about the MySQL part at:
http: //dev .mysql.com
[root@juispan mariadb] # echo $?
0

初始化显示“OK”和“echo $?”校验都表明了已正常初始化。

5、拷贝配置文件

1
2
3
4
5
6
[root@juispan mariadb] # cp support-files/my-small.cnf /usr/local/mariadb/my.cnf
[root@juispan mariadb] # vi /usr/local/mariadb/my.cnf 
......
basedir         = /usr/local/mariadb
datadir         = /data/mariadb
......

是选用“my-small.conf”还是“my-huge.cnf ”等这种文件和设备的配置有关,根据实际设备配置选择。

6、拷贝启动脚本文件

1
2
3
4
5
6
7
8
9
10
11
12
13
[root@juispan mariadb] # cp support-files/mysql.server /etc/init.d/mariadb
[root@juispan mariadb] # vi /etc/init.d/mariadb
......
basedir= /usr/local/mariadb       ##定义basedir
datadir= /data/mariadb            ##定义datadir
conf=$basedir /my .cnf             ##定义conf
......
     then
       # Give extra arguments to mysqld with the my.cnf file. This script
       # may be overwritten at next upgrade.
       $bindir /mysqld_safe  --defaults- file = "$conf" --datadir= "$datadir"  --pid- file = "$mysqld_pid_file_path"  "$@"  &         ##增加defaults-file启动参数
       wait_for_ready; return_value=$?
......

7、启动Mysql

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
[root@juispan mariadb] # chkconfig --add mariadb
[root@juispan mariadb] # chkconfig --list
 
注意:该输出结果只显示 SysV 服务,并不包含原生 systemd 服务。SysV 配置数据可能被原生 systemd 配置覆盖。 
       如果您想列出 systemd 服务,请执行  'systemctl list-unit-files'
       欲查看对特定 target 启用的服务请执行
       'systemctl list-dependencies [target]'
 
mariadb         0:关 1:关 2:开 3:开 4:开 5:开 6:关
netconsole         0:关 1:关 2:关 3:关 4:关 5:关 6:关
network         0:关 1:关 2:开 3:开 4:开 5:开 6:关
[root@juispan mariadb] # /etc/init.d/mariadb start
Reloading systemd:                                         [  确定  ]
Starting mariadb (via systemctl):  Job  for  mariadb.service failed because the control process exited with error code. See  "systemctl status mariadb.service"  and  "journalctl -xe"  for  details.
                                                            [失败]
[root@juispan mariadb] # systemctl status mariadb.service
● mariadb.service - LSB: start and stop MySQL
    Loaded: loaded ( /etc/rc .d /init .d /mariadb ; bad; vendor preset: disabled)
    Active: failed (Result:  exit -code) since 五 2017-07-21 08:13:42 CST; 35s ago
      Docs:  man :systemd-sysv-generator(8)
   Process: 10559 ExecStart= /etc/rc .d /init .d /mariadb  start (code=exited, status=1 /FAILURE )
 
7月 21 08:13:41 juispan mariadb[10559]: Fatal error  in  defaults handling. Program aborted
7月 21 08:13:41 juispan mariadb[10559]: WARNING: Defaults  file  '/usr/local/mariadb/my.cnf--datadir=/var/lib/mysql'  not found!
7月 21 08:13:41 juispan mariadb[10559]: 170721 08:13:41 mysqld_safe Logging to  '/usr/local/mysql/data/juispan.err' .
7月 21 08:13:41 juispan mariadb[10559]: 170721 08:13:41 mysqld_safe Starting mysqld daemon with databases from  /usr/local/mysql/data
7月 21 08:13:41 juispan mariadb[10559]: [147B blob data]
7月 21 08:13:42 juispan mariadb[10559]: ERROR!
7月 21 08:13:42 juispan systemd[1]: mariadb.service: control process exited, code=exited status=1
7月 21 08:13:42 juispan systemd[1]: Failed to start LSB: start and stop MySQL.
7月 21 08:13:42 juispan systemd[1]: Unit mariadb.service entered failed state.
7月 21 08:13:42 juispan systemd[1]: mariadb.service failed.

发现“ Defaults file '/usr/local/mariadb/my.cnf--datadir=/var/lib/mysql' not found!”错误。查看启动脚本,发现定义defaults-file的时候,两个参数之间没有空格导致。

1
2
3
4
5
6
7
8
9
10
11
12
[root@juispan mariadb] # /etc/init.d/mariadb start
Starting mariadb (via systemctl):                          [  确定  ]
[root@juispan mariadb] # netstat -lnpt
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address    Foreign Address         State       PID /Program  name
tcp        0      0 0.0.0.0:22       0.0.0.0:*               LISTEN      1337 /ssh 
tcp        0      0 127.0.0.1:25     0.0.0.0:*               LISTEN      1863 /master     
tcp        0      0 0.0.0.0:873      0.0.0.0:*               LISTEN      2368 /rsync      
tcp6       0      0 :::3306          :::*                    LISTEN      3307 /mysqld     
tcp6       0      0 :::22            :::*                    LISTEN      1337 /sshd       
tcp6       0      0 ::1:25           :::*                    LISTEN      1863 /master     
tcp6       0      0 :::873           :::*                    LISTEN      2368 /rsync


综上所述:mariadb的安装简直和mysql一模一样。如果服务器上面只有mariadb这个服务,我们完全可以把my.cnf放在etc下,同时也就不需要定义conf以及变量了。












本文转自Grodd51CTO博客,原文链接:http://blog.51cto.com/juispan/1951282,如需转载请自行联系原作者
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
这个问题涉及到 MariaDB 数据库的主备同步延迟。在你提供的信息中,"Seconds_Behind_Master" 的值为 18649234,表示备库相对于主库的延迟时间为 18649234 秒,即约为 5,180 小时或 215 天左右。这个延迟时间非常长,可能存在一些问题导致同步延迟增加。以下是一些可能的原因: 1. 网络问题:检查主备服务器之间的网络连接是否稳定,包括网络延迟和带宽限制。 2. 大量写入操作:如果主库上有大量写入操作,备库可能无法及时跟上同步。 3. 备库性能不足:备库的硬件配置可能较低,无法处理主库的写入负载。 4. 配置问题:检查 MariaDB 的配置文件,确保主备服务器上的相关参数设置一致。 5. 防火墙或安全设置:确保主备服务器之间的通信端口没有被防火墙或安全设置阻塞。 为了解决同步延迟问题,你可以尝试以下几个步骤: 1. 检查网络连接:确保主备服务器之间的网络连接稳定,并且没有任何网络问题。 2. 优化写入操作:如果可能的话,尝试减少主库上的写入操作,或者对写入操作进行优化,以减少备库的同步压力。 3. 升级备库硬件:如果备库的硬件配置较低,考虑升级硬件以提升性能。 4. 优化配置参数:根据具体情况,检查和优化 MariaDB 的配置参数,以提高同步性能。 5. 检查防火墙和安全设置:确保主备服务器之间的通信端口没有被防火墙或安全设置阻塞。 请注意,以上建议仅供参考,具体解决方法可能因实际情况而异。如果问题持续存在,请考虑咨询专业的数据库管理员或 MariaDB 的官方支持渠道。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值