TFS里的Nameserver(NS)是系统里的单点,目前采用主备的方式来保证其高可用性,当主NS挂掉时,vip会切换到备NS上,从而备NS接管服务。本文主要介绍TFS NS高可用的配置方式(使用heartbeat)。 NS主备原理 主备NS共享一个虚拟vip,NS启动时,检查vip是否拥有v
TFS里的Nameserver(NS)是系统里的单点,目前采用主备的方式来保证其高可用性,当主NS挂掉时,vip会切换到备NS上,从而备NS接管服务。本文主要介绍TFS NS高可用的配置方式(使用heartbeat)。
NS主备原理
主备NS共享一个虚拟vip,NS启动时,检查vip是否拥有vip,如果不再,NS将以slave的身份运行;否则如果NS拥有vip,NS就会认为自己是master。
为了避免出现多master的情况,当NS认为自己是master时,会向对端NS节点发送一个确认消息,获取其身份信息,如果发现对端也是master,此时就出现了多master的情况,通常是主备的配置有问题才会出现,这时NS会主动退出,NS启动失败;如果发现对端是slave,则NS正常启动,此时集群里NS正好一主一备。
NS运行过程中,会有后台线程不断检查是否自己拥有vip,当主发现自己不再拥有vip时,就将自己切换为备继续运行;当备发现自己拥有vip时,就会将自己切换为主,同样的,切换前要先确认对端的身份,避免出现两个master的情况。
硬件说明
两台物理机分别部署主备NS服务、主机名分别为tfs036201.sqa.cm4、tfs036203.sqa.cm4,虚拟ip为10.232.36.240,两个物理机的bond0网卡通过交换机连接,并没有使用直连线连接的方式(线上服务强烈建议使用直连线方式,否则如果公用的网络不稳定,容易出现脑裂的情况)。
软件安装
在两台机器上分别安装heartbeat和pacemaker,前者提供多个节点间通讯的基础设施,后者提供集群资源管理的功能。
[linqing.zyd@tfs036203.sqa.cm4 ~]$ rpm -q heartbeat heartbeat-3.0.3-2.el5 [linqing.zyd@tfs036203.sqa.cm4 ~]$ rpm -q pacemaker pacemaker-1.0.8-6.el5
主备NS的配置
修改两台机器上的ns.conf,主要是ip_addr和ip_addr_list两个配置项
[public] # 这里配置NS的vip ip_addr = 10.232.36.240 # NS监听端口 port =8100 [nameserver] # 主备NS的实际ip地址列表 ip_addr_list = 10.232.36.201|10.232.36.203
Heartbeat的配置
tfs-home/scripts/ha目录里包含一些配置模板和工具,进入该目录
修改ha.cf,各个参数的详细含义参考
debugfile /var/log/ha-debug debug 1 keepalive 2 warntime 5 deadtime 10 initdead 30 auto_failback off autojoin none #bcast eth1 ucast bond0 10.232.36.201 udpport 694 node tfs036201.sqa.cm4 node tfs036203.sqa.cm4 compression bz2 logfile /var/log/ha-log logfacility local0 crm respawn
几个重要的参数说明
keepalive 2 节点间的心跳包为2s warntime 5 5s没有心跳包,就发出警告 deadtime 10 10s没有心跳包,认为节点挂了 udpport 694 发送心跳包使用的udp端口 node tfs036201.sqa.cm4 集群里的节点 node tfs036203.sqa.cm4 autojoin none 不允许节点自动加入,必须使用上述node指令来配置 ucast bond0 10.232.36.201 使用单播的方式来发送心跳包,两台机器分别指定对端的地址 如果是直连线的方式,可以使用bcast的方式来发送心跳包
生成authkeys
配置authkeys主要是为了节点间做认证,ha目录下包含了配置工具deploy,直接执行即可。这个脚本的主要工作是生成authkeys,并将ha.cf、authkeys拷贝到/etc/ha.d目录下。
在一个节点配置好之后,将/etc/ha.d/ha.cf、/etc/ha.d/authkeys拷贝到另一个节点的/etc/ha.d目录,因为这里没有采用直连线,ha.cf里ucast那行配置,要稍作修改,设置为对端的ip地址。
配置NameServer资源
主备NS对HA的要求,除了机器宕机时,vip要切换;还要求NS的服务挂掉时,vip也要能切换到备NS,为了实现这个需求,首先要给heartbeat增加一种NameServer的资源,在主备两台机器上直接执行ha目录下的nsdep工具,其将ha/NameServer文件(提供了start、stop、monitor NS服务的功能)拷贝到/usr/lib/ocf/resource.d/heartbeat/目录下。
最后修改ha目录下的ns.xml,配置一下vip资源信息,以及ns服务的资源。
主要修改如下
ip的属性值设置为10.232.36.240 nic的属性值为bond0:0 basedir配置为/home/admin/tfs (设置为tfs的安装目录) nsip配置为10.232.36.204 (ns vip) nsport配置为8100 (ns port) user设置为admin (用于启动服务的用户)
ns.xml准备好后,在主备NS机器上分别执行
crm_attribute --type crm_config --attr-name symmetric-cluster --attr-value true crm_attribute --type crm_config --attr-name stonith-enabled --attr-value false crm_attribute --type rsc_defaults --name resource-stickiness --update 100 cibadmin --replace --obj_type=resources --xml-file /home/admin/tfs/scripts/ha/ns.xml 上述命令做到主要工作包含 1. 配置所有的节点为对等关系,即所有的节点都能接管服务 2. 禁用stonish 3. 应用ns.xml里的配置
最后启动主备NS服务,并在两台机器上启动heartbeat服务
service heartbeat start 或 /etc/init.d/heartbeat start
此时vip落在其中一台机器上,这台机器以主NS的身份运行,另外一个以备NS的身份运行。
测试主备切换
将主NS上的nameserver进程kill掉后会发现,vip已经切换到原来的备NS,原来的备NS(如果备上NS没有启动,会被heartbeat启动起来)检测到vip落在自己身上,切换为主的身份运行。
原来主NS的机器,查看其资源状态,会发现其failcount已经变为1了,该节点被heartbeat认为不可用了。
[linqing.zyd@tfs036201.sqa.cm4 tfs_new]$ sudo crm resource failcount tfs-name-server show tfs036201.sqa.cm4 scope=status name=fail-count-tfs-name-server value=1
此时如果原来的备NS接管服务后,再次宕机了,服务将不能切回到原来的主,必须先将其failcount清0,才能正确的切回。
sudo crm resource failcount tfs-name-server set tfs036201.sqa.cm4 0
The post TFS Nameserver HA配置 appeared first on Yun Notes.

InnoDBBufferPool reduces disk I/O by caching data and indexing pages, improving database performance. Its working principle includes: 1. Data reading: Read data from BufferPool; 2. Data writing: After modifying the data, write to BufferPool and refresh it to disk regularly; 3. Cache management: Use the LRU algorithm to manage cache pages; 4. Reading mechanism: Load adjacent data pages in advance. By sizing the BufferPool and using multiple instances, database performance can be optimized.

Compared with other programming languages, MySQL is mainly used to store and manage data, while other languages such as Python, Java, and C are used for logical processing and application development. MySQL is known for its high performance, scalability and cross-platform support, suitable for data management needs, while other languages have advantages in their respective fields such as data analytics, enterprise applications, and system programming.

MySQL is worth learning because it is a powerful open source database management system suitable for data storage, management and analysis. 1) MySQL is a relational database that uses SQL to operate data and is suitable for structured data management. 2) The SQL language is the key to interacting with MySQL and supports CRUD operations. 3) The working principle of MySQL includes client/server architecture, storage engine and query optimizer. 4) Basic usage includes creating databases and tables, and advanced usage involves joining tables using JOIN. 5) Common errors include syntax errors and permission issues, and debugging skills include checking syntax and using EXPLAIN commands. 6) Performance optimization involves the use of indexes, optimization of SQL statements and regular maintenance of databases.

MySQL is suitable for beginners to learn database skills. 1. Install MySQL server and client tools. 2. Understand basic SQL queries, such as SELECT. 3. Master data operations: create tables, insert, update, and delete data. 4. Learn advanced skills: subquery and window functions. 5. Debugging and optimization: Check syntax, use indexes, avoid SELECT*, and use LIMIT.

MySQL efficiently manages structured data through table structure and SQL query, and implements inter-table relationships through foreign keys. 1. Define the data format and type when creating a table. 2. Use foreign keys to establish relationships between tables. 3. Improve performance through indexing and query optimization. 4. Regularly backup and monitor databases to ensure data security and performance optimization.

MySQL is an open source relational database management system that is widely used in Web development. Its key features include: 1. Supports multiple storage engines, such as InnoDB and MyISAM, suitable for different scenarios; 2. Provides master-slave replication functions to facilitate load balancing and data backup; 3. Improve query efficiency through query optimization and index use.

SQL is used to interact with MySQL database to realize data addition, deletion, modification, inspection and database design. 1) SQL performs data operations through SELECT, INSERT, UPDATE, DELETE statements; 2) Use CREATE, ALTER, DROP statements for database design and management; 3) Complex queries and data analysis are implemented through SQL to improve business decision-making efficiency.

The basic operations of MySQL include creating databases, tables, and using SQL to perform CRUD operations on data. 1. Create a database: CREATEDATABASEmy_first_db; 2. Create a table: CREATETABLEbooks(idINTAUTO_INCREMENTPRIMARYKEY, titleVARCHAR(100)NOTNULL, authorVARCHAR(100)NOTNULL, published_yearINT); 3. Insert data: INSERTINTObooks(title, author, published_year)VA


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SublimeText3 English version
Recommended: Win version, supports code prompts!

SublimeText3 Chinese version
Chinese version, very easy to use

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software