这篇文章的内容主要围绕如何在CentOS 7 CPanel服务器上安装MariaDB 10进行讲述,文章内容清晰易懂,条理清晰,非常适合新手学习,值得大家去阅读。感兴趣的朋友可以跟随小编一起阅读吧。希望大家通过这篇文章有所收获!
MariaDB使用了Percona的 XtraDB,InnoDB的变体,分支的开发者希望提供访问即将到来的MySQL 5.4 InnoDB性能。下面和大家分享一下在 CentOS 7 CPanel 服务器上安装 MariaDB 10。
完全开源
快速且透明的安全版本
与 MySQL 高度兼容
性能更好
比 MySQL 的存储引擎多
在这篇文章中,我将谈论关于如何在 CentOS7 CPanel 服务器上升级 MySQL5.5 到最新的 MariaDB 。在安装前先完成以下步骤。
root@server1 [/var/]# mysqlWelcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 5859Server version: 5.5.47-cll MySQL Community Server (GPL)Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.root@server1 [~]# systemctl stop mysqlroot@server1 [~]# systemctl status mysql● mysql.service - LSB: start and stop MySQLLoaded: loaded (/etc/rc.d/init.d/mysql)Active: failed (Result: exit-code) since Sun 2016-01-31 10:00:02 UTC; 1min 31s agoDocs: man:systemd-sysv-generator(8)Main PID: 23430 (code=exited, status=203/EXEC)Jan 31 10:00:02 server1.centos7-test.com systemd[1]: Started MySQL Server.Jan 31 10:00:02 server1.centos7-test.com systemd[1]: Starting MySQL Server...Jan 31 10:00:02 server1.centos7-test.com systemd[1]: mysql.service: main process exited, code=exited, status=203/EXECJan 31 10:00:02 server1.centos7-test.com systemd[1]: Unit mysql.service entered failed state.Jan 31 10:00:02 server1.centos7-test.com systemd[1]: mysql.service failed.
转移数据库的存储路径和 MySQL 的配置文件
root@server1 [~]# cp -Rf /var/lib/mysql /var/lib/mysql-oldroot@server1 [/var/lib/mysql]# cat /etc/my.cnf[mysqld]default-storage-engine=MyISAMinnodb_file_per_table=1max_allowed_packet=268435456open_files_limit=10000root@server1 [~]#mv /etc/my.cnf /etc/my.cnf-old
运行以下命令来禁用 MySQL RPM 的目标target。通过运行此命令,cPanel 将不再处理 MySQL 的更新,并在系统上将这些 RPM 版本标记为已卸载。
/scripts/update_local_rpm_versions --edit target_settings.MySQL50 uninstalled/scripts/update_local_rpm_versions --edit target_settings.MySQL51 uninstalled/scripts/update_local_rpm_versions --edit target_settings.MySQL55 uninstalled/scripts/update_local_rpm_versions --edit target_settings.MySQL56 uninstalled
现在运行以下命令:
/scripts/checkcpanelrpms --fix --targets=MySQL50,MySQL51,MySQL55,MySQL56
移除服务器上所有已有的 MySQL RPM 来为 MariaDB 的安装清理环境。请看下面的输出:
root@server1 [/var/lib/mysql]# /scripts/check_cpanel_rpms --fix --targets=MySQL50,MySQL51,MySQL55,MySQL56[2016-01-31 09:53:59 +0000][2016-01-31 09:53:59 +0000] Problems were detected with cPanel-provided files which are RPM controlled.[2016-01-31 09:53:59 +0000] If you did not make these changes intentionally, you can correct them by running:[2016-01-31 09:53:59 +0000][2016-01-31 09:53:59 +0000] > /usr/local/cpanel/scripts/check_cpanel_rpms --fix[2016-01-31 09:53:59 +0000][2016-01-31 09:53:59 +0000] The following RPMs are unneeded on your system and should be uninstalled:[2016-01-31 09:53:59 +0000] MySQL55-client-5.5.47-1.cp1148[2016-01-31 09:53:59 +0000] MySQL55-devel-5.5.47-1.cp1148[2016-01-31 09:53:59 +0000] MySQL55-server-5.5.47-1.cp1148[2016-01-31 09:53:59 +0000] MySQL55-shared-5.5.47-1.cp1148[2016-01-31 09:53:59 +0000] MySQL55-test-5.5.47-1.cp1148[2016-01-31 09:53:59 +0000] compat-MySQL50-shared-5.0.96-4.cp1136[2016-01-31 09:53:59 +0000] compat-MySQL51-shared-5.1.73-1.cp1150[2016-01-31 09:53:59 +0000] Removing 0 broken rpms:[2016-01-31 09:53:59 +0000] rpm: no packages given for erase[2016-01-31 09:53:59 +0000] No new RPMS needed for install[2016-01-31 09:53:59 +0000] Disabling service monitoring.[2016-01-31 09:54:01 +0000] Uninstalling unneeded rpms: MySQL55-test MySQL55-server MySQL55-client compat-MySQL51-shared compat-MySQL50-shared MySQL55-shared MySQL55-devel[2016-01-31 09:54:04 +0000] Removed symlink /etc/systemd/system/multi-user.target.wants/mysql.service.[2016-01-31 09:54:04 +0000] Restoring service monitoring.
通过这些步骤,我们已经卸载了现有的 MySQL RPM,并做了标记来防止 MySQL的更新,服务器的环境已经清理,然后准备安装 MariaDB。
开始安装吧,我们需要根据 CentOS 和 MariaDB 的版本为 MariaDB 创建一个 yum 软件库。下面是我的做法!
root@server1 [~]# vim /etc/yum.repos.d/MariaDB.repo[mariadb]name = MariaDBbaseurl = http://yum.mariadb.org/10.0/centos7-amd64/gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDBgpgcheck=1root@server1 [/etc/yum.repos.d]# cat /etc/yum.repos.d/MariaDB.repo[mariadb]name = MariaDBbaseurl = http://yum.mariadb.org/10.0/centos7-amd64/gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDBgpgcheck=1
删除这一行:
exclude=courier* dovecot* exim* filesystem httpd* mod_ssl* mydns* mysql* nsd* php* proftpd* pure-ftpd* spamassassin* squirrelmail*
替换为:
exclude=courier* dovecot* exim* filesystem httpd* mod_ssl* mydns* nsd* proftpd* pure-ftpd* spamassassin* squirrelmail*
重要
需要确保我们已经从 exclude 列表中移除了 MySQL 和 PHP。
root@server1 [~]#yum install MariaDB-server MariaDB-client MariaDB-devel php-mysqlDependencies Resolved===============================================================================================================================================Package Arch Version Repository Size===============================================================================================================================================Installing:MariaDB-client x86_64 10.0.23-1.el7.centos mariadb 10 MMariaDB-devel x86_64 10.0.23-1.el7.centos mariadb 6.3 MMariaDB-server x86_64 10.0.23-1.el7.centos mariadb 55 Mphp-mysql x86_64 5.4.16-36.el7_1 base 99 kInstalling for dependencies:MariaDB-common x86_64 10.0.23-1.el7.centos mariadb 43 kMariaDB-shared x86_64 10.0.23-1.el7.centos mariadb 1.2 Mlibzip x86_64 0.10.1-8.el7 base 48 kphp-common x86_64 5.4.16-36.el7_1 base 563 kphp-pdo x86_64 5.4.16-36.el7_1 base 97 kTransaction Summary===============================================================================================================================================Install 4 Packages (+5 Dependent package)
root@server1 [~]# systemctl start mysqlroot@server1 [~]#root@server1 [~]#root@server1 [~]# systemctl status mysql● mysql.service - LSB: start and stop MySQLLoaded: loaded (/etc/rc.d/init.d/mysql)Active: active (exited) since Sun 2016-01-31 10:01:46 UTC; 3s agoDocs: man:systemd-sysv-generator(8)Process: 23717 ExecStart=/etc/rc.d/init.d/mysql start (code=exited, status=0/SUCCESS)Main PID: 23430 (code=exited, status=203/EXEC)Jan 31 10:01:46 server1.centos7-test.com systemd[1]: Starting LSB: start and stop MySQL...Jan 31 10:01:46 server1.centos7-test.com mysql[23717]: Starting MySQL SUCCESS!Jan 31 10:01:46 server1.centos7-test.com systemd[1]: Started LSB: start and stop MySQL.
它将检查所有数据库中的所有表与当前安装的版本是否兼容,并在必要时会更新系统表,以赋予当前版本新增加的权限或能力。
root@server1 [~]# mysql_upgradeMySQL upgrade detectedPhase 1/6: Checking and upgrading mysql databaseProcessing databasesmysqlmysql.columns_priv OKmysql.db OKmysql.event OKmysql.func OKmysql.help_category OKmysql.help_keyword OKmysql.help_relation OKmysql.help_topic OKmysql.host OKmysql.ndb_binlog_index OKmysql.plugin OKmysql.proc OKmysql.procs_priv OKmysql.proxies_priv OKmysql.servers OKmysql.tables_priv OKmysql.time_zone OKmysql.time_zone_leap_second OKmysql.time_zone_name OKmysql.time_zone_transition OKmysql.time_zone_transition_type OKmysql.user OKPhase 2/6: Fixing views from mysqlPhase 3/6: Running 'mysql_fix_privilege_tables'Phase 4/6: Fixing table and database namesPhase 5/6: Checking and upgrading tablesProcessing databasescphulkdcphulkd.auths OKcphulkd.blacklist OKcphulkd.brutes OKcphulkd.good_logins OKcphulkd.ip_lists OKcphulkd.known_netblocks OKcphulkd.login_track OKcphulkd.logins OKcphulkd.report OKcphulkd.whitelist OKeximstatseximstats.defers OKeximstats.failures OKeximstats.sends OKeximstats.smtp OKinformation_schemaleechprotectleechprotect.hits OKmodsecmodsec.hits OKperformance_schemaroundcuberoundcube.cache OKroundcube.cache_index OKroundcube.cache_messages OKroundcube.cache_shared OKroundcube.cache_thread OKroundcube.contactgroupmembers OKroundcube.contactgroups OKroundcube.contacts OKroundcube.cp_schema_version OKroundcube.dictionary OKroundcube.identities OKroundcube.searches OKroundcube.session OKroundcube.system OKroundcube.users OKsaheetha_testsaheetha_test.authors OKwhmxferwhmxfer.sessions OKPhase 6/6: Running 'FLUSH PRIVILEGES'OK
root@server1 [~]# systemctl restart mysqlroot@server1 [~]#root@server1 [~]# systemctl status mysql● mysql.service - LSB: start and stop MySQLLoaded: loaded (/etc/rc.d/init.d/mysql)Active: active (running) since Sun 2016-01-31 10:04:11 UTC; 9s agoDocs: man:systemd-sysv-generator(8)Process: 23831 ExecStop=/etc/rc.d/init.d/mysql stop (code=exited, status=0/SUCCESS)Process: 23854 ExecStart=/etc/rc.d/init.d/mysql start (code=exited, status=0/SUCCESS)Main PID: 23430 (code=exited, status=203/EXEC)CGroup: /system.slice/mysql.service├─23861 /bin/sh /usr/bin/mysqld_safe --datadir=/var/lib/mysql --pid-file=/var/lib/mysql/server1.centos7-test.com.pid└─23933 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --user=mysql --log-error=/v...Jan 31 10:04:10 server1.centos7-test.com systemd[1]: Starting LSB: start and stop MySQL...Jan 31 10:04:11 server1.centos7-test.com mysql[23854]: Starting MySQL. SUCCESS!Jan 31 10:04:11 server1.centos7-test.com systemd[1]: Started LSB: start and stop MySQL.
root@server1 [~]#/scripts/easyapache --build
重要
如果你在安装 MariaDB 之后忘记重建 Apache/PHP,将会报如下库错误:
root@server1 [/etc/my.cnf.d]# php -vphp: error while loading shared libraries: libmysqlclient.so.18: cannot open shared object file: No such file or directory
root@server1 [/var/lib/mysql]# mysqlWelcome to the MariaDB monitor. Commands end with ; or \g.Your MariaDB connection id is 15Server version: 10.0.23-MariaDB MariaDB ServerCopyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.MariaDB [(none)]> show storage engines;+--------------------+---------+----------------------------------------------------------------------------+--------------+------+------------+| Engine | Support | Comment | Transactions | XA | Savepoints |+--------------------+---------+----------------------------------------------------------------------------+--------------+------+------------+| CSV | YES | CSV storage engine | NO | NO | NO || MRG_MyISAM | YES | Collection of identical MyISAM tables | NO | NO | NO || MEMORY | YES | Hash based, stored in memory, useful for temporary tables | NO | NO | NO || BLACKHOLE | YES | /dev/null storage engine (anything you write to it disappears) | NO | NO | NO || MyISAM | YES | MyISAM storage engine | NO | NO | NO || InnoDB | DEFAULT | Percona-XtraDB, Supports transactions, row-level locking, and foreign keys | YES | YES | YES || ARCHIVE | YES | Archive storage engine | NO | NO | NO || FEDERATED | YES | FederatedX pluggable storage engine | YES | NO | YES || PERFORMANCE_SCHEMA | YES | Performance Schema | NO | NO | NO || Aria | YES | Crash-safe tables with MyISAM heritage | NO | NO | NO |+--------------------+---------+----------------------------------------------------------------------------+--------------+------+------------+10 rows in set (0.00 sec)
到此CentOS 7 CPanel 服务器上安装 MariaDB 10的分享结束,大家可以优雅的享受MariaDB 10了。
感谢你的阅读,相信你对“如何在CentOS 7 CPanel服务器上安装MariaDB 10”这一问题有一定的了解,快去动手实践吧,如果想了解更多相关知识点,可以关注亿速云网站!小编会继续为大家带来更好的文章!
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。