2020年4月17日金曜日

CentOS8 mariaDBインストール

 ※Status code: 404 for https://dlm.mariadb.com/repo/mariadb-server/10.7....
 → Ver.10 サポート切れ!!
# dnf remove MareaDB-client
# curl -sS https://downloads.mariadb.com/MariaDB/mariadb_repo_setup | bash
# dnf install MariaDB-client

# dnf install MariaDB-server  MariaDB-devel
# mysql_upgrade --user=root --password=password

※ ERROR
- Downloading successful, but checksum doesn't match. Calculated
→ dnf --nogpgcheck install xxxx  / update

※ERROR
dnf install OpenIPMI-libs
dnf install mariadb-connector-odbc

※ERROR
正しい鍵 URL がこのリポジトリー用に設定されているか確認してください。. 失敗したパッケージは: MariaDB-client-10.7.8-1.el8.x86_64
→rpm --import https://yum.mariadb.org/RPM-GPG-KEY-MariaDB


【CentOS8 にMariaDBの最新版をインストール】

【マウントした他ディスクにデータを置く場合。】
/u01にデータを格納するディスクをあらかじめマウント
# midir /u01
# vi /etc/fstab

/dev/vdb /u01 ext4 defaults
# sync;reboot
# mkdir -p /u01/MariaDB/mysql_data
# mkdir -p /u01/MariaDB/log
# touch /u01/MariaDB/log/mariadb_error.log

# curl -sS https://downloads.mariadb.com/MariaDB/mariadb_repo_setup | sudo bash
※プロキシ環境で上手く行かなかったので、wgetでダウンロードした後にbashで実行。
# cat /etc/yum.repos.d/mariadb.repo
[mariadb-main]
name = MariaDB Server
baseurl = https://downloads.mariadb.com/MariaDB/mariadb-10.5/yum/rhel/$releasever/$basearch
gpgkey = file:///etc/pki/rpm-gpg/MariaDB-Server-GPG-KEY
gpgcheck = 1
enabled = 1
module_hotfixes = 1

[mariadb-maxscale]
# To use the latest stable release of MaxScale, use "latest" as the version
# To use the latest beta (or stable if no current beta) release of MaxScale, use "beta" as the version
name = MariaDB MaxScale
baseurl = https://dlm.mariadb.com/repo/maxscale/latest/centos/$releasever/$basearch
gpgkey = file:///etc/pki/rpm-gpg/MariaDB-MaxScale-GPG-KEY
gpgcheck = 1
enabled = 1

[mariadb-tools]
name = MariaDB Tools
baseurl = https://downloads.mariadb.com/Tools/rhel/$releasever/$basearch
gpgkey = file:///etc/pki/rpm-gpg/MariaDB-Enterprise-GPG-KEY
gpgcheck = 1
enabled = 1


# dnf remove mysql*
# dnf remove Mariadb*

# dnf install MariaDB

# chown -R mysql:mysql /u01/MariaDB
# chown -R mysql:mysql /u01

# vi  /etc/my.cnf.d/server.cnf 
[mariadb]
character-set-server=utf8
log_error = /u01/MariaDB/log/mariadb_error.log
datadir   = /u01/MariaDB/mysql_data/

[mariadb-10.5]
character-set-server=utf8

# mv /var/lib/mysql/* /u01/MariaDB/mysql_data/

# systemctl start mariadb
# systemctl enable mariadb

# mysql -u root
MariaDB [(none)]>  alter user root@localhost identified by 'password';

※ amazon linux では syntax error
→set password for root@localhost = password('password');

(リモートアクセス用 ユーザの作成)
MariaDB [(none)]>  create user admin@'%';
MariaDB [(none)]> grant all privileges on *.* to admin@'%'  with grant option;
MariaDB [(none)]> alter user admin@'%'  identified by 'password';
※amazon linux では syntax error
→ set password for  admin@'%' =password('password');
MariaDB [(none)]> flush privileges;

※ 「@'%'」省略可

(ローカルアクセス用ユーザの作成)
MariaDB [(none)]>  create user admin@localhost;
MariaDB [(none)]> grant all privileges on *.* to admin@localhost  with grant option;
MariaDB [(none)]> alter user admin@localhost  identified by 'password';
MariaDB [(none)]> flush privileges;

MariaDB [(none)]> select user, host, plugin from mysql.user;
+-----------------+-------------+----------------------------------+
| User                   | Host          | plugin                                       |
+-----------------+-------------+----------------------------------+
| mariadb.sys  | localhost  | mysql_native_password  |
| root                   | localhost  | mysql_native_password  |
| mysql               | localhost  | mysql_native_password  |
|                            | localhost   |                                                     |
|                            | rocky           |                                                     |
| admin              | %                  | mysql_native_password |
| admin              | localhost   | mysql_native_password |
+-----------------+---------------+---------------------------------+
7 rows in set (0.001 sec)

MariaDB [(none)]> quit

※リモートアクセスとローカルアクセスの入り口を持つ各ユーザを作成。

# mysql -u admin -ppassword
MariaDB [(none)]> create database testdb;
MariaDB [(none)]> quit

【※】
# systemctl start mariadb
Job for mariadb.service failed because the control process exited with error code. See "systemctl status mariadb.service" and "journalctl -xe" for details.
# journalctl -xe
[ERROR] Could not open mysql.plugin table: "Table 'mysql.plugin' doesn't exist". Some plugins may be not loaded
Failed to start MariaDB 10.5.8 database server.

→データベースのアップグレードが必要そう。
  今回は、面倒臭いので、
# systemctl stop mysqld
# dnf remove MariaDB*
# dnf remove mysql*
# mv /usr/lib/mysql /usr/lib/mysql.old 
してから、mariadbを再インストール


【CentOS8 にMariaDB Repositoryからインストール】

CentOS8にMariaDB インストールは、下記を参照

RHEL 8 / CentOS 8 で MariaDB Package Repository を設定



---------------------------------------------------------------------------------------------------------------
# dnf list maria*          #インストール状況確認
# dnf info mariadb-server mariadb mariadb-devel
# dnf install -y mariadb-server mariadb mariadb-devel
# dnf list installed | grep mariadb
# systemctl start mariadb
# systemctl enable mariadb
# systemctl status mariadb

8/3下記問題は発生しなかった。
---------------------------------------------------------------------------------------------------------------
エラーで起動できない。
[Warning] Could not increase number of max_open_files to more than 1024 (request: 4206)
[Warning] Changed limits: max_open_files: 1024  max_connections: 151 (was 151)  table_cache: 421 (was 2000)

#  mkdir /etc/systemd/system/mariadb.service.d
# vi /etc/systemd/system/mariadb.service.d/limits.conf
[Service]
LimitNOFILE=5000

上記エラーは解消されたが、起動しない。
4月 17 16:50:30 libra.jp mysql-prepare-db-dir[12739]: Database MariaDB is probably initialized in /var/lib/mysql already, nothing is done.
 4月 17 16:50:30 libra.jp mysql-prepare-db-dir[12739]: If this is not the case, make sure the /var/lib/mysql is empty before running mysql-prepare-db-dir.
 4月 17 16:50:30 libra.jp mysqld[12779]: 2020-04-17 16:50:30 0 [Note] /usr/libexec/mysqld (mysqld 10.3.17-MariaDB) starting as process 12779 ...
 4月 17 16:50:32 libra.jp systemd[1]: mariadb.service: Main process exited, code=exited, status=1/FAILURE
 4月 17 16:50:32 libra.jp systemd[1]: mariadb.service: Failed with result 'exit-code'.
 4月 17 16:50:32 libra.jp systemd[1]: Failed to start MariaDB 10.3 database server.
-- Subject: Unit mariadb.service has failed

PCの再起動で解消????
-------------------------------------------------------------------------------------------------------------------
$ mysql -u root
>  select user, host from mysql.user;
> create user admin;
> grant all privileges on *.* to admin identified by 'password';
> alter user root@localhost identified by 'password';
or
> create user admin@libre.com identified by 'password';
※version 10.3.17  20200804追記





【CentOS7 にMariaDBの最新版をインストール】

# curl -sS https://downloads.mariadb.com/MariaDB/mariadb_repo_setup | sudo bash
※プロキシ環境で上手く行かなかったので、wgetでダウンロードした後にbashで実行。

# yum remove mysql*
# yum remove Mariadb*

# yum install MariaDB

# vi  /etc/my.cnf.d/server.cnf 
[mariadb]
character-set-server=utf8
[mariadb-10.5]
character-set-server=utf8

# systemctl enable mariadb
# systemctl start mariadb

# mysql -u root
MariaDB [(none)]>  alter user root@localhost identified by 'password';
MariaDB [(none)]>  create user admin@localhost identified by 'password';
MariaDB [(none)]> grant all privileges on *.* to admin@localhost  with grant option;
MariaDB [(none)]> alter user admin@localhost identified by 'password';
MariaDB [(none)]> flush privileges;
MariaDB [(none)]> quit
# mysql -u admin -p
MariaDB [(none)]> create database testdb;
MariaDB [(none)]> quit

【※】
# systemctl start mariadb
Job for mariadb.service failed because the control process exited with error code. See "systemctl status mariadb.service" and "journalctl -xe" for details.
# journalctl -xe
[ERROR] Could not open mysql.plugin table: "Table 'mysql.plugin' doesn't exist". Some plugins may be not loaded
Failed to start MariaDB 10.5.8 database server.

→データベースのアップグレードが必要そう。
  今回は、面倒臭いので、
# systemctl stop mysqld
# yum remove MariaDB*
# yum remove mysql*
# mv /usr/lib/mysql /usr/lib/mysql.old 
してから、mariadbを再インストール



0 件のコメント:

コメントを投稿

zabbix7 amazon linux2023 インストール postgres15

【postgres】 dnf -y install postgresql15-server postgresql15-server-devel postgresql-setup initdb passwd postgres vi `find / -name pg_hba.con...