在linux中安装zookeeper并设置开机自启
时间: 2024-10-26 22:17:57 浏览: 21
Linux上安装ZooKeeper(CentOS7+ZooKeeper3.4.10)相关文件下载
在Linux中安装Zookeeper通常分为几个步骤:
1. **更新包列表**:
```bash
sudo apt-get update
```
2. **安装Zookeeper**(基于Ubuntu或Debian系列):
```bash
sudo apt-get install zookeeper-common
```
或者对于RHEL/CentOS系列:
```bash
sudo yum install epel-release -y
sudo yum install zookeeper
```
3. **配置文件**(`/etc/zookeeper/conf/zoo.cfg`):
确保有适当的配置,比如数据存储目录、服务器地址等。例如:
```ini
dataDir=/var/lib/zookeeper
clientPort=2181
```
更改`clientPort`为你需要的服务端口。
4. **启动服务**:
```bash
sudo service zookeeper start
```
5. **检查是否启动成功**:
```bash
sudo netstat -tulpn | grep [2181]
```
6. **添加开机自启动**(CentOS/RHEL):
```bash
sudo systemctl enable zookeeper
```
或(Ubuntu/Debian):
```bash
sudo systemctl enable zookeeper.service
```
7. **验证服务是否开机自启**:
```bash
sudo systemctl status zookeeper
```
阅读全文