環(huán)境:
N F S: 172.16.0.3 (OS CentOS 7)
node1:172.16.0.5 (OS CentOS 6.7)
node2:172.16.0.6 (OS CentOS 6.7)
浮動(dòng)IP:172.16.0.168
# yum install php php-mysql 倆個(gè)節(jié)點(diǎn)都安裝
互信操作:倆邊都操作:
# ssh-keygen -t rsa # ssh-copy-id -i .ssh/id_rsa.pub root@x.x.x.x
修改主機(jī)名:
# cat /etc/sysconfig/network //node2 NETWORKING=yes HOSTNAME=node2.sunshine.com # cat /etc/sysconfig/network //node1 NETWORKING=yes HOSTNAME=node1.sunshine.com
本地/etc/hosts解析:
# cat /etc/hosts | tail -2 172.16.0.5 node2.sunshine.com node2 172.16.0.6 node1.sunshine.com node1 # cat /etc/hosts | tail -2 172.16.0.5 node2.sunshine.com node2 172.16.0.6 node1.sunshine.com node1
同步時(shí)間:兩邊都操作,這里測(cè)試就不做crontab 不同時(shí)間了:
# service ntpdate start # [root@HA2 ~]# date ;ssh node2 'date' Wed Oct 26 15:28:32 CST 2016 Wed Oct 26 15:28:32 CST 2016
重啟:
# shutdown -r now
安裝epel源:
# rpm -Uivh ftp://ftp.pbone.net/mirror/dl.iuscommunity.org/pub/ius/archive/Redhat/6/i386/epel-release-6-5.noarch.rpm
安裝依賴:
# yum install net-snmp-libs libnet PyXML pygtk2-libglade -y
安裝Heartbeat相關(guān)程序包:找不到的同學(xué)別灰心我的百度云盤:http://pan.baidu.com/s/1boGx6t5
# rpm -ivh heartbeat-2.1.4-12.el6.x86_64.rpm \ > heartbeat-stonith-2.1.4-12.el6.x86_64.rpm > heartbeat-pils-2.1.4-12.el6.x86_64.rpm > heartbeat-gui-2.1.4-12.el6.x86_64.rpm
如報(bào)以下錯(cuò)誤:安裝libtool-ltdl 既可以:
error: Failed dependencies: libltdl.so.7()(64bit) is needed by heartbeat-2.1.4-12.el6.x86_64 libltdl.so.7()(64bit) is needed by heartbeat-stonith-2.1.4-12.el6.x86_64 libltdl.so.7()(64bit) is needed by heartbeat-pils-2.1.4-12.el6.x86_64# yum install libtool-ltdl -y //安裝libtool-ltdl
-安裝支持xshell Xmanger包,否則網(wǎng)絡(luò)上很方法也是不可用的:
# yum install xorg-x11-xauth //如果不安裝使用hb_gui是無(wú)法調(diào)用x11
ha.cf配置:
# grep -v "#" ha.cf logfile /var/log/heartbeat-log mcast eth0 225.10.210.1 694 1 0 auto_failback on node node1.sunshine.com node node2.sunshine.com crm on ping 172.16.0.1 # grep -v "#" authkeys auth 2 2 sha1 Dn880wJZxfsUpioJWy7FgQ # passwd hacluster //在哪里啟動(dòng),就在哪里設(shè)置hacluster密碼 # hb_gui & compression bz2compression_threshold 2
authkeys配置
[root@node2 ha.d]# cat authkeys | tail -4 | grep -v "#"auth 22 sha1 Dn880wJZxfsUpioJWy7FgQ
在node{1|2}清除iptables并關(guān)閉selinux
# iptables -F# setenforce 0# cat /etc/selinux/config | tail -3 | head -1 SELINUXTYPE=targeted
httpd 安裝:
# yum install httpd -y //node{1|2} # echo "<h1>node1</h1>" > /var/www/html/index.html //node1執(zhí)行 # echo "<h1>node2</h1>" > /var/www/html/index.html //node2執(zhí)行 # curl node{1,2} //訪問測(cè)試 <h1>node1</h1> <h1>node2</h1> # service httpd stop ;ssh node2 'service httpd stop' Stopping httpd: [ OK ] Stopping httpd: [ OK ] # chkconfig httpd off ;ssh node2 'chkconfig httpd off' //關(guān)閉httpd自動(dòng)啟動(dòng) # chkconfig httpd --list ;ssh node2 'chkconfig httpd --list'//查看是否關(guān)閉 httpd 0:off 1:off 2:off 3:off 4:off 5:off 6:off httpd 0:off 1:off 2:off 3:off 4:off 5:off 6:off
NFS Server搭建:這是在NFS服務(wù)器上執(zhí)行
# groupadd -g 306 mysql # useradd -g 306 -u 306 -M -r mysql # mkdir /data/mydata # chown -R mysql.mysql /data/mydata # cat /etc/exports //編輯需要導(dǎo)出的文件 /data/mydata 172.16.0.0/24(rw,no_root_squash) //no_root_squash表示遠(yuǎn)端主機(jī)root用戶不轉(zhuǎn)換nobody用戶 # systemctl start nfs.service //啟動(dòng)nfs服務(wù) # cat /etc/rc.local | tail -1 //加入開機(jī)啟動(dòng) /usr/bin/systemctl start nfs.service
# mount -t nfs 172.16.0.3:/data/mydata /mydata //掛載nfs文件至本地 # yum install openssl-devel -yes //安裝openssl-devel包,至此Preconamysql的ssl # cd /usr/lib64 //進(jìn)入lib64# ln -s libssl.so.1.0.1e libssl.so.6 //軟連接,因?yàn)镻reconamysql要依賴該庫(kù),但是我們系統(tǒng)上的是libssl.so.1.0.1e # ln -sv libcrypto.so libcrypto.so.6 //軟連接,因?yàn)镻reconamysql要依賴該庫(kù),但是我們系統(tǒng)上的是libcrypto.so # tar xf /usr/local/src/Percona-Server-5.6.27-rel76.0-Linux.x86_64.ssl098e.tar.gz -C /usr/local //解壓縮至/usr/local,個(gè)人習(xí)慣 # cd /usr/local //進(jìn)入local # ln -sv Percona-Server-5.6.27-rel76.0-Linux.x86_64.ssl098e.tar.gz mysql //不要問為什么,大家都這么做 # groupadd -g 306 mysql //新建組,指定GID306 # useradd -g 306 -u 306 -r -M mysql //新建用戶,指定GID,UID為306 # mkdir /mydata //創(chuàng)建NFS掛載點(diǎn) # cd /usr/local/mysql //進(jìn)入程序包 # chown -R mysql.mysql ./* //-R遞歸 # scripts/mysql_install_db --datadir=/mydata/ --user=mysql //初始化 # cp -p support-files/mysql.server /etc/init.d/mysqld //拷貝啟動(dòng)腳本 # vim /etc/my.cnf //mysql的配置文件,里面的參數(shù)我調(diào)的很小,是因?yàn)閮H做博客測(cè)試使用 # The MySQL server[mysqld] port = 3306 user = mysql datadir = /mydata tmpdir = /dev/shm slave-load-tmpdir = /tmp socket = /mydata/mysql.sock key_buffer_size = 32M max_allowed_packet = 8M # table_cache = 30s join_buffer_size = 16M sort_buffer_size = 16M read_buffer_size = 16M read_rnd_buffer_size = 16M myisam_sort_buffer_size = 32M query_cache_size = 16M query_cache_type = 1 max_tmp_tables = 64 tmp_table_size = 64M max_heap_table_size = 64M thread_cache_size = 32 thread_concurrency = 16 max_connections = 1986 max_user_connections = 0 max_connect_errors = 99999999 wait_timeout = 28800 interactive_timeout = 7200 slow_query_log = 1 long_query_time = 3 log_slow_slave_statements=1 #slow_query_log_timestamp_always =1 slow_query_log_file = /mydata/slow.log back_log = 200 myisam_repair_threads = 1 myisam-recover = DEFAULT expire_logs_days = 20 pid-file = /mydata/mysql.pid binlog_format = mixed init-connect='SET NAMES utf8' character-set-server=utf8 skip-character-set-client-handshake bind-address=0.0.0.0 skip-external-locking #skip-symlink log-slave-updates skip-name-resolve # read_only skip-slave-start server-id = 3306 log-bin = 3306-bin relay-log = 3306-relay-bin log-error=error.log #------------- innodb -------------- innodb_file_format = Barracuda default-storage-engine = InnoDB innodb_buffer_pool_size = 64M innodb_additional_mem_pool_size = 32M innodb_data_file_path = ibdata1:100M:autoextend # innodb_autoextend_increment = 100M innodb_flush_log_at_trx_commit = 0 innodb_log_buffer_size = 8M innodb_log_file_size = 32M innodb_log_files_in_group = 3 innodb_max_dirty_pages_pct = 90 innodb_lock_wait_timeout = 20 innodb_file_per_table = 1 innodb_flush_method = O_DIRECT innodb_support_xa = 0 innodb_io_capacity = 500 # innodb_buffer_pool_instances = 4 [client] user = mysql port = 3306 socket = /mydata/mysql.sock [myisamchk] key_buffer = 32 sort_buffer_size = 32 read_buffer = 32M write_buffer = 32M
# service mysqld start //測(cè)試是否能夠啟動(dòng) # service mysqld stop //然后停止服務(wù) # chkconfig mysqld off //關(guān)閉自動(dòng)啟動(dòng) ps:node{1|2}都是一樣的操作
下載程序包
# cd /usr/local/src # wget https://cn.wordpress.org/wordpress-4.5.3-zh_CN.tar.gz
解壓并設(shè)置 777 權(quán)限,這邊為了方便
# tar xf wordpress-4.5.3-zh_CN.tar.gz -C /var/www/html/ # cd /var/www/html/ # chown -R 777 wordpress
手動(dòng)啟動(dòng)mysql
# service mysqd start
進(jìn)入mysql創(chuàng)建wordpress庫(kù),提供給wordpress初始化呢使用
# mysql -uroot -p //回車輸入自己的密碼,沒設(shè)定密碼直接回車 # CREATE DATABASE wordpess;
授權(quán)wordpress庫(kù)權(quán)限,生產(chǎn)機(jī)建議不要使用通配符
# GRANT ALL ON wordpress.* TO wordpress@‘172.16.%.%' INDENTIFIED BY 'redhat'; # FLUSH PRIVILEGES;
1、填上mysql地址:也就是我們的浮動(dòng)IP:172.16.0.168
2、填上用戶:在數(shù)據(jù)庫(kù)創(chuàng)建的:wordpress
3、填上密碼:redhat
4、其它根據(jù)自己定義填寫即可。
# hb_gui &
1、Resources新建組資源,并命名,注意Parameters里面的值
2、訪問測(cè)試
3、節(jié)點(diǎn)切換并訪問測(cè)
聯(lián)系客服