码迷,mamicode.com
首页 > 数据库 > 详细

Ubuntu LXD下Centos7搭建OpenJDK8+MariaDB

时间:2018-08-02 11:25:32      阅读:226      评论:0      收藏:0      [点我收藏+]

标签:登录   adb   追踪   red   select   共享主机   show view   tps   主机   

# centos7
lxc launch images:centos/7/amd64 centos7
lxc exec centos7 -- /bin/bash
# 验证centos7版本
lxc exec centos7 -- cat /etc/redhat-release
# 显示网络配置
lxc exec centos7 -- ip addr
# 查看公网IP ifconfig.me网站可显示本机公网IP https://ip8.com/
curl ifconfig.me
# 网络路径追踪
tracepath www.baidu.com
# MariaDB (兼容MYSQL)前缀 lxc exec centos7 --
yum -y install mariadb mariadb-server
systemctl start mariadb
systemctl enable mariadb
mysql_secure_installation
# 密码:123456
create user test IDENTIFIED by ‘123456‘;
grant select on testdb. to sytest;
grant show view on testdb.
to test;
select host,user,password from user;
# 实现远程连接(改表法)
use mysql;
update user set host = ‘%‘ where user = ‘test‘;
# 修改root远程访问
GRANT ALL PRIVILEGES ON . TO ‘root‘@‘%‘ IDENTIFIED BY ‘123456‘ WITH GRANT OPTION;
# 数据传输报Got a packet bigger than‘max_allowed_packet’bytes临时修改:
# 修改 #512M,在mysq下输入
set global max_allowed_packet=524288000;
# 刷新权限
flush privileges;
# 重新配置参照https://www.linuxidc.com/Linux/2016-03/128880.htm 和 服务器my.cnf
systemctl restart mariadb
# 安装 OpenJDK (WEB开发兼容Orcle JDK)前缀 lxc exec centos7 --
yum -y install java-1.8.0-openjdk java-1.8.0-openjdk-devel
# 获取openjdk真实路径
dirname $(readlink $(readlink $(whereis java)))
# 配置java系统变量写入/etc/profile.d/java_env_export.sh
echo -e "\n export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.171-7.b10.el7.x86_64\n \
export PATH=$PATH:$JAVA_HOME/bin\n \
export CLASSPATH=.:$JAVA_HOME/jre/lib:$JAVA_HOME/lib:$JAVA_HOME/lib/tools.jar\n" \

> /etc/profile.d/java_env_export.sh
# 应用系统变量
source /etc/profile.d/java_env_export.sh
# 永久打开,重启依然有效
vi /etc/sysctl.conf文件,将net.ipv4.ip_forward=1前面的#注释去掉,保存文件,然后执行sudo sysctl -p使其生效
# 在centos的之外的宿主操作系统临时保存端口转发,重启失效
sudo iptables -t nat -A PREROUTING -p tcp --dport 3306 -j DNAT --to 10.138.129.43:3306
sudo iptables -t nat -A PREROUTING -p tcp -s 192.168.188.0/24 --dport 80 -j DNAT --to 10.138.129.43:80
sudo iptables -t nat -A PREROUTING -p tcp -s 192.168.188.0/24 --dport 80 -j DNAT --to 10.138.129.43:80
# 保存当前iptables的所有规则
sudo iptables-save
# 共享主机用户目录
lxc config device add centos7 mntdir disk source=/home/ubuntu path=/mnt/outter
# 移除主机用户目录
lxc config device remove centos7 mntdir
# 查看容器配置
lxc config device show centos7
# 永久配置自脚本,无需登录,自建/etc/init.d/add-rules并在末尾添加,将/etc/init.d/add-rules链接加入到/etc/rcX.d/下,参考https://blog.csdn.net/apple_llb/article/details/50293179
echo 123456 | sudo -S iptables -t nat -A PREROUTING -p tcp --dport 80 -d 192.168.1.1/24 -j DNAT --to 10.0.3.26:80
echo 123456 | sudo -S iptables -t nat -A PREROUTING -p tcp --dport 3306 -d 192.168.1.1/24 -j DNAT --to 10.0.3.26:3306

Ubuntu LXD下Centos7搭建OpenJDK8+MariaDB

标签:登录   adb   追踪   red   select   共享主机   show view   tps   主机   

原文地址:http://blog.51cto.com/johjoh/2153427

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!