huoxiangdong / Blog

学习记录
0 stars 0 forks source link

环境部署 #27

Open huoxiangdong opened 6 years ago

huoxiangdong commented 6 years ago

sudo vi /etc/docker/daemon.json

添加以下内容

{ "registry-mirrors": ["https://ihep3sb9.mirror.aliyuncs.com"] }

重启进程

sudo service docker restart

- 创建共享目录
```bash
sudo su
mkdir /share && chmod 777 /share
ln -s /share .

-p 3306:3306:将容器的3306端口映射到主机的3306端口

-v $PWD/share:/var/lib/mysql:将主机当前目录下的/mysql挂载到容器的/var/lib/mysql

-e MYSQL_ROOT_PASSWORD=root:初始化root用户的密码

--name 给容器命名,mysql

-d 指定镜像

docker ps -a


- 配置mysql
```bash
# 进入
docker exec -it mysql bash
#进入mysql
mysql -uroot -p
#mysql 
show databases; 
#切换数据库
use mysql; 
SELECT `User`, `Host` FROM `user`;
# 创建用户
#CREATE USER 'admin'@'%' IDENTIFIED BY 'admin';
#授权
#grant all on *.* to 'admin'@'%';
#注意:用以上命令授权的用户不能给其它用户授权,如果想让该用户可以授权,用以下命令: 
# GRANT all ON databasename.tablename TO 'username'@'host' WITH GRANT OPTION; 
# 更改加密认证
#ALTER USER 'root'@'%' IDENTIFIED BY 'root' PASSWORD EXPIRE NEVER; #修改加密规则,永不过期
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'root';
#FLUSH PRIVILEGES; #刷新权限
#alter user 'root'@'%' identified by 'root';
huoxiangdong commented 6 years ago

npm更换源


npm config set registry https://registry.npm.taobao.org  
npm config list` ---查看更换

or:
npm install cnpm -g --registry=https://registry.npm.taobao.org
huoxiangdong commented 6 years ago

tnvm node版本管理


wget -O- https://raw.githubusercontent.com/aliyun-node/tnvm/master/install.sh | bash
#export METHOD=script
# 使环境生效
source /root/.bashrc
# 查看版本
tnvm ls-remote node
#安装
tnvm install node-v7.0.0
#切换版本
tnvm use node-v7.0.0
huoxiangdong commented 6 years ago

mysql补充


# 文件存放目录
show global variables like '%datadir%';
huoxiangdong commented 6 years ago

后台进程


nohup npm run dev &
huoxiangdong commented 6 years ago

# build
docker build -t="huoxiangdong/frp" .
# login
docker login
# 打标签
docker tag <existing-image> <hub-user>/<repo-name>[:<tag>]
# 上传
docker push <hub-user>/<repo-name>:<tag>
# 实例
docker tag huoxiangdong/frp huoxiangdong/frp:v0.0.1
docker push huoxiangdong/frp:v0.0.1