當前位置:首頁 > IT技術

CentOS 7 下編譯安裝AliSQL

時間:2019-06-14 20:42:06來源:IT技術作者:seo實驗室小編閱讀:59次「手機版」
 

alisql

運行環境:centos 7.5 + alisql5.6.32-9版本
# cat /etc/redhat-release 
CentOS linux release 7.5.1804 (Core) 

下載軟件:
# wget https://github.com/alibaba/alisql/archive/AliSQL-5.6.32-9.tar.gz
# du -sh AliSQL-5.6.32-9.tar.gz 
42M  AliSQL-5.6.32-9.tar.gz

編譯安裝的gcc和cmake版本要求( gcc >= 4.7, cmake >= 2.8)
安裝基礎的軟件:
# yum install gcc gcc-c++ ncurses-devel perl  cmake bison zlib zlib-devel openssl-devel autoconf
...
Downloading packages:
Delta RPMs disabled because /usr/bin/APPlydeltarpm not installed.
(1/17): cmake-2.8.12.2-2.el7.x86_64.rpm                             | 7.1 MB  00:00:02     
(2/17): cpp-4.8.5-28.el7_5.1.x86_64.rpm                             | 5.9 MB  00:00:03     
(3/17): glibc-devel-2.17-222.el7.x86_64.rpm                         | 1.1 MB  00:00:00     
(4/17): gcc-c++-4.8.5-28.el7_5.1.x86_64.rpm                         | 7.2 MB  00:00:03     
(5/17): glibc-headers-2.17-222.el7.x86_64.rpm                       | 678 kB  00:00:00     
(6/17): libgcc-4.8.5-28.el7_5.1.x86_64.rpm                          | 101 kB  00:00:00     
(7/17): kernel-headers-3.10.0-862.11.6.el7.x86_64.rpm               | 7.1 MB  00:00:01     
(8/17): libgomp-4.8.5-28.el7_5.1.x86_64.rpm                         | 156 kB  00:00:00     
(9/17): libarchive-3.1.2-10.el7_2.x86_64.rpm                        | 318 kB  00:00:00     
(10/17): libstdc++-4.8.5-28.el7_5.1.x86_64.rpm                      | 303 kB  00:00:00     
(11/17): libmpc-1.0.1-3.el7.x86_64.rpm                              |  51 kB  00:00:00     
(12/17): libstdc++-devel-4.8.5-28.el7_5.1.x86_64.rpm                | 1.5 MB  00:00:00     
(13/17): mpfr-3.1.1-4.el7.x86_64.rpm                                | 203 kB  00:00:00     
(14/17): m4-1.4.16-10.el7.x86_64.rpm                                | 256 kB  00:00:00     
(15/17): ncurses-devel-5.9-14.20130511.el7_4.x86_64.rpm             | 712 kB  00:00:00     
(16/17): bison-3.0.4-1.el7.x86_64.rpm                               | 674 kB  00:00:06     
(17/17): gcc-4.8.5-28.el7_5.1.x86_64.rpm                            |  16 MB  00:00:08     
-------------------------------------------------------------------------------------------
Total                                                      5.6 MB/s |  49 MB  00:00:08   
...



useradd -r -g mysql mysql
groupadd mysql 

[[email protected] ~]# useradd -r -g mysql mysql
useradd: user 'mysql' already exists
[[email protected] ~]# groupadd mysql
groupadd: group 'mysql' already exists
[[email protected] ~]# 
--解壓文件:
#tar -xzvf AliSQL-5.6.32-9.tar.gz  -C /usr/local/
#mv /usr/local/AliSQL-AliSQL-5.6.32-9/ /usr/local/alisql
--創建目錄:alisql的目錄疑似指定了編譯的目錄/opt/alisql,指定為別的目錄啟動的時候報錯。
mkdir -p /opt/alisql
chown -R mysql:mysql /opt/alisql

--獲取cmake支持的選項:
# cmake . -LH
--實際編譯的步驟:
# cd /usr/local/alisql
#
cmake .                              \
-DCMAKE_build_TYPE="Release"         \
-DCMAKE_INSTALL_PREFIX="/opt/alisql" \
-DWITH_EMBEDDED_SERVER=0             \
-DDEFAULT_CHARSET=utf8mb4   \
-DDEFAULT_COLLATION=utf8mb4_general_ci \
-DWITH_MYISAM_STORAGE_ENGINE=1       \
-DWITH_INNOBASE_STORAGE_ENGINE=1     \
-DWITH_PARTITION_STORAGE_ENGINE=1    \
-DWITH_CSV_STORAGE_ENGINE=1          \
-DWITH_ARCHIVE_STORAGE_ENGINE=1      \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1    \
-DWITH_FEDERATED_STORAGE_ENGINE=1    \
-DWITH_PERFSCHEMA_STORAGE_ENGINE=1   \
-DWITH_TOKUDB_STORAGE_ENGINE=1

--編譯提示信息:
-- Generating done
-- Build files have been written to: /usr/local/alisql


make -j4 && make install
說明:
-j4 表示開 4 個并發編譯進程,加速編譯,根據機器 cpu 核數調整,一般是 CPU 核數 + 1,最終二進制安裝在 /opt/alisql 目錄下。
上述的編譯安裝耗時較久,視CPU的性能和資源而定。
 
 
創建數據目錄并授權

mkdir -p /data/alisql
chown -R mysql:mysql /data/alisql
chmod -R 775 /data/alisql

 
準備工作:
1.設置
echo never > /sys/kernel/mm/transparent_hugepage/enabled ##開啟TokuDB,不執行會提示:[ERROR] TokuDB: Huge pages are enabled, disable them before continuing
2.參數文件:
cp support-files/my-default.cnf /etc/my.cnf
這里參照alisql官方提供的即可。
[mysqld]
user = mysql
explicit_defaults_for_timestamp=true
socket =  /tmp/alisql.sock
datadir = /data/alisql
pid-file = /tmp/alisql.pid
tmpdir = /tmp
port = 3306
back_log = 3000
character_set_server = utf8mb4
max_connect_errors = 100
max_connections = 4050
max_user_connections = 4050
max_heap_table_size = 64M
max_allowed_packet = 1024M
max_binlog_size = 500M
thread_stack = 256K
interactive_timeout = 7200
wait_timeout = 86400
sort_buffer_size = 848KB
read_buffer_size = 848KB
read_rnd_buffer_size = 432KB
join_buffer_size = 432KB
net_buffer_length = 16K
thread_cache_size = 100
ft_min_word_len = 4
transaction_isolation = READ-COMMITTED
tmp_table_size = 2097152
table_open_cache = 2000
skip_name_resolve
core-file
lower_case_table_names = 1
log_bin_trust_function_creators = 1
log-bin =  mysql-bin.log
log-bin-index = log-bin.index
log-error = error.log
relay-log = relay.log
relay-log-info-file = relay-log.info
relay-log-index =  relay-log.index
master-info-file = master.info
log-slave-updates = 1
binlog_cache_size = 2048KB
sync_binlog = 1
log_warnings
slow_query_log_file = slow_query.log
slow_query_log = 1
log_output = TABLE
long_query_time = 1
binlog_format = ROW
server_id = 1844593058
auto_increment_increment = 1
auto_increment_offset = 1
slave_net_timeout = 60
key_buffer_size = 16M
bulk_insert_buffer_size = 4M
innodb_data_home_dir = /data/alisql
innodb_log_group_home_dir = /data/alisql
innodb_additional_mem_pool_size = 2097152
innodb_buffer_pool_size = 13108M
innodb_data_file_path = ibdata1:200M:autoextend
innodb_file_per_table =on
innodb_file_io_threads = 4
innodb_flush_log_at_trx_commit = 1
innodb_log_buffer_size = 8M
innodb_log_file_size = 1500M
innodb_log_files_in_group = 2
innodb_max_dirty_pages_pct = 75
innodb_flush_method = O_DIRECT
innodb_lock_wait_timeout = 50
innodb_doublewrite = 1
innodb_rollback_on_timeout = OFF
innodb_autoinc_lock_mode = 1
innodb_read_io_threads = 4
innodb_write_io_threads = 4
innodb_io_capacity = 2000
innodb_purge_threads = 1
master_info_repository = TABLE
relay_log_info_repository = TABLE
query_cache_type = 0
concurrent_insert = 1
query_cache_limit = 1048576
query_cache_min_res_unit = 1K
log-slow-admin-statements
innodb_stats_on_metadata = OFF
innodb_file_format = Barracuda
innodb_read_ahead = 0
innodb_thread_concurrency = 0
innodb_sync_spin_loops = 100
innodb_spin_wait_delay = 30
default_storage_engine = InnoDB
innodb_stats_sample_pages = 8
open_files_limit = 65535
gtid_mode = ON
innodb_ft_max_token_size = 84
enforce-gtid-consistency = 1
log_bin_use_v1_row_events = 1
loose_performance_schema = off
loose_binlog_order_commits = OFF
loose_rds-anonymous-in-gtid-out-enable = 1
loose_tokudb_cache_size = 13108M
loose_opt_rds_enable_set_default_engine = OFF
loose_innodb_rds_autoinc_persistent_Interval = 1
delay_key_write = ON
key_cache_pision_limit = 100
innodb_old_blocks_pct = 37
loose_rds_gtid_precommit = ON
loose_implicit_primary_key = 1
ft_query_expansion_limit = 20
innodb_ft_min_token_size = 3
loose_tokudb_checkpointing_period = 60
innodb_thread_sleep_delay = 10000
loose_innodb_log_compressed_pages = OFF
init_connect = ''
loose_rds_sql_select_filter = ''
innodb_print_all_deadlocks = OFF
delayed_insert_timeout = 300
loose_thread_pool_stall_limit = 30
loose_thread_pool_oversubscribe = 10
loose_max_statement_time = 0
loose_tokudb_commit_sync = ON
binlog_stmt_cache_size = 32768
net_retry_count = 10
binlog_checksum = CRC32
low_priority_updates = 0
loose_tokudb_support_xa = ON
autocommit = 1
loose_rds_set_connection_id_enabled = ON
key_cache_age_threshold = 300
innodb_concurrency_tickets = 5000
loose_innodb_rds_log_checksum_algorithm = INNODB
table_definition_cache = 512
loose_rds_check_core_file_enabled = ON
loose_tokudb_rpl_lookup_rows = OFF
innodb_use_native_aio = 0
net_write_timeout = 60
loose_rds_threads_running_high_watermark = 50000
slave_exec_mode = strict
query_alloc_block_size = 8192
loose_tokudb_fs_reserve_percent = 5
max_prepared_stmt_count = 16382
net_read_timeout = 30
loose_innodb_rds_min_concurrency_tickets = 50
loose_rds_ic_reduce_hint_enable = OFF
max_write_lock_count = 102400
innodb_old_blocks_time = 1000
innodb_stats_method = nulls_equal
max_length_for_sort_data = 1024
query_prealloc_size = 8192
innodb_large_prefix = OFF
delayed_insert_limit = 100
group_concat_max_len = 1024
innodb_disable_sort_file_cache = ON
loose_tokudb_buffer_pool_ratio = 0
loose_innodb_rds_autoinc_persistent = ON
innodb_ft_min_token_size = 3
loose_rds_enable_log_global_var_update = ON
loose_opt_rds_last_error_gtid = ON
loose_skip_symbolic_links = ON
loose_tokudb_rpl_unique_checks = OFF
key_cache_block_size = 1024
loose_tokudb_directio = OFF
slow_launch_time = 2
innodb_online_alter_log_max_size = 134217728
innodb_open_files = 3000
eq_range_index_pe_limit = 10
p_precision_increment = 4
binlog_row_image = full
innodb_strict_mode = OFF
delayed_queue_size = 1000
default_week_format = 0
log_queries_not_using_indexes = OFF
innodb_read_ahead_threshold = 56
connect_timeout = 10
default_time_zone = SYSTEM
sql_mode = ''
innodb_table_locks = ON
query_cache_size = 3145728
innodb_adaptive_hash_index = ON
innodb_purge_BATch_size = 300
loose_innodb_rds_adaptive_tickets_algo = ON
loose_rpl_semi_sync_slave_trace_level = 1
loose_rpl_semi_sync_master_timeout = 1000
loose_rpl_semi_sync_master_trace_level = 1
loose_rpl_semi_sync_slave_enabled = OFF
loose_rpl_semi_sync_master_enabled = OFF
loose_rpl_semi_sync_master_wait_no_slave = ON
loose_rds_slave_read_no_lock = ON
loose_slave_parallel_workers = 8
loose_rds_expand_fast_index_creation = ON
loose_tokudb_row_format = tokudb_zlib
loose_rds_reset_all_filter = 0
loose_innodb_adaptive_hash_index_parts = 8
loose_tokudb_fsync_log_period = 0
loose_thread_handling = "one-thread-per-connection"
loose_rds_allow_unsafe_stmt_with_gtid = ON

[mysqldump]
quick
max_allowed_packet = 64M

[mysql]
no-auto-rehash
prompt = "\\[email protected]\\h : \\d \\R:\\m:\\s> "

[myisamchk]
key_buffer = 512M
sort_buffer_size = 512M
read_buffer = 8M
write_buffer = 8M

[mysqlhotcopy]
interactive-timeout

[mysqld_safe]
user = mysql
basedir = /opt/alisql

[mysql_install_db]
basedir = /opt/alisql

初始化
cd /opt/alisql/scripts/
 
/opt/alisql/scripts/mysql_install_db --user=mysql --basedir=/opt/alisql --datadir=/data/alisql --pid-file=/tmp/alisql.pid --tmpdir=/tmp

cp /opt/alisql/support-files/mysql.server /etc/init.d/mysql
 
環境變量配置
#echo "PATH=/usr/local/alisql/bin:/usr/local/alisql/lib:$PATH" >> 
/etc/profile.d/alisql.sh 

# source  /etc/profile.d/alisql.sh 
 
啟動并加入開機自啟
# /etc/init.d/mysql restart
 ERROR! MySQL server PID file could not be found!
Starting MySQL........ SUCCESS! 
chkconfig --level 35 mysql on

登錄進入alisql:
mysql -p -S /tmp/alisql.sock
[email protected] : (none) 23:28:19> show variables like '%version%';
+-------------------------+---------------------+
| Variable_name           | Value               |
+-------------------------+---------------------+
| innodb_version          | 5.6.32              |
| protocol_version        | 10                  |
| slave_type_conversions  |                     |
| tls_version             | TLSv1               |
| tokudb_version          |                     |
| version                 | 5.6.32-log          |
| version_comment         | Source distribution |
| version_compile_machine | x86_64              |
| version_compile_os      | Linux               |
+-------------------------+---------------------+
9 rows in set (0.01 sec)

[email protected] : (none) 23:28:28> show engines;
+--------------------+---------+----------------------------------------------------------------+--------------+------+------------+
| Engine             | Support | Comment                                                        | Transactions | XA   | Savepoints |
+--------------------+---------+----------------------------------------------------------------+--------------+------+------------+
| InnoDB             | DEFAULT | Supports transactions, row-level locking, and foreign keys     | YES          | YES  | YES        |
| CSV                | YES     | CSV storage engine                                             | NO           | NO   | NO         |
| TokuDB             | YES     | Tokutek TokuDB Storage Engine with Fractal Tree(tm) Technology | YES          | YES  | YES        |
| BLACKHOLE          | YES     | /dev/null storage engine (anything you write to it disappears) | NO           | NO   | NO         |
| MyISAM             | YES     | MyISAM storage engine                                          | NO           | NO   | NO         |
| MRG_MYISAM         | YES     | Collection of identical MyISAM tables                          | NO           | NO   | NO         |
| ARCHIVE            | YES     | Archive storage engine                                         | NO           | NO   | NO         |
| FEDERATED          | NO      | Federated MySQL storage engine                                 | NULL         | NULL | NULL       |
| PERFORMANCE_SCHEMA | YES     | Performance Schema                                             | NO           | NO   | NO         |
| MEMORY             | YES     | Hash based, stored in memory, useful for temporary tables      | NO           | NO   | NO         |
+--------------------+---------+----------------------------------------------------------------+--------------+------+------------+
10 rows in set (0.00 sec)
 


--編譯安裝過程報錯信息:
#/opt/alisql/scripts/mysql_install_db --user=mysql --basedir=/opt/alisql --datadir=/data/alisql --pid-file=/tmp/alisql.pid --tmpdir=/tmp
--報錯信息:
FATAL ERROR: please install the following Perl modules before executing ./scripts/mysql_install_db:
Data::Dumper
--解決辦法:
yum-y install autoconf
--啟動的時候報錯:
InnoDB: The Auto-extending innodb_system data file './ibdata1' is of a different size 640 pages
--解決辦法:
#刪除$datadir目錄下的數據原有的數據問你.

文章參考:
https://dev.mysql.com/doc/mysql-sourcebuild-excerpt/5.6/en/source-configuration-options.html
http://blog.fungo.me/2016/10/compile-alisql-from-source/

相關閱讀

Centos7 安裝并配置walle

Centos7 安裝并配置walle 前言: 因為官網的wiki和安裝手冊 都不是很完整 自己踩了很多坑 最后才弄好。因此記錄下來。 官方地址

CentOS6和CentOS7配置bond0的區別(雙網卡bond綁定)

在CentOS6.x下配置bond綁定,(以6.4系統為例)配置如下: 然后執行命令service network restart 重啟網卡,就可以看到bond0網卡, 同時也

CentOS 安裝rz和sz命令 lrzsz

在很多時候我們都需要往服務器上傳文件之類的,一般我們都試試用FTP上傳文件。這次介紹另外一種上傳文件的方式,使用Xshell+lrzsz的

如何在centOS上 apt-get install build-essential

https://access.redhat.com/solutions/1310043, 使用命令 yum group list 可以查看已經安裝的套件和可以安裝的套件, 試一下 yum g

用mac自帶terminal ssh連虛擬機centos提示port 22: Op

2018.8.14 17:45更新 找到了另外一條路。終于可以用mac自帶terminal ssh連虛擬機centos了。 各版本還是不變,在centos的初始狀態下

分享到:

欄目導航

推薦閱讀

熱門閱讀

美国扑克50手登陆