1. Connect to CentOS 7 server with Linux client tools such as SecureCRT or XShell.
Enter into the / usr/local/tools directory:
cd /usr/local/ If this directory is not available, create: mkdir -p tools
3 Download zookeeper-3.4.8.tar.gz:
wget http://apache.fayea.com/zookeeper/zookeeper-3.4.8/zookeeper-3.4.8.tar.gz
4 Return to the previous directory and create the zookeeper folder:
cd ..
mkdir -p zookeeper
5 Move the zookeeper-3.4.8 file from the / usr/local/tools folder to the / usr/local/zookeeper folder:
mv ./tools/zookeeper-3.4.8 ./zookeeper/
6 into the zookeeper/zookeeper-3.4.8/conf directory:
cd zookeeper/zookeeper-3.4.8/conf
7 Copy the zoo_sample.cfg file and name the new file zoo.cfg:
cp zoo_sample.cfg zoo.cfg
8 Modify zoo.cfg file:
vi zoo.cfg Enter into zoo.cfg file; Modify the data folder dataDir=/tmp/zookeeper to dataDir=/usr/local/zookeeper/zookeeper-3.4.8/data Configure the log folder dataLogDir=/usr/local/zookeeper/zookeeper-3.4.8/logs
Save and exit;
9 Set the root directory of zookeeper to the system environment variable PATH:
sudo vi /etc/profile
Add the following configuration at the end of the open profile file:
export ZOOKEEPER_HOME=/usr/local/zookeeper/zookeeper-3.4.8
export PATH=$ZOOKEEPER_HOME/bin:$PATH
export PATH
Save and exit vi;
Refresh the profile file to take effect immediately:
source /etc/profile
10 Execute the following command to start the zookeeper service:
cd /usr/local/zookeeper/zookeeper-3.4.8/bin
zkServer.sh start
Printing the following information indicates that zookeeper was started successfully:
ZooKeeper JMX enabled by default
Using config: /usr/local/zookeeper/zookeeper-3.4.8/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
Then the operation to start the zookeeper service is executed.
11 View zookeeper's current status:
zkServer.sh status
The following information appears:
Using config: /usr/local/zookeeper/zookeeper-3.4.8/bin/../conf/zoo.cfg
Mode: standalone
standalone is in stand-alone mode.
12 Close zookeeper service:
zkServer.sh stop
If the following information is printed, the zookeeper is successfully closed:
Using config: /usr/local/zookeeper/zookeeper-3.4.8/bin/../conf/zoo.cfg
Stopping zookeeper ... STOPPED
13 Restart the zookeeper service:
zkServer.sh restart
If the following information is printed, the zookeeper service is restarted successfully:
ZooKeeper JMX enabled by default
Using config: /usr/local/zookeeper/zookeeper-3.4.8/bin/../conf/zoo.cfg
ZooKeeper JMX enabled by default
Using config: /usr/local/zookeeper/zookeeper-3.4.8/bin/../conf/zoo.cfg
Stopping zookeeper ... STOPPED
ZooKeeper JMX enabled by default
Using config: /usr/local/zookeeper/zookeeper-3.4.8/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
14. Connect the zookeeper server of the specified IP through the client program, or connect the zookeeper server of any IP:
zkCli.sh -server localhost:2181
The following commands can also be used directly on this machine:
zkCli.sh
15 View zookeeper startup status:
echo ruok | nc localhost 2181
16 View zookeeper's process:
jps
The number before Quorum PeerMain in the printed information represents the PID of zookeeper.
17 Create myid file in / usr/local/zookeeper/zookeeper-3.4.8/data / directory with the content of service number;
There is no deliberate master/slave relationship between 18 zooKeeper services
Each node is a server. If the server leader hangs up, it will immediately elect a new leader server from the server follower. Each zookeeper server exchanges information through TCP protocol.
Appendix 1:
zookeeper Download List:
http://apache.fayea.com/zookeeper/
Can choose
http://apache.fayea.com/zookeeper/zookeeper-3.4.8/
Attached two:
zoo.cfg configuration file:
# The number of milliseconds of each tick
tickTime=2000
# The number of ticks that the initial
# synchronization phase can take
initLimit=10
# The number of ticks that can pass between
# sending a request and getting an acknowledgement
# During the synchronization phase, no more than a few tick s are allowed between relaxation and acceptance of requests.
syncLimit=5
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just
# example sakes.
# dataDir=/tmp/zookeeper
# Configuration Data Directory
dataDir=/usr/local/zookeeper/zookeeper-3.4.8/data
# Configuration log directory
dataLogDir=/usr/local/zookeeper/zookeeper-3.4.8/logs
# the port at which the clients will connect
# The port number of the client accessing zookeeper:
clientPort=2181
# the maximum number of client connections.
# increase this if you need to handle more clients
#maxClientCnxns=60
#
# Be sure to read the maintenance section of the
# administrator guide before turning on autopurge.
#
# http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance
#
# The number of snapshots to retain in dataDir
#autopurge.snapRetainCount=3
# Purge task interval in hours
# Set to "0" to disable auto purge feature
#autopurge.purgeInterval=1
# 2888,3888 are election port
# server.1, 2 and 3 represent servers 1, 2 and 3 in zookeeper cluster.
# Zookeeper represents the IP of the current zookeeper server. Since zookeeper maps the local IP in the hosts file, you can write zookeeper directly here.
# 2888 represents the port of communication between zookeeper server 1, 2, 3 and leader server in zookeeper cluster.
# 3888 indicates the port for exchanging information when the leader server in the zookeeper cluster hangs up to elect a new leader server.
server.1=192.168.1.100:2888:3888
server.2=192.168.1.101:2888:3888
server.3=192.168.1.102:2888:3888
Attached three:
zookeeper configuration file description:
clientPort # The port of client connecting server, i. e. external service port, is generally set to 2181.
dataDir # The directory where snapshot files are stored. By default, the transaction log is also stored here. It is suggested to configure the parameter dataLogDir at the same time. Transaction log writing performance directly affects zk performance.
tickTime # A time unit in ZK. All the time in ZK is based on this unit of time and integer multiple configuration. For example, the minimum timeout time for session is 2*tickTime.
dataLogDir # Transaction log output directory. Try to configure a separate disk or mount point for the output of the transaction log, which will greatly improve ZK performance.
globalOutstandingLimit # Maximum number of requests stacked. The default is 1000. When ZK runs, although server is no longer free to handle more client requests, it allows clients to submit requests to the server to improve throughput performance. Of course, in order to prevent Server memory overflow, the number of requests stacked needs to be limited. Java system property:zookeeper.globalOutstandingLimit.
preAllocSize # Open up disk space in advance for subsequent write to transaction log. The default is 64M, and the size of each transaction log is 64M. If the snapshot frequency of ZK is high, it is suggested to reduce this parameter appropriately.
snapCount # After each snapCount transaction log output, a snapshot is triggered, at which time ZK generates a snapshot. * file and creates a new transaction log file log. *. The default is 100000. (In real code implementations, some random number processing is performed to avoid all servers taking snapshots at the same time affecting performance.)
traceFile # Logs used to record all requests are generally available during debugging, but are not recommended in production environments, which can seriously affect performance.
maxClientCnxns # The limit on the number of connections between a single client and a single server is at the IP level. The default is 60. If set to 0, then no restrictions are made. Note that the scope of use of this restriction is only the number of connections between a single client machine and a single ZK server, not for the specified client IP, nor for the number of connections in a ZK cluster, nor for all clients in a single ZK.
clientPortAddress # For multi-network card machines, different listening ports can be specified for each IP. By default, all IP listens on the port specified by clientPort.
minSessionTimeoutmaxSessionTimeout # Session timeout time limit, if the client set timeout is not in this range, then it will be forced to set the maximum or minimum time. The default Session timeout is in the range of 2 * tickTime to 20 * tickTime.
fsync.warningthresholdms # When the transaction log is output, if the fsync method is called more than the specified timeout time, the warning message is output in the log. The default is 1000ms.
autopurge.purgeInterval # In version 3.4.0 and later, ZK provides the function of automatically cleaning transaction logs and snapshot files. This parameter specifies the cleaning frequency, unit of hour, and needs to configure an integer of 1 or more. By default, ZK does not open the automatic cleaning function.
autopurge.snapRetainCount # This parameter is used in conjunction with the above parameter, which specifies the number of files to be retained. The default is to keep three.
electionAlg #In previous versions, this parameter configuration allowed us to choose the leader election algorithm, but since in future versions, only a "TCP-based version of fast leader election" algorithm will be left, this parameter seems useless at present.
initLimit # Follower synchronizes all the latest data from Leader during startup, and then determines the start state of its external service. Leader allows F to do this in initLimit time. Normally, we don't care too much about setting this parameter. If the amount of data in the ZK cluster is really large, the synchronization time from Leader will be longer when F starts, so in this case, it is necessary to adjust this parameter appropriately.
syncLimit # During the running process, Leader is responsible for communicating with all the machines in the ZK cluster, for example, through some heartbeat detection mechanisms to detect the machine's survival status. If L sends out a heartbeat packet after syncLimit and has not received a response from F, then it is assumed that F is no longer online. Note: Do not set this parameter too large, or it may cover up some problems.
leaderServes # By default, Leader accepts client connections and provides normal read-write services. However, if you want Leader to focus on the coordination of machines in the cluster, you can set this parameter to no, which greatly improves the performance of write operations.
server.X=A:B:C # Where X is a number, indicating which server. A is the IP address of the server. B configures the port used for exchanging messages between the server and the leader in the cluster. C configures the port used for electing the leader. Here x is a number, consistent with the id in the myid file. On the right, you can configure two ports, the first for data synchronization and other communications between F and L, and the second for voting communications during Leader elections.
group.x=nnnnn[:nnnnn]weight.x=nnnnn # For machine grouping and weight settings,
cnxTimeout # During the Leader election, the time-out for opening a connection is 5 s by default.
zookeeper.DigestAuthenticationProvider.superDigest # ZK permission settings are relevant
skipACL # No ACL checks are performed on all client requests. If permission restrictions were set on previous nodes, once this start is opened on the server, it will also fail.
forceSync # This parameter determines whether FileChannel. force needs to be invoked when the transaction log is submitted to ensure that the data is fully synchronized to disk.
jute.maxbuffer # The maximum amount of data per node is 1 M by default. This restriction must be set on both server and client sides before it takes effect.
------------------------—–
java Architect Project, High Concurrency Cluster Distributed, Large Data High Availability Video Tutorial, 760G
Download address:
https://item.taobao.com/item.htm?id=555888526201
01. Forty-two phases of senior architects
02.Java Advanced System Training Architecture Course 148 Hours
03.Java Advanced Internet Architect Course
04.Java Internet Architecture Netty, Nio, Mina, etc. - Video tutorials
05.Java Advanced Architecture Design 2016 Arrangement - Video Tutorial
06. Architect Foundation, Advanced Film
07.Java Architect Compulsory linux Operations and Maintenance Series
08.Java Advanced System Training Architecture Course 116 Hours
+
hadoop series of tutorials, java design patterns and data structures, Spring Cloud micro services, Spring Book introductory
Details:
[Introduction]
Application of Socket network programming in J2SE
Advanced Application of J2SE Reflection Mechanism
J2SE Profound Explanation
Intermediate Course of JAVA Programming Thought
JAVA Programming Thought Primary Course
Advanced Course of JAVA Programming Thought
Development of QQ Chat Tool Based on J2SE
For me, object-oriented
[Advanced Chapter]
CRM project
Eclipse
Hibernate
JAVA WEB Develops Video
JAVAWEB Development Practical Classic-Advanced Case
JAVAWEB
JAVA Thread Concurrency Tutorial
java Online Payment Video
java Design Patterns
jdbc
junit
mybatis
spring mvc
Spring Mvc+Spring+MyBatis+Maven Integrated Video
SpringMVC
Spring
Struts 2 Development Practical Explanation
Struts 2 + Spring 3 + Hibernate 4 + Maven + EasyUI integration introductory video
Struts
SVN
tomcat
weblogic
Web Service from Initial to Beginning Enterprise Development
OA Office Automation of Enterprise System
Mobile Phone Purchase, Sale and Storage System
Data Structure and Algorithmic Video
Design pattern series
[Advanced Chapter]
Cas Single Sign-on
Extjs 4.1 + Spring 3.2 + Hibernate 4.1 + MySql5 Mall
Git Authoritative Guide
groovy introductory video
New features of Java 8
Lucene
Mongodb
node.js
Nutch related framework
OA Office Automation System
Quartz Job Timing Task
Solr Advanced Application Video
Spring Security Rights Control
Spring Source Code Interpretation and Design
Struts 2 Source Analysis and Architectural Guidance
Large CMS Content Management System Project
Wechat Introductory Video
Deep into JVM Kernel-Principle, Diagnosis and Optimization
In-depth analysis of the actual development of Wechat public platform (micro-website, LBS cloud, Api interface call, service number advanced interface)
Bank Interface Information
[Architecture Chapter]
ActiveMQ Actual Warfare
Apache-Tomcat Cluster Building
Linux cluster
Linux Advanced Architecture Scheme and Implementation Guide
Memcached Distributed Cluster
Mysql Super Optimized Course
Nginx+Tomcat+Memcached Cluster Configuration Package
Nginx Server Construction
Nginx Web Architecture Practice (Web Server Load Balancing and Reverse Proxy)
SOA Dubbo
storm Initial to Proficiency
Building storm Cluster
storm Project
UML modeling
Internet Corporation Technology Architecture Series
Practice and Consideration of Recommended Search on Jingdong B2C Platform
Beijing East University Data Analysis and Innovative Application
Continuous research and development of large-scale storage in Jingdong
Key Technologies of OFC System for Massive Order Processing in Jingdong E-Commerce
Architectural Design Scheme of Youmi Network
Million Data Architecture Based on SOA
MySQL optimization for speeding up large websites
Architecture Design of Large Website
Practical case of large data high concurrency architecture
Data optimization technology Redis
High concurrency principle of database
Deep into Java program performance tuning
A Brief Introduction to MongoDB Application Practical Cluster and System Architecture
Deep Secret Server-side Insider
Solr Application of E-commerce Website
System Architect Designer
Ali Distributed Database Service Practice
------------------------—–