想了想仍是研究一下怎麼源碼安裝pxc吧,畢竟不少組件都是源碼安裝的。node
yum install -y boost-devel libodb-boost-devel check-devel openssl-devel libaio-devel
須要2.7+ 的Python wget https://nchc.dl.sourceforge.net/project/scons/scons/3.0.1/scons-3.0.1.tar.gz tar xf scons-3.0.1.tar.gz cd scons-3.0.1 python setup.py install
tcmalloc 安裝忽略,mysql用戶建立忽略python
wget ftp://ftp.pbone.net/mirror/apt.sw.be/redhat/el6/en/x86_64/rpmforge/RPMS/socat-1.7.2.4-1.el6.rf.x86_64.rpm rpm -ivh socat-1.7.2.4-1.el6.rf.x86_64.rpm wget ftp://ftp.pbone.net/mirror/ftp5.gwdg.de/pub/opensuse/repositories/home:/rudi_m:/devel-snap/CentOS_CentOS-6/x86_64/libev4-4.15-7.1.x86_64.rpm rpm -ivh libev4-4.15-7.1.x86_64.rpm wget ftp://ftp.pbone.net/mirror/ftp.centos.org/6.9/os/x86_64/Packages/numactl-2.0.9-2.el6.x86_64.rpm rpm -ivh numactl-2.0.9-2.el6.x86_64.rpm wget ftp://ftp.pbone.net/mirror/ftp5.gwdg.de/pub/opensuse/repositories/home:/viliampucik:/obs/RedHat_RHEL-6/x86_64/compat-readline5-5.2-17.4.x86_64.rpm rpm -ivh compat-readline5-5.2-17.4.x86_64.rpm wget https://repo.percona.com/release/centos/6Server/RPMS/x86_64/percona-xtrabackup-24-2.4.12-1.el6.x86_64.rpm rpm -ivh percona-xtrabackup-24-2.4.12-1.el6.x86_64.rpm
wget https://www.percona.com/downloads/Percona-XtraDB-Cluster-57/Percona-XtraDB-Cluster-5.7.23-31.31-2/source/tarball/Percona-XtraDB-Cluster-5.7.23-31.31.tar.gz tar xf Percona-XtraDB-Cluster-5.7.23-31.31.tar.gz cd Percona-XtraDB-Cluster-5.7.23-31.31/percona-xtradb-cluster-galera/ scons -j4 psi=1 --config=force revno= libgalera_smm.so
以後,當前目錄下就有一個libgalera_smm.so文件mysql
#將boost_1_59_0.tar.gz放到源碼包當前目錄,cmake過程會自動加壓 cd ../ cp /dist/dist/boost_1_59_0.tar.gz . mkdir build cd build/ CHOST="x86_64-pc-linux-gnu" CFLAGS="-march=nocona -O2 -pipe" CXXFLAGS="-march=nocona -O2 -pipe" \ cmake ../ \ -DMYSQL_USER=mysql \ -DCMAKE_BUILD_TYPE:STRING=Release \ -DBUILD_CONFIG=mysql_release \ -DWITH_EMBEDDED_SERVER=OFF \ -DFEATURE_SET=community \ -DENABLE_DTRACE=OFF \ -DWITH_SSL=system \ -DWITH_ZLIB=system \ -DCMAKE_INSTALL_PREFIX=/usr/local/mysql\ -DMYSQL_SERVER_SUFFIX=-29.22 \ -DWITH_INNODB_DISALLOW_WRITES=ON \ -DWITH_WSREP=ON \ -DWITH_UNIT_TESTS=0 \ -DWITH_READLINE=system \ -DWITHOUT_TOKUDB=ON \ -DWITHOUT_ROCKSDB=ON \ -DWITH_PAM=ON \ -DWITH_INNODB_MEMCACHED=ON \ -DDOWNLOAD_BOOST=1 \ -DWITH_BOOST=..\ -DWITH_SCALABILITY_METRICS=ON \ -DCMAKE_EXE_LINKER_FLAGS="-ltcmalloc" \ -DWITH_SAFEMALLOC=OFF \ -DWITHOUT_BLACKHOLE_STORAGE_ENGINE=1 \ -DWITHOUT_FEDERATED_STORAGE_ENGINE=1 \ -DWITHOUT_ARCHIVE_STORAGE_ENGINE=1 \ make -j $CPUcount make install #將libgalera_smm.so複製到basedir的lib目錄中,或者能夠再mysql實例的配置文件中指定文件位置也行 cd ../ cp percona-xtradb-cluster-galera/libgalera_smm.so /usr/local/mysql/lib/
到目前爲止,pxc的一個實例就安裝好了。剩下的就是按套路配置啓動了。linux
#必定要讓path變量能找獲得pxc實例的二進制文件和相關腳本 ln -sv /usr/local/mysql/bin/* /usr/local/bin/
mkdir -p /data/database/mysql chown mysql:mysql -R /data/database/mysql
#讓mysqld支持tcmalloc cd /usr/local/mysql sed -i '/Initialize script globals/ a export LD_PRELOAD=/usr/local/lib/libtcmalloc.so' bin/mysqld_safe
# 配置文件: [client] port=3306 socket = /tmp/mysql.sock [mysqld] server-id=132 port=3306 datadir=/data/database/mysql tmpdir=/data/database/mysql #basedir=/usr/local/mysql socket = /tmp/mysql.sock log-error=/data/database/mysql/thai_pxc_cluster.err pid-file=/data/database/mysql/thai_pxc_cluster.pid user=mysql secure_file_priv = "" performance_schema_max_table_instances=50000 table_definition_cache=400 table_open_cache=1024 # General back_log=2000 connect_timeout=15 max_connections=1024 max_allowed_packet = 16M max_heap_table_size = 128M sort_buffer_size = 8M net_buffer_length = 8K read_buffer_size = 8M read_rnd_buffer_size = 32M query_cache_size = 128M join_buffer_size=8M bulk_insert_buffer_size=128M concurrent_insert=2 delay_key_write=ON delayed_insert_limit=4000 delayed_insert_timeout=600 delayed_queue_size=4000 tmp_table_size = 256M thread_cache_size=120 character-set-server=utf8 metadata_locks_hash_instances=256 open-files-limit = 10240 skip-name-resolve core_file transaction-isolation=READ-COMMITTED sql_mode = "" # Innodb innodb_buffer_pool_size = 4096M innodb_buffer_pool_instances=8 innodb_log_file_size = 1024M innodb_log_buffer_size = 16M innodb_lock_wait_timeout = 20 innodb_autoinc_lock_mode=2 innodb_read_io_threads = 5 innodb_write_io_threads = 5 innodb_thread_concurrency = 8 innodb_doublewrite=1 innodb_flush_log_at_trx_commit = 2 innodb_flush_method = 'O_DIRECT' innodb-page-cleaners=8 innodb_purge_threads=4 innodb_lru_scan_depth=2048 innodb_io_capacity=8000 innodb_io_capacity_max=16000 innodb_adaptive_hash_index=OFF innodb-change-buffering=none innodb_flush_neighbors=0 innodb_max_dirty_pages_pct = 90 innodb_max_dirty_pages_pct_lwm = 10 # Binlog relay-log=relay-1 binlog_format=ROW enforce-gtid-consistency gtid-mode=on master-info-repository=TABLE relay-log-info-repository=TABLE binlog-checksum=NONE log-bin=mysql-bin max-binlog-size=128M log_slave_updates expire_logs_days=3 sync_binlog=1 binlog_cache_size = 4M log_output=FILE slow_query_log=1 slow_query_log_file=/data/database/mysql/slowquery.log max_slowlog_size=1024m max_slowlog_files=10 long_query_time=1 # Monitoring innodb_monitor_enable='%' performance_schema=ON performance_schema_instrument='%synch%=on' # Galera symbolic-links=0 explicit_defaults_for_timestamp=true #wsrep_provider=/usr/lib64/galera3/libgalera_smm.so wsrep_provider=/usr/local/mysql/lib/libgalera_smm.so wsrep_cluster_address=gcomm://30.0.0.227,30.0.0.226,30.0.0.225 default_storage_engine=InnoDB wsrep_slave_threads= 20 wsrep_log_conflicts wsrep_cluster_name=pxc_cluster wsrep_node_name=pxc_node_30.0.0.226 wsrep_node_address=30.0.0.226 wsrep_sst_method=xtrabackup-v2 wsrep_sst_auth="sstuser:s3cret" pxc_strict_mode=DISABLED
/usr/local/mysql/bin/mysqld --initialize --datadir=/data/database/mysql/ --basedir=/usr/local/mysql/ --user=mysql
在初始化過程當中會生成root@local的密碼,須要用這個密碼作第一次登陸並修改。相似:sql
2018-05-08T02:34:50.116777Z 1 [Note] A temporary password is generated for root@localhost: dGpgf>_vj90>
/usr/local/mysql/bin/mysqld_safe --defaults-file=/etc/my.cnf --wsrep-new-cluster --lc_messages_dir=/usr/local/mysql/share/ --lc_messages=en_US &
mysql> alter user root@localhost identified by '20c0dc7315fe8db65cbab532818e0e7a';
mysql> CREATE USER 'sstuser'@'localhost' IDENTIFIED BY 's3cret'; mysql> GRANT RELOAD, LOCK TABLES, PROCESS, REPLICATION CLIENT ON *.* TO 'sstuser'@'localhost'; mysql> FLUSH PRIVILEGES;
/usr/local/mysql/bin/mysqld_safe --defaults-file=/etc/my.cnf --lc_messages_dir=/usr/local/mysql/share/ --lc_messages=en_US &