mariadb 安装

yum 源准备

根据自己的系统和软件版本,自动生成yum配置

https://downloads.mariadb.org/mariadb/repositories/

如果是内网,需要将tar包下载下来,并加压,放入apache httpserver中

创建MariaDB.repo

[mariadb]
name = MariaDB
baseurl = http://ip:port/mariadb/mariadb-10.2.6-rhel-6-x86_64-rpms/
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=0

yum install MariaDB-server

Running Transaction
  Installing : MariaDB-common-10.2.6-1.el6.x86_64                                                                                 1/7 
  Installing : MariaDB-compat-10.2.6-1.el6.x86_64                                                                                 2/7 
  Installing : MariaDB-client-10.2.6-1.el6.x86_64                                                                                 3/7 
  Installing : boost-program-options-1.41.0-28.el6.x86_64                                                                         4/7 
  Installing : galera-25.3.20-1.rhel6.el6.x86_64                                                                                  5/7 
  Installing : MariaDB-server-10.2.6-1.el6.x86_64                                                                                 6/7 
chown: cannot access `/var/lib/mysql': No such file or directory

PLEASE REMEMBER TO SET A PASSWORD FOR THE MariaDB root USER !
To do so, start the server, then issue the following commands:

'/usr/bin/mysqladmin' -u root password 'new-password'
'/usr/bin/mysqladmin' -u root -h cnsz033394 password 'new-password'

Alternatively you can run:
'/usr/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.

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
Consider joining MariaDB's strong and vibrant community:
https://mariadb.org/get-involved/

  Erasing    : mysql-libs-5.1.71-1.el6.x86_64                                                                                     7/7 
rhel-base/productid                                                                                            | 1.6 kB     00:00     
  Verifying  : galera-25.3.20-1.rhel6.el6.x86_64                                                                                  1/7 
  Verifying  : MariaDB-compat-10.2.6-1.el6.x86_64                                                                                 2/7 
  Verifying  : MariaDB-client-10.2.6-1.el6.x86_64                                                                                 3/7 
  Verifying  : MariaDB-common-10.2.6-1.el6.x86_64                                                                                 4/7 
  Verifying  : MariaDB-server-10.2.6-1.el6.x86_64                                                                                 5/7 
  Verifying  : boost-program-options-1.41.0-28.el6.x86_64                                                                         6/7 
  Verifying  : mysql-libs-5.1.71-1.el6.x86_64                                                                                     7/7 

Installed:
  MariaDB-compat.x86_64 0:10.2.6-1.el6                              MariaDB-server.x86_64 0:10.2.6-1.el6                             

Dependency Installed:
  MariaDB-client.x86_64 0:10.2.6-1.el6     MariaDB-common.x86_64 0:10.2.6-1.el6     boost-program-options.x86_64 0:1.41.0-28.el6    
  galera.x86_64 0:25.3.20-1.rhel6.el6     

Replaced:
  mysql-libs.x86_64 0:5.1.71-1.el6                                                                                                    

Complete!

更新数据库配置

启动服务器

service mysql start

更新服务器安全配置

mysql_secure_installation

更新配置文件

配置文件默认通过 /etc/my.cnf 来引用 /etc/my.cnf.d 下面的文件
enable_encryption.preset mysql-clients.cnf server.cnf

修改数据存放目录

mysql, MariaDB 的默认数据存放在 /var/lib/mysql/ 目录下,如果不想放到此处,或者是想要程序和数据分离,或者是磁盘原因,需要切换到其他路径,则可以通过修改 datadir系统变量来达成目的.

停止数据库

service mysql stop

创建目录,假设没有的话

mkdir /appcom/mariadb_data

拷贝默认数据库到新的位置 ,-a 命令是将文件属性一起拷贝,否则各种问题

cp -a /var/lib/mysql /appcom/mariadb_data

在文件的 mysqld 节下添加内容

vim /etc/my.cnf.d/server.cnf

[mysqld]
datadir=/appcom/mariadb_data/mysql          
socket=/var/lib/mysql/mysql.sock
#default-character-set=utf8  
character_set_server=utf8  
slow_query_log=on  
slow_query_log_file=/appcom/mariadb_data/slow_query_log.log            
long_query_time=2

其中,也只有 datadir 和 socket 比较重要; 而 default-character-set 是 mysql 自己认识的,而 mariadb5.5 就不认识,相当于变成了 character_set_server

创建慢查询日志文件

既然上面指定了慢查询日志文件,我后来看了下MariaDB的err日志,发现MariaDB不会自己创建该文件,所以我们需要自己创建,并修改相应的文件权限(比如 MySQL 采用 mysql用户,可能我们使用 root用户创建的文件,此时要求慢查询日志文件对mysql用户可读可写就行。)

touch /appcom/mariadb_data/slow_query_log.log
chmod 666 /appcom/mariadb_data/slow_query_log.log

然后重新启动MySQL.

数据库和用户管理

create database hadoop_monitor;
grant all on hadoop_monitor.* to hadoop@localhost identified by ‘xxx’;
grant all on hadoop_monitor.* to hadoop@’%’ identified by ‘xxx’;

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值