Centos 7.6 下Mysql8.0.16編譯安裝
Centos 7.6 下Mysql8.0.16編譯安裝
1.最小化安裝系統
2.安裝基礎包
yum -y install ntpdate gcc gcc-c++ ncurses ncurses-devel cmake readline-devel zlib.x86_64 zlib-devel.x86_64 bison libcurl-* net-tool* tree nmap sysstat lrzsz dos2unix telnet.x86_64 nethogs iftop iotop unzip ftp.x86_ 64 xfs* expect vim wget psmisc openssh-client* libaio libaio1 libnuma openssl-devel bzip2
3.基礎環境配置
systemctl stop firewalld systemctl disabled firewalld systemctl stop postfix systemctl disable postfix sed -i 's/^SELINUX=.*/SELINUX=disabled/g' /etc/selinux/config && cat /etc/selinux/config >> ${tmplog_dir}/base.log 2>&1 setenforce 0 getenforce useradd -M -s /sbin/nologin mysql mkdir -pv /data/{conf,dumpdir,backupsets,scripts,mysql3306/{data,tmp,logs}}
4.核心引數修改
echo "vm.swappiness=10">>/etc/sysctl.conf echo "net.ipv4.tcp_tw_recycle=1">>/etc/sysctl.conf echo "net.ipv4.tcp_tw_reuse=1">>/etc/sysctl.conf echo "vm.dirty_background_ratio=8">>/etc/sysctl.conf echo "* soft nofile 1024000" >>/etc/security/limits.conf echo "* hard nofile 1024000" >>/etc/security/limits.conf
資料盤掛掛載引數
rw,noatime,nodiratime,nobarrier
5.升級gcc
mkdir /usr/local/tools && cd /usr/local/tools wget tar xf gcc-5.5.0.tar.xz cd gcc-5.5.0 ./contrib/download_prerequisites mkdir build && cd build ../configure --enable-checking=release --enable-languages=c,c++ --disable-multilib make && make install
6.升級cmake
建議另外開一個session防止環境變數未生效
cd /usr/local/tools wget ./bootstrap make && make install
如果出現以下錯誤
ibstdc++.so.6: version `CXXABI_1.3.9' not found (required by ./destructor)
處理如下:
find / -name "libstdc++.so*" mv /usr/lib64/libstdc++.so.6.0.21 /tmp/ cp /usr/local/tools/gcc-5.5.0/build/x86_64-unknown-linux-gnu/libstdc++-v3/src/.libs/libstdc++.so.6.0.21 /usr/lib64/ mv /usr/lib64/libstdc++.so.6 /tmp/ ln -s libstdc++.so.6.0.21 libstdc++.so.6
7.編譯安裝Mysql
cd /usr/local/tools tar xf mysql-boost-8.0.16.tar.gz cd mysql-8.0.16 cmake . \ -DWITH_BOOST=/usr/local/tools/mysql-8.0.16/boost/boost_1_69_0 \ -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \ -DMYSQL_DATADIR=/data/mysql3306/data \ -DWITHOUT_CSV_STORAGE_ENGINE=1 \ -DWITHOUT_FEDERATED_STORAGE_ENGINE=1 \ -DWITHOUT_ARCHIVE_STORAGE_ENGINE=1 \ -DFORCE_INSOURCE_BUILD=1 \ -DWITH_SSL=system \ -DCMAKE_CXX_COMPILER=/usr/local/bin/g++ \ -DCMAKE_C_COMPILER=/usr/local/bin/gcc make -j 8 make install
8.生成配置檔案
注:採用葉總的模板生成的()
cat /data/conf/my3306.cnf [client] port = 3306 socket = /data/mysql3306/data/mysql.sock [mysql] prompt="\u@netdatdb01-137-32 \R:\m:\s [\d]> " no-auto-rehash [mysqld] user = mysql port = 3306 basedir = /usr/local/mysql datadir = /data/mysql3306/data tmpdir = /data/mysql3306/tmp socket = /data/mysql3306/data/mysql.sock pid-file = netdatdb01-137-32.pid character-set-server = utf8mb4 skip_name_resolve = 1 #若你的MySQL資料庫主要執行在境外,請務必根據實際情況調整本引數 default_time_zone = "+8:00" open_files_limit = 65535 back_log = 1024 max_connections = 512 max_connect_errors = 1000000 table_open_cache = 1024 table_definition_cache = 1024 table_open_cache_instances = 64 thread_stack = 512K external-locking = FALSE max_allowed_packet = 32M sort_buffer_size = 4M join_buffer_size = 4M thread_cache_size = 768 interactive_timeout = 600 wait_timeout = 600 tmp_table_size = 32M max_heap_table_size = 32M slow_query_log = 1 log_timestamps = SYSTEM slow_query_log_file = /data/mysql3306/slow.log log-error = /data/mysql3306/error.log long_query_time = 0.1 log_queries_not_using_indexes =1 log_throttle_queries_not_using_indexes = 60 min_examined_row_limit = 100 log_slow_admin_statements = 1 log_slow_slave_statements = 1 server-id = 3306 log-bin = /data/mysql3306/logs/mybinlog sync_binlog = 1 binlog_cache_size = 4M max_binlog_cache_size = 2G max_binlog_size = 1G #注意:MySQL 8.0開始,binlog_expire_logs_seconds選項也存在的話,會忽略expire_logs_days選項 expire_logs_days = 7 master_info_repository = TABLE relay_log_info_repository = TABLE gtid_mode = on enforce_gtid_consistency = 1 log_slave_updates slave-rows-search-algorithms = 'INDEX_SCAN,HASH_SCAN' binlog_format = row binlog_checksum = 1 relay_log_recovery = 1 relay-log-purge = 1 key_buffer_size = 32M read_buffer_size = 8M read_rnd_buffer_size = 4M bulk_insert_buffer_size = 64M myisam_sort_buffer_size = 128M myisam_max_sort_file_size = 10G myisam_repair_threads = 1 lock_wait_timeout = 3600 explicit_defaults_for_timestamp = 1 innodb_thread_concurrency = 0 innodb_sync_spin_loops = 100 innodb_spin_wait_delay = 30 transaction_isolation = REPEATABLE-READ #innodb_additional_mem_pool_size = 16M innodb_buffer_pool_size = 2867M innodb_buffer_pool_instances = 4 innodb_buffer_pool_load_at_startup = 1 innodb_buffer_pool_dump_at_shutdown = 1 innodb_data_file_path = ibdata1:1G:autoextend innodb_flush_log_at_trx_commit = 1 innodb_log_buffer_size = 32M innodb_log_file_size = 2G innodb_log_files_in_group = 2 innodb_max_undo_log_size = 4G innodb_undo_directory = /data/mysql3306/data/undolog innodb_undo_tablespaces = 95 # 根據您的伺服器IOPS能力適當調整 # 一般配普通SSD盤的話,可以調整到 10000 - 20000 # 配置高階PCIe SSD卡的話,則可以調整的更高,比如 50000 - 80000 innodb_io_capacity = 4000 innodb_io_capacity_max = 8000 innodb_flush_sync = 0 innodb_flush_neighbors = 0 innodb_write_io_threads = 8 innodb_read_io_threads = 8 innodb_purge_threads = 4 innodb_page_cleaners = 4 innodb_open_files = 65535 innodb_max_dirty_pages_pct = 50 innodb_flush_method = O_DIRECT innodb_lru_scan_depth = 4000 innodb_checksum_algorithm = crc32 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 = 4G innodb_stats_on_metadata = 0 #注意:MySQL 8.0.16開始刪除該選項 #internal_tmp_disk_storage_engine = InnoDB # some var for MySQL 8 log_error_verbosity = 3 innodb_print_ddl_logs = 1 binlog_expire_logs_seconds = 604800 #innodb_dedicated_server = 0 innodb_status_file = 1 #注意: 開啟 innodb_status_output & innodb_status_output_locks 後, 可能會導致log-error檔案增長較快 innodb_status_output = 0 innodb_status_output_locks = 0 #performance_schema performance_schema = 1 performance_schema_instrument = '%memory%=on' performance_schema_instrument = '%lock%=on' #innodb monitor 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" [mysqldump] quick max_allowed_packet = 32M
9.初始化資料庫
mkdir -pv /data/{mysql3306/{data,logs,tmp},conf,scripts,dumpdir} /usr/local/mysql/bin/mysqld --defaults-file=/data/conf/my3306.cnf --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql3306/data
10.配置啟動指令碼
#!/bin/sh port="3306" my_lp="3306_system" mysql_bin="/usr/local/mysql/bin/" mysql_sock="/data/mysql${port}/data/mysql.sock" config_file="/data/conf/my3306.cnf" #start Mysql Services function_start_mysql() { if [ ! -e "$mysql_sock" ];then printf "Starting MySQL_3306 ...\n" ${mysql_bin}/mysqld --defaults-file=${config_file} 2>&1 > /dev/null & else printf "MySQL_3306 is running...\n" exit fi } #stop Mysql Services function_stop_mysql() { if [ ! -e "$mysql_sock" ];then printf "MySQL_3306 is stopped...\n" exit else printf "Stoping MySQL_3306...\n" ${mysql_bin}/mysqladmin --login-path=${my_lp} -S ${mysql_sock} shutdown fi } #restart Mysql Services function_restart_mysql() { printf "Restarting MySQL_3306...\n" function_stop_mysql sleep 2 function_start_mysql } case $1 in start) function_start_mysql ;; stop) function_stop_mysql ;; restart) function_restart_mysql ;; *) printf "Usage: /data/scripts/mysql3306 {start|stop|restart}\n" esac chmod a+x /data/scripts/mysql3306
11.啟動服務
/data/scripts/mysql3306 start
12.修改密碼
mysql -uroot -p -S /data/mysql3306/data/mysql.sock alter user user() identified by "netdata";
13.設定login-path
mysql_config_editor set --login-path=3306_root -uroot -p -S /data/mysql3306/data/mysql.sock
14.設定環境變數
echo "alias mysql3306='mysql --login-path=3306_root --defaults-file=/data/conf/my3306.cnf --default-character-set=utf8mb4' ">>~/.bashrc source ~/.bashrc
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/24486203/viewspace-2649760/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- CentOS7.6 下 Redis4 編譯安裝及主從配置CentOSRedis編譯
- CentOS 下編譯安裝 NginxCentOS編譯Nginx
- CentOS 下編譯安裝 apacheCentOS編譯Apache
- centos 安裝mysql8.0.16CentOSMySql
- 【記錄】CentOS7.6 編譯安裝最新版 GitCentOS編譯Git
- [記錄] CentOS7.6 編譯安裝最新版 GitCentOS編譯Git
- Centos7.6下安裝配置JenkinsCentOSJenkins
- CentOS 下編譯安裝 PHP7.2CentOS編譯PHP
- 在CentOS7.6裡編譯安裝PHP7.4,很詳細CentOS編譯PHP
- centos 7.6 安裝 nginxCentOSNginx
- CentOS7.6下安裝Redis5.0.7CentOSRedis
- CentOS 7下編譯安裝Python3CentOS編譯Python
- CentOS下編譯安裝Python3教程CentOS編譯Python
- centos PHP 編譯安裝CentOSPHP編譯
- CentOS7.6-pip安裝CentOS
- Centos7.6安裝FTPCentOSFTP
- CentOS 7.6 安裝11.2.0.4 RACCentOS
- CentOS 7.6 安裝 Elasticsearch 7.2CentOSElasticsearch
- Linux系統安裝——Centos 7.6安裝LinuxCentOS
- CentOS 下編譯安裝 PHP7.2(apache 版)CentOS編譯PHPApache
- CentOS 下編譯安裝 PHP7.2(nginx 版)CentOS編譯PHPNginx
- Centos下Ambari2.7.5的編譯和安裝CentOS編譯
- Centos7下原始碼編譯安裝apacheCentOS原始碼編譯Apache
- CentOS 6.4 編譯安裝 apacheCentOS編譯Apache
- 【Linux】Centos7.6 安裝ZookeeperLinuxCentOS
- Centos8編譯安裝核心CentOS編譯
- Centos7編譯安裝OpenRestyCentOS編譯REST
- Centos 編譯安裝 PHP7.4.7CentOS編譯PHP
- centos7.6安裝php7.3CentOSPHP
- 【Linux】Centos7.6 安裝JDK 1.8LinuxCentOSJDK
- CentOS 7.6 使用kubeadm安裝Kubernetes 13CentOS
- CentOS6.7下使用cmake編譯安裝MySQL5.5.32CentOS編譯MySql
- CentOS 7.4 環境下原始碼編譯安裝 postgreSQL 11.4CentOS原始碼編譯SQL
- 如何在CentOS7安裝Node?(編譯安裝)CentOS編譯
- Centos7編譯安裝Apache教程。CentOS編譯Apache
- Centos7編譯安裝Memcached教程。CentOS編譯
- Centos7編譯安裝Docker教程。CentOS編譯Docker
- Centos7編譯安裝Tomcat教程。CentOS編譯Tomcat