Install zookeeper on CentOS7

Source: Internet
Author: User

Install zookeeper on CentOS7
Install 1. Modify the operating system/etc/hosts and add the following zookeeper servers

192.168.104.102 zookeeper-01

2. Official Website: http://mirrors.hust.edu.cn/apache/zookeeper/
$ wget http://mirrors.hust.edu.cn/apache/zookeeper/
3. Extract
$ tar -zxvf zookeeper-3.4.6.tar.gz
4. Create data and log folders
$ cd /usr/local/zookeeper-3.4.6$ mkdir data$ mkdir logs
5. Copy zoo_sample.cfg under conf In the zookeeper directory and name it zoo. cfg.
$ cp zoo_sample.cfg zoo.cfg
6. Modify the zoo. cfg configuration file
$ Vi zoo. cfgtickTime = 2000 initLimit = 10 syncLimit = 5 dataDir =/usr/local/zookeeper/datadataLogDir =/usr/local/zookeeper/logsclientPort = 2181 // The following ip Address can also be used as hosts alias zookeeper-01server.1 = 192.168.104.156: 2888: 3888server. 2 = 192.168.104.157: 2888: 3888 // Where 2888 is the port for communications between zookeeper services // 3888 is the port for communications between zookeeper and other applications
Zoo. cfg parameter descriptionParameter NameDescriptionThe clientPort port used by the client to connect to the server, that is, the external service port. Generally, it is set to a time unit in tickTimeZK of 2181. All time in ZK is configured as an integer multiple based on this time unit. For example, the minimum timeout time of a session is 2 * tickTimedataDir directory that stores the snapshot file snapshot. Transaction logs are stored here by default. We recommend that you configure the dataLogDir parameter at the same time. The Write Performance of transaction logs directly affects the zk performance. The dataLogDir transaction log output directory. Configure a separate disk or mount point for the output of transaction logs as much as possible, which will greatly improve the ZK performance and the maximum number of requests accumulated by globalOutstandingLimit. The default value is 1000. When ZK is running, although the server is no longer idle to process more client requests, it still allows the client to submit the requests to the server to improve throughput performance. Of course, in order to prevent Server memory overflow, this number of requests must be limited. (Java system property: zookeeper. globalOutstandingLimit.) preAllocSize pre-opens disk space for subsequent transaction log writing. The default value is 64 MB, and the size of each transaction log is 64 MB. If the snapshot frequency of ZK is large, we recommend that you reduce this parameter to trigger a snapshot (snapshot) every time the snapCount transaction log is output. At this time, ZK will generate a snapshot. and create a new transaction log file .. 100000 by default. (in real code implementation, random number processing is performed to avoid all servers taking snapshots at the same time and affecting performance) (Java system property: zookeeper. snapCount) traceFile is used to record the logs of all requests. It can be used during debugging, but is not recommended in the production environment, which seriously affects the performance. (Java system property :? RequestTraceFile) the maximum number of connections between a single client and a single server in maxClientCnxns is ip. The default value is 60. If it is set to 0, no restrictions are imposed. Note that this restriction only applies to the number of connections between a single client machine and a single ZK server. It does not apply to the specified Client IP address or the number of connections of a ZK cluster, it is not the limit on the number of connections of all clients for a single ZK. Specify the policy of the Client IP address, where there is a patch, you can try: http://rdc.taobao.com/team/jm/archives/1334 (No Java system property) clientPortAddress for machines with multiple NICs, you can specify a different listening port for each IP address. By default, all IP addresses listen to the port specified by clientPort. New in 3.3.0minSessionTimeoutmaxSessionTimeoutSession timeout limit. If the timeout time set by the client is not in this range, it is forcibly set to the maximum or minimum time. The default Session timeout value is 2 * tickTime ~ 20 * the range of tickTime is New in 3.3.0fsync.warningthresholdms. When the transaction log is output, if the fsync method is called more than the specified Timeout time, the warning information is output in the log. The default value is 1000 ms. (Java system property: fsync. warningthresholdms) New in 3.3.4autopurge.purgeInterval as mentioned above, ZK provides the function of automatically clearing transaction logs and snapshot files in versions 3.4.0 and later. This parameter specifies the cleaning frequency, in the unit of hours, you need to configure a 1 or greater integer. The default value is 0, indicating that the automatic cleaning function is not enabled. (No Java system property) the New in 3.4.0autopurge.snapRetainCount parameter is used with the preceding parameter. This parameter specifies the number of files to be retained. By default, three are retained. (No Java system property) New in 3.4.0electionAlg in earlier versions, this parameter configuration allows us to select the leader election algorithm, but since in later versions, only the "TCP-based version of fast leader election" algorithm will be left, so this parameter does not seem to be used at present, and we will not detail it here. (No Java system property) during startup, initLimitFollower synchronizes all the latest data from the Leader, and then determines the Starting Status of the service. Leader allows F to complete this task within the initLimit time. In general, we do not need to care too much about the setting of this parameter. If the amount of data in the ZK cluster is large, the time for synchronizing data from the Leader will also become longer when F is started. Therefore, in this case, it is necessary to increase this parameter properly. (No Java system property) syncLimit during operation, Leader is responsible for communicating with all machines in the ZK cluster, for example, through some heartbeat detection mechanisms to detect the survival status of machines. If the heartbeat packet sent by L has not received a response from F after syncLimit, it is deemed that the F is no longer online. Note: Do not set this parameter too large. Otherwise, some problems may be covered up. (No Java system property) by default, Leader accepts client connections and provides normal read/write services. However, if you want the Leader to focus on the coordination of machines in the cluster, you can set this parameter to no, which will greatly improve the performance of write operations. (Java system property: zookeeper. leaderServes) server. x = [hostname]: nnnnn [: nnnnn] Here x is a number, which is consistent with the id in the myid file. You can configure two ports on the right. The first port is used for data synchronization between F and L and other communications. The second port is used for voting communication during Leader election. (No Java system property) group. x = nnnnn [: nnnnn] weight. x = nnnnn: Specifies the machine group and weight. For more information, see (No Java system property) cnxTimeoutLeader. The timeout value for enabling a connection is 5 s by default. (Java system property: zookeeper. cnxTimeout) zookeeper. digestAuthenticationProvider. for more information about superDigestZK permission settings, see "use super identity to operate on nodes with permissions" and "ZooKeeper permission control" skipACL does not perform ACL checks on all client requests. If you set a permission restriction on the previous node, once this header is opened on the server, it will also become invalid. (Java system property: zookeeper. skipACL) forceSync determines whether to call FileChannel. force when transaction logs are submitted to ensure that data is fully synchronized to the disk. (Java system property: zookeeper. forceSync) maximum data volume of each node in jute. maxbuffer. The default value is 1 MB. This restriction takes effect only when both the server and client are configured. (Java system property: jute. maxbuffer)7. Create a myid file under/home/www/zookeeper-3.4.8/data created above, and write 1 in the machine number (server.1 above) of the corresponding ip address in it
$ vi myid1
8. Configure the environment variables, go to the root (or other users) user directory, Edit. bash_profile, and make the changes take effect.
$ cd ~$ vi .bash_profile#zookeeper envexport ZOOKEEPER_HOME=/usr/local/zookeeper-3.4.8export PATH=$ZOOKEEPER_HOME/bin:$PATH$ source .bash_profile
9. Enable the firewall and enable the above ports
$ chkconfig iptables on$ service iptables start$ vi /etc/sysconfig/iptables-A FORWARD -j REJECT --reject-with icmp-host-prohibited RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 8080 -j ACCEPT-A FORWARD -j REJECT --reject-with icmp-host-prohibited RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 2181 -j ACCEPT-A FORWARD -j REJECT --reject-with icmp-host-prohibited RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 2888 -j ACCEPT-A FORWARD -j REJECT --reject-with icmp-host-prohibited RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 3888 -j ACCEPT $ service iptables restart$ service iptables status

If firewalled of centOS7 is not used here, you can disable firewalled and install iptables. 1. configure the firewall. enable port 80 and port 3306. By default, CentOS 7.0 uses firewall as the firewall. Here, it is changed to iptables firewall. 1. disable firewall: systemctl stop firewalld. service # Stop firewall systemctl disable firewalld. service # disable firewall startup 2. install iptables firewall yum install iptables-services # install vi/etc/sysconfig/iptables # edit firewall configuration file 3. systemctl restart iptables. service # restart the firewall to make the configuration take effect. systemctl enable iptables. service # Set firewall startup

10 start the zookeeper Test
$./ZkServer. sh start $ jps // view the process // view the Production status $./zkServer. sh status // stop the service $./zkServer. sh stop
11 set startup
$ vi /etc/rc.localsu - root -c '/usr/local/jie/zookeeper-3.4.8/bin/./zkServer.sh start'

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.