欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

MySQL運(yùn)維實(shí)戰(zhàn)使用RPM進(jìn)行安裝部署

 更新時(shí)間:2023年12月21日 15:00:14   作者:云掣科技  
這篇文章主要為大家介紹了MySQL運(yùn)維實(shí)戰(zhàn)使用RPM進(jìn)行安裝部署實(shí)現(xiàn)示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪

MySQL使用RPM安裝部署

我們?cè)谏a(chǎn)環(huán)境部署mysql時(shí),一般很少使用RedHat Package Manager(RedHat軟件包管理工具)。用rpm或或者其他包管理器安裝mysql有其好處,例如安裝簡(jiǎn)單,并且許多系統(tǒng)可能已經(jīng)自帶了某個(gè)版本的MySQL。

當(dāng)然,使用RPM安裝也存在一些缺點(diǎn):

  • 1、rpm依賴包的問(wèn)題。如果刪除線上機(jī)器的沖突包,可能引起其他軟件運(yùn)行異常。
  • 2、多版本管理不方便。升級(jí)mysql或降級(jí)mysql不方便。無(wú)法多個(gè)版本同時(shí)運(yùn)行。
  • 3、單機(jī)多實(shí)例管理不方便。

但是,對(duì)于我們數(shù)據(jù)庫(kù)管理員,需要掌握如何使用rpm包安裝mysql。因?yàn)楹芸赡苄枰幚碛眠@種方式安裝的mysql遇到的一些問(wèn)題,如數(shù)據(jù)庫(kù)無(wú)法啟動(dòng)、默認(rèn)路徑空間占滿,需要將數(shù)據(jù)需要換到別的磁盤、調(diào)整參數(shù)等。

1 環(huán)境

CentOS 7.9

[root@box1 software]# cat /etc/redhat-release
CentOS Linux release 7.9.2009 (Core)
[root@box1 software]# uname -a
Linux box1 3.10.0-1160.el7.x86_64 #1 SMP Mon Oct 19 16:18:59 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

2 RPM安裝

2.1下載RPM安裝包

到官網(wǎng)https://dev.mysql.com/downloads/mysql/下載社區(qū)版,歷史版本點(diǎn)擊“Archives”下載。

建議選擇下載 RPM Bundle包,里面包含了需要的各個(gè)rpm包解壓bundle包,可以看到里面的rpm包

# tar xf mysql-5.7.44-1.el7.x86_64.rpm-bundle.tar -C rpm/5.7/
#
[root@box1 5.7]# ls -lh
總用量 1.1G
-rw-r--r--. 1 root root  518M 9月  25 2020 mysql-5.7.32-1.el7.x86_64.rpm-bundle.tar
-rw-r--r--. 1 7155 31415  26M 9月  25 2020 mysql-community-client-5.7.32-1.el7.x86_64.rpm
-rw-r--r--. 1 7155 31415 308K 9月  25 2020 mysql-community-common-5.7.32-1.el7.x86_64.rpm
-rw-r--r--. 1 7155 31415 3.8M 9月  25 2020 mysql-community-devel-5.7.32-1.el7.x86_64.rpm
-rw-r--r--. 1 7155 31415  46M 9月  25 2020 mysql-community-embedded-5.7.32-1.el7.x86_64.rpm
-rw-r--r--. 1 7155 31415  23M 9月  25 2020 mysql-community-embedded-compat-5.7.32-1.el7.x86_64.rpm
-rw-r--r--. 1 7155 31415 125M 9月  25 2020 mysql-community-embedded-devel-5.7.32-1.el7.x86_64.rpm
-rw-r--r--. 1 7155 31415 2.4M 9月  25 2020 mysql-community-libs-5.7.32-1.el7.x86_64.rpm
-rw-r--r--. 1 7155 31415 1.3M 9月  25 2020 mysql-community-libs-compat-5.7.32-1.el7.x86_64.rpm
-rw-r--r--. 1 7155 31415 174M 9月  25 2020 mysql-community-server-5.7.32-1.el7.x86_64.rpm
-rw-r--r--. 1 7155 31415 120M 9月  25 2020 mysql-community-test-5.7.32-1.el7.x86_64.rpm

2.2安裝rpm包

需要安裝mysql-community-server, mysql-community-common, mysql-community-client, mysql-community-libs這些包

[root@box1 5.7]# rpm -ivh mysql-community-client-5.7.32-1.el7.x86_64.rpm mysql-community-common-5.7.32-1.el7.x86_64.rpm mysql-community-server-5.7.32-1.el7.x86_64.rpm mysql-community-libs-5.7.32-1.el7.x86_64.rpm
警告:mysql-community-client-5.7.32-1.el7.x86_64.rpm: 頭V3 DSA/SHA1 Signature, 密鑰 ID 5072e1f5: NOKEY
錯(cuò)誤:依賴檢測(cè)失敗:
    mariadb-libs 被 mysql-community-libs-5.7.32-1.el7.x86_64 取代

2.3卸載沖突的包

安裝報(bào)錯(cuò),因?yàn)橄到y(tǒng)里已經(jīng)安裝了mariadb相關(guān)lib,需要先將這些lib卸載

[root@box1 5.7]# rpm -qa | grep maria
mariadb-devel-5.5.68-1.el7.x86_64
mariadb-libs-5.5.68-1.el7.x86_64

[root@box1 5.7]# rpm -evf mariadb-devel-5.5.68-1.el7.x86_64 mariadb-libs-5.5.68-1.el7.x86_64
錯(cuò)誤:依賴檢測(cè)失?。?
    libmysqlclient.so.18()(64bit) 被 (已安裝) net-snmp-agent-libs-1:5.7.2-49.el7.x86_64 需要
    libmysqlclient.so.18()(64bit) 被 (已安裝) net-snmp-1:5.7.2-49.el7.x86_64 需要
    libmysqlclient.so.18()(64bit) 被 (已安裝) postfix-2:2.10.1-9.el7.x86_64 需要
    libmysqlclient.so.18()(64bit) 被 (已安裝) qt-mysql-1:4.8.7-8.el7.x86_64 需要
    libmysqlclient.so.18()(64bit) 被 (已安裝) qt5-qtbase-mysql-5.9.7-4.el7.x86_64 需要
    libmysqlclient.so.18()(64bit) 被 (已安裝) qt3-MySQL-3.3.8b-51.el7.x86_64 需要
    libmysqlclient.so.18()(64bit) 被 (已安裝) MySQL-python-1.2.5-1.el7.x86_64 需要
    libmysqlclient.so.18(libmysqlclient_18)(64bit) 被 (已安裝) net-snmp-agent-libs-1:5.7.2-49.el7.x86_64 需要
    libmysqlclient.so.18(libmysqlclient_18)(64bit) 被 (已安裝) postfix-2:2.10.1-9.el7.x86_64 需要
    libmysqlclient.so.18(libmysqlclient_18)(64bit) 被 (已安裝) qt-mysql-1:4.8.7-8.el7.x86_64 需要
    libmysqlclient.so.18(libmysqlclient_18)(64bit) 被 (已安裝) qt5-qtbase-mysql-5.9.7-4.el7.x86_64 需要
    libmysqlclient.so.18(libmysqlclient_18)(64bit) 被 (已安裝) qt3-MySQL-3.3.8b-51.el7.x86_64 需要
    libmysqlclient.so.18(libmysqlclient_18)(64bit) 被 (已安裝) MySQL-python-1.2.5-1.el7.x86_64 需要
    mysql-libs 被 (已安裝) net-snmp-1:5.7.2-49.el7.x86_64 需要

### 加--nodeps強(qiáng)制卸載mariadb lib
[root@box1 5.7]# rpm -ev --nodeps mariadb-devel-5.5.68-1.el7.x86_64 mariadb-libs-5.5.68-1.el7.x86_64
軟件包準(zhǔn)備中...
mariadb-devel-1:5.5.68-1.el7.x86_64
mariadb-libs-1:5.5.68-1.el7.x86_64

卸載完mariadb lib包之后重新安裝

[root@box1 5.7]# rpm -ivh mysql-community-client-5.7.32-1.el7.x86_64.rpm mysql-community-common-5.7.32-1.el7.x86_64.rpm mysql-community-server-5.7.32-1.el7.x86_64.rpm mysql-community-libs-5.7.32-1.el7.x86_64.rpm
警告:mysql-community-client-5.7.32-1.el7.x86_64.rpm: 頭V3 DSA/SHA1 Signature, 密鑰 ID 5072e1f5: NOKEY
準(zhǔn)備中...                          ################################# [100%]
正在升級(jí)/安裝...
   1:mysql-community-common-5.7.32-1.e################################# [ 25%]
   2:mysql-community-libs-5.7.32-1.el7################################# [ 50%]
   3:mysql-community-client-5.7.32-1.e################################# [ 75%]
   4:mysql-community-server-5.7.32-1.e################################# [100%]

2.4安裝完之后的相關(guān)文件

/usr/bin目錄下,主要是mysql相關(guān)的客戶端命令、管理命令

[root@box1 5.7]# ls /usr/bin/mysql*
/usr/bin/mysql        /usr/bin/mysqlcheck           /usr/bin/mysqldump      /usr/bin/mysql_install_db  /usr/bin/mysql_secure_installation  /usr/bin/mysql_ssl_rsa_setup
/usr/bin/mysqladmin   /usr/bin/mysql_config_editor  /usr/bin/mysqldumpslow  /usr/bin/mysql_plugin      /usr/bin/mysqlshow                  /usr/bin/mysql_tzinfo_to_sql
/usr/bin/mysqlbinlog  /usr/bin/mysqld_pre_systemd   /usr/bin/mysqlimport    /usr/bin/mysqlpump         /usr/bin/mysqlslap                  /usr/bin/mysql_upgrade

/usr/sbin

mysqld,mysql服務(wù)器的可執(zhí)行文件

[root@box1 5.7]# ls /usr/sbin/mysql*
/usr/sbin/mysqld  /usr/sbin/mysqld-debug

/usr/lib64/mysql

mysql client lib和plugin lib

[root@box1 5.7]# ls /usr/lib64/mysql/
libmysqlclient.so.20  libmysqlclient.so.20.3.19  mecab  plugin

/usr/share/mysql

主要是mysql字符集和error msg相關(guān)文件

[root@box1 5.7]# ls /usr/share/mysql/
bulgarian  dictionary.txt   estonian              greek                        italian   mysql-log-rotate              mysql_system_tables.sql       polish      serbian  ukrainian
charsets   dutch            fill_help_tables.sql  hungarian                    japanese  mysql_security_commands.sql   mysql_test_data_timezone.sql  portuguese  slovak   uninstall_rewriter.sql
czech      english          french                innodb_memcached_config.sql  korean    mysql_sys_schema.sql          norwegian                     romanian    spanish
danish     errmsg-utf8.txt  german                install_rewriter.sql         magic     mysql_system_tables_data.sql  norwegian-ny                  russian     swedish

/etc/my.cnf

配置文件

/var/lib/mysql

mysql數(shù)據(jù)文件

[root@box1 5.7]# ls /var/lib/mysql*
/var/lib/mysql:
/var/lib/mysql-files:
/var/lib/mysql-keyring:

啟動(dòng)腳本

服務(wù)啟動(dòng)文件 /etc/systemd/system/multi-user.target.wants/mysqld.service

數(shù)據(jù)庫(kù)初始化腳本 /usr/bin/mysqld_pre_systemd

3 啟動(dòng)mysql

使用service 啟動(dòng)mysql實(shí)例

[root@box1 5.7]# service mysqld start
Redirecting to /bin/systemctl start mysqld.service
[root@box1 5.7]# ps -elf | grep mysqld
1 S mysql    12663     1  0  80   0 - 280540 poll_s 08:17 ?       00:00:00 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid
0 S root     12959  2276  0  80   0 - 28206 pipe_w 08:21 pts/0    00:00:00 grep --color=auto mysqld

4 登陸mysql

第一次安裝后,會(huì)生產(chǎn)mysql root賬號(hào)的默認(rèn)的臨時(shí)密碼,可以在/var/log/mysql.log中找到。

用臨時(shí)密碼登陸后,需要修改密碼才能進(jìn)行操作

[root@box1 5.7]# grep -i pass /var/log/mysqld.log
2021-03-31T12:14:47.169374Z 1 [Note] A temporary password is generated for root@localhost: _0eaf&hyQ9Ha
2021-03-31T12:23:26.373529Z 2 [Note] Access denied for user 'root'@'localhost' (using password: NO)
[root@box1 5.7]# mysql -uroot -h127.0.0.1 -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.32
Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> select 1;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
mysql> alter user 'root'@'localhost' identified by 'helloWorld#';
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
mysql> alter user 'root'@'localhost' identified by 'helloWorld#123';
Query OK, 0 rows affected (0.00 sec)
mysql> select now();
+---------------------+
| now()               |
+---------------------+
| 2021-03-31 08:27:57 |
+---------------------+
1 row in set (0.00 sec)

5 關(guān)于mysql初始化

使用service啟動(dòng)mysql時(shí),初次使用mysql,會(huì)執(zhí)行腳本/usr/bin/mysqld_pre_systemd進(jìn)行初始化,
腳本里進(jìn)行了幾個(gè)重要操作

  • 往mysql.plugin里添加validate_password插件
  • 使用mysqld --initialize初始化mysql系統(tǒng)數(shù)據(jù)庫(kù)
  • 使用mysql_ssl_rsa_setup創(chuàng)建ssl證書文件
# more /usr/bin/mysqld_pre_systemd
...
install_validate_password_sql_file () {
    local initfile
    initfile="$(mktemp /var/lib/mysql-files/install-validate-password-plugin.XXXXXX.sql)"
    chmod a+r "$initfile"
    echo "SET @@SESSION.SQL_LOG_BIN=0;" > "$initfile"
    echo "INSERT INTO mysql.plugin (name, dl) VALUES ('validate_password', 'validate_password.so');" >> $initfile
    echo $initfile
}
...
    # If special mysql dir is in place, skip db install
    [ -d "$datadir/mysql" ] && exit 0
    # Create initial db and install validate_password plugin
    initfile="$(install_validate_password_sql_file)"
    /usr/sbin/mysqld ${instance:+--defaults-group-suffix=@$instance} --initialize \
                     --datadir="$datadir" --user=mysql --init-file="$initfile"
    rm -f "$initfile"
    # Generate certs if needed
    if [ -x /usr/bin/mysql_ssl_rsa_setup -a ! -e "${datadir}/server-key.pem" ] ; then
        /usr/bin/mysql_ssl_rsa_setup --datadir="$datadir" --uid=mysql >/dev/null 2>&1
    fi

以上就是MySQL運(yùn)維實(shí)戰(zhàn)使用RPM進(jìn)行安裝部署的詳細(xì)內(nèi)容,更多關(guān)于MySQL RPM安裝部署的資料請(qǐng)關(guān)注腳本之家其它相關(guān)文章!

相關(guān)文章

  • 防止web項(xiàng)目中的SQL注入

    防止web項(xiàng)目中的SQL注入

    這篇文章介紹了防止web項(xiàng)目中的SQL注入,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。需要的朋友可以收藏下,方便下次瀏覽觀看
    2021-12-12
  • mysql簡(jiǎn)單實(shí)現(xiàn)查詢結(jié)果添加序列號(hào)的方法

    mysql簡(jiǎn)單實(shí)現(xiàn)查詢結(jié)果添加序列號(hào)的方法

    這篇文章主要介紹了mysql簡(jiǎn)單實(shí)現(xiàn)查詢結(jié)果添加序列號(hào)的方法,結(jié)合實(shí)例形式演示了2種查詢結(jié)果添加序列號(hào)的技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下
    2016-06-06
  • MYSQL數(shù)據(jù)庫(kù)如何設(shè)置主從同步

    MYSQL數(shù)據(jù)庫(kù)如何設(shè)置主從同步

    大家好,本篇文章主要講的是MYSQL數(shù)據(jù)庫(kù)如何設(shè)置主從同步,感興趣的同學(xué)趕快來(lái)看一看吧,對(duì)你有幫助的話記得收藏一下
    2022-01-01
  • JDBC如何連接mysql

    JDBC如何連接mysql

    這篇文章主要介紹了JDBC如何連接mysql問(wèn)題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2024-04-04
  • MySQL分布式事務(wù)xa的介紹與使用小結(jié)

    MySQL分布式事務(wù)xa的介紹與使用小結(jié)

    xa指的是分布式事務(wù),傳統(tǒng)的事務(wù)針對(duì)的是單機(jī)MySQL,本文主要介紹了MySQL分布式事務(wù)xa的介紹與使用小結(jié),有一定的參考價(jià)值,有需要的朋友可以參考一下,希望對(duì)你有所幫助
    2024-07-07
  • MySQL驅(qū)動(dòng)包下載全過(guò)程

    MySQL驅(qū)動(dòng)包下載全過(guò)程

    這篇文章主要介紹了MySQL驅(qū)動(dòng)包下載全過(guò)程,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2024-05-05
  • mysql CPU高負(fù)載問(wèn)題排查

    mysql CPU高負(fù)載問(wèn)題排查

    這篇文章主要介紹了mysql CPU高負(fù)載問(wèn)題排查的相關(guān)資料,幫助大家更好的理解和使用MySQL,維護(hù)數(shù)據(jù)庫(kù),感興趣的朋友可以了解下
    2020-11-11
  • mysql斷電后無(wú)法啟動(dòng)的問(wèn)題小結(jié)

    mysql斷電后無(wú)法啟動(dòng)的問(wèn)題小結(jié)

    這篇文章主要介紹了mysql斷電后無(wú)法啟動(dòng)的問(wèn)題小結(jié),本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友參考下吧
    2024-04-04
  • 講解MySQL中<=>操作符的用法

    講解MySQL中<=>操作符的用法

    這篇文章主要介紹了講解MySQL中<=>操作符的用法,整理自stackoverflow的相關(guān)實(shí)際問(wèn)題,需要的朋友可以參考下
    2015-04-04
  • MySQL復(fù)制架構(gòu)的搭建及配置過(guò)程

    MySQL復(fù)制架構(gòu)的搭建及配置過(guò)程

    這篇文章主要介紹了MySQL復(fù)制架構(gòu)的相關(guān)知識(shí),本文通過(guò)實(shí)例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2022-02-02

最新評(píng)論