安装mysql:
1. 安装:sudo yum install mysql-server
2. 改密码:
获取密码grep "password"/var/log/mysqld.log
使用mysqladmin修改密码mysqladmin -u root -p oldpasswd -password newpasswd
3. 由于在公司需要改端口
http://blog.itpub.net/26148431/viewspace-1466379/
4. 权限问题
a. Mysql -u root -p
b. Grant all privileges on *.* to ‘user’@’%’identifiedby ‘password’;
c. Flush privileges;
d. Service mysql restart
5. 防火墙:
a. 先添加配置firewall-cmd --add-port=/tcp --permanent
b. reload使配置生效firewall-cmd --reload
Docker:
1. 安装docker:
安装:sudoyum install docker
2. 启进程:systemctl start docker
3. 创建Dockerfile文件
Vi Dockerfile
a. 准备dockerfile
4. 上传文件到服务器:
a. 允许scp上传文件 Yum install openssh-server
b. Windows端:git bash: scp restmanagement.xiproot@host:/home
c. 解压文件:unzip zipfile(first should: yuminstall -y unzip)
5. 制作镜像
a. 启动docker:systemctl start docker
b. Docker build -t .
c. Docker run -p :80 -t -i
6. Docker run server successfully,Web access denied.
7. 出错debug
a. 配置http服务器:
Down httpd.conf
scproot@198.13.35.165:/home/temp/httpd.confhttpd.conf
scp httpd.confroot@198.13.35.165:/home/temp/httpd.conf
addbelow code in httpd.conf:
LoadModule wsgi_modulemodules/mod_wsgi.so
WSGIScriptAlias //var/www/html/restmanage-tool/restmanagement/restmanagement/wsgi.py
Alias /static//var/www/html/restmanage-tool/restmanagement/static/
ServerName198.13.35.165
DocumentRoot/var/www/html/
Order allow,deny
Allow from all
Order allow,deny
Allow from all
ErrorLog/etc/httpd/logs/restmanagement.log
Loglevel warn
b. 看Log cd /etc/conf/logs
c. Wsgi.py load error/can’t find project/settings:
Add below code in wsgi.py file
sys.path.append(r'/etc/www/html/restmanage-tool')
sys.path.append(
r'/etc/www/html/restmanage-tool/restmanagement')
8. 备份dockerfile
a. Download Dockerfile from server
b. Upload Dockerfile to git
Git command:
Git clone
Git add
Git commit -m <‘versionname’>
Git push
9. 数据库dump
备份数据:mysqldump --add-drop-table --triggers --routines -c -u Janny-h10.71.2.138 -pJanny123! janny > janny.backup.sql
恢复数据:
mysql -u janny -p janny < janny.backup.sql
10. 自动调用apachectl:
在dockerfile相同的文件夹下面,创建file:run.sh,内容如下:
#!/bin/bash
/sbin/sshd &
/sbin/httpd-D FOREGROUND
Addbelow content in Dockerfile:
#启动apache服务
RUN /sbin/httpd
#复制服务启动脚本并设置权限
ADD run.sh /usr/local/sbin/run.sh
RUN chmod 755/usr/local/sbin/run.sh
#开放80端口
EXPOSE 80
CMD ["/sbin/run.sh"]
网友评论