银河麒麟高级服务器操作系统(AMD64版)V10 上编译安装社区版MySQL5.7.38
一 、服务器环境
- 机型品牌 浪潮信创服务器
- 机器型号 英信ND2180M3
- CPU 飞腾FT-2000+/64 ARM
- 内存 64GB(32GB * 2)
- 硬盘 480GB SSD + 600GB*4 HDD
- 操作系统 银河麒麟高级服务器操作系统(AMD64版)V10
二 、MySQL下载地址
https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-boost-5.7.38.tar.gz
MD5: 0073fe18949b9957693d1a90e7847f66
三、编译
(1)安装依赖包
yum install ncurses-devel rpcgen cmake gcc gcc-c++ bison bison-devel \
ncurses autoconf automake libaio-devel bison perl-Time-HiRes libatomic \
openssl-devel.aarch64 openssl-devel.aarch64 libtirpc libtirpc-devel -y
(2) 编译
cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql/src/mysql-5.7.38 \
-DMYSQL_DATADIR=/data/mysql/mysql3306/data \
-DSYSCONFDIR=/etc \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DWITH_FEDERATED_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DENABLE_DTRACE=0 \
-DDEFAULT_CHARSET=utf8mb4 \
-DDEFAULT_COLLATION=utf8mb4_general_ci \
-DWITH_EMBEDDED_SERVER=1 \
-DDOWNLOAD_BOOST=1 \
-DWITH_BOOST=/home/mysql-5.7.38/boost/
make -j60
make install
mv /usr/local/src/mysql-5.7.38 /usr/local/src/mysql-5.7.38-arm64
cd /usr/local/src
tar -zcvf mysql-5.7.38-arm64.tar.gz mysql-5.7.38-arm64
四 安装脚本
#!/bin/bash
# author:yanwei.wei
# Email:yanwei.wei@flaginfo.com.cn
#date 20171123
#version 0.0.2
#set system
#$1 mysql server PORT
#$2 mysql DATADIR
#$3 databasename
install_dir=`pwd`
if [ $# -ne 2 ];then
echo "Usage:bash $0 PORT DATADIR"
echo -e "eg: bash $0 3306 data"
exit 1
fi
if [ $UID -ne 0 ];then
echo "Must be use ROOT"
exit 2
fi
PORT=$1
DATADIR=$2
MEM=`free -m|grep Mem|awk -F " " '{print $2}'`
PER=0.4
I=$(echo "$MEM * $PER" | bc)
INNODB_BUFFER=`printf "%1.f\n" $I`
TARFILE="mysql-5.7.38-arm64.tar.gz"
TARFILEDIR="${TARFILE%.tar.gz*}"
REALPATH=$(readlink -f "$0")
REALDIR=$(dirname "$REALPATH")
ln -s /usr/lib64/libncurses.so.6.1 /usr/lib64/libncurses.so.5
ln -s /usr/lib64/libtinfo.so.6 /usr/lib64/libtinfo.so.5
#ntpdate 0.pool.ntp.org
#timedatectl set-timezone "Asia/Shanghai"
echo -e "#####ADD USER mysql#######"
MYSQL_USER=$(id mysql)
if [ -z "$MYSQL_USER" ]
then
groupadd mysql
useradd -r -g mysql -s /sbin/nologin mysql
echo "create user mysql by this script"
else
echo "user mysql has been created before run this script"
fi
cd "${REALDIR}"
#wget https://cdn.mysql.com//Downloads/MySQL-5.7/${tarfile}
if [ ! -d ${TARFILEDIR} ];then
tar xf $TARFILE -C /usr/local/src
ln -s /usr/local/src/mysql-5.7.38-arm64 /usr/local/mysql
fi
cp /usr/local/mysql/extra/lib* /lib64/
unlink /lib64/libstdc++.so.6
ln -s /lib64/libstdc++.so.6.0.24 /lib64/libstdc++.so.6
#创建数据库目录
mkdir /${DATADIR}/mysql/mysql${PORT}/{data,logs,tmp} -p
#授权目录mysql权限
chown mysql.mysql /usr/local/src/mysql-5.7.38-arm64 /usr/local/mysql /usr/local/mysql/ /${DATADIR}/mysql -R
echo "add my.cnf"
cat > /etc/my.cnf << EOF
[client]
port = ${PORT}
socket = /tmp/mysql${PORT}.sock
default-character-set=utf8mb4
[mysql]
prompt="\\u@\\h [\\d]>"
no-auto-rehash
[mysqld]
user = mysql
basedir = /usr/local/mysql
datadir = /${DATADIR}/mysql/mysql${PORT}/data
port = ${PORT}
socket = /tmp/mysql${PORT}.sock
event_scheduler = 0
explicit-defaults-for-timestamp=on
tmpdir = /${DATADIR}/mysql/mysql${PORT}/tmp
skip-name-resolve
######timeout settings######
interactive_timeout = 2880000
wait_timeout = 2880000
character-set-server = utf8mb4
########connection settings########
lower_case_table_names=1
open_files_limit = 65535
max_connections = 2000
max_user_connections= 1998
max_connect_errors = 100000
default-time-zone = '+8:00'
########log settings########
log-output=file
slow_query_log = 1
slow_query_log_file = /${DATADIR}/mysql/mysql${PORT}/logs/slow.log
log-error = error.log
log_error_verbosity=1
pid-file = mysql.pid
long_query_time = 1
log-slow-slave-statements = 1
#####binlog settings#######
auto_increment_increment = 1
auto_increment_offset = 1
binlog_format = row
server-id = ${PORT}${IP_LAST}
log-bin = /${DATADIR}/mysql/mysql${PORT}/logs/mysql-bin
binlog_cache_size = 4M
max_binlog_size = 1G
max_binlog_cache_size = 2G
sync_binlog = 1
expire_logs_days = 7
#procedure
log_bin_trust_function_creators=1
####GTID settings########
gtid-mode=on
binlog_gtid_simple_recovery = 1
enforce_gtid_consistency = 1
log_slave_updates
####relay log settings#####
skip_slave_start = 1
max_relay_log_size = 128M
relay_log_purge = 1
relay_log_recovery = 1
relay-log=/${DATADIR}/mysql/mysql${PORT}/logs/relay-bin
relay-log-index=/${DATADIR}/mysql/mysql${PORT}/logs/relay-bin.index
#skip-grant-tables
####buffers & cache settings########
table_open_cache = 2048
table_definition_cache = 2048
table_open_cache = 2048
max_heap_table_size = 96M
sort_buffer_size = 16M
join_buffer_size = 16M
thread_cache_size = 3000
query_cache_size = 0
query_cache_type = 0
query_cache_limit = 256K
query_cache_min_res_unit = 512
thread_stack = 192K
tmp_table_size = 96M
key_buffer_size = 8M
read_buffer_size = 2M
read_rnd_buffer_size = 16M
bulk_insert_buffer_size = 32M
#######myisam sttings#####
myisam_sort_buffer_size = 128M
myisam_max_sort_file_size = 10G
myisam_repair_threads = 1
innodb_temp_data_file_path = ibtmp1:12M:autoextend:max:3G
#####innodb settings######
innodb_buffer_pool_size = ${INNODB_BUFFER}M
innodb_buffer_pool_instances = 8
innodb_data_file_path = ibdata1:1G:autoextend
innodb_flush_log_at_trx_commit = 1
innodb_log_buffer_size = 1G
innodb_log_file_size = 2G
innodb_log_files_in_group = 3
innodb_max_dirty_pages_pct = 50
innodb_file_per_table = 1
innodb_rollback_on_timeout
innodb_status_file = 1
innodb_buffer_pool_load_at_startup = 1
innodb_buffer_pool_dump_at_shutdown = 1
transaction_isolation = READ-COMMITTED
innodb_flush_method = O_DIRECT
innodb_lock_wait_timeout = 10
innodb_rollback_on_timeout = 1
innodb_print_all_deadlocks = 1
innodb_file_per_table = 1
innodb_online_alter_log_max_size = 1G
internal_tmp_disk_storage_engine = InnoDB
innodb_stats_on_metadata = 0
######undo settings############
innodb_undo_directory = /${DATADIR}/mysql/mysql${PORT}/data/
innodb_undo_logs = 128
innodb_undo_log_truncate = 1
innodb_undo_tablespaces = 2
innodb_max_undo_log_size = 4G
######io settings############
innodb_io_capacity = 4000
innodb_io_capacity_max = 8000
innodb_flush_neighbors = 0
innodb_write_io_threads = 8
innodb_read_io_threads = 8
innodb_purge_threads = 4
innodb_page_cleaners = 4
#performance_schema
performance_schema = 1
performance_schema_instrument = '%=on'
######innodb monitor settings#####
innodb_monitor_enable="module_innodb"
innodb_monitor_enable="module_server"
innodb_monitor_enable="module_dml"
innodb_monitor_enable="module_ddl"
innodb_monitor_enable="module_trx"
innodb_monitor_enable="module_os"
innodb_monitor_enable="module_purge"
innodb_monitor_enable="module_log"
innodb_monitor_enable="module_lock"
innodb_monitor_enable="module_buffer"
innodb_monitor_enable="module_index"
innodb_monitor_enable="module_ibuf_system"
innodb_monitor_enable="module_buffer_page"
innodb_monitor_enable="module_adaptive_hash"
EOF
echo -e "######initialize mysql##############"
cd /usr/local/mysql
./bin/mysqld --initialize-insecure
envsubst < ${install_dir}/mysqld.tmpl >/lib/systemd/system/mysqld.service
systemctl daemon-reload
systemctl enable mysqld
systemctl start mysqld
echo -e "########start mysql###########"
sleep 15
echo -e "########Set mysql PATH########"
echo 'export PATH=/usr/local/mysql/bin:$PATH' >>/etc/profile
source /etc/profile
/usr/local/mysql/bin/mysql -uroot -e "set password=password('qaz123!@#')"
echo -e "MySQL root password is qaz123!@#"
echo -e "################Test mysql#####################"
TEST=`mysql -u root -pqaz123!@# -e "show databases;"|grep sys|wc -l`
if [ $TEST -ne 1 ];then
echo -e "mysql install is flase"
else
echo -e "mysql is install successfull"
fi
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· AI 智能体引爆开源社区「GitHub 热点速览」
· 从HTTP原因短语缺失研究HTTP/2和HTTP/3的设计差异
· 三行代码完成国际化适配,妙~啊~