Red Hat Enterprise Linux 7 Betaã«ãããMariaDB 5.5ã®æ§æ
MySQL Casual Advent Calendar 2013ã®14æ¥ç®ã§ãã
2013å¹´12æ11æ¥ã«Red Hat Enterprise Linux 7 Betaããªãªã¼ã¹ããã¾ããã以åããåããã¦ããã¨ãããRHEL 7ã§ã¯MySQLã§ã¯ãªãMariaDBãæ¡ç¨ããã¦ãã¾ããæ¬æ¥ã¯ãRHEL 7 Betaã«ããã¦MariaDBãã©ã®ãããªæ§æã«ãªã£ã¦ããã®ããç°¡åã«ç¢ºèªãã¦ããããã¨æãã¾ãã
ããã±ã¼ã¸æ§æ
MariaDBé¢é£ããã±ã¼ã¸ã¯13åç¨æããã¦ãã¾ãã
mariadb-bench.x86_64 : MariaDB benchmark scripts and data mariadb-devel.i686 : Files for development of MariaDB/MySQL applications mariadb-devel.x86_64 : Files for development of MariaDB/MySQL applications mariadb-embedded-devel.i686 : Development files for MariaDB as an embeddable library mariadb-embedded-devel.x86_64 : Development files for MariaDB as an embeddable library mariadb-embedded.i686 : MariaDB as an embeddable library mariadb-embedded.x86_64 : MariaDB as an embeddable library mariadb-libs.i686 : The shared libraries required for MariaDB/MySQL clients mariadb-libs.x86_64 : The shared libraries required for MariaDB/MySQL clients mariadb-server.x86_64 : The MariaDB server and related files mariadb-test.x86_64 : The test suite distributed with MariaD mariadb.i686 : A community developed branch of MySQL mariadb.x86_64 : A community developed branch of MySQL
ç¾å¨ã®ãã¼ã¸ã§ã³ã¯5.5.33aã§ãã
åå : mariadb-server ã¢ã¼ããã¯ãã£ã¼ : x86_64 ã¨ãã㯠: 1 ãã¼ã¸ã§ã³ : 5.5.33a ãªãªã¼ã¹ : 3.el7 容é : 55 M ãªãã¸ããªã¼ : installed æä¾å ãªãã¸ããªã¼ : rhel-7-public-beta-rpms è¦ç´ : The MariaDB server and related files URL : http://mariadb.org ã©ã¤ã»ã³ã¹ : GPLv2 with exceptions and LGPLv2 and BSD
以ä¸ã¯æ¯è¼ã®ããã«ç¨æããRHEL 6ã®MySQLé¢é£ããã±ã¼ã¸ã§ããæ§æã¯ã»ã¼åãã§ãã
mysql-bench.x86_64 : MySQL benchmark scripts and data mysql-connector-java.noarch : Official JDBC driver for MySQL mysql-connector-odbc.x86_64 : ODBC driver for MySQL mysql-devel.i686 : Files for development of MySQL applications mysql-devel.x86_64 : Files for development of MySQL applications mysql-embedded-devel.i686 : Development files for MySQL as an embeddable library mysql-embedded-devel.x86_64 : Development files for MySQL as an embeddable library mysql-embedded.i686 : MySQL as an embeddable library mysql-embedded.x86_64 : MySQL as an embeddable library mysql-libs.i686 : The shared libraries required for MySQL clients mysql-libs.x86_64 : The shared libraries required for MySQL clients mysql-server.x86_64 : The MySQL server and related files mysql-test.x86_64 : The test suite distributed with MySQL mysql.x86_64 : MySQL client programs and shared libraries
ãã¤ã³ãã¨ãã¦ãRHEL 7ã«ããã¦ãJDBCãã©ã¤ãã¨ODBCãã©ã¤ãã«ã¤ãã¦ã¯æ¬å®¶ã®ãã©ã¤ãããã³ãã«ããã¦ããç¹ãããã¾ãã
åå : mysql-connector-java ã¢ã¼ããã¯ãã£ã¼ : noarch ã¨ãã㯠: 1 ãã¼ã¸ã§ã³ : 5.1.25 ãªãªã¼ã¹ : 2.el7 容é : 1.3 M ãªãã¸ããªã¼ : rhel-7-public-beta-rpms è¦ç´ : Official JDBC driver for MySQL URL : http://dev.mysql.com/downloads/connector/j/ ã©ã¤ã»ã³ã¹ : GPLv2 with exceptions åå : mysql-connector-odbc ã¢ã¼ããã¯ãã£ã¼ : x86_64 ãã¼ã¸ã§ã³ : 5.2.5 ãªãªã¼ã¹ : 2.el7 容é : 141 k ãªãã¸ããªã¼ : rhel-7-public-beta-rpms è¦ç´ : ODBC driver for MySQL URL : http://dev.mysql.com/downloads/connector/odbc/ ã©ã¤ã»ã³ã¹ : GPLv2 with exceptions
MariaDBã§ã¯MariaDB Java Clientã¨ããLGPLã®JDBCãã©ã¤ããéçºããã¦ããã®ã§ããããã¡ãã¯æ¡ç¨ããã¾ããã§ããã
ã¤ã³ã¹ãã¼ã«
mariadb-libsã¯RHEL 6ã®mysql-libsã¨åæ§postfixã¨ã®ä¾åé¢ä¿ããããæå°æ§æã§ãåãããã¤ã³ã¹ãã¼ã«ããã¦ãã¾ãããã¼ã¿ãã¼ã¹ãµã¼ãã¨ãã¦ã¯mariadbãmariadb-develãmariadb-serverãå ãã¦ä½¿ç¨ããããã°ã©ãã³ã°è¨èªã«ãããã¦php-mysqlãperl-DBD-MySQLãMySQL-pythonãªã©ãã¤ã³ã¹ãã¼ã«ãããã¨ã«ãªãã¾ããç¹ã«ãããã©ããã¯ãªãã£ãã®ã§è©³ç´°ã¯å²æãã¾ãã
è¨å®ãã¡ã¤ã«
ã¤ã³ã¹ãã¼ã«ç´å¾ã®/etc/my.cnfã¯ä»¥ä¸ã®ããã«ãªã£ã¦ãã¾ãã
[mysqld] datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock # 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
æå¾ã®è¡ã§/etc/my.cnf.d以ä¸ã®è¨å®ãã¡ã¤ã«ãèªã¿è¾¼ãã§ãã¾ãã追å ã®è¨å®ãã¡ã¤ã«ãèªã¿è¾¼ãæ©è½ã¯ãã¨ãã¨MySQLã«ããããã®ã§ããããã®ãããªæ§æã§ããã±ã¼ã¸ã³ã°ããã¦ããç¹ã¯MariaDBã®ç¬èªæ¹éã¨ãªãã¾ãã/etc/my.cnf.dã«ã¯ä»¥ä¸ã®3ãã¡ã¤ã«ãé ç½®ããã¦ãã¾ãã
- client.cnf
- mysql-clients.cnf
- server.cnf
ãããã¯ããããæä¾å ã®ããã±ã¼ã¸ãç°ãªã£ã¦ãããclient.cnfã¯mariadbãmysql-clients.cnfã¯mariadb-libsãserver.cnfã¯mariadb-serverããã®ãã®ã¨ãªã£ã¦ãã¾ããRHEL 6ã®MySQL 5.1ã§ã¯mysql-libsãæä¾ããmy.cnfã«ãµã¼ãã®è¨å®ãè¨è¿°ãã¦ããããã§ãããä»åããã±ã¼ã¸ãã¨ã«è¨å®ãã¡ã¤ã«ãåé¢ããã¦ããç¹ã¯ãä¸åº¦è¦ãã¦ãã¾ãã°ã¾ãåççããªã¨æãã¾ãã
ãµã¼ãã¹ã®èµ·åã¨åæ¢
ãåç¥ã®æ¹ãå¤ãã¨æãã¾ãããRHEL 7ããã¯ãµã¼ãã¹ãsystemdã§ç®¡çããããã«ãªãã¾ããã
# systemctl start mariadb.service # systemctl status mariadb.service mariadb.service - MariaDB database server Loaded: loaded (/usr/lib/systemd/system/mariadb.service; disabled) Active: active (running) since å 2013-12-14 00:56:54 JST; 46s ago Process: 11180 ExecStartPost=/usr/libexec/mariadb-wait-ready $MAINPID (code=exited, status=0/SUCCESS) Process: 11106 ExecStartPre=/usr/libexec/mariadb-prepare-db-dir %n (code=exited, status=0/SUCCESS) Main PID: 11179 (mysqld_safe) CGroup: /system.slice/mariadb.service tq11179 /bin/sh /usr/bin/mysqld_safe --basedir=/usr mq11342 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin -... 12æ 14 00:56:52 k03rhel7b.local mariadb-prepare-db-dir[11106]: The latest information about MariaDB is available...g/. 12æ 14 00:56:52 k03rhel7b.local mariadb-prepare-db-dir[11106]: You can find additional information about the MyS...at: 12æ 14 00:56:52 k03rhel7b.local mariadb-prepare-db-dir[11106]: http://dev.mysql.com 12æ 14 00:56:52 k03rhel7b.local mariadb-prepare-db-dir[11106]: Support MariaDB development by buying support/new...rom 12æ 14 00:56:52 k03rhel7b.local mariadb-prepare-db-dir[11106]: Monty Program Ab. You can contact us about this a...om. 12æ 14 00:56:52 k03rhel7b.local mariadb-prepare-db-dir[11106]: Alternatively consider joining our community base...rt: 12æ 14 00:56:52 k03rhel7b.local mariadb-prepare-db-dir[11106]: http://kb.askmonty.org/en/contributing-to-the-mar...ct/ 12æ 14 00:56:52 k03rhel7b.local mysqld_safe[11179]: 131214 00:56:52 mysqld_safe Logging to '/var/log/mariadb/ma...og'. 12æ 14 00:56:52 k03rhel7b.local mysqld_safe[11179]: 131214 00:56:52 mysqld_safe Starting mysqld daemon with dat...ysql 12æ 14 00:56:54 k03rhel7b.local systemd[1]: Started MariaDB database server. Hint: Some lines were ellipsized, use -l to show in full.
systemdã§ã¯cgroupsãç¨ãã¦ãµã¼ãã¹ãã¨ã«ãªã½ã¼ã¹ã管çã§ããããã«ãªã£ã¦ãã¾ããRDBMSã¯ç¹ã«ãªã½ã¼ã¹æ¶è²»éã®å¤ãã½ããã¦ã§ã¢ã§ããããä»å¾ãã¦ãã¦ãèç©ãã¦ãããã¨ã§éç¨ã§å©ããå ´é¢ãåºã¦ãããã¨æãã¾ããä¸ååã«åºã¦ãããã°ã¯ãMariaDBã®ã¨ã©ã¼ãã°ã§ã¯ãªãOSã®syslogã§ãã
ãã¡ã¤ã¢ã¦ã©ã¼ã«
RHEL 7ããã¯firewalldã§ãã¡ã¤ã¢ã¦ã©ã¼ã«ã管çããããã«ãªãã¾ããã®ã§ããããè¦ããå¿ è¦ãããã¾ããåæç¶æ ã§ã¯ãMariaDBã«æ¥ç¶ããããã®TCP3306çªã¯éãããã¦ãã¾ãã
# firewall-cmd --add-service=mysql success # firewall-cmd --permanent --add-service=mysql success # firewall-cmd --list-services dhcpv6-client mysql ssh # firewall-cmd --permanent --list-services dhcpv6-client mysql ssh
ãµã¼ãã¹ã®å®ç¾©ãã¡ã¤ã«ã¯/usr/lib/firewalld/servicesã«æ ¼ç´ããã¦ãã¾ãã
# cat /usr/lib/firewalld/services/mysql.xml <?xml version="1.0" encoding="utf-8"?> <service> <short>MySQL</short> <description>MySQL Database Server</description> <port protocol="tcp" port="3306"/> </service>
SELinux
SELinuxã«ã¤ãã¦ã¯RHEL 7ã§å¤§ããå¤ãã£ãã¨ããã¯ãªãã¨æãã¾ãããã ãã¤ã¾ã§ãPermissiveãDisabledã«ãã¦ããã®ãé²æ©ããªãã§ãã®ã§ããã®æ©ä¼ã«å ¸åçãªããããã¿ã¼ã³ããç´¹ä»ãã¦ããã¾ããSELinuxã®ããªã·ã¼éåãsyslogã«åºåããããã«ããããããsetroubleshootãsetroubleshoot-serverãã¤ã³ã¹ãã¼ã«ãã¦ãããã¨ããããããã¾ãã
datadirã®å¤æ´
MySQLã§ãMariaDBã§ãdatadirã®ããã©ã«ãå¤ã¯/var/lib/mysqlã§ãããããå®éã«ã¯ã¹ãã¬ã¼ã¸ãå¢è¨ãã¦å¥ã®ãã£ã¬ã¯ããªã使ç¨ãããã¨ãå¤ãã¨æãã¾ãããã®ã¨ãã«ããééããã¨ã©ã¼ã以ä¸ã®ãã®ã§ãã
# systemctl start mariadb.service Job for mariadb.service failed. See 'systemctl status mariadb.service' and 'journalctl -xn' for details. # less /var/log/messages Dec 14 02:05:11 k03rhel7b mariadb-prepare-db-dir: Initializing MySQL database Dec 14 02:05:11 k03rhel7b mariadb-prepare-db-dir: Installing MariaDB/MySQL system tables in '/opt/mysql' ... Dec 14 02:05:11 k03rhel7b mariadb-prepare-db-dir: 131214 2:05:11 [Warning] Canât create test file /opt/mysql/k03rhel7b.lower-test Dec 14 02:05:11 k03rhel7b mariadb-prepare-db-dir: 131214 2:05:11 [ERROR] mysqld: Canât create/write to file '/opt/mysql/aria_log_control' (Errcode: 13) ⦠Dec 14 02:05:11 k03rhel7b setroubleshoot: SELinux is preventing /usr/libexec/mysqld from write access on the directory mysql. For complete SELinux messages. run sealert -l 678a1882-4c2c-43bd-8d50-b515db579e95 # perror 13 OS error code 13: Permission denied
ãã£ã¬ã¯ããªã®ææè ãã¢ã¯ã»ã¹æ¨©éã確èªãã¦ãåé¡ãè¦ã¤ãããªãã¨ãã¯ãSELinuxã®ãã¨ãæãåºãã¦ãã ãããsetroubleshoot-serverãã¤ã³ã¹ãã¼ã«ããã¦ããªãã¨ç¸å½ãããã¨æãã¾ãã
# sealert -l 678a1882-4c2c-43bd-8d50-b515db579e95 SELinux is preventing /usr/libexec/mysqld from write access on the directory mysql. ***** Plugin catchall_labels (83.8 confidence) suggests ******************* If you want to allow mysqld to have write access on the mysql directory Then mysql ã®ã©ãã«ãå¤æ´ããå¿ è¦ãããã¾ã Do # semanage fcontext -a -t FILE_TYPE 'mysql' ãã® FILE_TYPE 以ä¸ã®ã©ããã§ã: mysqld_db_t, mysqld_log_t, mysqld_tmp_t, mysqld_var_run_t, tmp_t, var_lib_t, var_log_t, var_run_t. 次ã«ãããå®è¡ãã¦ãã ãã: restorecon -v 'mysql' â¦
翻訳ãå°ã æªããã§ãããSELinuxãæå¹ãªå ´åãMySQL/MariaDBãã¢ã¯ã»ã¹ãããã¡ã¤ã«ã«ã¯é©åãªSELinuxã³ã³ããã¹ããä»ä¸ãã¦ããå¿ è¦ãããã¾ãã
# ls -lZ drwxr-xr-x. mysql mysql unconfined_u:object_r:usr_t:s0 mysql # semanage fcontext -a -t mysqld_db_t '/opt/mysql(/.*)?' # cat /etc/selinux/targeted/contexts/files/file_contexts.local /opt/mysql(/.*)? system_u:object_r:mysqld_db_t:s0 # restorecon -RFv /opt/mysql restorecon reset /opt/mysql context unconfined_u:object_r:usr_t:s0->system_u:object_r:mysqld_db_t:s0 # ls -lZ drwxr-xr-x. mysql mysql system_u:object_r:mysqld_db_t:s0 mysql # systemctl start mariadb.service # mysql -u root -e "SHOW GLOBAL VARIABLES LIKE 'datadir'" +---------------+-------------+ | Variable_name | Value | +---------------+-------------+ | datadir | /opt/mysql/ | +---------------+-------------+
TCPãã¼ãçªå·ã®å¤æ´
TCPãã¼ãçªå·ãSELinuxã®ç®¡çä¸ã«ããã¾ãã
# systemctl start mariadb.service Job for mariadb.service failed. See 'systemctl status mariadb.service' and 'journalctl -xn' for details. # less /var/log/mariadb/mariadb.log 131214 2:29:12 [ERROR] Canât start server: Bind on TCP/IP port. Got error: 13: Permission denied 131214 2:29:12 [ERROR] Do you already have another mysqld server running on port: 3307 ? 131214 2:29:12 [ERROR] Aborting # less /var/log/messages Dec 14 02:29:13 k03rhel7b setroubleshoot: SELinux is preventing /usr/libexec/mysqld from name_bind access on the tcp_socket . For complete SELinux messages. run sealert -l e459c5fc-2734-459b-8945-501644f238d5 # sealert -l e459c5fc-2734-459b-8945-501644f238d5 ***** Plugin bind_ports (92.2 confidence) suggests ************************ If you want to allow /usr/libexec/mysqld to bind to network port 3307 Then you need to modify the port type. Do # semanage port -a -t mysqld_port_t -p tcp 3307 ⦠# semanage port -a -t mysqld_port_t -p tcp 3307 # cat /etc/selinux/targeted/modules/active/ports.local portcon tcp 3307 system_u:object_r:mysqld_port_t:s0 # systemctl start mariadb.service # mysql -u root -e "SHOW GLOBAL VARIABLES LIKE 'port'" +---------------+-------+ | Variable_name | Value | +---------------+-------+ | port | 3307 | +---------------+-------+
ããã«ãå ã»ã©ãç´¹ä»ãããã¡ã¤ã¢ã¦ã©ã¼ã«ã®è¨å®ãå¿ è¦ã§ãã
# cd /etc/firewalld/services # cp /usr/lib/firewalld/services/mysql.xml mysql3307.xml # vim mysql3307.xml # cat mysql3307.xml <?xml version="1.0" encoding="utf-8"?> <service> <short>MySQL 3307</short> <description>MySQL Database Server 3307</description> <port protocol="tcp" port="3307"/> </service> # firewall-cmd --reload success # firewall-cmd --add-service=mysql3307 success # firewall-cmd --permanent --add-service=mysql3307 success $ mysql -h k03rhel7b -P 3307 -u scott -p Enter password: Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 15 Server version: 5.5.33a-MariaDB MariaDB Server Copyright (c) 2000, 2013, Oracle, Monty Program Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]>
ããã¯ãããç²ããã¾ã§ãããMySQLãMariaDBãã¨ããããããã¾ãRHEL 7ã®ä½¿ãæ¹ãè¦ããã®ã«æéããããããã§ããææ¥ã¯@tmtmsããã§ãã