目录
docker
yum install docker
systemctl start docker
systemctl enable docker
docker pull centos
- 执行
yum install
等待很漫长。如果报错:Cannot set property TasksAccounting, or unknown property
安装java
cp jdk*.tar.gz到容器中,解压
-
vi /etc/profile
export JAVA_HOME=/usr/local/java8 export PATH=$JAVA_HOME/bin:$PATH export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
source /etc/profile
java -version
安装mysql
- 获取 mysql 的yum源
#获取 mysql 的yum源
wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
#安装上面的yum 源
yum -y install mysql57-community-release-el7-10.noarch.rpm
#yum 安装 mysql
yum -y install mysql-community-server
#开启服务
systemctl start mysqld
- 查看配置文件位置
mysqld --verbose --help --pid-file=/var/run/mysqld/mysqld.pid | grep -A 1 "Default options"
Default options are read from the following files in the given order:
/etc/my.cnf /etc/mysql/my.cnf /usr/etc/my.cnf ~/.my.cnf
- 更改mysql 配置:/etc/my/cnf
validate_password=OFF
character-set-server=utf8
collation-server=utf8_general_ci
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
[client]
default-character-set=utf8
- 获取mysql 初始密码
grep "password" /var/log/mysqld.log
#结果:[Note] A temporary password is generated for [email protected]: k:nT<dT,t4sF
#使用这个密码登录mysql
#r.,X_Wj3o3uc
#fGR2hW)tC;.(
- 进入到mysql,进行操作
# 进入
mysql -u root -p
#更改密码
ALTER USER 'root'@'localhost' IDENTIFIED BY '111111';
# 更改 使mysql可以远端访问
update user set host = '%' where user = 'root';
- 测试,可以使用物理机,使用navicat 对docker中的mysql进行访问
安装python3
yum install -y https://centos7.iuscommunity.org/ius-release.rpm
yum update
yum install -y python36u python36u-libs python36u-devel python36u-pip
yum install gcc
python3.6 --version
pip3.6 --version
安装supervisor
pip3.6 install supervisor
mkdir /etc/supervisor
echo_supervisord_conf > /etc/supervisor/supervisord.conf
- 更改配置文件
minfds= 819200
[include]
files = /etc/supervisor/*.ini
/tmp/supervisor.sock 改成 /var/run/supervisor.sock,
/tmp/supervisord.log 改成 /var/log/supervisor.log,
/tmp/supervisord.pid 改成 /var/run/supervisor.pid
[supervisorctl]
serverurl=unix:///tmp/supervisor.sock ;改为serverurl=unix:///var/run/supervisor.sock
chmod 777 /run
chmod 777 /var/log
touch /var/run/supervisor.sock
chmod 777 /var/run/supervisor.sock
unlink /var/run/supervisor.sock
supervisord -c /etc/supervisor/supervisord.conf
#将需要监控的编写ini放到/etc/supervisor文件下
1. touch /usr/lib/systemd/system/supervisord.service
2. vi /usr/lib/systemd/system/supervisord.service
# supervisord service for systemd (CentOS 7.0 )
# by ET-CS (https://github.com/ET-CS)
[Unit]
Description=Supervisor daemon
[Service]
Type=forking
ExecStart=/usr/bin/supervisord -c /etc/supervisor/supervisord.conf
ExecStop=/usr/bin/supervisorctl shutdown
ExecReload=/usr/bin/supervisorctl reload
KillMode=process
Restart=on-failure
RestartSec=42s
[Install]
WantedBy=multi-user.target
2. systemctl enable supervisord
3. systemctl is-enabled supervisord
- ini例子
[program:test]
user=root
command = nohup java -Xms3g -Xmx3g -jar test.jar > test.log 2>&1 &
directory=/root/test
startsecs=3
stopwaitsecs=0
autostart=true
autorestart=true
stdout_logfile=/var/log/test.log
stderr_logfile=/var/log/test.err
安装ElasticSearch
需要Java环境
- 下载tar.gz并解压,并移动
mv elasticsearch-7.1.0 /usr/local/elasticsearch
- 修改配置
vi /usr/local/elasticsearch/config/elasticsearch.yml
- yml文件
network.host: 0.0.0.0
http.port: 9200
discovery.seed_hosts: ["127.0.0.1", "[::1]"]
# 7.1 版本即便不是多节点也需要配置一个单节点,否则
#the default discovery settings are unsuitable for production use; at least one of [discovery.seed_hosts, discovery.seed_providers, cluster.initial_master_nodes] must be configured
cluster.initial_master_nodes: ["node-1"]
# 配置indices fielddata得内存,超过80%就会释放
indices.fielddata.cache.size: 80%
# request数量使用内存限制,默认为JVM堆的40%。
indices.breaker.request.limit: 80%
- 创建一个非
root
用户elsearch
来执行elasticsearch脚本。ES不能用root用户启动
# elasticsearch can not run elasticsearch as root
adduser elsearch # 会自动建组 test
# 将文件夹以及子文件夹全部该为test用户
chown -R elsearch:elsearch elasticsearch
ll
# drwxr-xr-x 1 elsearch elsearch 4096 May 28 16:54 elasticsearch
- 7.X新特性
- removal mapping types官方:https://www.elastic.co/guide/en/elasticsearch/reference/current/removal-of-types.html
目前版本有一个默认的type _doc,使用api对文档操作的时候,也不需要在url上加入 type了,直接index即可,具体的api可以大部分都可以通过在url去掉type进行操作。
- not_analyzed不存在了,如果需要不拆分
可以对index进行analyzer设置,将默认的analyzer设置成keyword就不会拆分了。
----------------------------------------------------------------
设置analyzer:需要先关闭index
1. POST http://server_ip/index_name/_close?pretty
2. PUT : http://server_ip/index_name/_settings?pretty
BODY:
{
"index":{
"analysis" : {
"analyzer" : {
"default" : {
"type" : "keyword"
}
}
}
}
}
3. POST http://server_ip/index_name/_open?pretty
- 没有
string
这个 column type了。可以换成text
或者keyword
- 在查询中,新增
{"track_total_hits":true}
,可以查询出total得总数。不会被限制成10000
打包images
- 上传到dockerhub得做法
sudo docker commit -a kane testdocker.io/kane0725/test:v1
# 注,这里为了能够提交到dockerhub上, 命名规则必须为docker.io/dockerhub name/****
docker login
docker push docker.io/kane0725/test:java
- 本地保存镜像得做法
# 导出打成本地 tar 包
docker export -o test.tar a404c6c174a2
# 将 tar 包导入成镜像
docker import test.tar test_images