마리아디비에서 발생했던 문제와 해결책을 기록해 둡니다.
서비스 시작 안됨
갑자기 시스템 종료가 되지 않더니, 아래와 같은 오류가 생기면서 서비스가 기동하지 않습니다.
[ERROR] Found 1 prepared transactions! It means that mysqld was not shut down properly last time and critical recovery information (last binlog or tc.log file) was manually deleted after a crash. You have to start mysqld with --tc-heuristic-rec
다음 명령으로 오류를 수정하고 서비스를 시작할 수 있습니다.
- sudo mysqld --tc-heuristic-recover=ROLLBACK
anacron 오류 메시지 : 시스템 설치 후에 이전의 mysql의 테이블을 가져와서 접근하면, anacron으로부터 다음과 같은 메시지가 도착합니다.
mysqladmin: connect to server at 'localhost' failed error: 'Access denied for user 'root'@'localhost' (using password: NO)'
이 문서의 내용에 따라 처리해 줍니다.
- sudo systemctl stop mysql
- sudo mysqld_safe --skip-grant-tables &
- mysql -u root
MariaDB [mysql]> use mysql;
MariaDB [mysql]> update user set password=PASSWORD("NEW-ROOT-PASSWORD") where User='root';
MariaDB [mysql]> flush privileges;
MariaDB [mysql]> quit
- sudo killall mysqld_safe
- sudo systemctl start mysql
cron에서 오류
크론에서 다음 오류가 생깁니다:
/etc/cron.daily/logrotate: logrotate_script: 3: [: /var/run/mysqld/mysqld.pid: unexpected operator
여기서 정보를 확인할 수 있습니다. 다음 파일을 수정하십시오.
- sudo nano /etc/logrotate.d/mysql-server
if [ -f `my_print_defaults --mysqld | grep -oPm1 "pid-file=\K[^$]+"` ]; then
서비스 시작 안됨
위의 서비스 시작 안됨과 같은 오류로 보입니다.
시스템 종료시에 mariadb가 정상적으로 종료되지 않아서, 파워 버튼으로 강제 종료한 후에 다음 메시지가 나옵니다.
[ERROR] Found 1 prepared transactions! It means that mysqld was not shut down properly last time and critical recovery information
우선, 부팅시에 /etc/mysql/my.conf에 다음을 추가해서
innodb_force_recovery = 5
로그를 무시하고 서비스를 시작합니다. 그러나, 데이터베이스를 mysqlcheck를 통해서 repair를 해도 같은 메시지가 출력됩니다.
다시 아래의 것을 추가했습니다.
tc-heuristic-recover=COMMIT or tc-heuristic-recover=ROLLBACK
이것을 추가하고 서비스를 시작하면 서비스는 시작되지 않지만, 해당 오류가 수정되는 것으로 보입니다. 이 줄을 제거하고 시작하면 정상적으로 서비스가 시작됩니다.
시스템 업데이트
시스템 패키지 업데이트 중에 다음 메시지가 출력됩니다.
N: Skipping acquire of configured file 'main/binary-i386/Packages' as repository 'http://ftp.kaist.ac.kr/mariadb/repo/10.4/ubuntu bionic InRelease' doesn't support architecture 'i386'
아래와 같이 원하는 아키텍츠를 적어줄 수 있습니다.
deb [arch=amd64] http://ftp.kaist.ac.kr/mariadb/repo/10.4/ubuntu bionic main
위키 접근 오류
갑자기 위키 지면이 접근이 되지 않는 문제가 생겼습니다. 다음과 같이 점검을 했습니다.
- ifconfig
- nslookup dawoum.duckdns.org
우선 도메인 이름이 정상적으로 ip 주소로 바뀌는지 확인을 했습니다.
- ping -c 3 dawoum.duckdns.org
핑이 제대로 동작하는지 확인을 했습니다.
- sudo systemctl status nginx
- sudo systemctl status php7.1-fpm
- sudo systemctl status mysql
오류가 mariadb 데이터베이스에서 생겼습니다. 다음과 같은 오류가 사용하는 mysql과 wikidb 데이터베이스에서 발생을 합니다.
InnoDB: Column last_update in table `mysql`.`innodb_table_stats` is INT UNSIGNED NOT NULL but should be BINARY(4) NOT NULL (type mismatch).
Mariadb 업데이트를 하면서 정상적으로 이루어졌으나, 일부 테이블에서 업데이트가 정상적으로 이루어지지 않았습니다. 먼저 mariadb에 접근하는 것을 차단하고, 다음과 같이 조치해 줍니다.
- sudo systemctl stop nginx
- sudo systemctl stop php7.1-fpm
- mysqldump -u root -p --events --quick --single-transaction mysql > mysql-dump.sql
- sudo mysql -u root -p mysql < mysql-dump.sql
데이터에이스에 접근을 하셔서 모든 데이터베이스를 위와 같이 조치해 주어야 합니다. 이제 새롭게 서비스를 시작합니다.
- sudo systemctl restart mysql
- sudo systemctl start nginx
- sudo systemctl start php7.1-fpm
데이터베이스 접근 오류
가상 기계에 있는 우분투에서 판올림 후에 갑자기 아래와 같은 오류가 생겼습니다.
- mysql -u root -p
ERROR 1524 (HY000): Plugin 'unix_socket' is not loaded
인증과 관련된 플럭-인이 설치가 되지 않아서 그렇습니다. 인증에는 unix_socket 플럭-인을 이용하는 방법이 있고, mysql_native_password 플럭-인을 이용하는 방법이 있습니다. 2번째 플럭-인을 설치해서 인증 오류를 해결해 보겠습니다.
먼저 데이터베이스를 중지하고, 인증 없이 데이터베이스에 접근하도록 데이터베이스 서버스를 시작합니다.
- sudo systemctl stop mysql
- sudo mysqld_safe --skip-grant-tables &
데이터베이스에 접근해서 root 사용자의 인증 플럭-인을 확인해 봅니다.
- mysql -u root
MariaDB [(none)]> select Host,User,plugin from mysql.user where User='root';
결과가 unix_socket이라고 나올 것입니다. 이제 새로운 플럭-인을 사용하도록 바꾸고, 암호가 바꾸어줍니다.
newpassword를 새로운 암호로 대체합니다.
- mysql -u root
MariaDB [(none)]> update mysql.user set plugin='mysql_native_password';
MariaDB [(none)]> update mysql.user set password=PASSWORD("newpassword") where User='root';
MariaDB [(none)]> flush privileges;
MariaDB [(none)]> quit;
서비스를 중지하고 새롭게 데이터베이스를 기동해서, 데이터베이스에 접근해 봅니다.
- sudo kill -9 $(pgrep mysql)
- sudo systemctl start mysql
- mysql -u root -p