银河麒麟arm编译安装mysql数据库
参考文章
https://blog.csdn.net/baililiushu/article/details/109262794
https://cloud.tencent.com/developer/beta/article/2193032
https://blog.51cto.com/u_6930123/5190766
机器环境:4.19.90-25.4.v2101.ky10.aarch64 (银河麒麟v10 sp2)
数据库版本:mysql-5.7.36
1.查看是否安装mariadb,若是已安装,需要卸载
#要是有,需要卸载[root@localhost zswl]# rpm -qa|grep mariadb mariadb-common-10.3.9-11.p01.ky10.aarch64mariadb-errmessage-10.3.9-11.p01.ky10.aarch64mariadb-connector-c-3.0.6-7.ky10.aarch64mariadb-server-10.3.9-11.p01.ky10.aarch64mariadb-10.3.9-11.p01.ky10.aarch64#卸载mariadb相关[root@localhost zswl]# yum remove mariadb[root@localhost zswl]# rpm -qa|grep mariadb
2.下载源码包,上传解压
wget https://cdn.mysql.com/archives/mysql-5.7/mysql-boost-5.7.36.tar.gz
mysql官方下载地址:https://downloads.mysql.com/archives/community/
如下图,我们要源码编译安装
选择mysql-5.7.36.tar.gz或者mysql-boost-5.7.36.tar.gz(这个MySQL源码包里包含了boost)
如果选择mysql-5.7.36.tar.gz这个源码包,就必须要下载一个boost库包boost_1_59_0.tar(否则预编译时会通不过报错)。
3.yum安装编译所需要的工具和库
[root@localhost mysql-5.7.36]# yum install gcc gcc-c++ cmake ncurses-devel bison openssl-devel rpcgenkylinsp2 217 kB/s | 3.8 kB 00:00 上次元数据过期检查:0:00:01 前,执行于 2023年01月29日 星期日 13时28分38秒。软件包 gcc-7.3.0-20190804.35.p02.ky10.aarch64 已安装。软件包 gcc-c++-7.3.0-20190804.35.p02.ky10.aarch64 已安装。软件包 cmake-3.16.5-4.p01.ky10.aarch64 已安装。软件包 ncurses-devel-6.2-1.ky10.aarch64 已安装。软件包 bison-3.6.4-1.ky10.aarch64 已安装。软件包 openssl-devel-1:1.1.1f-4.p04.ky10.aarch64 已安装。未找到匹配的参数: rpcgen错误:没有任何匹配: rpcgen
rpcgen未安装,单独下载安装
[root@localhost rpcsvc-proto-1.4]# wget https://github.com/thkukuk/rpcsvc-proto/releases/download/v1.4/rpcsvc-proto-1.4.tar.gztar xf rpcsvc-proto-1.4.tar.gzcd rpcsvc-proto-1.4./configuremakemake install
编译过程
[root@localhost rpcsvc-proto-1.4]# ./configure configure: loading site script /usr/share/config.sitechecking for a BSD-compatible install... /usr/bin/install -cchecking whether build environment is sane... yeschecking for a thread-safe mkdir -p... /usr/bin/mkdir -pchecking for gawk... gawkchecking whether make sets $(MAKE)... yeschecking whether make supports nested variables... yeschecking for gcc... gccchecking whether the C compiler works... yeschecking for C compiler default output file name... a.outchecking for suffix of executables... checking whether we are cross compiling... nochecking for suffix of object files... ochecking whether we are using the GNU C compiler... yeschecking whether gcc accepts -g... yeschecking for gcc option to accept ISO C89... none neededchecking for style of include used by make... GNUchecking dependency style of gcc... gcc3checking how to run the C preprocessor... gcc -Echecking for grep that handles long lines and -e... /usr/bin/grepchecking for egrep... /usr/bin/grep -Echecking for ANSI C header files... yeschecking for sys/types.h... yeschecking for sys/stat.h... yeschecking for stdlib.h... yeschecking for string.h... yeschecking for memory.h... yeschecking for strings.h... yeschecking for inttypes.h... yeschecking for stdint.h... yeschecking for unistd.h... yeschecking minix/config.h usability... nochecking minix/config.h presence... nochecking for minix/config.h... nochecking whether it is safe to define __EXTENSIONS__... yeschecking whether gcc and cc understand -c and -o together... yeschecking how to run the C preprocessor... gcc -Echecking for library containing strerror... none requiredchecking whether make sets $(MAKE)... (cached) yeschecking that generated files are newer than configure... doneconfigure: creating ./config.statusconfig.status: creating Makefileconfig.status: creating rpcgen/Makefileconfig.status: creating rpcsvc/Makefileconfig.status: creating config.hconfig.status: executing depfiles commands[root@localhost rpcsvc-proto-1.4]# makemake all-recursivemake[1]: 进入目录“/home/zswl/test/rpcsvc-proto-1.4”Making all in rpcgenmake[2]: 进入目录“/home/zswl/test/rpcsvc-proto-1.4/rpcgen”gcc -DHAVE_CONFIG_H -I. -I.. -g -O2 -MT rpc_clntout.o -MD -MP -MF .deps/rpc_clntout.Tpo -c -o rpc_clntout.o rpc_clntout.cmv -f .deps/rpc_clntout.Tpo .deps/rpc_clntout.Pogcc -DHAVE_CONFIG_H -I. -I.. -g -O2 -MT rpc_cout.o -MD -MP -MF .deps/rpc_cout.Tpo -c -o rpc_cout.o rpc_cout.cmv -f .deps/rpc_cout.Tpo .deps/rpc_cout.Pogcc -DHAVE_CONFIG_H -I. -I.. -g -O2 -MT rpc_hout.o -MD -MP -MF .deps/rpc_hout.Tpo -c -o rpc_hout.o rpc_hout.cmv -f .deps/rpc_hout.Tpo .deps/rpc_hout.Pogcc -DHAVE_CONFIG_H -I. -I.. -g -O2 -MT rpc_main.o -MD -MP -MF .deps/rpc_main.Tpo -c -o rpc_main.o rpc_main.cmv -f .deps/rpc_main.Tpo .deps/rpc_main.Pogcc -DHAVE_CONFIG_H -I. -I.. -g -O2 -MT rpc_parse.o -MD -MP -MF .deps/rpc_parse.Tpo -c -o rpc_parse.o rpc_parse.cmv -f .deps/rpc_parse.Tpo .deps/rpc_parse.Pogcc -DHAVE_CONFIG_H -I. -I.. -g -O2 -MT rpc_sample.o -MD -MP -MF .deps/rpc_sample.Tpo -c -o rpc_sample.o rpc_sample.cmv -f .deps/rpc_sample.Tpo .deps/rpc_sample.Pogcc -DHAVE_CONFIG_H -I. -I.. -g -O2 -MT rpc_scan.o -MD -MP -MF .deps/rpc_scan.Tpo -c -o rpc_scan.o rpc_scan.cmv -f .deps/rpc_scan.Tpo .deps/rpc_scan.Pogcc -DHAVE_CONFIG_H -I. -I.. -g -O2 -MT rpc_svcout.o -MD -MP -MF .deps/rpc_svcout.Tpo -c -o rpc_svcout.o rpc_svcout.cmv -f .deps/rpc_svcout.Tpo .deps/rpc_svcout.Pogcc -DHAVE_CONFIG_H -I. -I.. -g -O2 -MT rpc_tblout.o -MD -MP -MF .deps/rpc_tblout.Tpo -c -o rpc_tblout.o rpc_tblout.cmv -f .deps/rpc_tblout.Tpo .deps/rpc_tblout.Pogcc -DHAVE_CONFIG_H -I. -I.. -g -O2 -MT rpc_util.o -MD -MP -MF .deps/rpc_util.Tpo -c -o rpc_util.o rpc_util.cmv -f .deps/rpc_util.Tpo .deps/rpc_util.Pogcc -g -O2 -o rpcgen rpc_clntout.o rpc_cout.o rpc_hout.o rpc_main.o rpc_parse.o rpc_sample.o rpc_scan.o rpc_svcout.o rpc_tblout.o rpc_util.o make[2]: 离开目录“/home/zswl/test/rpcsvc-proto-1.4/rpcgen”Making all in rpcsvcmake[2]: 进入目录“/home/zswl/test/rpcsvc-proto-1.4/rpcsvc”../rpcgen/rpcgen -h -o klm_prot.h klm_prot.x../rpcgen/rpcgen -h -o nlm_prot.h nlm_prot.x../rpcgen/rpcgen -h -o rstat.h rstat.x../rpcgen/rpcgen -h -o spray.h spray.x../rpcgen/rpcgen -h -o bootparam_prot.h bootparam_prot.x../rpcgen/rpcgen -h -o mount.h mount.x../rpcgen/rpcgen -h -o rex.h rex.x../rpcgen/rpcgen -h -o rusers.h rusers.x../rpcgen/rpcgen -h -o key_prot.h key_prot.x../rpcgen/rpcgen -h -o nfs_prot.h nfs_prot.x../rpcgen/rpcgen -h -o rquota.h rquota.x../rpcgen/rpcgen -h -o sm_inter.h sm_inter.xmake[2]: 离开目录“/home/zswl/test/rpcsvc-proto-1.4/rpcsvc”make[2]: 进入目录“/home/zswl/test/rpcsvc-proto-1.4”make[2]: 离开目录“/home/zswl/test/rpcsvc-proto-1.4”make[1]: 离开目录“/home/zswl/test/rpcsvc-proto-1.4”[root@localhost rpcsvc-proto-1.4]# make installMaking install in rpcgenmake[1]: 进入目录“/home/zswl/test/rpcsvc-proto-1.4/rpcgen”make[2]: 进入目录“/home/zswl/test/rpcsvc-proto-1.4/rpcgen” /usr/bin/mkdir -p '/usr/bin' /usr/bin/install -c rpcgen '/usr/bin' /usr/bin/mkdir -p '/usr/share/man/man1' /usr/bin/install -c -m 644 rpcgen.1 '/usr/share/man/man1'make[2]: 离开目录“/home/zswl/test/rpcsvc-proto-1.4/rpcgen”make[1]: 离开目录“/home/zswl/test/rpcsvc-proto-1.4/rpcgen”Making install in rpcsvcmake[1]: 进入目录“/home/zswl/test/rpcsvc-proto-1.4/rpcsvc”make[2]: 进入目录“/home/zswl/test/rpcsvc-proto-1.4/rpcsvc”make[2]: 对“install-exec-am”无需做任何事。 /usr/bin/mkdir -p '/usr/include/rpcsvc' /usr/bin/install -c -m 644 klm_prot.h nlm_prot.h rstat.h spray.h bootparam_prot.h mount.h rex.h rusers.h key_prot.h nfs_prot.h rquota.h sm_inter.h '/usr/include/rpcsvc' /usr/bin/mkdir -p '/usr/include/rpcsvc' /usr/bin/install -c -m 644 klm_prot.x nlm_prot.x rstat.x spray.x bootparam_prot.x mount.x rex.x rusers.x key_prot.x nfs_prot.x rquota.x sm_inter.x '/usr/include/rpcsvc'make[2]: 离开目录“/home/zswl/test/rpcsvc-proto-1.4/rpcsvc”make[1]: 离开目录“/home/zswl/test/rpcsvc-proto-1.4/rpcsvc”make[1]: 进入目录“/home/zswl/test/rpcsvc-proto-1.4”make[2]: 进入目录“/home/zswl/test/rpcsvc-proto-1.4”make[2]: 对“install-exec-am”无需做任何事。make[2]: 对“install-data-am”无需做任何事。make[2]: 离开目录“/home/zswl/test/rpcsvc-proto-1.4”make[1]: 离开目录“/home/zswl/test/rpcsvc-proto-1.4”
4.创建用户及数据库目录
用户创建useradd -r -s /sbin/nologin mysql#useradd -r -s /sbin/nologin -d /data/mysql mysql #-r创建一个系统账号,-s /sbin/nologin改用户不能登录,-d家目录目录创建mkdir /data/mysql3306/{binlogs,dbfiles,logs,relays} -pmkdir -p /data/db_backupchown mysql.mysql -R /data/mysql3306/chown mysql.mysql -R /data/db_backup/
5.编译安装
#预编译cd /home/zswl/mysql-5.7.36cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql-5.7.36/ -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/home/zswl/mysql-5.7.36/boost
等执行完成之后,看到如下内容,表示执行成功。
– Configuring done
– Generating done
– Build files have been written to: /home/zswl/mysql-5.7.36
[root@localhost mysql-5.7.36]#
编译安装##用make -j带一个参数,可以把项目在进行并行编译,比如在一台双核的机器上,完全可以用make -j4,让make最多允许4个编译命令同时执行,这样可以更有效的利用CPU资源[root@localhost mysql-5.7.36]# make -j 4 && make install
#等待漫长的执行,这个时间有点长,要看Linux的硬件配置和网络情况,一直要等到执行完成。
#如果上述预编译和编译操作过程中未出现错误(每个步骤结束后,都可以使用echo $?看返回值是否为0,为0则表示正确)
[root@localhost mysql-5.7.36]# echo $?0[root@localhost mysql-5.7.36]#
编译报错需要再次编译时执行下面命令
##make clean 清除上次的make命令所产生的object文件(后缀为“.o”的文件)及可执行文件make clean ## 删除缓存文件CMakeCache.txtrm CMakeCache.txt
(扩展)
cd /home/zswl/mysql-5.7.36#编译cmake . \-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \-DMYSQL_DATADIR=/data/mysql3306/dbfiles \-DSYSCONFDIR=/etc/ \-DMYSQL_USER=mysql \-DWITH_INNOBASE_STORAGE_ENGINE=1 \-DWITH_ARCHIVE_STORAGE_ENGINE=1 \-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \-DWITH_PARTITION_STORAGE_ENGINE=1 \-DWITHOUT_MROONGA_STORAGE_ENGINE=1 \-DWITH_DEBUG=0 \-DWITH_READLINE=1 \-DWITH_SSL=system \-DWITH_ZLIB=system \-DWITH_LIBWRAP=0 \-DENABLED_LOCAL_INFILE=1 \-DMYSQL_UNIX_ADDR=/data/mysql3306/mysql.sock \-DDEFAULT_CHARSET=utf8 \-DDEFAULT_COLLATION=utf8_general_ci \-DWITH_BOOST=/home/zswl/mysql-5.7.36/boost#cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/data/mysql3306/dbfiles -DSYSCONFDIR=/etc -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/home/zswl/mysql-5.7.42/boost -DWITHOUT_PARTITION_STORAGE_ENGINE=0
6.配置/etc.my.cnf文件
#MySQL_version = 5.7.36[client]socket=/data/mysql3306/mysql.sock[mysqld]port = 3306user = mysqlbasedir = /usr/local/mysqldatadir = /data/mysql3306/dbfilestmpdir=/data/mysql3306socket = /data/mysql3306/mysql.sockpid-file=/data/mysql3306/mysql.pidsecure-file-priv=''default_authentication_plugin = mysql_native_passwordlower_case_table_names=1relay_log_purge=1server-id = 13transaction_isolation = READ-COMMITTEDautocommit = 1character_set_server=utf8mb4max_connections = 4000max_connect_errors = 1844674407370954751connect_timeout = 10lock_wait_timeout=86400thread_cache_size=256#sql_mode = "NO_ENGINE_SUBSTITUTION,ERROR_FOR_DIVISION_BY_ZERO"sql_mode = "NO_ENGINE_SUBSTITUTION,NO_AUTO_CREATE_USER"join_buffer_size = 4Mread_buffer_size = 2Mread_rnd_buffer_size = 8Mmax_allowed_packet = 256Msort_buffer_size = 16M########basic settings#########skip-grant-tables#secure_file_priv = /data/mysql3306/skip_name_resolve = 1explicit_defaults_for_timestamp = 1tmp_table_size = 67108864#interactive_timeout = 1800#wait_timeout = 1800########log settings########log_error = /data/mysql3306/logs/mysql_err.loglog_timestamps = systemslow_query_log = 1slow_query_log_file = /data/mysql3306/logs/slow.loglog_queries_not_using_indexes = 1log_slow_admin_statements = 1log_slow_slave_statements = 1log_throttle_queries_not_using_indexes = 10general_log_file = /data/mysql3306/logs/general.logexpire_logs_days = 8long_query_time = 1min_examined_row_limit = 100########replication settings########master_info_repository = TABLErelay_log_info_repository = TABLElog_bin = /data/mysql3306/binlogs/mysql-binsync_binlog = 0gtid_mode = onenforce_gtid_consistency = 1log_slave_updates=1binlog_format = row relay_log = /data/mysql3306/relays/relay.logrelay_log_recovery = 1########innodb settings########innodb_page_size = 16384innodb_buffer_pool_size = 8Ginnodb_buffer_pool_instances = 8innodb_lock_wait_timeout = 50innodb_rollback_on_timeout = ONinnodb_buffer_pool_load_at_startup = 1innodb_buffer_pool_dump_at_shutdown = 1innodb_lru_scan_depth = 256innodb_io_capacity = 200innodb_io_capacity_max = 800innodb_flush_method = O_DIRECTinnodb_log_group_home_dir = /data/mysql3306/dbfilesinnodb_undo_directory = /data/mysql3306/dbfilesinnodb_undo_logs = 128innodb_undo_tablespaces = 3innodb_flush_neighbors = 1innodb_log_file_size = 1Ginnodb_log_files_in_group = 3innodb_log_buffer_size = 8Minnodb_purge_threads = 4innodb_thread_concurrency = 64innodb_print_all_deadlocks = 1table_open_cache = 4096open_files_limit = 8192[mysqld-5.7]innodb_buffer_pool_dump_pct = 40innodb_page_cleaners = 8innodb_undo_log_truncate = 1innodb_max_undo_log_size = 2Ginnodb_purge_rseg_truncate_frequency = 128binlog_gtid_simple_recovery=1
7.初始化数据库
/usr/local/mysql-5.7.36/bin/mysqld --initialize-insecure --init-file=/opt/init.sql --user=root --basedir=/usr/local/mysql-5.7.36 --datadir=/data/mysql3306/dbfiles/usr/local/mysql-5.7.36/bin/mysqld --initialize --init-file=/opt/init.sql --user=root --basedir=/usr/local/mysql-5.7.36 --datadir=/data/mysql3306/dbfiles/usr/local/mysql-5.7.36/bin/mysqld --initialize --user=root --basedir=/usr/local/mysql-5.7.36 --datadir=/data/mysql3306/dbfiles#--initialize #生成随机的初始root密码#--initialize-insecure #不会生成root密码,登录连接后,使用ALTER USER语句分配新的root密码。
可以不指定–init-file=/opt/init.sql 会生成一个随机密码,随后修改密码;
#init.sqlalter user root@'localhost' identified by '密码';flush privileges;
8.配置启动脚本,并启动服务
/etc/systemd/system/mysqld.service
[Unit]Description=mysqlAfter=network-online.target[Service]Type=forkingExecStart=/usr/local/mysql-5.7.36/support-files/mysql.server start ExecStop=/usr/local/mysql-5.7.36/support-files/mysql.server stopExecReload=/usr/local/mysql-5.7.36/support-files/mysql.server restartUser=mysqlGroup=mysqlRestart=alwaysRestartSec=5LimitNOFILE=infinityLimitNPROC=infinityLimitCORE=infinityDelegate=yesKillMode=process[Install]WantedBy=multi-user.target
[root@localhost system]# systemctl daemon-reload #重新加载[root@localhost system]# systemctl start mysqld[root@localhost system]# systemctl status mysqld● mysqld.service - mysqlLoaded: loaded (/etc/systemd/system/mysqld.service; disabled; vendor preset: disabled)Active: active (running) since Tue 2023-05-16 10:11:26 CST; 1min 14s agoProcess: 19787 ExecStart=/usr/local/mysql-5.7.36/support-files/mysql.server start (code=exited, status=0/SUCCESS)Main PID: 19803 (mysqld_safe)Tasks: 35Memory: 876.1MCGroup: /system.slice/mysqld.service├─19803 /bin/sh /usr/local/mysql-5.7.36/bin/mysqld_safe --datadir=/data/mysql3306/dbfiles --pid-file=/data/m>└─20906 /usr/local/mysql-5.7.36/bin/mysqld --basedir=/usr/local/mysql-5.7.36 --datadir=/data/mysql3306/dbfil>5月 16 10:10:19 localhost.localdomain systemd[1]: Starting mysql...5月 16 10:11:26 localhost.localdomain systemd[1]: Started mysql.[root@localhost system]#
9.登录数据库
初始化时设置了账号密码。
[root@localhost system]# /usr/local/mysql-5.7.36/bin/mysql -uroot -p密码mysql: [Warning] Using a password on the command line interface can be insecure.Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 2Server version: 5.7.36-log Source distributionCopyright (c) 2000, 2021, Oracle and/or its affiliates.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.mysql>
mysql> show databases;+--------------------+| Database |+--------------------+| information_schema || mysql || performance_schema || sys || zhzx_henanzx || zhzx_sjzx |+--------------------+6 rows in set (0.05 sec)mysql> select version();+------------+| version() |+------------+| 5.7.36-log |+------------+1 row in set (0.00 sec)mysql>
安装过程中出现的问题
Package 'libtirpc', required by 'virtual:world', not foundCMake Error at cmake/rpc.cmake:76 (MESSAGE):Could not find rpc/rpc.h in /usr/include or /usr/include/tirpcCall Stack (most recent call first):rapid/plugin/group_replication/configure.cmake:60 (MYSQL_CHECK_RPC)rapid/plugin/group_replication/CMakeLists.txt:25 (INCLUDE)-- Configuring incomplete, errors occurred!解决办法:yum install -y libtirpc-devel
来源地址:https://blog.csdn.net/qq_39346632/article/details/130746887
免责声明:
① 本站未注明“稿件来源”的信息均来自网络整理。其文字、图片和音视频稿件的所属权归原作者所有。本站收集整理出于非商业性的教育和科研之目的,并不意味着本站赞同其观点或证实其内容的真实性。仅作为临时的测试数据,供内部测试之用。本站并未授权任何人以任何方式主动获取本站任何信息。
② 本站未注明“稿件来源”的临时测试数据将在测试完成后最终做删除处理。有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341