快上网专注成都网站设计 成都网站制作 成都网站建设
成都网站建设公司服务热线:028-86922220

网站建设知识

十年网站开发经验 + 多家企业客户 + 靠谱的建站团队

量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决

OracleLinux7.1中安装Mariadb-创新互联

在Oracle Linux 7.1中安装Mariadb 10.0.38,因为Mariadb是Mysql的分支,安装操作基本类似。

让客户满意是我们工作的目标,不断超越客户的期望值来自于我们对这个行业的热爱。我们立志把好的技术通过有效、简单的方式提供给客户,将通过不懈努力成为客户在信息化领域值得信任、有价值的长期合作伙伴,公司提供的服务项目有:域名注册、网页空间、营销软件、网站建设、太谷网站维护、网站推广。

1.首先下载安装介质mariadb-10.0.38-linux-glibc_214-x86.tar.gz 并将其上传到服务器的/soft目录

2.创建用户与用户组

[root@cs1 soft]# groupadd mysql

[root@cs1 soft]# useradd -g mysql mysql

3.将介质解压到/usr/local/目录下

[root@cs1 soft]# cd /usr/local

[root@cs1 local]# gunzip < /soft/mariadb-10.0.38-linux-glibc_214-x86.tar.gz | tar xvf -

mariadb-10.0.38-linux-glibc_214-x86/

mariadb-10.0.38-linux-glibc_214-x86/man/

mariadb-10.0.38-linux-glibc_214-x86/man/man8/

mariadb-10.0.38-linux-glibc_214-x86/man/man8/mysqld.8

........省略..........

[root@cs1 local]# ls -lrt

总用量 4

drwxr-xr-x.  2 root root    6 5月   8 2014 src

drwxr-xr-x.  2 root root    6 5月   8 2014 sbin

drwxr-xr-x.  2 root root    6 5月   8 2014 libexec

drwxr-xr-x.  2 root root    6 5月   8 2014 libdrwxr-xr-x.  2 root root    6 5月   8 2014 lib

drwxr-xr-x.  2 root root    6 5月   8 2014 include

drwxr-xr-x.  2 root root    6 5月   8 2014 games

drwxr-xr-x.  2 root root    6 5月   8 2014 etc

drwxr-xr-x.  5 root root   46 10月 12 2017 share

drwxr-xr-x.  2 root root   46 3月   9 2018 bin

drwxrwxr-x  13 1021 1004 4096 1月  31 02:40 mariadb-10.0.38-linux-glibc_214-x86

4.创建软链接

[root@cs1 local]# ln -s mariadb-10.0.38-linux-glibc_214-x86 mysql

[root@cs1 local]# ls -lrt

总用量 4

drwxr-xr-x.  2 root root    6 5月   8 2014 src

drwxr-xr-x.  2 root root    6 5月   8 2014 sbin

drwxr-xr-x.  2 root root    6 5月   8 2014 libexec

drwxr-xr-x.  2 root root    6 5月   8 2014 libdrwxr-xr-x.  2 root root    6 5月   8 2014 lib

drwxr-xr-x.  2 root root    6 5月   8 2014 include

drwxr-xr-x.  2 root root    6 5月   8 2014 games

drwxr-xr-x.  2 root root    6 5月   8 2014 etc

drwxr-xr-x.  5 root root   46 10月 12 2017 share

drwxr-xr-x.  2 root root   46 3月   9 2018 bin

drwxrwxr-x  13 1021 1004 4096 1月  31 02:40 mariadb-10.0.38-linux-glibc_214-x86 

lrwxrwxrwx   1 root root   38 6月   4 14:43 mysql -> mariadb-10.0.38-linux-glibc_214-x86

5.确保目录mysql能够被用户mysql访问

[root@cs1 local]# cd mysql

[root@cs1 mysql]# chown -R mysql .

[root@cs1 mysql]# chgrp -R mysql .

6.在安装Mariadb之前,必须创建Mariadb存放数据的目录并初始化grant表,执行mysql_install_db命令来安装Mariadb,如果使用root用户来执行,必须包含--user选项来指定用户,如果是mysql用户来执行可以忽略--user选项。使用 --basedir=path 选项指定Mariadb安装目录的路径,--datadir=path选项指定Mariadb数据目录的路径。如果没有指定--basedir与--datadir选项它们在/usr/local/mysql目录下创建一个data目录。

[root@cs1 mysql]# scripts/mysql_install_db --user=mysql

Installing MariaDB/MySQL system tables in './data' ...

190604 14:44:44 [Note] ./bin/mysqld (mysqld 10.0.38-MariaDB) starting as process 19627 ...

190604 14:44:45 [Note] InnoDB: innodb_empty_free_list_algorithm has been changed to legacy because of small buffer pool size. In order to use backoff, increase buffer pool at least up to 20MB.

190604 14:44:45 [Note] InnoDB: Using mutexes to ref count buffer pool pages

190604 14:44:45 [Note] InnoDB: The InnoDB memory heap is disabled

190604 14:44:45 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins

190604 14:44:45 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier

190604 14:44:45 [Note] InnoDB: Compressed tables use zlib 1.2.11

190604 14:44:45 [Note] InnoDB: Using Linux native AIO

190604 14:44:45 [Note] InnoDB: Using CPU crc32 instructions

190604 14:44:45 [Note] InnoDB: Initializing buffer pool, size = 128.0M

190604 14:44:45 [Note] InnoDB: Completed initialization of buffer pool

190604 14:44:45 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!

190604 14:44:45 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB

190604 14:44:45 [Note] InnoDB: Database physically writes the file full: wait...

190604 14:44:45 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB

190604 14:44:45 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB

190604 14:44:46 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0

190604 14:44:46 [Warning] InnoDB: New log files created, LSN=45781

190604 14:44:46 [Note] InnoDB: Doublewrite buffer not found: creating new

190604 14:44:46 [Note] InnoDB: Doublewrite buffer created

190604 14:44:46 [Note] InnoDB: 128 rollback segment(s) are active.

190604 14:44:46 [Warning] InnoDB: Creating foreign key constraint system tables.

190604 14:44:46 [Note] InnoDB: Foreign key constraint system tables created

190604 14:44:46 [Note] InnoDB: Creating tablespace and datafile system tables.

190604 14:44:46 [Note] InnoDB: Tablespace and datafile system tables created.

190604 14:44:46 [Note] InnoDB: Waiting for purge to start

190604 14:44:46 [Note] InnoDB:  Percona XtraDB (http://www.percona.com) 5.6.42-84.2 started; log sequence number 0

190604 14:44:48 [Note] InnoDB: FTS optimize thread exiting.

190604 14:44:48 [Note] InnoDB: Starting shutdown...

190604 14:44:48 [Note] InnoDB: Waiting for page_cleaner to finish flushing of buffer pool

190604 14:44:50 [Note] InnoDB: Shutdown completed; log sequence number 1616697

OK

Filling help tables...

190604 14:44:50 [Note] ./bin/mysqld (mysqld 10.0.38-MariaDB) starting as process 19661 ...

190604 14:44:50 [Note] InnoDB: innodb_empty_free_list_algorithm has been changed to legacy because of small buffer pool size. In order to use backoff, increase buffer pool at least up to 20MB.

190604 14:44:50 [Note] InnoDB: Using mutexes to ref count buffer pool pages

190604 14:44:50 [Note] InnoDB: The InnoDB memory heap is disabled

190604 14:44:50 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins

190604 14:44:50 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier

190604 14:44:50 [Note] InnoDB: Compressed tables use zlib 1.2.11

190604 14:44:50 [Note] InnoDB: Using Linux native AIO

190604 14:44:50 [Note] InnoDB: Using CPU crc32 instructions

190604 14:44:50 [Note] InnoDB: Initializing buffer pool, size = 128.0M

190604 14:44:50 [Note] InnoDB: Completed initialization of buffer pool

190604 14:44:50 [Note] InnoDB: Highest supported file format is Barracuda.

190604 14:44:50 [Note] InnoDB: 128 rollback segment(s) are active.

190604 14:44:50 [Note] InnoDB: Waiting for purge to start

190604 14:44:50 [Note] InnoDB:  Percona XtraDB (http://www.percona.com) 5.6.42-84.2 started; log sequence number 1616697

190604 14:44:50 [Note] InnoDB: FTS optimize thread exiting.

190604 14:44:50 [Note] InnoDB: Starting shutdown...

190604 14:44:51 [Note] InnoDB: Waiting for page_cleaner to finish flushing of buffer pool

190604 14:44:53 [Note] InnoDB: Shutdown completed; log sequence number 1616707

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 cs1.jy.net 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 /tupian/20230522/ or the

MySQL manual for more instructions.

You can start the MariaDB daemon with:

cd '.' ; ./bin/mysqld_safe --datadir='./data'

You can test the MariaDB daemon with mysql-test-run.pl

cd './mysql-test' ; perl mysql-test-run.pl

Please report any problems at /tupian/20230522/Dashboard.jspa

The latest information about MariaDB is available at /tupian/20230522/

You can find additional information about the MySQL part at:

/tupian/20230522/

Consider joining MariaDB's strong and vibrant community:

/tupian/20230522/

7.因为安装Mariadb的用户是root用户,而data目录必须要被mysql用户访问,因此修改data目录的用户与组权限

[root@cs1 mysql]# chown -R root .

[root@cs1 mysql]# chown -R mysql data

8.在安装完成后来测试Mariadb的启动

[root@cs1 mysql]# bin/mysqld_safe --user=mysql &

[1] 19770

[root@cs1 mysql]# 190604 14:45:25 mysqld_safe Logging to '/usr/local/mysql/data/cs1.jy.net.err'.

190604 14:45:25 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data

mysqld_safe是服务端工具,用于启动mysqld,并且是mysqld的守护进程,mysqld_safe加&在后台运行$BASEDIR/bin/mysqld_safe &。因为mysqld_safe是mysqld的守护进程,所以mysqld_safe脚本会在启动MySQL服务器后继续监控其运行情况,并在其死机时重新启动它。直接使用mysqld_safe启动mysqld时,mysqld_safe可以使用参数选项见mysqld_safe --help,此时可以使用其他配置文件,相当于mysqld_safe把参数传递给mysqld。mysql.server脚本其实也是调用mysqld_safe脚本去启动MySQL服务器的,但此时mysqld_safe不能使用参数选项即不能mysqld_safe --defaults-file这样的模式。

9.将启动Mariadb的脚本配置成服务通过service name start命令来启用

[root@cs1 mysql]# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld

[root@cs1 mysql]# cat /etc/init.d/mysqld

[root@cs1 Packages]# service mysqld status

 SUCCESS! MariaDB running (19839)

[root@cs1 Packages]# service mysqld stop

Shutting down MariaDB... SUCCESS! 

[root@cs1 Packages]# service mysqld start

Starting MariaDB.190604 18:26:04 mysqld_safe Logging to '/usr/local/mysql/data/cs1.jy.net.err'.

190604 18:26:05 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data

 SUCCESS!

10.修改root用户密码

-bash-4.2$ mysql

Welcome to the MariaDB monitor.  Commands end with ; or \g.

Your MariaDB connection id is 4

Server version: 10.0.38-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> 

MariaDB [mysql]> set password=password("123456");

Query OK, 0 rows affected (0.00 sec)

MariaDB [mysql]> exit

-bash-4.2$ mysql -u root -p

Enter password: 

Welcome to the MariaDB monitor.  Commands end with ; or \g.

Your MariaDB connection id is 6

Server version: 10.0.38-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> show databases;

+--------------------+

| Database           |

+--------------------+

| information_schema |

| mysql              |

| performance_schema |

| test               |

+--------------------+

4 rows in set (0.01 sec)

MariaDB [(none)]> use mysql;

Reading table information for completion of table and column names

You can turn off this feature to get a quicker startup with -A

Database changed

11.使用mytop工具来监控Mariadb,mytop在Mariadb安装时也会自动安装,而mysql中需要单独安装

-bash-4.2$ mytop --prompt -u root -d mysql

Password: 

install_driver(mysql) failed: Can't locate DBD/mysql.pm in @INC (@INC contains: /usr/local/lib/perl5 /usr/local/share/perl5 /usr/lib/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib/perl5 /usr/share/perl5 .) at (eval 13) line 3,  line 1.

Perhaps the DBD::mysql perl module hasn't been fully installed,

or perhaps the capitalisation of 'mysql' isn't right.

Available drivers: DBM, ExampleP, File, Gofer, Proxy, SQLite, Sponge.

 at /usr/local/mysql//bin/mytop line 253.

错误信息说明没有安装perl-DBD-MySQL工具包

12.安装perl-DBD-MySQ工具包

[root@cs1 bin]# yum install perl-DBD-MySQL

已加载插件:langpacks

Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast

file:///run/media/jy/OL-7.1%20Server.x86/repodata/repomd.xml: [Errno 14] curl#37 - "Couldn't open file /run/media/jy/OL-7.1%20Server.x86/repodata/repomd.xml"

正在尝试其它镜像。

正在解决依赖关系

--> 正在检查事务

---> 软件包 perl-DBD-MySQL.x86.0.4.023-5.0.1.el7 将被 安装

--> 正在处理依赖关系 libmysqlclient.so.18(libmysqlclient_18)(bit),它被软件包 perl-DBD-MySQL-4.023-5.0.1.el7.x86 需要

--> 正在处理依赖关系 libmysqlclient.so.18()(bit),它被软件包 perl-DBD-MySQL-4.023-5.0.1.el7.x86 需要

--> 正在检查事务

---> 软件包 mysql-community-libs.x86.0.5.6.23-3.el7 将被 安装

--> 正在处理依赖关系 mysql-community-common(x86-) = 5.6.23-3.el7,它被软件包 mysql-community-libs-5.6.23-3.el7.x86 需要

--> 正在检查事务

---> 软件包 mysql-community-common.x86.0.5.6.23-3.el7 将被 安装

--> 解决依赖关系完成

依赖关系解决

============================================================================================================================================================================================================================================

 Package                                                            架构                                               版本                                                         源                                                 大小

============================================================================================================================================================================================================================================

正在安装:

 perl-DBD-MySQL                                                     x86                                             4.023-5.0.1.el7                                              local                                             140 k

为依赖而安装:

 mysql-community-common                                             x86                                             5.6.23-3.el7                                                 local                                             256 k

 mysql-community-libs                                               x86                                             5.6.23-3.el7                                                 local                                             2.0 M

事务概要

============================================================================================================================================================================================================================================

安装  1 软件包 (+2 依赖软件包)

总下载量:2.4 M

安装大小:12 M

Is this ok [y/d/N]: y

Downloading packages:

Error downloading packages:

  mysql-community-common-5.6.23-3.el7.x86: [Errno 256] No more mirrors to try.

  perl-DBD-MySQL-4.023-5.0.1.el7.x86: [Errno 256] No more mirrors to try.

  mysql-community-libs-5.6.23-3.el7.x86: [Errno 256] No more mirrors to try.

出现不能下载相关工具包的错误

13.将操作系统ISO文件挂载到系统中并进入Packages目录执行rpm命令来安装

root@cs1 Packages]# ls -lrt mysql*

-rw-rw-r-- 1 root root  13136 5月  14 2014 mysql-connector-java-5.1.25-3.el7.noarch.rpm

-rw-rw-r-- 1 root root   145144 8月   6 2014 mysql-connector-odbc-5.2.5-6.0.1.el7.x86.rpm

-rw-r--r-- 1 root root   4203 2月  19 2015 mysql-community-bench-5.6.23-3.el7.x86.rpm

-rw-r--r-- 1 root root 19378376 2月  19 2015 mysql-community-client-5.6.23-3.el7.i686.rpm

-rw-r--r-- 1 root root  3435828 2月  19 2015 mysql-community-devel-5.6.23-3.el7.i686.rpm

-rw-r--r-- 1 root root   2624 2月  19 2015 mysql-community-common-5.6.23-3.el7.x86.rpm

-rw-r--r-- 1 root root   262516 2月  19 2015 mysql-community-common-5.6.23-3.el7.i686.rpm

-rw-r--r-- 1 root root 19979168 2月  19 2015 mysql-community-client-5.6.23-3.el7.x86.rpm

-rw-r--r-- 1 root root  3543424 2月  19 2015 mysql-community-devel-5.6.23-3.el7.x86.rpm

-rw-r--r-- 1 root root 23060740 2月  19 2015 mysql-community-embedded-5.6.23-3.el7.i686.rpm

-rw-r--r-- 1 root root 23733580 2月  19 2015 mysql-community-embedded-5.6.23-3.el7.x86.rpm

-rw-r--r-- 1 root root 4916 2月  19 2015 mysql-community-embedded-devel-5.6.23-3.el7.i686.rpm

-rw-r--r-- 1 root root  2104968 2月  19 2015 mysql-community-libs-5.6.23-3.el7.x86.rpm

-rw-r--r-- 1 root root  2040356 2月  19 2015 mysql-community-libs-5.6.23-3.el7.i686.rpm

-rw-r--r-- 1 root root 68058508 2月  19 2015 mysql-community-embedded-devel-5.6.23-3.el7.x86.rpm

-rw-r--r-- 1 root root 60224180 2月  19 2015 mysql-community-server-5.6.23-3.el7.x86.rpm

-rw-r--r-- 1 root root 59280136 2月  19 2015 mysql-community-test-5.6.23-3.el7.x86.rpm

[root@cs1 Packages]# rpm -ihv mysql-community-libs-5.6.23-3.el7.x86.rpm

警告:mysql-community-libs-5.6.23-3.el7.x86.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID ec551f03: NOKEY

错误:依赖检测失败:

        mysql-community-common(x86-) = 5.6.23-3.el7 被 mysql-community-libs-5.6.23-3.el7.x86 需要

[root@cs1 Packages]# rpm -ivh mysql-community-common-5.6.23-3.el7.x86.rpm

警告:mysql-community-common-5.6.23-3.el7.x86.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID ec551f03: NOKEY

准备中...                             ################################# [100%]

正在升级/安装...

   1:mysql-community-common-5.6.23-3.e################################# [100%]

[root@cs1 Packages]# rpm -ihv mysql-community-libs-5.6.23-3.el7.x86.rpm

警告:mysql-community-libs-5.6.23-3.el7.x86.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID ec551f03: NOKEY

准备中...                             ################################# [100%]

正在升级/安装...

   1:mysql-community-libs-5.6.23-3.el7################################# [100%]

[root@cs1 Packages]# ls -lrt perl-DBD-MySQL

ls: 无法访问perl-DBD-MySQL: 没有那个文件或目录

[root@cs1 Packages]# ls -lrt perl-DBD-MySQL*

-rw-rw-r-- 1 root root 143092 8月   6 2014 perl-DBD-MySQL-4.023-5.0.1.el7.x86.rpm

[root@cs1 Packages]# rpm -ivh perl-DBD-MySQL-4.023-5.0.1.el7.x86.rpm

警告:perl-DBD-MySQL-4.023-5.0.1.el7.x86.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID ec551f03: NOKEY

准备中...                             ################################# [100%]

正在升级/安装...

   1:perl-DBD-MySQL-4.023-5.0.1.el7   ################################# [100%]

14.执行mytop命令来监控Mariadb

-bash-4.2$ mytop -u root -p 123456

MariaDB on localhost (10.0.38-MariaDB)                                                                                                                                                                  up 0+01:04:21 [15:49:46]

 Queries: 170.0   qps:    0 Slow:     0.0         Se/In/Up/De(%):    06/00/00/00

 Sorts:     0 qps now:    1 Slow qps: 0.0  Threads:    2 (   1/   0) 00/00/00/00

 Handler: (R/W/U/D)     0/    0/    0/    0        Tmp: R/W/U:    89/   89/    0

 ISAM Key Efficiency: 0.0%  Bps in/out:   1.4/ 66.6   Now in/out:  22.6/ 2.9k

       Id     User         Host/IP        DB   Time     %    Cmd           State Query

       --     ----         -------        --   ----     -    ---           ----- ----------

       12     root       localhost     mysql     10   0.0  Sleep                                                                                                                                                                          

       10     root       localhost      test      0   0.0  Query            init show full processlist

到此安装也就完成了。


文章题目:OracleLinux7.1中安装Mariadb-创新互联
文章起源:http://6mz.cn/article/ddgojg.html

其他资讯