1.开启ssh服务
- 安装:
sudo apt-get install openssh-server
- 启动:
sudo service ssh start
- 查询服务状态:
sudo ps -e | grep ssh
或者sudo service ssh status
- 设置开机自动启动:
sudo systemctl enable ssh
2.安装python虚拟环境
- 安装:
sudo apt-get install virtualenv
和sudo apt-get install virtualenvwrapper
- 激活:
找到脚本位置whereis virtualenvwrapper.sh
执行一下source /usr/share/virtualenvwrapper/virtualenvwrapper.sh
3.换源(阿里云)
-
输入命令:
sudo vim /etc/apt/sources.list
-
更换阿里云的源:
# deb cdrom:[Ubuntu 16.04 LTS _Xenial Xerus_ - Release amd64 (20160420.1)]/ xenial main restricted deb-src http://archive.ubuntu.com/ubuntu xenial main restricted #Added by software-properties deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted multiverse universe #Added by software-properties deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted multiverse universe #Added by software-properties deb http://mirrors.aliyun.com/ubuntu/ xenial universe deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe deb http://mirrors.aliyun.com/ubuntu/ xenial multiverse deb http://mirrors.aliyun.com/ubuntu/ xenial-updates multiverse deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse #Added by software-properties deb http://archive.canonical.com/ubuntu xenial partner deb-src http://archive.canonical.com/ubuntu xenial partner deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted multiverse universe #Added by software-properties deb http://mirrors.aliyun.com/ubuntu/ xenial-security universe deb http://mirrors.aliyun.com/ubuntu/ xenial-security multiverse
4.安装sublime(添加仓库)
- 添加key和仓库:
wget -qO - https://download.sublimetext.com/sublimehq-pub.gpg | sudo apt-key add -
echo "deb https://download.sublimetext.com/ apt/stable/" | sudo tee /etc/apt/sources.list.d/sublime-text.list
- 安装:
sudo apt-get update
sudo apt-get install sublime-text
- 卸载:
sudo apt-get remove sublime-text && sudo apt-get autoremove
5.安装mysql
-
执行命令:
sudo apt-get install mysql-server sudo apt install mysql-client sudo apt install libmysqlclient-dev
-
检查安装:
sudo netstat -tap | grep mysql
-
登录:
mysql -uroot -p你的密码
-
修改配置:
sudo vi /etc/mysql/mysql.conf.d/mysqld.cnf
注释掉:
bind-address = 127.0.0.1
执行授权命令:grant all on . to root@'%' identified by '你的密码' with grant option; flush privileges;
6.安装thrift
-
安装依赖工具和库:
sudo apt-get install automake bison flex g++ git libboost-all-dev libevent-dev libssl-dev libtool make pkg-config
-
安装thrift编译器和程序库:
打开:下载地址
或者:wget http://mirror.bit.edu.cn/apache/thrift/0.11.0/thrift-0.11.0.tar.gz
然后:tar -zxvf thrift-0.11.0.tar.gz cd thrift-0.11.0 ./configure --prefix=/usr/local/ --without-php --without-java --without-perl --without-nodejs sudo make sudo make install
最后验证:
thrift -version
7.Ubuntu16.04安装kafka服务
7.1下载安装
- 下载: 下载地址
- 不想下载直接按照我的方式安装也行
下载:curl "http://mirror.bit.edu.cn/apache/kafka/2.1.0/kafka_2.11-2.1.0.tgz" -o ~/Downloads/kafka.tgz
解压:tar -xzvf ~/Downloads/kafka.tgz --strip 1 -C ~/kafka/
- 安装jiava依赖(有可跳过)
sudo apt-get install openjdk-8-jdk
- 开启zookeeper服务
bin/zookeeper-server-start.sh config/zookeeper.properties
- 开启kafka服务
bin/kafka-server-start.sh config/server.properties
- 开启一个topic
./bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic xxx
查看:bin/kafka-topics.sh --list --zookeeper localhost:2181
- 生产者
bin/kafka-console-producer.sh --broker-list localhost:9092 --topic xxx
- 消费者
bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic xxx
参考链接:https://segmentfault.com/a/1190000012730949
7.2用supervisor进行管理
-
安装:
sudo apt-get install supervisor
-
配置:
# 配置zookeeper:
sudo vim /etc/supervisor/conf.d/zookeeper.conf
# 写入如下内容
[program:zookeeper_for_kafka]
command=/home/will/kafka/bin/zookeeper-server-start.sh /home/will/kafka/config/zookeeper.properties ; 程序启动命令
autostart=true ; 在supervisor启动的时候也自动启动
startsecs=10 ; 启动十秒后没有异常退出,就表示进程正常启动了
autorestart=true ; 程序退出后自动重启
startretries=3 ; 启动失败自动重试次数,默认是3
user=will ; 是哪个用户启动进程,默认是root
priority=999 ; 进程启动优先级,默认999,值小的启动
redirect_stderr=true ; 将stderr重定向到stdout,默认false
stdout_logfile_maxbytes=20MB ; stdout 日志文件大小,默认50MB
stdout_logfile_backups = 20 ; stdout 日志文件备份数,默认是10
stdout_logfile=/home/will/kafka/logs/supervisor_zookeeper.log ; 要保证路径存在,supervisor会自动创建日志文件
stopasgroup=false ;默认为false,进程被杀死时,是否向这个进程组发送stop信号,包括子进程
killasgroup=false ;默认为false,向进程组发送kill信号,包括子进程
# 配置kafka:
sudo vim /etc/supervisor/conf.d/kafka.conf
# 写入如下内容
[program:kafka]
command=/home/will/kafka/bin/kafka-server-start.sh /home/will/kafka/config/server.properties
autostart=true ; 在supervisor启动的时候也自动启动
startsecs=10 ; 启动十秒后没有异常退出,就表示进程正常启动了
autorestart=true ; 程序退出后自动重启
startretries=3 ; 启动失败自动重试次数,默认是3
user=will ; 是哪个用户启动进程,默认是root
priority=999 ; 进程启动优先级,默认999,值小的启动
redirect_stderr=true ; 将stderr重定向到stdout,默认false
stdout_logfile_maxbytes=20MB ; stdout 日志文件大小,默认50MB
stdout_logfile_backups = 20 ; stdout 日志文件备份数,默认是10
stdout_logfile=/home/will/kafka/logs/supervisor_kafka.log ; 要保证路径存在,supervisor会自动创建日志文件
stopasgroup=false ;默认为false,进程被杀死时,是否向这个进程组发送stop信号,包括子进程
killasgroup=false ;默认为false,向进程组发送kill信号,包括子进程