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 root@localhost: 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进行访问
安装Mysql8
# 下载el7的mysql8rpm包
wget https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-8.0.18-1.el7.x86_64.rpm-bundle.tar
tar -xf mysql-8.0.18-1.el7.x86_64.rpm-bundle.tar
yum install -y mysql-community-{client,common,devel,embedded,libs,server}-*
# 报错 Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
yum provides '*/applydeltarpm'
yum install deltarpm -y
# 再次执行
yum install -y mysql-community-{client,common,devel,embedded,libs,server}-*
systemctl start mysqld
systemctl enable mysqld
# 获取 随机密码
grep 'temporary password' /var/log/mysqld.log
vi /etc/my.cnf
validate_password.check_user_name =OFF
validate_password.length =0
validate_password.mixed_case_count =0
validate_password.number_count =0
validate_password.policy =0
validate_password.special_char_count =0
#validate_password=OFF # 8中不好用了
character-set-server=utf8
collation-server=utf8_general_ci
[client]
default-character-set=utf8
# 重启 一定得先做
systemctl restart mysqld
# 登录修改密码与远程访问
mysql -u root -p
#更改密码
ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';
use mysql;
update user set host = '%' where user = 'root';
# 测试 navicat 远程没法访问 [1251 client does not support authentication protocol requested by server]
## 更新密码时 需要用 `WITH mysql_native_password`
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '123456';
FLUSH PRIVILEGES;
安装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